Skip to content

mihaiandreineacsu/django-example

Repository files navigation

Django Demo Live-Call

This project is a demo used in Backend Live-Calls to exercise Django and other Backend matters.


Prerequisites

  • GIT: to download the Repository
  • Python if you prefer to start on your local machine: version that is supported by the Django Version set in requirements.txt
  • Docker if you prefer to start inside of container

Quickstart

Download and setup Environments

# Clone Repository
git clone https://github.com/mihaiandreineacsu/django-example.git
# Navigate to project
cd django-example

# Create a .env file from template.env file
cp template.env .env  # for bash (Linux/MacOS)
Copy-Item -Path template.env -Destination .env  # for powershell (Windows)
# Replace the default values from template.env in .env with your own

Starting the project on your local machine

# Create a local python environment
python -m venv venv

# Activate python virtual environment
source env/bin/activate  # for bash (Linux/MacOS)
.\venv\Scripts\Activate  # for powershell (Windows)

# Install requirements
pip install -r requirements.txt

# Create Database and migration files
python manage.py makemigrations

# Create Tables in Database
python manage.py migrate

# Start development server
python manage.py runserver

Staring the project using docker

# Build Docker Image
docker build -t django_example .

# Start the container in bash (Linux/MacOS)
docker run -it --rm \
    --name django_example \
    --env-file .env \
    -p 8000:8000 \
    -v $(pwd):/app \
    django_example

# Start the container in powershell (Windows)
docker run -it --rm `
    --name django_example `
    --env-file .env `
    -p 8000:8000 `
    -v ${PWD}:/app `
    django_example

Open the application on localhost:8000


Development

Vscode Extensions (Optional)

Command to Fetch remote Branches (Optional)

git fetch --prune && git branch -vv | grep ': gone]' | awk '{print $1}' | xargs git branch -D
git fetch --prune; git branch -vv | Select-String ': gone]' | %{ $_.ToString().Trim().Split(' ')[0] } | %{ git branch -D $_ }

You can automatically delete local branches that do not exist on the remote by running the following command:

This command does the following:

  1. git fetch --prune: Fetches the latest changes from the remote repository and prunes any remote-tracking branches that no longer exist on the remote.
  2. git branch -vv: Lists all local branches with additional information, including their last commit and the remote branch they are tracking.
  3. grep ': gone]': Filters the output to only show branches that are no longer present on the remote repository.
  4. awk '{print $1}': Extracts the branch names from the filtered output.
  5. xargs git branch -D: Deletes the local branches that were identified in the previous step.

You can run this command manually whenever you want to clean up your local branches. Alternatively, you can set up a cron job or a scheduled task to run this command automatically at regular intervals.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy