1

Following the Django tutorial (part 2), I can't seem to see my Polls app in my django admin panel after registering it. My screen looks a bit like this, with a distinct lack of a section for the Polls app:

Django Admin Screen

What I've done so far (following parts of this answer and the tutorial itself):

  1. Registered my app in the admin.py file.
  2. Added it to INSTALLED_APPS in settings.py in my project folder.
  3. Ran python manage.py makemigrations & python manage.py migrate without any changes (btw, for future readers - that's the new >1.8 incarnation of syncdb, I believe).
  4. Made sure the user I'm signing in with has superuser priviliges (as per this answer).
  5. Restarted my nginx.

I'm still hazy as to what the problem is or, for that matter, how to debug it.

My admin.py file:

from django.contrib import admin

from .models import Question

admin.site.register(Question)

My models.py file (notice the Question object):

import datetime

from django.utils import timezone
from django.db import models

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

    def __str__(self):
        return self.question_text

    def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)


class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

    def __str__(self):
        return self.choice_text

INSTALLED_APPS portion of my settings.py project file:

INSTALLED_APPS = [
    'polls.apps.PollsConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
Community
  • 1
  • 1
Tom Granot
  • 1,840
  • 4
  • 22
  • 52

1 Answers1

1

As it turns out, I wasn't paying attention to the process in which the application was served.

So, riding on this answer, I figured out it breaks down like this:

  1. nginx gets a URL, decides where to pull from - in our case, Gunicorn.
  2. Gunicorn searches for the proper Python file to pull - in our case, Django.
  3. Djnago gets executed and the app loads (including our admin panel).

In this case, after making the changes to the admin panel I've restarted nginx, but not Gunicorn. Restarting Gunicorn solved the problem, and if you looked at my last comment - nginx crashed because of a typo in my admin.py file (added well after writing this question, during my attempt to fix it, and thus does not appear in the OP).

Tom Granot
  • 1,840
  • 4
  • 22
  • 52