95π
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
documentation:
startapp <app_label> [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 do you need to do?
1. You need to first create a directory, appname
, inside /server
.
mkdir ./server/appname # Create a directory from the root level
2. Then, run the startapp
command to create the app.
django-admin.py startapp appname ./server/appname
16π
I always have my app in an internal folder (the same that Django creates, with the name of the project) following the design of Two Scoops of Django that is similar to what you want to do. When you want to create a new app, you can use, as the previous answer says,
python ../manage.py startapp my_new_app
from within the folder in which you want to create the app. Another thing, even easier that is what I do, is that you can run
django-admin startapp my_new_app
from this inner folder, of apps and it will work.
- [Django]-Whats the difference between a OneToOne, ManyToMany, and a ForeignKey Field in Django?
- [Django]-How do you serialize a model instance in Django?
- [Django]-What is the path that Django uses for locating and loading templates?
7π
If you are already in the server
directory, then you can run
python ../manage.py startapp appname
And appname
will be created in the server
directory instead of in the project root.
- [Django]-Are sessions needed for python-social-auth
- [Django]-Django REST framework: non-model serializer
- [Django]-Django JSONField inside ArrayField
5π
To Create a New App in Django project.
First:
- Go to your folder using Terminal, where you want to create app
Second:
- Type the below command in terminal,
django-admin startapp <new_app_name>
Now, you can check, new app created with the given name.
- [Django]-Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty
- [Django]-Django admin, hide a model
- [Django]-What is the advantage of Class-Based views?
1π
The simplest way I found is to go inside the server
folder and create an __init__.py
file:
touch __init__.py
Then, create any app you want:
django-admin startapp {{APP NAME}}
- [Django]-How to return HTTP 400 response in Django?
- [Django]-Django Forms: if not valid, show form with error message
- [Django]-Using Cloudfront with Django S3Boto
1π
If you started the project using cookiecutter-django, then steps are given in the link below.
The difference from the accepted answer and other answers I see here is that you need to change the name of the app in apps.py as an extra step.
New apps created are located in the project root, not inside the project slug #1725
To copy paste that here:
- create the <name-of-the-app> app with
python manage.py startapp
- move <name-of-the-app> directory to the <project_slug> directory
- edit <project_slug>/<name-of-the-app>/apps.py and change name = "<name-of-the-app>" to name = "<project_slug>.<name-of-the-app>"
- add "<project_slug>.<name-of-the-app>.apps.<NameOfTheAppConfigClass>", in your LOCAL_APPS in file config/settings/base.py
Here <project_slug> would be your "server" directory.
- [Django]-What is an efficient way of inserting thousands of records into an SQLite table using Django?
- [Django]-Django annotate count with a distinct field
- [Django]-Removing 'Sites' from Django admin page
0π
Use an absolute path for the manage file. It works well for me, and here is an example to run from the destination folder:
python /home/user/project_name/manage.py startupapp app_name
- [Django]-Django test RequestFactory vs Client
- [Django]-Pip install PIL fails
- [Django]-Django.db.utils.ProgrammingError: relation "bot_trade" does not exist