On Mon, Jan 18, 2010 at 2:59 PM, Alex Robbins <alexander.j.robb...@gmail.com> wrote: > Hmm, you posted the save method for your Event model, but not the > definition. I think you haven't gotten any feed back because no one > really knows what you are asking. Could you show the Event model, and > then show what a finished save should look like? What should the data > end up like?
Thanks for the reply Alex, I hadn't posted the model definition because there's a lot of irrelevant stuff, but point taken, here's most of it: class Event(models.Model): name = models.CharField("Listings title", max_length=100) disciplines = models.CharField(max_length=250) classes_involved = models.ManyToManyField("categories.Class", blank=True, null=True) start_date = models.DateField("First day of the event") end_date = models.DateField("Last day of the event") approved = models.BooleanField() # some removed. def __unicode__(self): return self.name It's fairly simple, the complex bit is filling in the disciplines. I tried to add something to the save() to fill it in. In the Admin area, the event form shows the classes_involved (a choice of about 20), but doesn't show the disciplines. I was hoping to fill in the disciplines from the classes_involved. It's just used in listings, not for comparison, so a text string is fine. There are two problems: 1. The performance hit by going through 2 levels of manytomany fields. The first to get all classes_involved and then for each of those, to get it's parent. (I assume this is bad, my laptop seems to think so.) 2. When I edit an event, the save() doesn't seem to work from the form-data, it works on the previously saved data. I.e. if edit the classes_involved once and save, the discipline is not adjusted. If I save it twice, the discipline is adjusted. I was aiming for a cheap way to do two-level categorisation, however, I'm now thinking I just keep the categories separate and make admin users fill in the discipline manually. Kind regards, -Alastair
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.