Django Associations with the user model
Ho开发者_高级运维w can I associate lists apps Listing model with an user. User has_many lists.
What shall I include in my List model for being able to use models.ForeignKey(User)
Here you go (Although you should just look at the Django DOcs the next Time):
from django.db import models
from django.contrib.auth.models import User
class Listing(models.Model):
user = models.ForeignKey(User)
Hope this helps
精彩评论