📜  外键 django createview - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:55.737000             🧑  作者: Mango

代码示例1
class PhoneCreate(CreateView):
    model = Phone
    fields = ['number', 'type']

    def form_valid(self, form):
        form.instance.person_id = self.kwargs.get('pk')
        return super(PhoneCreate, self).form_valid(form)