Django anonymous user in model

anonymous, django, model

Solution

Only users actually in `django.contrib.auth.models.User` can be in the field, so no. Stick with `None`/`NULL`.

Problem

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?

Original source