I deleted my database and all my migrations and would like to re-build them from scratch.
When I run makemigrations I get the error:
django.db.utils.OperationalError: no such table: registration_setting
I was able to trace this to my urls.py which reference several views. If I comment this out it builds the migrations fine.
urlpatterns = [
url(r'results', views.results, name='results'),
url(r'all', views.results_all, name='results_all'),
url(r'results_batch', views.results_batch, name='results_batch'),
url(r'form', views.RegistrationFormView.as_view(), name='reg_form'),
url(r'^$', views.login, name='login'),
url(r'tokensignin', views.token_sign_in, name='token_sign_in'),
url(r'logout', views.logout, name='logout'),
url(r'^ajax/get_course_description$', views.get_course_description, name='get_course_description'),
url(r'^not_registered_report', views.not_registered_report, name='not_registered_report'),
]
As best as I can tell it is this line from views.py
settings_CGPS_REG_TERM = Setting.objects.filter(key="CGPS_REG_TERM").first().value
Which in-fact references the Settings table which has not been built yet by migrate. But isn't this a very normal situation? Of course I have code that references values to fetch from tables in my database. Why is makemigrations trying to execute any code whatsoever before creating the underling database tables? Is there some best practice I am not following that is causing this?
settings.pyfile: thesettings.pyfile is one of the first modules that is loaded, long before themodels.pyof the apps.