i have a project in which i try to use the inline formset factory so
when i try to fill the form it throw the following error:
UnboundLocalError at /catalogo/adicionar/articulo/
local variable 'imagen_formset' referenced before assignment
in my view i had:
if request.POST:
form = ArticuloForm(request.POST)
if form.is_valid():
articulo = form.save()
imagen_formset = ImagenesFormSet(request.POST,
instance = articulo)
if
imagen_formset.is_valid():
articulo.save()
imagen_formset.save()
return HttpResponseRedirect('/catalogo/
articulo/')
else:
form = ArticuloForm()
imagen_formset = ImagenesFormSet(instance =
Articulo())
return render_to_response("catalogo/articulo_form.html", {
"form": form,
"imagen_formset": imagen_formset,
}, context_instance=RequestContext(request))
my form is:
ImagenesFormSet = inlineformset_factory(Articulo,Imagenes)
class ArticuloForm(forms.ModelForm):
class Meta:
model = Articulo
def __init__(self, *args, **kwargs):
super(ArticuloForm, self).__init__(*args, **kwargs)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.