django project in ubuntu
- Install Python and pip:
- Open the terminal and run the following command to install Python:
sudo apt-get install python3
Then, install pip using the command:
sudo apt-get install python3-pip
Create a virtual environment:
- Run the command:
python3 -m venv myenv
Activate the virtual environment using:
source myenv/bin/activate
Install Django:
Use pip to install Django:
pip install django
Create a new Django project:
Run the command:
django-admin startproject myproject
Navigate into the project directory:
Use:
cd myproject
Start the development server:
Run the command:
python manage.py runserver
Open a web browser and access the development server:
Visit
http://localhost:8000
in your browserCreate a new Django app within the project:
Use:
python manage.py startapp myapp
Update the settings.py file:
Open the file
myproject/settings.py
and add'myapp',
to theINSTALLED_APPS
list.Create database tables:
- Run the command:
python manage.py migrate
- Run the command:
Create a Django superuser:
- Use:
python manage.py createsuperuser
- Use:
Start building your Django app:
- Open the
myapp
directory and start creating models, views, and templates according to your project requirements.
- Open the
Configure URL routing:
- Open the
myproject/urls.py
file and add URL patterns to map the views you created in your app.
- Open the
Run the development server again:
- Use:
python manage.py runserver
- Use:
Test your Django app:
- Open a web browser and visit
http://localhost:8000
to see your Django app in action.
- Open a web browser and visit
Continue developing your Django app by adding more functionality and features as needed.
Note: Make sure to refer to the official Django documentation for more detailed explanations and additional configuration options.