Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将列表应用列表模型与用户相关联。用户 has_many 列表。
我应该在我的 List 模型中包含什么才能使用 models.ForeignKey(User)
给你(虽然你下次应该看看 Django DOcs):
from django.db import models from django.contrib.auth.models import User class Listing(models.Model): user = models.ForeignKey(User)
希望这可以帮助