72👍
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']
1👍
In addition to Francisco Lavin’s answer, you can exclude "short_description" field from your form by using "fields" with "author" and "title" as shown below:
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
fields = ['author', 'title'] # Here
And also by adding "editable=False" to "short_description" field, you can exclude "short_description" field from your form as shown below ("BookInline" class is not needed):
class Book(models.Model):
author = models.ForeignKey(Author)
title = models.CharField(max_length=100) # Here
short_description = models.CharField(max_length=200, editable=False)
- [Django]-Django gunicorn sock file not created by wsgi
- [Django]-Creating my own context processor in django
- [Django]-How can I filter a Django query with a list of values?
Source:stackexchange.com