Re: ManyToManyField not populated in form

2006-08-30 Thread Ivan Sagalaev

Kenneth Gonsalves wrote:
> i always use it, but for some reason it is not in the official docs -  
> although it is in the wiki

Yes this is it: http://code.djangoproject.com/wiki/NewAdminChanges

There is also a small point that is easy to miss: on POST one should 
call do_html2python both when there are errors and when there aren't.

However I hope an upcoming manipulator's rewrite will render all this 
trickiness a thing of the past.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyField not populated in form

2006-08-30 Thread Kenneth Gonsalves


On 30-Aug-06, at 2:33 PM, cyberco wrote:

> So should I always use 'manipulator.flatten_data()' instead of
> 'obj.__dict__' for filling forms with existing values?

i always use it, but for some reason it is not in the official docs -  
although it is in the wiki

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyField not populated in form

2006-08-30 Thread cyberco

That works, great!
So should I always use 'manipulator.flatten_data()' instead of
'obj.__dict__' for filling forms with existing values?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyField not populated in form

2006-08-30 Thread Ivan Sagalaev

cyberco wrote:
> ==VIEW=
> errors = {}
> pizza = 
> new_data = pizza.__dict__

This is why it doesn't work. There is a method in manipulators 
'flatten_data' that correctly fills data for ForeignKeys and ManyToMany:

 manipulator = Pizza.ChangeManipulator(id) # or whatever you use
 new_data = manipulator.flatten_data()

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyField not populated in form

2006-08-30 Thread cyberco

I'm using manipulators.

==MODELS==
class Pizza(models.Model):
toppings = models.ManyToManyField(Topping)

class Topping(models.Model):
name = models.CharField(maxlength=100)
===

==VIEW=
errors = {}
pizza = 
new_data = pizza.__dict__
pizzaFormWrapper = FormWrapper(translatorManipulator, new_data, errors)
return render_to_response('pizza_edit.html', {'pizzaFormWrapper':
pizzaFormWrapper})
==

In the template I'm simply displaying the ManyToMany field in a form:

==TEMPLATE===

Toppings: {{ pizzaFormWrapper.toppings}}


==


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyField not populated in form

2006-08-30 Thread Ivan Sagalaev

cyberco wrote:
> In a form for changing a model instance all fields get correctly filled
> with existing values except the ManyToManyField form fields (which
> renders as a choice list in a form). It shows the correct list of
> options, but none of the options is selected, even though the instance
> of the model should have some values selected. Can this be changed?

What are you using to display the form? Generic view? Manipulators? 
Drawing "" by hand? A code snippet would be nice...

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: ManyToManyField not populated in form

2006-08-29 Thread [EMAIL PROTECTED]

I have the same problem :|


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---