App model doesn't appear in Django admin in production
See original GitHub issueDanny, First of all, thank you for this. It exponentially speeded up my starting a new project. Everything was going along swimmingly until I moved to production. I put this up as a question on StackOverflow that is totally empty.
The short version is this: The model for my app works fine in my local runserver. When I deploy to Heroku, everything works perfectly except my app doesn’t show up in the Django admin.
Here’s the long version:
I’ve been building a Django app and testing locally for some time. On my machine, when I visit the admin page, my app appears. When I deploy to Heroku, it no longer does. The odd thing is that when setting user permissions in the admin, I can access the tables for my app in the postgres db, so it doesn’t appear to be a db issue, just my custom admin is not being found or loaded.
My directory listing is roughly this
overall
- myproject
manage.py
urls.py
wsgi.py
-templates
-contrib
-users
-myapp
admin.py
forms.py
models.py
fixtures
My urls.py file
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.views.generic import TemplateView
urlpatterns = patterns('',
url(r'^$', # noqa
TemplateView.as_view(template_name='pages/home.html'),
name="home"),
url(r'^about/$',
TemplateView.as_view(template_name='pages/about.html'),
name="about"),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls), name="admin"),
# User management
url(r'^users/', include("users.urls", namespace="users")),
url(r'^accounts/', include('allauth.urls')),
# Uncomment the next line to enable avatars
url(r'^avatar/', include('avatar.urls')),
# Your stuff: custom urls go here
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
In myapp/admin.py, I have this:
from django.contrib import admin
from myapp.models import State, Facility, Report
from forms import ReportForm
@admin.register(State)
class StateAdmin(admin.ModelAdmin):
list_display=('state_name','state_abbrev')
ordering=('state_name',)
@admin.register(Faculty)
class FacultyAdmin(admin.ModelAdmin):
pass
In my django settings on heroku, i have this:
INSTALLED_APPS = ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions',
'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'suit',
'django.contrib.admin', 'crispy_forms', 'allauth', 'allauth.account', 'allauth.socialaccount',
'users', 'myapp', 'djangosecure', 'gunicorn', 'storages', 'collectfast')
But my admin only contains users, sites, accounts in it, and not myapp, like it does on my local testing environment.
(In a separate issue, when I try to use heroku’s foreman to test the app locally, it can’t seem to find the environment variables to run gunicorn, so that’s tripping up my debugging too. )
Please, please help me figure this out. It’s driving me crazy. Any advice would be greatly appreciated.
Thanks!
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (7 by maintainers)
Top GitHub Comments
try to restart uwsgi. it works for me.
I had this problem today in production. Just had to restart the server. 😃