R
R
Ruslan Ezhgurov2015-10-15 20:49:24
Search Engine Optimization
Ruslan Ezhgurov, 2015-10-15 20:49:24

How to properly optimize urls in Django?

Tell me the right way to optimize the url in a Django project. Now I am getting a specific article at the link localhost/articles/get/1 I would like to do localhost/krem-dlya-britya

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Shultais, 2015-10-15
@Oyaseo

1. Add a field to the model, something like this
2. Then specify the slug in the urls, like this
3. Well, already in the view

def article_detail(request, slug):
    article = get_object_or_404(Article, slug=slug)
    ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question