开发者

Admin site registering models

I have those models

class A(models.Model):
    name = CharField(max_length=255)

class B(models.Model):
    name = CharField(max_length=255)
    relation = ForeignKey(A)

And I can register like this:

admin.site.register(A)
admin.site.register(B)

In /admin/ page, I can see A and B registered. and "Add B" admin page, will display a combo with (+) icon to add a new "A". What I want is only regi开发者_Go百科ster "B" and keep the (+) icon, the problem is: if "A" is not registered this icon dissapears of this place :( so and I cant add "A" when adding "B"s

Thanks :)


relation = ForeignKey(A, null=True, blank=True) will let you save a B without needing to link it to an A. Does that help?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜