How to store data in Django Model without having an input field -


I have a model for example:

  class meeting (models.Model) : Date = Model DataTimeField (default = datetime.datetime.now) Team = Model.Carfild (max_length = 100) Class Meta: Verbose_name_name_pluger = U 'meetings' sequence = ['-Date', 'Team'] def __unicode __ (self): Return U '% S% s'% (selfetected, self) class entry (models.Model): meeting = model. Finnish (meeting, empty = true) meeting_data = model.defilled (empty = true) description = model. TextField () class meta: verbose_name_name = UNNUNTRY 'def __unicode __ (self): return satellite  

I am getting a form that I am controlling input

  <<> <<> <<> <<>  class  meeting = form. Model Chawalffield (Quarantet = Meeting.Obsports Pty_label = None)  

I want to remove part of the date of the meeting area (I am able to manage it). This date part should be input to the meeting_data field. The meeting_adet field has no input field and it must be populated automatically.

  cleaned_data ['meeting_date'] I do not know how to remove this date in the meeting_data field and how to store it  

] = Date_extract_from_meeting <

>

There is probably a way to override the FORF save () method and the date has been put in that phase, but I can not find an example to do this.

A The way I know that is to work is to pass in wrong = commit.save (such as the actual database entry is not yet):

  example = form.save (commit = false)  

Then you can set the meeting date and save the object:

  Example.meeting_date = instance.meeting.date instance.save ()  

Hope it helps.


Comments