Friday, November 24, 2017

Re: Limit a view to superuser only

Bear in mind that unless you are running Django's built-in dev server, you will need to restart your production server for changes to propagate.

On Sunday, 19 November 2017 17:21:28 UTC+2, yingi keme wrote:
All of a sudden and out of the blue, it just worked. I had the re-run my server

On Sunday, November 19, 2017 at 5:54:11 AM UTC-8, Jani Tiainen wrote:
Hi.

Could you paste the full traceback here because having an OSError sounds like there is is something else wrong in your system.

On 19 Nov 2017, at 15.22, yingi keme <ying...@gmail.com> wrote:

I have a function that i want to be accessed only if the user is a supersuser.

I have tried this

from django.contrib.admin.views.decorators import staff_member_required

@staff_member_required
def my_view(request):
    template_name = 'Core\CustomizedAdmin.html'
    return render(request, template_name)


What happens is that when i try to access this view, it directs me to the default login admin page. 
And then when i login as a superuser, it gives an OSError invalid argument:

I expected that after login in as a superuser it will redirect to the Page i want.

Am i doing it the wrong way?

Is there an alternative way to Limit a view to superuser only?

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fc05e300-5e71-4bc5-b388-2996c5b8bb0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/426f7c53-318f-4137-992f-8281627c2efa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment