Cannot start any django app

前端 未结 14 1579
离开以前
离开以前 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:06

    this error is because of the name conflicts between the app name and project name.you had given same name for your app and project .your project and app need to be different name .if you had given the same name the above mentioned error will occur .

    understand the difference between app and project

    Projects vs. apps

    What’s the difference between a project and an app? An app is a Web application that does something – e.g., a Weblog system, a database of public records or a simple poll app. A project is a collection of configuration and apps for a particular Web site. A project can contain multiple apps. An app can be in multiple projects.

    first create the project. then create the app.

    NOTE: name for app and project should be different

    first create a project with projectname

     django-admin.py startproject Projectname .
    

    Then create app with appname. (to create your app make sure you are in the same directory manage.py and type this command)

    python manage.py  startapp Appname 
    
    0 讨论(0)
  • 2021-01-02 07:09

    I ran into this issue while trying to set up a Wagtail project.

    Before creating the app, I had created and activated a virtualenv (using virtualenvwrapper) with the same name: $APPNAME. When I then ran wagtail start $APPNAME, Django looks for naming conflics in the $PYTHONPATH which in this instance points to /Users/User/.virtualenvs.

    Naturally, this results in a conflict as /Users/User/.virtualenvs/$APPNAME already exists.

    0 讨论(0)
  • 2021-01-02 07:09

    if you want to make an empty directory that will contain your new app

    project-dir
        └── blog
            ├── __init__.py
            ├── ...
            ├── blog-ext #this empty dir that will contain the new app
            └── views.py
    

    so instead of typing :

    python manage.py newapp blog/blog-ext
    

    it should be :

    django-admin startapp newapp blog/blog-ext
    
    0 讨论(0)
  • 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 <app_label> [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

    0 讨论(0)
  • 2021-01-02 07:14

    This message is displayed if you run "startapp" twice with the same app name. As pointed out above by the OP it doesn't reload the app, it creates one.

    0 讨论(0)
  • 2021-01-02 07:14

    Try classic "mysite" or "myproject". You can delete it anytime you want, so if it will accepted, then all your privious ideas conflict with Python modules.

    Edit: I tried all your ideas, there was no error for me. So, if you installed support libraries or modules for django, then some of them can contains such names.

    0 讨论(0)
提交回复
热议问题