Answer the question
In order to leave comments, you need to log in
How to implement tree url in django?
Hello! Using django, mptt created tree categories for articles. Tell me how to implement so that the url to each article looks like this /blog/category/......./subcategoru/post.
Tell me in which direction to dig? So far, I have no idea how to implement it.
Answer the question
In order to leave comments, you need to log in
Faced a similar problem. Processing and creating such corners on the fly turned out to be too expensive, so I settled on the option:
There are two fields in the model - one contains only the native slug (subcategoru), the second contains the full path (/blog/category/....... /subcategory). It turns out that the fields change only when the models themselves change, only the second one is involved in the formation of urls, and since we store the original slug, with a "full refactoring" you can file a better solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question