Search code examples
pythondjangodjango-flatpages

Django Flatpages DB Tables Not Created


  • Ubuntu 14.04
  • Python 3.4.0
  • Django 1.7

I just followed the 4 step directions to set up flatpages, but when I ran python3 manage.py migrate, none of the DB tables for the flatpages were created. All the other tables were created, just not the ones needed to flatpages. I'm pretty puzzled by this, 'cause this isn't complicated. I added the right stuff into my settings.py --

SITE_ID = 1 # added for flatpages

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites', # added
    'django.contrib.flatpages.urls', # added for flatpages
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', #added 
)

...and into my urls.py (though I don't think this could affect DB table creation) --

from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
from django.contrib import admin

urlpatterns = patterns('',
    # Examples:
    url(r'^$', 'pets.views.home', name='home'),
    url(r'^pages/', include('django.contrib.flatpages.urls')),
    url(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt',
                                               content_type='text/plain')),
    url(r'^admin/', include(admin.site.urls)),
)

...am I having a brain fart or something? I don't see why this won't work, but it's just not creating the DB tables needed for flatpages. This isn't my 1st time creating something with Django, but it is my 1st time trying out flatpages.


Solution

  • Yes, probably a brain fart: you've added the urls module to INSTALLED_APPS, rather than the app itself.

    'django.contrib.flatpages', # added for flatpages