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'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
<https://fedoraproject.org/wiki/User:Fellipeh>*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh <https://github.com/fellipeh>*
*Twitter: @fh_bash*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF1jwZEkknLPm%2BiwG9zfXH-Ee_8X15Y8dt0S%2BCNNTF6owBaDfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to