question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App model doesn't appear in Django admin in production

See original GitHub issue

Danny, 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:closed
  • Created 9 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ddaitestcommented, Apr 14, 2017

try to restart uwsgi. it works for me.

0reactions
mchesler613commented, Apr 22, 2021

I had this problem today in production. Just had to restart the server. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

App model doesn't appear in Django admin in production #162
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...
Read more >
Django App Not Showing up in Admin Interface - Stack Overflow
Another possible reason for not showing app in admin page is Apache doesn't have permissions. Sometimes we create an app with permission that...
Read more >
Writing your first Django app, part 7
You'll follow this pattern – create a model admin class, then pass it as the second argument to admin.site.register() – any time you...
Read more >
Django Model not showing in admin : r/django - Reddit
I have a Django model, that I have migrated into my MySql database. The model shows up in the database, but doesn't show...
Read more >
Chapter 6: The Django Admin Site
This chapter is about Django's automatic admin interface. The feature works by reading metadata in your model to provide a powerful and production-ready ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found