I\'m running Django 1.6.6 on production and have recently upgraded to 1.9.7 on staging (dev server). This update was performed on the server and I followed the steps outline
The problem is that your queryset is being evaluated when the urls.py
loads. When you run makemigrations
for a new project, this causes the error because the table has not been created yet.
You can fix this by subclassing ListView
and moving the queryset into get_queryset
.
class MyListView(ListView):
template_name = 'numeric/apply.html'
def get_queryset(self):
return list(chain(models.HowToApply.objects.filter(active=True).order_by('sequence_number'), models.AcademyAdmin.objects.all()))
Then change your url pattern to use your new view.
url(r'^academy/howtoapply/$',
MyListView.as_view(),
name='apply',
),
Django 1.9 runs some checks to validate your url patterns, which means that the url patterns are loaded before the makemigrations
command runs. Django 1.8 does not have these checks, so you can get away with setting the queryset as you have done.