views:

59

answers:

1

I'm creating a new model called Tickets which I want to ensure always has a valid userID assigned to it.

I'm using AUTH_PROFILE_MODULE to setup the profile which also gives the error NameError: name 'User' is not defined when I try to run syndb.

How do I setup a foreign key to make sure this always is the case?

## tickets/models.py

class Ticket(models.Model):
    user = models.ForeignKey(User,)
    # More model stuff.



# accounts/models.py   

class UserProfile(models.Model):
     user = models.ForeignKey(User, unique=True)
+2  A: 

so the problem was I was missing an import on my models.

from django.contrib.auth.models import User
Brandon
@Felix - he did, that's what NameError means.
Daniel Roseman
@Daniel Roseman: I know, I could swear the name error thingy was added after my comment, but the time says something different ;). So, never mind.
Felix Kling