﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26762	Allow using parts of flatpages without install the app	Vlastimil Zíma	Vlastimil Zíma	"Our application uses it's own version of `django.contrib.flatpages`. To reduce the amount of code needed to reuse flatpages (which is a lot, but that's another issue) we reuse as much code from flatpages as we can - e.g. `FlatpageForm`, `render_flatpage` and so on. We don't have `django.contrib.flatpages` in `INSTALLED_APPS` and we really don't want to do that, since it raises a whole other set of issues. It works fine in Django 1.8, but stops to work when we switch to Django 1.9 with error

{{{
RuntimeError: Model class django.contrib.flatpages.models.FlatPage doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
}}}

The error itself doesn't quite make sense, since we don't use `FlatPage` model at all, it just gets loaded.

There is simple fix which allows flatpages to be at least somewhat reused even in 1.9, that is defining the `app_label` in `FlatPage`.
{{{
#!diff
diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
index 69e84f8..abb19c1 100644
--- a/django/contrib/flatpages/models.py
+++ b/django/contrib/flatpages/models.py
@@ -25,6 +25,7 @@ class FlatPage(models.Model):
     sites = models.ManyToManyField(Site, verbose_name=_('sites'))
 
     class Meta:
+        app_label = 'flatpages'
         db_table = 'django_flatpage'
         verbose_name = _('flat page')
         verbose_name_plural = _('flat pages')
}}}

I'm aware that this is sort of hotfix, since it doesn't solve underlying issue, but it would allow flatpages to be used as a library."	Bug	closed	contrib.flatpages	1.9	Normal	wontfix			Accepted	1	0	0	0	0	0
