Commit Graph

37 Commits

Author SHA1 Message Date
Carlton Gibson
fc588f539b
Version 3.8 Release (#5769) 2018-04-03 15:35:26 +02:00
Ryan P Kilby
73203e6b59 Rework dynamic list/detail actions (#5705)
* Merge list/detail route decorators into 'action'

* Merge dynamic routes, add 'detail' attribute

* Add 'ViewSet.get_extra_actions()'

* Refactor dynamic route checking & collection

* Refactor dynamic route generation

* Add 'ViewSet.detail' initkwarg

* Fixup schema test

* Add release notes for dynamic action changes

* Replace list/detail route decorators in tests

* Convert tabs to spaces in router docs

* Update docs

* Make 'detail' a required argument of 'action'

* Improve router docs
2018-01-25 09:40:49 +01:00
Jon Dufresne
0552810410 Use dict and set literals instead of calls to dict() and set() (#5559)
Set literals are available on all supported Python versions. They are
idiomatic and always faster:

$ python3 -m timeit '{}'
10000000 loops, best of 3: 0.0357 usec per loop
$ python3 -m timeit 'dict()'
10000000 loops, best of 3: 0.104 usec per loop

$ python3 -m timeit '{1, 2, 3}'
10000000 loops, best of 3: 0.0754 usec per loop
$ python3 -m timeit 'set([1, 2, 3])'
1000000 loops, best of 3: 0.228 usec per loop
2017-11-06 10:03:01 +01:00
Carlton Gibson
7b1582e00e Allow schema = None. Deprecate exclude_from_schema (#5422)
* Add tests for schema exclusions

* Move exclusion check to should_include_endpoint

* Update docs

* Switch to using `schema = None`

* Test PendingDeprecationWarnings

* Add note to release notes.

* s/deprecated/pending deprecation/

* Add PR link to release notes

* Correct typo in test class name

* Test 'exclude_from_schema' deprecation warning message (#1)

* Correct deprecation warning message
2017-09-20 11:29:47 +02:00
Carlton Gibson
d54df8c438 Refactor schema generation to allow per-view customisation (#5354)
* Initial Refactor Step

* Add descriptor class
* call from generator
* proxy back to generator for implementation.

* Move `get_link` to descriptor

* Move `get_description` to descriptor

* Remove need for generator in get_description

* Move get_path_fields to descriptor

* Move `get_serializer_fields` to descriptor

* Move `get_pagination_fields` to descriptor

* Move `get_filter_fields` to descriptor

* Move `get_encoding` to descriptor.

* Pass just `url` from SchemaGenerator to descriptor

* Make `view` a property

Encapsulates check for a view instance.

* Adjust API Reference docs

* Add `ManualSchema` class

* Refactor to `ViewInspector` plus `AutoSchema`

The interface then is **just** `get_link()`

* Add `manual_fields` kwarg to AutoSchema

* Add schema decorator for FBVs

* Adjust comments

* Docs: Provide full params in example

Ref feedback b52e372f8f (r137254795)

* Add docstring for ViewInstpector.__get__ descriptor method.

Ref https://github.com/encode/django-rest-framework/pull/5354#discussion_r137265022

* Make `schemas` a package.

* Split generators, inspectors, views.

* Adjust imports

* Rename to EndpointEnumerator

* Adjust ManualSchema to take `fields`

… and `description`.

Allows `url` and `action` to remain dynamic

* Add package/module docstrings
2017-09-14 09:46:34 +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
TakesxiSximada
5df54a711f Set a view function's __module__ value to the WrappedAPIView object's __module__ (#4465) 2016-09-05 11:16:41 +01:00
Stephan Groß
a101251a2a Fix blank lines around docstrings 2016-03-17 11:06:47 +00:00
José Padilla
83c9136c90 Cleanup import following PEP 8 style guide 2015-06-25 16:10:17 -04:00
Greg Kempe
e13d2af137 Parens around if clause 2015-02-04 16:26:23 +02:00
Greg Kempe
d920683237 Use inline if 2015-02-04 16:13:30 +02:00
Greg Kempe
7bb5fd270d FIX: Don't default to list in method args
Fixes @list_route and @detail_route so that they don't initialize their `methods` parameter as a list. In some cases the list gets cleared, and the result is that default parameter is now empty, and may get reused unexpectedly.
2015-02-04 16:03:03 +02:00
Tom Christie
08c727add3 @api_view defaults to allowing GET 2014-11-28 15:55:02 +00:00
Tom Christie
371d30aa87 Remove unused imports. 2014-08-29 12:54:52 +01:00
Tom Christie
f87d32558e Remove .link() and .action() decorators. 2014-08-29 12:53:45 +01:00
Tom Christie
63d02dbea8 Drop six from compat. 1.4.2 is now the lowest supported version. 2014-08-19 17:06:55 +01:00
Tom Christie
bf09c32de8 Code linting and added runtests.py 2014-08-19 13:28:07 +01:00
Tom Christie
8acee2e626 Commenting link/action decorators as pending deprecation 2013-08-19 21:02:22 +01:00
Alex Burgel
eaae8fb2d9 Combined link_* and action_* decorators into detail_route and list_route, marked the originals as deprecated. 2013-07-15 18:35:13 -04:00
Alex Burgel
e14cbaf696 Changed collection_* decorators to list_* 2013-07-15 17:59:36 -04:00
Alex Burgel
d72603bc6a Add support for collection routes to SimpleRouter 2013-07-15 17:59:03 -04:00
Tom Christie
27d8b848bc Add notes on 'method' argument to '@action' decorator 2013-06-02 20:40:56 +01:00
Pascal Borreli
8f35ac4f93 Fixed typos 2013-05-28 15:09:23 +01:00
Alex Burgel
112b52f57e Allow action decorator to handle multiple http methods 2013-05-24 18:28:47 -04:00
Tom Christie
95abe6e844 Cleanup docstrings 2013-04-25 12:47:34 +01:00
Tom Christie
fb41d2ac8f Add support for action and link routing 2013-04-04 20:35:40 +01:00
Tom Christie
b052c92ac3 Cleanup imports
Mostly adding `from __future__ import unicode_literals` everywhere.
2013-02-04 20:55:35 +00:00
Tom Christie
37d49429ca Raise assertion errors if @api_view decorator is applied incorrectly. Fixes #596. 2013-01-19 15:51:14 +00:00
Stephan Groß
44ff2e0add fixed some typos 2012-11-14 19:36:29 +01:00
Tom Christie
ee8ab283f0 Style tweaks 2012-10-29 14:41:33 +00:00
Tom Christie
115e61be09 Added quickstart guide 2012-10-09 12:01:17 +01:00
Tom Christie
beea6487b2 Function based views get proper naming in browseable API 2012-10-09 09:57:08 +01:00
Tom Christie
0cc7030aab Fix @api_view decorator tests 2012-09-26 21:47:19 +01:00
Jamie Matthews
686a034817 No need to use setattr 2012-09-26 20:18:57 +01:00
Jamie Matthews
c13c8fe5bc Update to new rest_framework package name, simplify implementation 2012-09-26 13:52:29 +01:00
Jamie Matthews
01770c53cd Merge branch 'restframework2' of git://github.com/tomchristie/django-rest-framework into improved-view-decorators
* 'restframework2' of git://github.com/tomchristie/django-rest-framework: (56 commits)
  Bits of cleanup
  Add request.QUERY_PARAMS
  Add readonly 'id' field
  Tweak browseable API
  Don't display readonly fields
  Fix some bits of serialization
  Add csrf note
  Fix incorrect bit of tutorial
  Added tox.ini
  Tweak media_type -> accepted_media_type.  Need to document, but marginally less confusing
  Tweak media_type -> accepted_media_type.  Need to document, but marginally less confusing
  Tweak media_type -> accepted_media_type.  Need to document, but marginally less confusing
  Clean up bits of templates etc
  Hack out bunch of unneccesary private methods on View class
  Clean up template tags
  Remove dumbass __all__ variables
  Remove old 'djangorestframework directories
  Change package name: djangorestframework -> rest_framework
  Dont strip final '/'
  Use get_script_prefix to play nicely if not installed at the root.
  ...

Conflicts:
	rest_framework/decorators.py
2012-09-26 13:05:21 +01:00
Tom Christie
4b691c4027 Change package name: djangorestframework -> rest_framework 2012-09-20 13:06:27 +01:00