Django
Django
What it does: Creates a virtual environment named venv . This is an isolated Python environment
where you can install project-specific dependencies without interfering with the system's Python or other
projects.
source venv/Scripts/activate
On Mac/Linux:
source venv/bin/activate
What it does: Activates the virtual environment so that the Python interpreter and libraries from this
environment are used instead of the system-wide versions.
What it does: Installs Django in your virtual environment. This ensures that Django is accessible within
your project.
What it does: Creates a new Django project named prem . This generates the following structure:
projectname/
manage.py
projectname/
__init__.py
settings.py
urls.py
asgi.py
wsgi.py
Alternatively:
What it does: Initializes the Django project in the current directory instead of creating a new folder.
What it does: Validates your project setup for any issues like configuration errors. It should return
System check identified no issues (0 silenced) .
What it does: Starts a development server at http://127.0.0.1:8000/ . This allows you to check the
project in a browser. Visit the URL, and you should see Django's default welcome page.
What it does: Applies the migration files to the database, creating or updating tables. For a new project,
this sets up the default database tables Django needs (e.g., for user authentication).
What it does: Creates an admin user to manage the site via Django's admin interface. You'll be
prompted to enter:
Username: admin (or your choice)
Email: [email protected] (or your choice)
Password: admin (or your choice)
Summary Workflow
1. Set up and activate a virtual environment to isolate dependencies.
2. Install Django.
3. Start a new project with django-admin startproject .
4. Check that the project is functional with check and runserver .
5. Configure and set up the database with migrations.
6. Create a superuser for admin tasks.
You can now access the admin panel at http://127.0.0.1:8000/admin/ using the superuser credentials!
Create another user and check if it reflects in db.sqlite