Re: Frustration with custom Inline forms
Thank you thank you thank you! I knew I was doing something simple wrong. :) I've been enjoying my experience using Django so far, but one thing I have noticed is that the error messages (or in this case lack of error messages) can be frustrating. It sometimes takes me quite a while to figure out what caused an exception especially if there are no line numbers of my own code. In this case, it's actually the Python syntax and I'm not sure what Django could do if your syntax is wrong, but I sure spent a while tracking this down Cheers, Ben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Frustration with custom Inline forms
On Nov 17, 2:01 pm, Ben Gerdemann <[EMAIL PROTECTED]> wrote: > Ok, so I just noticed that the a55_id field which is the primary key, > was declared as an IntegerField instead of an AutoField which is why > it was showing up on the inline form, but I still can't get any of the > other fields excluded from the inline form so the problem is still > there. > > Also, if it helps for understanding Pais = Parents and Visitas = > Visits in Portuguese. > > Thanks again for any and all help. > > Cheers, > Ben The only thing I can see in your code that might cause problems is the value for exclude: exclude = ('a55_id') This is not what you think it is. It's not a single-element tuple. It is actually a single string, which will be treated as if it were a list of characters ie ['a', '5', '5', '_', 'i', 'd']. Naturally, the admin doesn't recognise this as a field, so won't exclude it. I think what you meant was exclude = ('a55_id',) - note the extra comma, which is how you define a single-element tuple. There's no reason you can't have custom forms in an inline formset - I do this all the time, using very similar code to the above. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Frustration with custom Inline forms
There's a problem with the exclude statements above, you've got tuple- trouble, missing trailing commas: exclude = ('a55_id') should be ('a55_id',) or ['a55_id'] easy mistake, search for "tuple" in this group and you'll see you have company. Kip. On Nov 17, 2:01 pm, Ben Gerdemann <[EMAIL PROTECTED]> wrote: > Ok, so I just noticed that the a55_id field which is the primary key, > was declared as an IntegerField instead of an AutoField which is why > it was showing up on the inline form, but I still can't get any of the > other fields excluded from the inline form so the problem is still > there. > > Also, if it helps for understanding Pais = Parents and Visitas = > Visits in Portuguese. > > Thanks again for any and all help. > > Cheers, > Ben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: Frustration with custom Inline forms
Ok, so I just noticed that the a55_id field which is the primary key, was declared as an IntegerField instead of an AutoField which is why it was showing up on the inline form, but I still can't get any of the other fields excluded from the inline form so the problem is still there. Also, if it helps for understanding Pais = Parents and Visitas = Visits in Portuguese. Thanks again for any and all help. Cheers, Ben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---
Frustration with custom Inline forms
I'm trying to customize the inline forms of a model that are displayed when I'm editing it's parent, but I can't get anything to work! Can someone help? First, here are my models: class T22Pais(models.Model): a22_id = models.AutoField(primary_key=True) a22_nome_1 = models.CharField("Nome Responsavel #1",max_length=255) class T55Visitas(models.Model): a55_id = models.IntegerField(primary_key=True) a55_visita_agendada = models.DateTimeField(null=True, blank=True) a22 = models.ForeignKey(T22Pais,verbose_name="Pais") The documentation says "The InlineModelAdmin class is a subclass of ModelAdmin so it inherits all the same functionality as well as some of its own," so first I tried this: class T22PaisAdmin(admin.ModelAdmin): inlines = [T55VisitasInline] class T55VisitasInline(admin.StackedInline): exclude = ('a55_id') model = T55Visitas but nothing changes. I tried a couple variations of the name without and without quotes and adding the model hierarchy exclude= ('T55Visitas.a55_id') but nothing worked. Then I noticed that the documentation refers to form and formset fields in InlineModelAdmin. The documentation isn't very clear how to use these, but I tried the following things and nothing had any effect: the inline form was always rendered with all of its fields: class T55VisitasInlineForm(forms.ModelForm): class Meta: model = T55Visitas exclude = ('a55_id') class T55VisitasInline(admin.StackedInline): model = T55Visitas form = T55VisitasInlineForm tried adding a formset: class T55VisitasInline(admin.StackedInline): model = T55Visitas form = T55VisitasInlineForm formset = inlineformset_factory( T22Pais, T55Visitas, exclude = ('a55_id') ) adding the same form back into the formset even though I'm already setting T55VisitasInline.form, but no dice. :( class T55VisitasInline(admin.StackedInline): model = T55Visitas form = T55VisitasInlineForm formset = inlineformset_factory( T22Pais, T55Visitas, form = T55VisitasInlineForm, exclude = ('a55_id') ) How can I get this to work??? Grrr... Ideally, I'd like to have a fully custom inline form using "fieldsets," but for now I'll settle for just hiding fields. Cheers, Ben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~--~~~~--~~--~--~---