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
ex
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:
The problem is that city name is not unique.
Can I pass the city instance in the overrided AddRestaurantForm's save
method?
thank you
On Nov 27, 5:12 pm, Tim Valenta wrote:
> Try overriding your AddRestaurantForm's "save" method:
>
> def save(self, commit=True):
> self.instance.city =
Try overriding your AddRestaurantForm's "save" method:
def save(self, commit=True):
self.instance.city = get_object_or_404(City,
name=self.instance.city)
# Finish by passing control back to the normal Django flow:
super(AddRestaurantForm, self).save(commit)
I think th
4 matches
Mail list logo