8

I'm a front-end dev struggling along with Django. I have the basics pretty much down but I've hit at wall at the following point.

I have a site running locally and also on a dev machine. Locally I've added an extra class model to an already existing app, registered it in the relevant admin.py and checked it in the settings. Locally the new class and relevant fields appear in admin but when I move this all to dev they're not appearing. The app is called 'publish'.

My method was as follows:

  1. Created the new class in the publish > models.py file:

    class Whitepaper(models.Model):
        title = models.CharField(max_length=200)
        slug = models.SlugField(max_length=100, blank=True)
        pub_date = models.DateField('date published')
        section = models.ForeignKey('Section', related_name='whitepapers', blank=True, null=True)
        description = models.CharField(max_length=1000)
        docfile = models.FileField(upload_to="whitepapers/%Y/%m/%d", null=True, blank=True)

  1. Updated and migrated the model with South using:
python manage.py schemamigration publish --auto

and

python manage.py migrate publish
  1. Registered the class in the admin.py file:

    from models import Section, Tag, Post, Whitepaper
    from django.contrib import admin
    from django import forms

    admin.site.register(Whitepaper)

The app is listed in the settings.py file:


    INSTALLED_APPS = (
        ...,
        ...,
        'publish',
        ...,

)

As this is running on a dev server that's hosting a few other testing areas, restarting the whole thing is out of the question so I've been 'touching' the .wsgi file.

On my local version this got the model and fields showing up in the admin but on the dev server they are nowhere to be seen.

What am I missing?

Thanks ye brainy ones.

Marnchair
  • 161
  • 1
  • 6

2 Answers2

8

I figured out the problem. Turns out the login I was using to get into the admin didn't have superuser privileges. So I made a new one with:

python manage.py createsuperuser

After logging in with the new username and password I could see all my new shiny tables!

Marnchair
  • 161
  • 1
  • 6
0

Are you sure touching .wsgi file does restart your app?

It looks like it doesn't.

Make sure the app is restarted. Find the evidence touching .wsgi file restarts the app maybe.

Since you don't provide any insight about how the dev server runs the apps, we won't be able to help you any further.

Krzysztof Szularz
  • 5,151
  • 24
  • 35
  • Thanks for the response. I suppose there's the possibility that touching isn't working for that specific app. It has certainly worked for other apps. I pushed through to the live server anyway and the whole process worked fine there. I was under the impression that touching the .wsgi was the only way to get the server to restart the environment rather than hard restarting. – Marnchair Jul 26 '13 at 09:47
  • I believe the server is running on mod_wsgi. Touching the wsgi file is recompiling the .pyc files and the new table has been created in the database. I really don't understand why the new fields aren't showing up in the admin. Is there another step here that I'm missing when working on a server? – Marnchair Aug 15 '13 at 10:38
  • It is because the server probably didn't restart. Are you sure it did? – Krzysztof Szularz Aug 16 '13 at 08:03
  • I figured it out in the end. The user I was using to log into the admin section didn't have all privileges and therefore couldn't see all the tables. After creating a superuser and logging in as that everything was there. – Marnchair Aug 19 '13 at 09:49