Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - Excluding some fields in Inline Admin Interface

In Django admin interface, Is to possible to exclude some of the fields in Inline?

like image 278
Sivasubramaniam Arunachalam Avatar asked Nov 15 '10 17:11

Sivasubramaniam Arunachalam


People also ask

How do I hide fields in Django admin?

In Django 1.8 exclude = ('fieldname',) does works with admin. ModelAdmin so one does not have to inherit from InlineModelAdmin anymore. Also works in Django 1.6.

How can I remove extra's from Django admin panel?

Take a look at the Model Meta in the django documentation. Within a Model you can add class Meta this allows additional options for your model which handles things like singular and plural naming. Show activity on this post. inside model.py or inside your customized model file add class meta within a Model Class.

What is Inlines in Django admin?

The admin interface is also customizable in many ways. This post is going to focus on one such customization, something called inlines. When two Django models share a foreign key relation, inlines can be used to expose the related model on the parent model page. This can be extremely useful for many applications.


1 Answers

with exclude you can do it

ex:

class Book(models.Model):    author = models.ForeignKey(Author)    title = models.CharField(max_length=100)    short_description = models.CharField(max_length=200)  class BookInline(admin.TabularInline):     model = Book     exclude = ['short_description'] 
like image 97
Francisco Lavin Avatar answered Sep 21 '22 16:09

Francisco Lavin