Django User table as Foreign Key

django, python, web

Solution

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.

Problem

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?

Original source