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:
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)
python manage.py schemamigration publish --auto
and
python manage.py migrate publish
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.
To automate this process, we can programmatically fetch all the models in the project and register them with the admin interface. Open admin.py file and add this code to it. This will fetch all the models in all apps and registers them with the admin interface.
contrib import admin # Register your models here.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With