Ok...this might work for the second option . How about getting a drop down box from a data base table column
On Jun 30, 2:03 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > Op donderdag 30 juni 2011 21:42:57 UTC+1 schreef sony het volgende: > > > > > > > I am sorry I think I posted one line wrong. > > > class Report(models.Model): > > reportType = models.ForeignKey(ReportCategory) > > name = models.CharField(max_length=200) > > description = models.CharField(max_length=300) > > > def __unicode__(self): > > return self.name > > > Now, inside the meta class I am trying to do two things: > > > Firstly, populating the Report Type dropdown box with the value from > > the 'name' column of ReportCategory table. > > Secondly, when all the other fields in the form are filled by the user > > and the button is pressed, the data in the fields should be saved in > > the Report table keeping in mind the foreign key constraint it has > > from the ReportCategory table. > > But you don't need to do anything to get that - that is the default > behaviour. > > In any case, even if you did need to do custom logic, the place for that is > *not* in Meta. __init__ might be a good place. But, as I said, all the > things you want are the standard way forms behave with ForeignKeys. > -- > DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.