开发者

Django - access m2m objects (or raw pks) from ``clean`` before model is saved

Of course you can't just use self.related_field.objects.all(), or you'll get a ...needs to have a primary key... error, but if I want to run custo开发者_运维知识库m validation inside of Model.clean, there appears to be no way to access this data. Of course you can use Form.clean to do this, but I'm not always using forms.


What you are asking for is impossible - the M2M records cannot exist until the main object has a primary key value. There is no way to access the data because it does not exist.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜