I d like to deploy dynamic URL s for my app in two ways:
- when viewing available vehicle, I get a link like: http://www.url.com/2006-Acura-MDX-Technology-Package
- I also have a filter page, so here, the URL will change according to the filters selected like: http://www.url.com/2007-Nissan or http://www.url.com/2007-Nissan-Maxima and so on depending on the filters the user has chosen.
What s the best way to go about this?
EDIT 1
This now works
def get_absolute_url(self):
return u %s-%s-%s-%s-%s % (self.common_vehicle.year.year,
self.common_vehicle.series.model.manufacturer,
self.common_vehicle.series.model.model,
self.common_vehicle.series.series,
self.stock_number)
Then in my template I have:
<a href="{{ vehicle.get_absolute_url }}/">
<span class="vehicle-title">
{{ vehicle.common_vehicle.year.year }}
{{ vehicle.common_vehicle.series.model.manufacturer }}
{{ vehicle.common_vehicle.series.model.model }}
{{ vehicle.common_vehicle.series.series }}
</span>
</a>
All that remains is getting the stock number passed to the details view...so far I ve done it like so:
(r ^inventory/details/(?P<stock_number>[-w]+)/$ ,....