I use contrib.sites I think successfully to differentiate between dev, staging and production for purposes of adjusting URLs as intended for linked resources.

However, I cannot find a way to make contrib.sites data readonly in the Admin

How can I make it readonly in the Admin?

I've tried changing settings to make it a local app "sites" instead of "django.contrib.sites" and importing it as follows ...

#myproject/sites/__init__.py
from django.contrib.sites import *


#myproject/sites/admin.py
from django.contrib import admin
from .admin import SiteAdmin
from .models import Site

admin.site.unregister(Site)

class MySiteAdmin(SiteAdmin):

    verbose_name = "Website"

    def has_add_permission(self, request=None, obj=None):
        return False

    def has_change_permission(self, request=None, obj=None):
        return False

    def has_delete_permission(self, request=None, obj=None):
        return False

    def has_view_permission(self, request=None, obj=None):
        return False

admin.site.register(MySite, SiteAdmin)

This has no effect

Is there a way to do this?

Thanks

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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71a70cee-d670-f1cb-95ae-ac213d35f45a%40dewhirst.com.au.

Reply via email to