Django first migration has one anonymous user

Django first migration has one anonymous user



When setting up a django project, the first time I run manage.py migrate and go to manage.py shell and run:


manage.py migrate


manage.py shell


from users.models import User
users = User.objects.all()
users
[<User: AnonymousUser>]



I always get this AnonymousUser. After creating my superuser and checking on the admin page I get:


AnonymousUser



enter image description here



Does Django create this lonely AnonymousUser for a specific purpose, or am I configuring something wrong?


AnonymousUser




2 Answers
2



I'm by no means an expert here but looking through the django auth docs, it seems as though django creates this user to handle apps where users can choose not to authenticate and still interact with app in some level.



If the current user has not logged in, this attribute [request.user] will be set to an instance of AnonymousUser, otherwise it will be an instance of User.



Is this what you were looking for?






Precisely, I haven't found the migration implementation on the source code, but it's a good surprise to see this in the documentation.

– sargas
Sep 6 '15 at 3:58



I have this issue with django-guardian, this apps creates AnonymousUser in the first migrate.



The docs says:



GUARDIAN_GET_INIT_ANONYMOUS_USER
New in version 1.2.
Guardian supports object level permissions for anonymous users, however when in
our project we use custom User model, default function might fail. This can lead
to issues as guardian tries to create anonymous user after each syncdb call.
Object that is going to be created is retrieved using function pointed by this
setting. Once retrieved, save method would be called on that instance.
Defaults to "guardian.management.get_init_anonymous_user".



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế