On 4/02/2020 5:47 pm, אורי wrote:
Did you try `django_admin.site.unregister(Site)` before you register
Site with your own admin?
Yes.
I have tried lots of things but I think I'm missing something very
basic. It must begin in settings.INSTALLED_APPS somehow. This is how it
is currently sitting:
#settings.py
INSTALLED_APPS = [
...
#"django.contrib.sites",
sites,
...
]
#<project>/sites/__init__.py
from django.contrib.sites import *
#<project>/sites/admin.py
from django.contrib import admin
from .models import Site
django.admin.site.unregister(Site)
class SiteAdmin(admin.ModelAdmin):
list_display = ('domain', 'name')
search_fields = ('domain', 'name')
def has_view_permission(self, request=None, obj=None):
return False # request.user.is_superuser
admin.site.register(Site, SiteAdmin)
That "return False" line works properly when monkey-patching
contrib/sites/admin.py
Mike
אורי
[email protected] <mailto:[email protected]>
On Tue, Feb 4, 2020 at 7:56 AM Mike Dewhirst <[email protected]
<mailto:[email protected]>> wrote:
How do I control contrib.sites in the Admin?
I want to make it invisible to everyone except the superuser.
I have tried - inexpertly - to hijack the sites app in my own project
but it stubbornly insists on using its own admin.py
Thanks for switching on any light bulbs
Cheers
Mike
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected]
<mailto:django-users%[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/9eee993a-98d0-fa77-9e92-a8bd447af37d%40dewhirst.com.au.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CABD5YeHi-N1wmz5buJgUEMfqRET5U6ZuFnSsOFSWp7iUOQWgjg%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CABD5YeHi-N1wmz5buJgUEMfqRET5U6ZuFnSsOFSWp7iUOQWgjg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/6b344f1c-e2ca-4933-9424-1ea1a57eab51%40dewhirst.com.au.