开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜