I have a Django project hosted on heroku
I added a new slug field to model
from django.db import models
class Category(models.Model):
name = models.CharField(max_length=30)
slug = models.SlugField(unique=True)
def __unicode__(self):
return self.name
migrated it using south on heroku. Checked the heroku postgresDB as well for added field. All fine.
Opened Admin. No slug field showing...
added slug to fields[] in admin.py. Still not showing. Here is admin.py
from django.contrib import admin
from models import Category
class CategoryAdmin(admin.ModelAdmin):
fields = ('name', 'slug')
admin.site.register(Category, CategoryAdmin).
I even did a heroku restart... No change. What can be done to show it ?
Try to use list_display like following:
from django.contrib import admin
from models import Category
class CategoryAdmin(admin.ModelAdmin):
fields = ('name', 'slug')
#list of fields to display in django admin
list_display = ['id', 'name', 'slug']
#if you want django admin to show the search bar, just add this line
search_fields = ['name', 'slug']
#to define model data list ordering
ordering = ('id','name')
admin.site.register(Category, CategoryAdmin).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With