Home > Software engineering >  Data in table is not showing in Django admin
Data in table is not showing in Django admin

Time:11-16

Model:

from django.db import models

class VilleStation(models.Model):
    nomVille = models.CharField(max_length=255)
    adresse = models.CharField(max_length=255)
    cp = models.CharField(max_length=5)

    def __str__(self):
        return self.nomVille

admin.py :

from django.contrib import admin
from prixcarbu.models import VilleStation

class VilleStationAdmin(admin.ModelAdmin):
    list_display = ('nomVille',  'adresse','cp',)
    fields = ('nomVille', 'adresse','cp',)

admin.site.register(VilleStation, VilleStationAdmin)

I imported a CSV file using database browser for SQLite. Table contains the data but admin page doesn't show it.

CodePudding user response:

Do you see empty model in admin or no model at all?

If you don't see your model in the admin at all check if you added your app to INSTALLED_APPS in settings.py.

CodePudding user response:

After closing my computer and reopening, the data is now visible in the admin. Probably a cache problem. Everything is fine now. Thank you all.

  • Related