Specific url in Django

Asked

Viewed 80 times

1

I’m rewriting a website using Django. This is a blog and I need the urls to be the same as the old site so that the site does not lose ranking in the search engines. What would be the best way to address this problem?

  • The current blog is of what type/technology? Wordpress? There is a scheme of Urls defined for the current blog, or a file . htaccess with a definition of regular expressions?

  • The current blog is in wordpress.

1 answer

1

In practice it is necessary to create the same URL structure of the current blog on Dispatcher URL django.

Below is an example of a definition of Urls (copied from the Django documentation). You need to make the necessary adaptations to your new blog, based on the URL structure of the current blog. The Dispatcher URL uses regular expressions to define the paths:

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'^articles/2003/$', views.special_case_2003),
    url(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive),
    url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', views.month_archive),
    url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<day>[0-9]{2})/$', views.article_detail),
]

The first step is to identify exactly what the current URL structure is. Depending on the type/technology of the current blog, it may be in configuration files, or inside the .htaccess. file..

The second step is to replicate this structure in the Dispatcher URL (usually in the.py urls file).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.