Home  >  Q&A  >  body text

python - 创建完django项目,最后runserver有如下提示,求大神指点一下

PHP中文网PHP中文网2741 days ago252

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:59:41

    Title: After creating a new project, let’s create an app.
    Then add views, models, urls, etc. in the app.

    reply
    0
  • PHPz

    PHPz2017-04-18 09:59:41

    You haven’t imported your new project yet, when you are writing urlpatterns

    reply
    0
  • 迷茫

    迷茫2017-04-18 09:59:41

    There is a problem with the url syntax, and views are not imported

    reply
    0
  • PHPz

    PHPz2017-04-18 09:59:41

    The code in the urlpatterns part of your urls module should be as follows:

    urlpatterns = [
        '',
        url(r'^index$','newproject.views.hello'),
        ...
    ]

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:59:41

    The writing method of URL after Django 1.10 is different from the previous version. The above comments describe three supported writing methods. The function should be introduced first and then called. You may be seeing an old version of the tutorial

    import newproject.views
    
    urlpatterns = [
        url(r'^index$',newproject.views.hello,name='hello'),
        ...
    ]

    reply
    0
  • Cancelreply