An old Query / I know that but need assistance! so dear django users see what i want to ask and what i did:
Just
to be consistent I'm going to add "has\_view_permission" to the system.
Looks like it should be somewhere in *contrib/admin/options.py*. Made
sure if the user has has change permission, then view permissions are
automatically implied.
index.html.
This could also be handled by copying the file to the local templates
directory instead. I made changes in both so I have a copy if a later
upgrade overwrites my changes.
{% for model in app.models %}
<tr>
{% if model.perms.change %}
<th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
{% else %}
{% if model.perms.view %}
<th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th>
{% else %}
<th scope="row">{{ model.name }}</th>
{% endif %}
{% endif %}[X] 6. Confirm user can "view" but not "change" the modelFound contrib/admin/templatetags/admin_modify.py
appears to control save / save and continue buttons appearing or not.
Changed "save" field from default of always True, to check for context
and permissions. User should be able to save if they have change or add
permissions.
'show_save': (change and contexthas_change_permission?) or (contextadd? and contexthas_add_permission?)[X] 7. Remove "Save and Add another" button if user is viewing an itemModified contrib/admin/templatetags/admin_modify.py again. I don't know what 'save_as' means so maybe I broke something, but it seems to work.
#'show_save_and_add_another': contexthas_add_permission? and
# not is_popup and (not save_as or contextadd?) ,
'show_save_and_add_another': not is_popup and
(( change and contexthas_change_permission?) or (contextadd? and contexthas_add_permission?))
and
(not save_as or contextadd?),
[X] 8. Modify "view" permission to make form read onlyIf the user has "view" permission and "change" permission, then do nothing. Change overrides view.
If
the user has "view" permission without "change" then change the default
forms and add DISABLED or READONLY attributes to the form elements. Not
all browsers support this, but for my purposes I can require that users
use the right one. [Disabled / Readonly example][1]
Found that
not all browsers honor "readonly" so it sets some controls to readonly,
others to disabled. This allows users to copy data from the text
controls if needed.
#/django/contrib/admin/templates/admin/change_form.html
{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}
</div>
</form></div>
{% if has_view_permission and not has_change_permission %}
<script type="text/javascript">
jQuery('input:text').attr('readonly', 'readonly');
jQuery('textarea').attr('readonly', 'readonly');
jQuery('input:checkbox').attr('disabled', true);
jQuery('select').attr('disabled', true);
jQuery('.add-another').hide();
</script>
{% endif %}
PATCH SOURCE : http://stackoverflow.com/questions/1336382/how-can-i-modify-django-to-create-view-permission/1348076#1348076Question:
After following above answer i have done and can see this 127.0.0.1:8000/en-us/admin/ page as read-only but the users in users is not visible 127.0.0.1:8000/en-us/admin/user and auth/users page is not linked with /auth url! strange but it is! . Need help!