Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Setup and Workflow

Installing Django

Option 1: Using pip

pip install django  # Installs Django globally

Option 2: Using pipenv (Recommended)

pipenv install django  # Installs Django in the project folder

Create a virtual environment named env using Python and activate it in the current PowerShell session.

python -m venv env
env\Scripts\activate

Setting Up pipenv

  1. Install pipenv:

    pip install pipenv
  2. Verify installation:

    pip show pipenv
    pipenv --version
  3. Activate the virtual environment:

    pipenv shell

Starting a Django Project

  1. View available Django admin commands:

    django-admin
  2. Start a new Django project:

    django-admin startproject storefront .
  3. Run the Django project:

    python manage.py runserver  # Runs on the default port (8000)
    python manage.py runserver 7000  # Runs on a custom port (7000)

Setting Python Interpreter in VS Code

  1. Find the virtual environment path:

    pipenv --venv
  2. Copy the path and append \Scripts\python.exe (e.g., C:\Users\charith\.virtualenvs\storefront-JshKXDAk\Scripts\python.exe).

  3. Set the Python interpreter in VS Code:

    • Press Ctrl + P.
    • Search for Python: Select Interpreter.
    • Choose Enter Interpreter Path and paste the path.

VS Code Terminal Shortcuts

  • Open terminal: Ctrl + ` or J
  • Clear terminal: Ctrl + L

Creating a Django App

  1. Create a new app:

    python manage.py startapp playground
  2. Key files and their purposes:

    • migrations/: Tracks and applies database migrations (e.g., generating database tables).
    • admin.py: Customizes the Django admin interface.
    • apps.py: Configures the app.
    • models.py: Defines model classes to interact with the database.
    • views.py: Handles requests and returns responses.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages