Django authentication and permissions
<p>I posted a question on SO regarding Django authentication and permissions even though it's already there. My question is ,</p>

<p>I have a backend ready with a lot of views, models and serializers from DRF. Now I want to apply authentication to my app and create RESTful apis that are consumed at the front-end. So the doubts that I have</p>

<ul>
<li>How does authentication work? Does Django create different model tables for each of its user?</li>
<li>If so, how do I retrieve data per user from Django?</li>
</ul>

<p>Now comes the second case</p>

<ul>
<li>If above two are true, then how do I use permission in DRF to serve only the data that is relevant to a particular user?</li>
</ul>

<p>I hope my questions are clear. If not, suggest me edits.
I'd also like some examples(if any) on how does this all happens.</p>

<p>Also, if you want to see the <a href="http://stackoverflow.com/questions/39484907/django-authentication-with-drf">original post</a>.</p>

<p>Django uses table <code>auth_user</code> to save user and password</p>

<p>Django has an API to check <code>is_authenticated</code></p>

<hr>

<p>Django rest framework uses table <code>authtoken_token</code> </p>

<p>Django rest framework has an API <code>rest_framework.authtoken.views.obtain_auth_token</code> for the same purpose</p>

<p>In DRF, for permissions you can do something like below..</p>

<pre><code>class UserDetail(generics.RetrieveUpdateDestroyAPIView):
    """
    User Detail API
    """
    permission_classes = ("check_permission1", "check_permission2",) ### you can define your permissions using this
</code></pre>

python django django-rest-framework