#26762: Can't reuse code from django.contrib.flatpages
-----------------------------------+--------------------
     Reporter:  vzima              |      Owner:  nobody
         Type:  Bug                |     Status:  new
    Component:  contrib.flatpages  |    Version:  1.9
     Severity:  Normal             |   Keywords:
 Triage Stage:  Unreviewed         |  Has patch:  0
Easy pickings:  0                  |      UI/UX:  0
-----------------------------------+--------------------
 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/26762>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.cf655a3cae803e1fa5ca12e32aa19c10%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to