DakshThank you for that. Unfortunately contrib.sites doesn't behave like other 
apps that I have built or seen. The real problem (I think) is that 
contrib.sites has its own admin.py and somehow I need to influence that. If I 
could override contrib.sites.admin my problem would evaporate.For example 
refusing all "sites" permissions makes no difference.Any ideas?Mike
-------- Original message --------From: Daksh agnihotri <dakshcoo...@gmail.com> 
Date: 12/1/20  15:39  (GMT+10:00) To: django-users@googlegroups.com Subject: 
Re: contrib.sites readonly question In admin.py Class 
UserProfileAdmin(admin.ModelAdmin):List_display = ()Readonly_fields 
=()........Field in readonly_field... will have read permissions only..I have 
used it.On Sun, Jan 12, 2020, 8:47 AM Mike Dewhirst <mi...@dewhirst.com.au> 
wrote: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.




-- 
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/CAFDq7NJxw6QGfGQnidLnVwtAH7FbCu1YnW7R7cHive_uurUGtw%40mail.gmail.com.

-- 
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/5e1af715.1c69fb81.b8c47.63f8SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

Reply via email to