How can I disable the format suffix OR allow primary key's containing a dot ( . ) without them being interpreted as a format suffix?
246 views
Skip to first unread message
Eric Honkanen
unread,
Aug 14, 2016, 1:59:30 AM8/14/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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)