Tuesday, March 1, 2011

Populating charfield with ID's from many to many

I am trying to populate a CharField with id's from a many-to-many
field.

I am doing this by overriding the save method on the model save and
using the default django admin for data entry, however, it requires 2
saves in order to get the data from the many-to-many field to populate
the varchar field.

basically it's like this:

def save(self, *args, **kwargs):
winners = self.winner_select.values_list('id', flat=True)
super(Model, self).save(*args, **kwargs)


What I am wanting to do is grab the id's of what is being saved in the
many to many field and add them to the varchar field on save.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment