New url format in Django 1.9

前端 未结 2 1842
失恋的感觉
失恋的感觉 2021-02-07 03:38

I recently upgraded my Django project to version 1.9.

When I try to run migrate, I am getting the following two errors:

  1. Support for stri
相关标签:
2条回答
  • 2021-02-07 04:03

    Import your views directly, or your views modules:

    from apps.views import about
    from accounts import views as account_views
    

    Do not use patterns at all, just use a list or tuple:

    urlpatterns = [
        url(r'^about/$', about,
            name='about'),
    ]
    
    urlpatterns += [
        url(r'^signin/$', account_views.auth_login,
            name='login'),
    ]
    
    0 讨论(0)
  • 2021-02-07 04:12

    You should remove the quotes around views name. So your code will be like that

    urlpatterns = patterns('',
        url(r'^about/$', app.views.about, #without quote!
            name='about'),
    )
    

    Point 2, use lists, so your code will transform to

    urlpatterns = [
            url(r'^about/$', app.views.about, #without quote!
                name='about'),
        ]
    
    0 讨论(0)
提交回复
热议问题