Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to format Django urls for two parameters, either of which are optional?

Tags:

django

I'm designing a gallery application for viewing vehicle pictures and there are two parameters:

  1. Manufacturer
  2. Vehicle type

Right now you can view either, but not both. Urls go like so:

  1. /manufacturer/#
  2. /type/#

Where # is an ID number. How/can I format my URLs so it can accept both? My current solution is to do: /both/#/# but this requires some retooling since the application doesn't know when you want to filter by both. Any insight would be appreciated.

like image 756
Parker Avatar asked Dec 07 '25 04:12

Parker


1 Answers

If you're in a situation where both are optional, perhaps your best bet is to handle it through GET parameters.

like image 167
digitaldreamer Avatar answered Dec 08 '25 21:12

digitaldreamer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!