Django anonymous user in model
Posted
by jack
on Stack Overflow
See other posts from Stack Overflow
or by jack
Published on 2010-03-19T02:13:27Z
Indexed on
2010/03/19
2:21 UTC
Read the original article
Hit count: 415
I have a model defined as below:
class Example(models.Model):
user = models.ForeignKey(User, null=True)
other = models.CharField(max_length=100)
The problem is Django refuses to assign django.contrib.auth.models.AnonymousUser directly to Example.user as null field so everytime I have to check if request.user.is_authenticated() ans assign Example.user = None manually.
Is there a default value for AnonymousUser to use in a model field?
© Stack Overflow or respective owner