2👍
I had the same trouble on my Mac as well.
I did solve it upgrading Django from vervion 1.3 to version 1.4.
37👍
Try this:
mkdir Apps\newapp
python manage.py startapp NewApp Apps/newapp
And you will to create a app called “NewApp” inside folder “Apps/newapp”.
- [Django]-Django project root self discovery
- [Django]-How can I chain Django's "in" and "iexact" queryset field lookups?
- [Django]-Running ./manage.py migrate during Heroku deployment
17👍
Create your Apps directory from your project’s root directory-
mkdir Apps
Move to your Apps directory-
cd Apps
Run python by calling the manage.py in your root project directory-
python ../manage.py startapp newapp
There you go
- [Django]-One app with many models vs. many apps with single model
- [Django]-Django templates – split string to array
- [Django]-Django Admin Page missing CSS
10👍
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.
django-admin.py startapp myapp /Users/jezdez/Code/myapp
So try python manage.py startapp myApp ./Apps/myApp
or with the full path.
- [Django]-Custom ordering in Django
- [Django]-Saving image/file through django shell
- [Django]-What is the difference between a site and an app in Django?
3👍
Manage.py file is a thin wrapper of django-admin.py
In case, you want to create a new app in any directory
Try this:
$ cd <directory path>
$ django-admin.py startapp <app-anme>
- [Django]-Django no such table:
- [Django]-When to use fabric or ansible?
- [Django]-Django icontains with __in lookup
3👍
For django 3.2.9
Create a sub directory Apps
to hold all the apps, move into it, create a directory for the app myApp
, then come back to root directory
mkdir Apps && cd Apps && mkdir myApp && cd ..
add a __init__.py
file (is a python way to treat a directory as a package)
Create a myApp inside Apps sub directory
manage.py startapp myApp Apps/myApp
(in windows, please use backslash)
above two lines of code will create myApp
Now, in settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Local
'Apps.myApp.apps.MyAppConfig', # new
]
in ./Apps/myApp/apps.py file, change name='myApp'
to name='Apps.myApp'
will solve the issue
- [Django]-Sqlite3.OperationalError: unable to open database file
- [Django]-Django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No module named psycopg
- [Django]-How to access request body when using Django Rest Framework and avoid getting RawPostDataException
1👍
As the documentation says you can use the command
django-admin startapp name [directory]
but in the example
django-admin startapp myapp /Users/jezdez/myapp
the documentation does not say that python creates the myapp folder. You should do it before the startapp command.
- [Django]-Django: 'unique_together' and 'blank=True'
- [Django]-Redirect to same page after POST method using class based views
- [Django]-In Django, how do I select 100 random records from the database?
0👍
For newer versions of Django
1. Create the required folder structure
mkdir -p apps/myapp && touch apps/__init__.py
2. Create the app
python manage.py startapp myapp apps/myapp
3. Configure the apps/myapp/apps.py
file as follows:
from django.apps import AppConfig
class MyappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.myapp'
4. Append the app in the INSTALLED_APPS
list at [project]/settings.py
INSTALLED_APPS = [
...
'apps.myapp',
]
Tested on Django 4.2.3 🤖
- [Django]-Equivalent of get_or_create for adding users
- [Django]-Django serializer Imagefield to get full URL
- [Django]-What is "load url from future" in Django