thank you.
Excluding city from the ModelForm seems to work as well...

class AddRestaurantForm(ModelForm):

    rating = forms.IntegerField(widget=forms.Select(choices =
RATING_CHOICE), required=False)
    city = forms.CharField(max_length=100)

    class Meta:
        model = Restaurant
        exclude = ('slug', 'city')


On Nov 27, 9:10 pm, Steve Howell <showel...@yahoo.com> wrote:
> I am not fully tracking to the problem here, but when it comes to
> overriding save() behavior on forms, I find the following helper to be
> handy:
>
> def build_instance_from_form(model_form):
>     instance = model_form.save(commit=False)
>     return instance
>
> Then in your view code do something like this:
>
>    restaurant = build_instance_from_form(form)
>    # fix up data like city
>    restaurant.save()
>
> This can help you avoid all the complexity of overriding save() on the
> form object and delegating to super(), etc., at least in some cases.

--

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.


Reply via email to