» Django InlineModelAdmin: Show partially an inline model and link to the complete model
Django InlineModelAdmin: Show partially an inline model and link to the complete model
|January 22, 2010
Posted by forumadmin
I defined several models: Journals, volumes, volume_scanInfo etc.
A journal can have more volumes and a volume can have more scanInfo.
What I want to do is:
- in the admin page of journals I want to have the list of the volumes inline (done)
- connect each volume of the previous list to its admin page where I can show the form to edit the volume and the list of its “scan info” inline.
so I want to have something like:
Journal #1 admin page
list of volumes inline
[volume 10] [..(other fields)..] <a href="/link/to/volume/10">Full record</a>
[volume 20] [..(other fields)..] <a href="/link/to/volume/20">Full record</a>
Volume #20 admin page
list of the scan info inline
[scan info 33] [..(other fields)..] <a href="/link/to/scaninfo/33">Full record</a>
[scan info 44] [..(other fields)..] <a href="/link/to/scaninfo/44">Full record</a>
What I tried to do is defining a model method that create the code and trying to use it inside the class that defines “volume inline” in the admin, but it doesn’t work.
In other words
the model “Volume” has inside something like:
return '<a href="/admin/journaldb/volume/%s/">Full record</a>' % self.vid
selflink.allow_tags = True
fields = ['volumenumber', 'selflink']
model = Volume
extra = 1
But this gives the following error:
Exception Value: 'VolumeInline.fields' refers to field 'selflink' that is missing from the form.
More Related Questions
- Django Admin: OneToOne Relation as an Inline? I am putting together the admin for a satchmo application. Satchmo uses OneToOne relations to extend the base Product model, and I'd like to edit it all on one page.
It is possible to […]
- Django admin – inline inlines (or, three model editing at once) I've got a set of models that look like this:
title = models.CharField(max_length=255)
page = models.ForeignKey(Page)
- Multiple ModelAdmins/views for same model in Django admin How can I create more than one ModelAdmin for the same model, each customised differently and linked to different URLs?
Let's say I have a Django model called Posts. By default, the admin […]
- What is "inline_admin_form.original" in Django InlineModelAdmin and how to change it Here are my models and admin module:
categories = models.ManyToManyField('Category', null=True, related_name='shops')
- filter admin show in django by users I add one ManyToManyField to my Users profile:
user = models.OneToOneField(User)
news_letters = models.ManyToManyField(news_letter)
and replace it […]
- Foreign keys in django admin list display If a django model contains a foreign key field, and if that field is shown in list mode, then it shows up as text, instead of displaying a link to the foreign object.
Is it possible to […]
- Database error: no such table: auth_user. Extending AbstractUser and using model to register on admin I'm trying to use AbstractUser to add a field to Django's standard User model. This is my code:
uuid = UUIDField(auto=True)
This has been successful […]
- Django TabularInline using popup to add/edit item intead of the inline inputs In Django admin when using TabularInline for inline models, is there an option to add/edit an item by using a popup? I'm especially wondering about when we have multiple fields. […]
- Django. You dont have permission to edit anything I created a little app a while ago. I created admin.py and used admin.site.register(MenuEntry) to add the class to admin console. It showed the items of that class just fine.
Then I began […]
- Custom user model in django does not allow setting password in admin I have created a custom user model which I am successfully using within my app.
The problem is that within the Admin, on the user edit screen, I get a display of the present password […]