url - django routes help -
O people, I am creating a simple car sales website. I have a very good URL template which works as expected.
/ car / 1 /
goes to a car with that ID, simple?
However, for SEO reasons I want to add additional data to the URL, but I want to ignore it. As an example, how do I modify my peder to keep the extra parts into account in mind?
Do you?
2 patterns will go to one place and load the same scene.
Any thoughts?
This will not help your SEO - in reality it will actually harm it. If / car / 1 /
, / car / 1 / Ford /
, / car / 1 / ford / focus /
all go the same URL, you have actually reduced your search equity for that page. This is a very bad idea.
If you really want to do this, then it is very easy:
r '^ / car (? Pindt; car_id & gt; \ d +) / . * / $ '
But I do not really do this. To use the make and model to get a car, skipping the ID and making better use is:
r '^ car / (? P> make & gt; \ w +) / (? P & lt; Model & gt; \ w +) / $ '
So now you have / car / ford / focus /
form You can do this by:
def myview (request, make, model): car = car.bizzets.jet (make = make, model = model)
Comments
Post a Comment