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 [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
-~----------~----~----~----~------~----~------~--~---