0

I have a RestAPI created with the Django rest framework.

I need to create authentication for the API that will allow access on a predefined by the admin user name and password.

IS it possible with DRF?

Also, I want that every object created will be assigned to the user (which I guess includes using some kind of decorator in the view?)

1 Answer 1

1
  • DRF already ships with BasicAuthentication, which has the user send their username + password with each request. That sounds like what you want. (If it isn't, you can write your own Authentication class.)
  • To automagically assign created objects to the authenticated user, use CurrentUserDefault on the relevant User field.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.