Hello,
I have my ModelForm... and I need to filter my products with Current User.. if a change my modelform init, doesn't show me any error, but when I use in my inlineformset, show me on error..
Here is my code:
View:
ofertasinlineformset = inlineformset_factory(Assinatura, Ofertas,
form=OfertasEditForm(usuario=request.user),
max_num=ass_ativa.total_produtos_oferta,
# min_num=ass_ativa.total_produtos_oferta,
extra=ass_ativa.total_produtos_oferta,
exclude=(),
can_delete=False)
Form:
class OfertasEditForm(ModelForm):
class Meta:
model = Ofertas
exclude = []
def __init__(self, *args, **kwargs):
u = kwargs.pop('usuario', None)
super(OfertasEditForm, self).__init__(*args, **kwargs)
self.fields['produto'].queryset = Produto.objects.filter(usuario_id=u).filter(status='A')
and the error:
'OfertasEditForm' object has no attribute '__name__'
It's appears, when I use in my inlineformset only OfertasEditForm, work fine, because returns the class.. but when I use OfertasEditForm(usuario=reqquest.user) returns the HTML not the class.
How can I do these? What's the better approach?
Regards
T.·.F.·.A.·. S+F
Fellipe Henrique P. Soares
e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash