How can I disable the format suffix OR allow primary key's containing a dot ( . ) without them being interpreted as a format suffix?

184 views
Skip to first unread message

Eric Honkanen

unread,
Aug 14, 2016, 1:59:30 AM8/14/16
to Django REST framework
I am using mostly standard DRF stuff including the DefaultRouter and I have a route like:

api/users/<user>

If I do e.g. GET api/users/mr.ghetto, I get { detail: Not Found } and from inspecting I can see that the kwargs in the View are split out like {format: 'ghetto', pk: 'mr'} http://i.imgur.com/U9fBvUV.png

How can I support usernames with a dot?

Thanks!
- Eric

Tom Christie

unread,
Aug 15, 2016, 4:44:47 AM8/15/16
to Django REST framework
I'd suggest subclassing DefaultRouter and setting the `include_format_suffixes` attribute to `False`.

Alternatively just use SimpleRouter, and include a root view explicitly. (All DefaultRouter does is give you format suffixes and a default API root view)
Reply all
Reply to author
Forward
0 new messages