foreign key django createview

Solutions on MaxInterview for foreign key django createview by the best coders in the world

showing results for - "foreign key django createview"
Marion
05 Apr 2020
1class PhoneCreate(CreateView):
2    model = Phone
3    fields = ['number', 'type']
4
5    def form_valid(self, form):
6        form.instance.person_id = self.kwargs.get('pk')
7        return super(PhoneCreate, self).form_valid(form)