startapp with manage.py to create app in another directory

前端 未结 6 902
谎友^
谎友^ 2021-01-31 14:25

My Django project structure is:

/proj
  /frontend
  /server
    /proj
    /app1
    /app2
  manage.py

How do I run python ma

6条回答
  •  旧巷少年郎
    2021-01-31 15:04

    You can specify the path to /server/appname directory after appname as the destination i.e. where the Django app directory structure will be created.

    From the startapp docs:

    startapp  [destination] # startapp command usage 
    

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

    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

    So, you can specify the path to your /server/appname directory as the destination value.

    django-admin.py startapp appname [destination] # specify destination
    

    What you need to do?

    1. You need to first create a directory appname inside /server.

    mkdir /server/appname # create directory from root level
    

    2. Then, run the startapp command to create the app.

    django-admin.py startapp appname ./server/appname
    

提交回复
热议问题