-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makes it easy to change AuthToken model class when overriding built-in O... #2151
Conversation
…n ObtainAuthToken view
I thought |
Looks like some tweaks needed if this view (eg let's also use .is_valid(raise_exception=True) |
You mean something simple like this?
I don't think there's much we can do with the hardcoded |
Exactly, yes. I would drop the
Probably simplest as it is, yup. |
Update token auth view. Closes #2151.
This was closed automatically by merging ... argh — I was going to ask you to review @tomchristie (since I wasn't sure they were identical) — but I see you have. |
@ur001 Contrary to some python design you'll see we actually choose to favor slightly more coarse grained API in some cases. The "hooks for everything" approach doesn't recognize that there's a trade off in increasing the surface area of the API. In this case if you need to alter the behavior just override the view explicitly. It's still drop-dead simple, but there's less API for us to document and support, and your view behavior will actually be more obvious and maintainable by not relying on API hooks and implicit behavior. Hope that gives enough context to explain the design decision. It runs contrary to what you'll tend to see, but I think it actually makes for better design. (Yup, thanks @carltongibson!) |
@tomchristie ok, I agree with your approach |
Makes it easy to change AuthToken model class when overriding built-in ObtainAuthToken view.
ObtainAuthToken view has a
model
attribute, but it uses a Token class whatever inpost()
method.