Monday, June 21, 2010

ModelForm with ManyToManyField on the other side

class Material(models.Model):

products = ManyToManyField('Product', related_name='materials')

class Products(models.Model):

...

class ProductForm(forms.ModelForm):

class Meta:
model = Product
fields = ('materials', )

I want to do this.

I saw this discussion:

http://groups.google.com/group/django-users/browse_thread/thread/49213bf57a6a3033/cceb6912ad43fca0?show_docid=cceb6912ad43fca0&pli=1

And, I tried this snippet:
http://djangosnippets.org/snippets/1295/

The related names of this snippet make no sense. If they are made to
make sense, then there would be an accessor clash. Without the class,
the accessors are redundant at best...

Has any progress been made on this convenience or is the recommended
course just to create a non-Model form and make a save method?

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate