Cannot start any django app

前端 未结 14 1819
离开以前
离开以前 2021-01-02 06:22

I am a newbie at Django and everytime I try to run python panel/manage.py startapp %app% (panel is my project) it gives me the error:

Error: \'         


        
14条回答
  •  梦谈多话
    2021-01-02 07:10

    I had the same issue because I was trying to "restart" my app after carrying out changes, but startapp is meant to be used once to create a new app. To view changes, syncronize app with DB with python manage.py migrate and restart the server with python manage.py runserver instead.

    From the django-admin docs

    (manage.py does essentially the same thing as django-admin)

    startapp [destination]

    django-admin startapp

    Creates a Django app directory structure for the given app name in the current directory or the given destination.

    By default the directory created contains a models.py file and other app template files. (See the source for more details.) If only the app name is given, the app directory will be created in the current working directory.

    If the optional destination is provided, Django will use that existing directory rather than creating a new one. You can use ‘.’ to denote the current working directory.

    For example:

    django-admin startapp myapp /Users/jezdez/Code/myapp

提交回复
热议问题