I can't start a Django blog on the server.



  • The following mistake is made:

      File "/root/pyserver/news/news/urls.py", line 1, in <module>
        from django.conf.urls import patterns, url, include
    ImportError: cannot import name patterns
    

    Not on the server at the localhost, it's all good.



  • Official https://docs.djangoproject.com/en/1.10/ref/urls/ Django is a warning.

    Deprecated since version 1.8:
    urlpatterns should be a plain list of django.conf.urls.url() instances instead.
    

    So correct your urls - now they have to look like this.

    from django.conf.urls import patterns, url
    

    urlpatterns = [
    url(r'^articles/([0-9]{4})/$', ArticleView.as_view()),
    ]

    By the word, automatic imports through the line are also removed. Now, I'm gonna have to write it out.

    from news.views import year_archive
    ...
    url(r'^articles/([0-9]{4})/$', year_archive),




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2