خرید بک لینک

Vote count: 0

I am setting up a Django/Django Rest Framework API and most of the queries are generated using parameters inside the url. The patte follows {param name}/{param value}.

For example:

users/
users/id/{id}/
users/name/{name}/
users/group/{group}/name/{name}/
users/group/{group}/email/{email}/

The parameters are parsed with regexes and sent to view methods as in the tutorial. Each of these three has a separate view method.

I am curious if there is a way to write one view method that can capture all of these parameters, no matter the order they are presented in. For example:

users/id/{id}/
users/group/{group}/
users/name/{name}/
users/email/{email}/
users/email/{email}/group/{group}

Would all go to one view method that filters the User model/table. Is it possible to write a concise regex/url resolver that does this without having to write a url patte match that covers all possible iterations?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 30 تير 1395 ساعت: 6:40

صفحه بندی