Weit
Weit

Reputation: 591

How to get Token from Django Rest Framework using postman

I try to get Token like in Django Rest Framework Documentation

from rest_framework.authtoken import views
urlpatterns = [
    url(r'^api-token-auth/', views.obtain_auth_token),
]

inside models.py

@receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs):
    if created:
        Token.objects.create(user=instance)

But it always return to me

  {
  "username": [
    "This field is required."
  ],
  "password": [
    "This field is required."
  ]
}

Postman window

Upvotes: 2

Views: 3252

Answers (1)

Werton Guimaraes
Werton Guimaraes

Reputation: 96

You should add the informations in body request (choice this option). for example:

{"username": "Werton", "password": "xpto"}

enter image description here

Upvotes: 8

Related Questions