Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Use without django.contrib.sites #16

Open
rgov opened this issue Jan 19, 2020 · 2 comments
Open

Enhancement: Use without django.contrib.sites #16

rgov opened this issue Jan 19, 2020 · 2 comments

Comments

@rgov
Copy link

rgov commented Jan 19, 2020

This package did exactly what I needed, but it would be nice if it worked without django.contrib.sites. Almost certainly a vast majority of Django projects only have one site, and for them sites has some drawbacks.

  1. It adds a large "Sites" multiple selection form widget to the top of the preferences admin page which will only have one element anyway. (This form widget does not display the site name but the site domain, which is inconsistent with other parts of the UI.)

  2. It requires some additional configuration and throws errors when things aren't quite right.

  3. It creates a default example.com site which needs to be manually removed or removed with a custom migration for every deployment.

  4. It adds an undesired "Sites" section to Django Admin.

@manuellpsk
Copy link

manuellpsk commented Apr 12, 2022

Idk if someone have this problem yet, but here my little contribution.
Usage indicates this:
from django.contrib import admin
from preferences.admin import PreferencesAdmin
from <my_app>.models import MyPreferences

admin.site.register(MyPreferences, PreferencesAdmin)

You can override exluding the field

class PreferencesAdminCustom(PreferencesAdmin):

exclude = ['sites']

admin.site.register(MyPreferences, PreferencesAdminCustom)

@yakimenko73
Copy link

yakimenko73 commented Sep 12, 2022

so you can add this code to your admin.py

from django.contrib import admin
from django.contrib.sites.models import Site

admin.site.unregister(Site)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants