Issue with Django startproject

Viewed 802

I'm new to django and python. I am currently trying to create a new django project by doing "django-admin startproject project" in the terminal, which works, but the only file that is in the folder is manage.py. I am not sure why the other files such as settings.py, urls.py, etc. are not located there

2 Answers

please try this one:

django-admin startproject project .

Please note the . at the end of the line.

After running it, you should have a project folder, and several files inside of that folder (init.py, asgi.py, settings.py, urls.py, wsgi.py)

EDIT it is best to use separate environments for each django project.

  1. make sure you downloaded and installed python.
  2. in the terminal, first make directory for this project.
$ mkdir project2020
$ cd project2020

after this step: you should have something like MacBook-Air:project2020 user$

  1. set up virtual environment
$ python3 -m venv myvenv
$ source myvenv/bin/activate

after this step: you should have something like the : (myvenv) MacBook-Air:project2020 user$ # note (myvenv)

  1. you can now install Django
$ python -m pip install Django

It will take some time to install

  1. now it's time to create a new project
(myvenv) MacBook-Air:project2020 user$ django-admin startproject mysite .

Here, make sure you add . at the end.

  1. check your project2020 folder. you should see what I wrote before.

When you run

django-admin startproject my_project_name

Your project structure will look like this

my_project_name/
    manage.py
    my_project_name/
        settings.py
        asgi.py
        wsgi.py
        urls.py

If you didn't get something like that then you probably didn't install Django correctly so try running

pip3 uninstall django
pip3 install django

Also if you are ono mac and didn't configure permissions properly and django-admin tells you command not found then run:

python3 -m django <The django-admin command you want>

One last note, you don't have to create a virtual environment to start working with Django, so didn't confuse yourself with them and focus on Django only

Related