3

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?

Community
  • 1
  • 1
Shreyas
  • 1,410
  • 3
  • 11
  • 15
  • Did u restart the Dev server after adding in admin.py? – Rakesh Sep 12 '12 at 04:34
  • Yes I did...multiple times. Each time I deleted the db and saw that on executing syncdb django creates the tables, but they are just not visible in the admin UI – Shreyas Sep 12 '12 at 12:58

2 Answers2

2
class ProviderProfileAdmin(admin.ModelAdmin):
    pass
admin.site.register(ProviderProfile, ProviderProfileAdmin)
Constantinius
  • 34,183
  • 8
  • 77
  • 85
freylis
  • 814
  • 6
  • 15
  • Per this link https://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-objects, since I am not doing any customizations, the following should suffice. admin.site.register(ProviderProfile) Is that incorrect? – Shreyas Sep 12 '12 at 13:01
0

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