Django Admin interface- Recent object title and object name doesn't work
- Post By Coll 23
- 4 years ago
I have tried this method:
1) python manage.py makemigrations >>No changes detected
2) python manage.py migrate>>
Operations to perform:
Apply all migrations: admin, auth, contenttypes, menu, sessions
Running migrations:
No migrations to apply.
3) CTRL + SHIFT + R to hard reset http://127.0.0.1:8000/admin/
4) Adding a new menu via http://127.0.0.1:8000/admin/menu/menu/add/
#models.py page
from django.db import models
class Menu(models.Model):
productName = models.CharField(max_length=255)
price = models.FloatField()
image_url = models.CharField(max_length=2083)
category = models.CharField(max_length=255)
def _str_ (self):
return self.product_name
#admin.py page
from django.contrib import admin
from .models import Menu
class MenuAdmin(admin.ModelAdmin):
list_display =('productName', 'price','image_url','category')
admin.site.register(Menu, MenuAdmin)