Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

foreign key django createview

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #foreign #key #django #createview
ADD COMMENT
Topic
Name
5+6 =