I'm a new user to Django and am just starting my first app, "myapp".
In my models.py for my app I have the following model:
class Subcalendar(models.Model):
user = models.ForeignKey(User)
But when I try running:
python manage.py sql myapp
I get an error stating:
NameError: name 'User' is not defined
Do I need to make my own model for User or is there another way of calling it in my model's foreign key field?
You need import the User
model at the top of your file
from django.contrib.auth.models import User
so python can resolve the reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With