Z
Z
zkweb2016-11-30 15:53:44
Django
zkweb, 2016-11-30 15:53:44

How to pass dynamic fields to save()?

There are 4 fields that are not in the database and not in the model, I need them when a certain status is selected.
That is, the required fields when choosing a status.

forms.py
  delivery= forms.CharField(required = False, label = u"Доставка", widget=forms.TextInput(attrs={'size':40}))

model.py
   def save()
     как сюда вывести request.POST
???

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2016-11-30
@zkweb

Offhand - your form has a save method. This is where you accept your fields in cleaned_data, and pass the required field to the save() method of the model.
This is better than trying to push request directly into the model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question