django - how to save form (not a modelForm) -


Maybe there is a silly question, but I'm not sure how this can handle 'right'.

I have found a general form with some areas. I can insert data without problems when I want to edit a record, I am using "Model_to_dict" - to populate the form. After editing the record, I want to save it, and here my problems begin.

The Dzegoo Docs says that a model updates the record on its own or PK-value basis. If pk-value is present, then an update of it, otherwise putting one. So I have created this saved-function:

  def save (self, primary_key = 0): mymodel = somedellel (pk = primary_key, sample field = self.cleaned_data ['samplefield'],) Mymodel .seave () Print 'PK:' + str (DPK) # Handle yourself in multiple ChoiceField X. ScaledDedata ['Payment Method']: x.mymodel_set.add (d)  

So, when I edit a record it works fine but when I put a new record I'm justified, but mymodel.id = 0 means that I can not save the relationships of multiple Swissfields.

So I would like to know that this is a good way to handle it? And after saving the model why mymodel.id = 0 any .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -