5

The following warning appears twice when I run ./manage.py runserver after upgrading Django from 1.7 to 1.8.

.../django/contrib/sites/models.py:78: RemovedInDjango19Warning: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.

The project still runs fine, but I want to get rid of the warning. I'm not using the Sites framework in my project, but the warning disappeared when I added 'django.contrib.sites' to the INSTALLED_APPS list in the project's settings.py. So that took care of the warning and I was happy.

But then the project starts demanding a Site in the database at the login prompt. Now, the whole thing is that I don't want the Sites framework at all. But now I seem forced to manage a database entry and need to consider it during installation and such when I'm just trying to get rid of a warning.

It appears that the login code in django.contrib.auth relies on it from the code. However, in Django's documentation I found this assertion: "site_name: An alias for site.name. If you don’t have the site framework installed, this will be set to the value of request.META['SERVER_NAME']. For more on sites, see The “sites” framework."

So it appears that the authors of django.contrib.auth consider the Sites framework optional, but judging from my situation, it isn't.

Hence my question. Is it possible to use Django's (presumably contributed) authentication system without using the Sites framework at all and still getting rid of that warning and everything related to the Sites framework?

Teekin
  • 12,581
  • 15
  • 55
  • 67
  • 1
    Try to track down where the `Site` model is being imported. The `auth` app shouldn't import it if `django.contrib.sites` is not not in `INSTALLED_APPS`. You can get python to treat warnings as errors by running `python -We manage.py runserver --traceback`, then you can see the location of the import in the traceback. – Alasdair Dec 17 '15 at 16:21

1 Answers1

0

Had the same issue, created default site entry (Id=1) and never had any issue ever since

Ramast
  • 7,157
  • 3
  • 32
  • 32
  • Yes, I could configure the Sites framework, but it's overhead, both in performance, management and configuration, which I'd prefer not to include in my project. – Teekin Dec 18 '15 at 11:43
  • sitemaps, flatpages, contenttypes, syndication feeds, django auth (views and forms only) are using sites framework. If you stop using all these apps you should be fine – Ramast Dec 18 '15 at 12:20
  • The authors of 'auth' seems to consider the Sites framework optional, though, as explained in the question. That's what confuses me. – Teekin Dec 24 '15 at 16:31
  • Only auth views and forms. You can still use the models without depending on Sites . – Ramast Dec 24 '15 at 18:08
  • Alright, I guess that settles it, then. :) Thanks for the info. Is't not the news I hoped for, but it appears it's the correct answer so I've marked it as the correct one for everyone else who's wondering about this. – Teekin Dec 28 '15 at 21:39