Django: Support for string view arguments to url() is deprecated and will be removed in Django 1.10

前端 未结 3 1012
暗喜
暗喜 2020-12-18 17:51

New python/Django user (and indeed new to SO):

When trying to migrate my Django project, I get an error:

RemovedInDjango110Warning: Support for stri         


        
3条回答
  •  北海茫月
    2020-12-18 18:23

    I have found the answer to my question. It was indeed an import error. For Django 1.10, you now have to import the app's view.py, and then pass the second argument of url() without quotes. Here is my code now in urls.py:

    from django.conf.urls import url
    from django.contrib import admin
    import main.views
    
    urlpatterns = [
        url(r'^admin/', admin.site.urls),
        url(r'^$', main.views.home)
    ]
    

    I did not change anything in the app or view.py files.

    Props to @Rik Poggi for illustrating how to import in his answer to this question: Django - Import views from separate apps

提交回复
热议问题