Commit Graph

101 Commits

Author SHA1 Message Date
Anton Zaslavskiy
b25ac6c5e3
Don't hit db to access user_id in TokenProxy (#7852) 2021-03-19 11:46:09 +00:00
Kryštof Pilnáček
79daf315c4
Fix: authtoken.TokenProxy cannot be proxy when not installed (#7571)
closes https://github.com/encode/django-rest-framework/issues/7442
2020-10-09 12:16:15 +01:00
Xavier Ordoquy
ebc1ebf0c4
Merge pull request #7481 from smithdc1/app-config
default_app_config application variable is deprecated in Django 3.2
2020-10-06 22:16:29 +02:00
Hugo Rodger-Brown
995188f8c5
Add missing TokenProxy migration (#7557)
Fixes #7554
2020-09-28 16:16:18 +01:00
David Smith
b8ab30683a default_app_config application variable is deprecated in Django 3.2 2020-09-03 21:57:41 +01:00
Charles
35c0abf24e
Change Token.generate_key to a Classmethod (#7502)
* adds classmethod decorator to generate_key and test to confirm change is acceptable

* self -> cls
2020-09-03 11:51:03 +01:00
Carlton Gibson
e2bd3b6a57
Adjusted token admin to map to user ID. (#7341)
Closes #6131.

* Adds a proxy model for Token that uses the user.pk, rather than it's own.
* Adjusts Admin to map back from User ID to token instance.
2020-06-15 11:43:09 +01:00
Daniil Okhlopkov
4ac0fae75b
use @admin decorator (#7022) 2020-05-11 09:04:37 +01:00
Martin Desrumaux
609f708a27
Fix schema generation for ObtainAuthToken view. (#7211) 2020-03-03 13:27:34 +01:00
Tom Christie
044252af1c
Version 3.10.1 (#6817)
* Ensure that requiring 'uritemplate' does not also require 'coreapi'

* Don't include autocomplete fields on TokenAuth admin

* Version 3.10.1
2019-07-17 14:17:45 +01:00
Jan Pieter Waagmeester
cfd3ea0996 TokenAdmin: add 'user' to autocomplete_fields (#6762)
TokenAdmin is unusable with a big number of user records (in this case ~150k). Django 2.0 added the [ModelAdmin.autocomplete_fields](https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields) option to use select2 to provide a better user experience.

If support for django 1.11 is dropped, this change would make the `TokenAdmin` usable again.
2019-06-28 13:44:15 +01:00
Jon Dufresne
3f19e66d9f Replace all usage ugettext functions with the non-u versions (#6634)
On Python 3, the ugettext functions are a simple aliases of their non-u
counterparts (the 'u' represents Python 2 unicode type). Starting with
Django 3.0, the u versions will be deprecated.

https://docs.djangoproject.com/en/dev/releases/3.0/#id2

> django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
> ungettext(), and ungettext_lazy() are deprecated in favor of the
> functions that they’re aliases for:
> django.utils.translation.gettext(), gettext_lazy(), gettext_noop(),
> ngettext(), and ngettext_lazy().
2019-05-01 07:49:54 +02:00
Carlton Gibson
0407a0df8a
Dropped Python 2 compatibility. (#6615)
Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com>
2019-04-30 17:53:44 +02:00
Ryan P Kilby
a628a2dbce Drop Django 1.10 support (#5657)
* Remove Django 1.10 from CI

* Remove Django 1.10 compat code
2018-07-06 12:14:31 +02:00
gsvr
32caca4dd3 Import coreapi from rest_framework.compat, not directly. (#5921) 2018-04-05 15:07:49 +02:00
Ryan P Kilby
1bc826e6fd
Fix authtoken views imports (#5818) 2018-02-07 14:46:17 -05:00
Paulo Scardine
0d5a3a00b0 Add schema to ObtainAuthToken
Add encoding parameter to ManualSchema

Closes #5676

* Fixed lint errors
* Added docs for ManualSchema encoding parameter
2018-02-05 16:16:42 +01:00
Jon Dufresne
ff556a91fd Remove references to unsupported Django versions in docs and code (#5602)
Per the trove classifiers, DRF only supports Django versions 1.10+. Can
drop documentation, code comments, and workarounds for older Django
versions.
2017-11-20 09:35:54 +01:00
Carlton Gibson
c674687782 Remove Django 1.8 & 1.9 compatibility code (#5481)
* Identify code that needs to be pulled out of/removed from compat.py

* Extract modern code from get_names_and_managers in compat.py and remove compat code

* Extract modern code from is_authenticated() in compat.py and remove.

* Extract modern code from is_anonymous() in compat.py and remove

* Extract modern code from get_related_model() from compat.py and remove

* Extract modern code from value_from_object() in compat.py and remove

* Update postgres compat

JSONField now always available.

* Remove DecimalValidator compat

* Remove get_remote_field compat

* Remove template_render compat

Plus isort.

* Remove set_many compat

* Remove include compat
2017-10-05 20:41:38 +02:00
Jascha Geerds
161dc2df2c Call Django's authenticate function with the request object (#5295)
As of Django 1.11 the `authenticate` function accepts a request as an
additional argument. This commit fixes compatibility between newer Django
versions and custom authentication backends which already depend on the request
object.

See also:

[Django 1.11 release](https://docs.djangoproject.com/en/1.11/releases/1.11/)

```
authenticate() now passes a request argument to the authenticate() method of
authentication backends. Support for methods that don’t accept request as the
first positional argument will be removed in Django 2.1.
```
2017-10-05 10:43:49 +01:00
Sergei Azarkin
9aaea2586b Fix authtoken managment command (#5415)
* Fix authtoken managment command username param
2017-09-12 14:03:29 +01:00
Andrea Grandi
d2459710ca Implement option to reset User token 2017-06-03 11:58:01 +01:00
Andrea Grandi
34c38e0cfe Use self.sdtout and CommandError to print output 2017-06-03 11:06:14 +01:00
Andrea Grandi
cf196a4424 Get UserModel from get_user_model and do not infer the natural key 2017-06-03 10:38:01 +01:00
Andrea Grandi
be590d61c0 Handle invalid User situation 2017-05-31 23:01:35 +01:00
Andrea Grandi
d198b1abe6 Add Django manage command to create a DRF user Token 2017-05-29 17:07:50 +01:00
Thomas Achtemichuk
70205cc64e
Lint 2017-05-17 15:17:55 -04:00
Thomas Achtemichuk
c9c383dfad
Don't trim whitespace from authtoken passwords
* Fixes #5148
2017-05-17 14:52:39 -04:00
José Padilla
c1f31492ae
Update links after moving to encode org 2017-04-07 10:28:35 -04:00
Tom Christie
a3802504a0 Error codes (#4550)
Add error codes to `APIException`
2016-10-11 10:25:21 +01:00
Tom Christie
0dec36eb41 Version 3.5 (#4525)
* Start test case

* Added 'requests' test client

* Address typos

* Graceful fallback if requests is not installed.

* Add cookie support

* Tests for auth and CSRF

* Py3 compat

* py3 compat

* py3 compat

* Add get_requests_client

* Added SchemaGenerator.should_include_link

* add settings for html cutoff on related fields

* Router doesn't work if prefix is blank, though project urls.py handles prefix

* Fix Django 1.10 to-many deprecation

* Add django.core.urlresolvers compatibility

* Update django-filter & django-guardian

* Check for empty router prefix; adjust URL accordingly

It's easiest to fix this issue after we have made the regex.  To try
to fix it before would require doing something different for List vs
Detail, which means we'd have to know which type of url we're
constructing before acting accordingly.

* Fix misc django deprecations

* Use TOC extension instead of header

* Fix deprecations for py3k

* Add py3k compatibility to is_simple_callable

* Add is_simple_callable tests

* Drop python 3.2 support (EOL, Dropped by Django)

* schema_renderers= should *set* the renderers, not append to them.

* API client (#4424)

* Fix release notes

* Add note about 'User account is disabled.' vs 'Unable to log in'

* Clean up schema generation (#4527)

* Handle multiple methods on custom action (#4529)

* RequestsClient, CoreAPIClient

* exclude_from_schema

* Added 'get_schema_view()' shortcut

* Added schema descriptions

* Better descriptions for schemas

* Add type annotation to schema generation

* Coerce schema 'pk' in path to actual field name

* Deprecations move into assertion errors

* Use get_schema_view in tests

* Updte CoreJSON media type

* Handle schema structure correctly when path prefixs exist. Closes #4401

* Add PendingDeprecation to Router schema generation.

* Added SCHEMA_COERCE_PATH_PK and SCHEMA_COERCE_METHOD_NAMES

* Renamed and documented 'get_schema_fields' interface.
2016-10-10 13:03:46 +01:00
Asif Saifuddin Auvi
04e5b5b20a removed AUTH_USER_MODEL compat property (#4176)
Removed unnecessary `AUTH_USER_MODEL` compat variable.

(No longer required)
2016-06-07 12:13:35 +01:00
Tom Christie
9c996d7d2a Clean up existing deprecation warnings. (#4166)
* Add Meta.fields = '__all__' to serializer classes where required.
* Add explicit on_delete=models.CASCADE to ForeignKey fields.
* Use '.remote_field' and '.model' in preference to '.rel' and '.to' when inspecting model fields.
* Use new value_from_object in preference to internal _get_val_from_obj
2016-06-02 14:39:10 +01:00
Xavier Ordoquy
753f4dc477 Fix sorting order. 2016-02-27 01:46:59 +01:00
Xavier Ordoquy
6ea6e37ac9 Add missing migration file for #3887 2016-02-27 00:51:35 +01:00
Mikhail Nacharov
d0f7b04805 enhancement #3886 Internationalization in admin interface rest_framework.authtoken
+ verbose_name in models.Token fields
+ Meta-options verbose_name & verbose_name_plural
+ Labels in AuthTokenSerializer fields in case of usages in Brousable API
+ provide AppConfig class as described in django documentation with verbose_name came through ugettext_lazy
2016-02-01 13:20:16 +05:00
Xavier Ordoquy
9e8ddb88fc Restore the abstract on Token model when the app isn't declared
The fact that we don't import Token from authentication doesn't invalidate
the need for the model to be abstract whenever the authtoken isn't listed
in the INSTALLED_APPS.
2016-01-21 13:28:32 +01:00
Mads Jensen
215e1b6c6b Regarding #3729
python -Werror generates warnings informing that on_delete is a required keyword in Django 2.0
2016-01-14 15:14:33 +01:00
S. Andrew Sheppard
ff29fdd875 don't import authtoken model until needed 2015-12-30 15:44:19 -06:00
Xavier Ordoquy
7a5d81c0b4 Add extra args/kwargs to authtoken's views (#3718) 2015-12-11 07:16:04 +01:00
auvipy
4db2501399 removed south_migrations directory 2015-10-15 14:17:56 +06:00
auvipy
392df94693 removed south migrations 2015-10-15 14:16:35 +06:00
Marlon
670b0b710b Use serializers.ValidationError
Per django rest framework docs, and to prevent confusion with Django's ValidationError, `serializers.ValidationError` is preferred to `exceptions.ValidationError`.
2015-09-30 21:09:37 -05:00
José Padilla
7351a3f6ca Sort imports with isort 2015-06-25 16:55:51 -04:00
José Padilla
83c9136c90 Cleanup import following PEP 8 style guide 2015-06-25 16:10:17 -04:00
Tom Christie
166801063d Merge pull request #2743 from maurodoglio/serializer_class-html-renderer
Use `serializer_class` for browsable API display, even on plain APIView.
2015-03-23 09:43:39 +00:00
mdoglio
d0126b7e31 Set serializer_class on ObtainAuthToken view 2015-03-22 12:35:56 +00:00
mdoglio
fde02ae6eb AuthTokenSerializer - properly render password field 2015-03-22 12:13:28 +00:00
Tom Christie
4ee4b4f2dc Merge master 2015-01-30 14:00:25 +00:00
Lucas Wiman
a1eba885e2 Use the proper db_table argument when constructing meta 2015-01-27 19:30:44 -08:00