Re: User and Permission from admin to the app

2015-08-18 Thread Russell Keith-Magee
Hi Predator,

Permission checks need to be manually added to each view, on a case-by-case
basis. Django can't "interpret" what your view is trying to do - all user
views look the same to Django - so you need to provide the extra
information to describe which permissions are needed at any given part in a
view.

For example, you might require "View" permissions to GET a particular view,
but require a Change permission (or multiple change permissions, if you're
modifying multiple objects, or even a custom permission) to POST to the
same view.

The easiest way to do this is to put the @permission_required decorator on
a view:

https://docs.djangoproject.com/en/1.8/topics/auth/default/#the-permission-required-decorator

However, you can also use user.has_perm('foo.add_bar') method inside a view
(returning a 404 or 403 if the test fails) if you need a more fine-grained
approach.

Yours,
Russ Magee %-)

On Thu, Aug 13, 2015 at 10:24 AM, Predator  wrote:

> Hi there!
>
> I have a question regarding user permissions.
>
> How can I use the user permissions that I have set in the admin to my
> django app?
>
> For example, I have a user* 'Trainee'* and in django admin, I set
> *'Trainee'* to only add to my model. So, 'Trainee' can only add to this
> model, not change and delete it. When I logged in to* my app*, I can
> still delete and change. I may be missing some vital points and I hope
> someone can point me to the right direction.
>
> Thanks and have a great day!
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d64cc98d-40c7-43b1-aecc-25fc7a1d752c%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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq8495Ds_gQ%3DOkraOuE%3D5LrVBjE%2B%3D1um32HBxAHLPtBS6FXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


User and Permission from admin to the app

2015-08-13 Thread Predator
Hi there! 

I have a question regarding user permissions.

How can I use the user permissions that I have set in the admin to my 
django app?

For example, I have a user* 'Trainee'* and in django admin, I set 
*'Trainee'* to only add to my model. So, 'Trainee' can only add to this 
model, not change and delete it. When I logged in to* my app*, I can still 
delete and change. I may be missing some vital points and I hope someone 
can point me to the right direction.

Thanks and have a great day!

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d64cc98d-40c7-43b1-aecc-25fc7a1d752c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.