Reputation: 33553
I just started fiddling with Django, and I try now to use the users that are available in the admin page in a model.
This is my model:
class Game(models.Model):
started_at = models.DateTimeField()
class Player(models.Model):
game = models.ForeignKey(Game)
user = models.ForeignKey(models.User)
but this doesn't work: python manage.py makemigrations
returns:
AttributeError: 'module' object has no attribute 'User'
Upvotes: 0
Views: 21
Reputation: 10119
The default User
model is available from django.contrib.auth.models
:
from django.contrib.auth.models import User
from django.db import models
class Game(models.Model):
started_at = models.DateTimeField()
class Player(models.Model):
game = models.ForeignKey(Game)
user = models.ForeignKey(User) # models.User doesn't exist
Upvotes: 3