Re: Requiring format extension on all URLs

2021-06-22 Thread Carl Nobile
Phil, The correct, normal, and common ways are not always the same as many people don't understand that RFCs define the correct way to do things, not a specific framework like DRF. The quick a dirty way will ALWAYS lead to issues down the road. I use format queries also but only when maneuvering a

Re: Requiring format extension on all URLs

2021-06-22 Thread Phil Gyford
Thanks Carl. I'll think about your suggestion. I'm a little hesitant as I usually try to do things the most conventional way, especially with a tool like DRF that I'm using for the first time. I want to go with the flow and do things the expected, "normal" way. The DRF docs are a little confusi

Re: Requiring format extension on all URLs

2021-06-21 Thread Carl Nobile
Hi Phil, The best way to solve all these issues is to use mime types to determine the type of return data. For example application/vnd.{company name}.{endpoint name}+json;ver=1. In the above you would replace {company name} with your company or organization name, and {endpoint name} with something

Requiring format extension on all URLs

2021-06-21 Thread Phil Gyford
Hi, I'm trying to set up DRF as a read-only API, and want to require that all URLs have either a .api or .json format extension. I've sort of managed this so far by copying the DefaultRouter class and in its get_urls() method changing this call: urls = format_suffix_patterns(urls) to this