Shreyas
Shreyas

Reputation: 1410

Django app tables not visible in admin UI

Gist - Tables have been successfully created from model but not visible in admin UI - Environment - Windows 7, Python 2.7, VirtualEnv, SQLite

I have a couple of models defined in my django app. Here is the relevant content of the model.py file

from django.contrib.auth.models import User, models

class ProviderProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)

    # Other fields for Provider here
    number = models.CharField(('Number'), max_length = 30, blank = True)
    street_line1 = models.CharField(('Address 1'), max_length = 100, blank = True)
    street_line2 = models.CharField(('Address 2'), max_length = 100, blank = True)
    zipcode = models.CharField(('ZIP code'), max_length = 5, blank = True)
    city = models.CharField(('City'), max_length = 100, blank = True)
    state = models.CharField(('State'), max_length = 100, blank = True)

    class Admin:
        pass

Per the instructions here https://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objects, I added an admin.py file to this app which has the following contents

from django.contrib import admin
from UserProfile.apps.ProviderProfile.models import Service, ServiceProvider, ProviderProfile

admin.site.register(Service)
admin.site.register(ServiceProvider)
admin.site.register(ProviderProfile)

I had also added the following in my settings.py file per this django ignoring admin.py

INSTALLED_APPS = (
        'Path.To.MyApp',
)

Now when I do a syncdb, django tells me it has created the tables (and I verified using SQLiteManager). Unfortunately, I don't see them in the admin UI. I see tables from other apps in there.

What am I missing?

Upvotes: 3

Views: 1790

Answers (2)

freylis
freylis

Reputation: 814

class ProviderProfileAdmin(admin.ModelAdmin):
    pass
admin.site.register(ProviderProfile, ProviderProfileAdmin)

Upvotes: 2

user1167195
user1167195

Reputation:

Did you put admin.autodiscover() in the urls.py? That method is looking for the admin.py files in your applications.

Upvotes: 0

Related Questions