django-rest-framework/rest_framework
Paul Melnikow a1d7aa8f71 Allow viewset to specify lookup value regex for routing
This patch allows a viewset to define a pattern for its lookup field, which the router will honor. Without this patch, any characters are allowed in the lookup field, and overriding this behavior requires subclassing router and copying and pasting the implementation of get_lookup_regex.

It's possible it would be better to remove this functionality from the routers and simply expose a parameter to get_lookup_regex which allows overriding the lookup_regex. That way the viewset config logic could be in the a subclass, which could invoke the super method directly.

I'm using this now for PostgreSQL UUID fields using https://github.com/dcramer/django-uuidfield . Without this patch, that field passes the lookup string to the database driver, which raises a DataError to complain about the invalid UUID. It's possible the field ought to signal this error in a different way, which could obviate the need to specify a pattern.
2014-01-04 16:45:03 -05:00
..
authtoken Don't import compat.py from authtoken.models. Closes #1297 2013-12-16 08:59:10 +00:00
runtests
static/rest_framework
templates/rest_framework Merge branch 'master' into 2.4.0 2013-12-13 16:32:34 +00:00
templatetags
tests Allow viewset to specify lookup value regex for routing 2014-01-04 16:45:03 -05:00
utils Merge branch 'master' into 2.4.0 2013-12-13 16:32:34 +00:00
__init__.py Version 2.3.10 2013-12-06 22:13:50 +00:00
authentication.py Merge branch 'bennbollay-patch-1' into 2.4.0 2013-12-23 09:48:59 +00:00
compat.py Merge branch 'bennbollay-patch-1' into 2.4.0 2013-12-23 09:48:59 +00:00
decorators.py
exceptions.py
fields.py Merge branch 'bennbollay-patch-1' into 2.4.0 2013-12-23 09:48:59 +00:00
filters.py Add queryset aggregates to allowed fields in OrderingFilter 2013-11-12 23:40:07 +00:00
generics.py Merge branch 'master' into 2.4.0 2013-12-13 16:32:34 +00:00
mixins.py Merge branch 'master' into 2.4.0 2013-12-13 16:32:34 +00:00
models.py
negotiation.py
pagination.py
parsers.py Fixed exception handling with YAML and XML parsers. 2013-10-31 15:03:50 -07:00
permissions.py Merge branch 'bennbollay-patch-1' into 2.4.0 2013-12-23 09:48:59 +00:00
relations.py
renderers.py Catch and mask ParseErrors that occur during rendering of the BrowsableAPI. 2013-12-09 07:34:08 +00:00
request.py Catch and mask ParseErrors that occur during rendering of the BrowsableAPI. 2013-12-09 07:34:08 +00:00
response.py Remove Content-Type header from empty responses. Fixes #1196 2013-12-03 16:55:11 +00:00
reverse.py
routers.py Allow viewset to specify lookup value regex for routing 2014-01-04 16:45:03 -05:00
serializers.py Merge branch 'bennbollay-patch-1' into 2.4.0 2013-12-23 09:48:59 +00:00
settings.py Add get_ident method to pass new tests. 2013-12-06 14:21:52 -08:00
status.py Version 2.3.10 2013-12-06 22:13:50 +00:00
test.py
throttling.py Allow NUM_PROXIES=0 and include more docs 2013-12-13 00:02:18 +00:00
urlpatterns.py Merge branch 'master' into 2.4.0 2013-12-13 16:32:34 +00:00
urls.py
views.py Update comment in get_parser_context. 2013-10-24 13:45:16 +01:00
viewsets.py minor typo 2013-10-29 15:10:06 -05:00