#33650: Update startproject template with config directory
-------------------------------------+-------------------------------------
     Reporter:  Timothy Allen        |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Core (Management     |                  Version:  dev
  commands)                          |
     Severity:  Normal               |               Resolution:
     Keywords:  startproject,        |             Triage Stage:
  template                           |  Someday/Maybe
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by lauryfriese):

 To update the Django `startproject` template to include a `config`
 directory, you can follow these steps:

 1. Open your terminal or command prompt.

 2. Create a new Django project using the `startproject` command. For
 example:
 ```
 django-admin startproject myproject
 ```
 This will create a new Django project in a directory named `myproject`.

 3. Navigate to the root directory of your Django project:
 ```
 cd myproject
 ```

 4. Create a new directory named `config` within your project directory:
 ```
 mkdir config
 ```

 5. Move the project-level configuration files (such as `settings.py`,
 `urls.py`, etc.) into the `config` directory:
 ```
 mv manage.py myproject/ config/
 mv myproject/settings.py config/
 mv myproject/urls.py config/
 ```

 6. Update the `manage.py` file to reflect the new location of the
 `settings.py` module. Open the `manage.py` file and change the line:
 ```python
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
 ```
 to:
 ```python
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
 ```

 7. Update the `wsgi.py` file within the `config` directory to reflect the
 new location of the `settings.py` module. Open the `config/wsgi.py` file
 and change the line:
 ```python
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
 ```
 to:
 ```python
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
 ```

 8. Update the `asgi.py` file within the `config` directory to reflect the
 new location of the `settings.py` module. Open the `config/asgi.py` file
 and change the line:
 ```python
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
 ```
 to:
 ```python
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
 ```

 9. Finally, update your project-level `.gitignore` file (if using version
 control) to exclude the `myproject` directory, as it is no longer used:
 ```
 # .gitignore
 myproject/
 ```

 With these steps, you have updated the Django `startproject` template to
 include a `config` directory and reorganized the project-level
 configuration files accordingly. Remember to adjust any import statements
 or file references in your codebase accordingly to reflect the updated
 file locations.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33650#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018a91a01192-b5c8764f-58d2-44c4-8ad2-d143bc585d0f-000000%40eu-central-1.amazonses.com.

Reply via email to