This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager | |
from django.contrib.auth.models import PermissionsMixin | |
from django.db import models | |
from django.utils import timezone | |
class UserManager(BaseUserManager): | |
"""Custom user manager""" | |
use_in_migrations = True | |
def _create_user(self, email, password, **extra_fields): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import string | |
from django.utils.text import slugify | |
# generate a rondom string to be appended to slug if the slug queried already exists | |
def random_string_generator(size=10, chars=string.ascii_lowercase + string.digits): | |
return ''.join(random.choice(chars) for _ in range(size)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.11.4-slim-bullseye | |
WORKDIR /app | |
ENV PYTHONUNBUFFERED 1 | |
ENV PYTHONDONTWRITEBYTECODE 1 | |
# install system dependencies | |
RUN apt-get update | |
# install dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
django: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
image: local_django | |
container_name: local_django | |
command: python manage.py runserver 0.0.0.0:8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git | |
**/.git | |
**/.gitignore | |
# vscode | |
**/.vscode | |
# docker | |
Dockerfile | |
docker-compose-deploy.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uwsgi_param QUERY_STRING $query_string; | |
uwsgi_param REQUEST_METHOD $request_method; | |
uwsgi_param CONTENT_TYPE $content_type; | |
uwsgi_param CONTENT_LENGTH $content_length; | |
uwsgi_param REQUEST_URI $request_uri; | |
uwsgi_param PATH_INFO $document_uri; | |
uwsgi_param DOCUMENT_ROOT $document_root; | |
uwsgi_param SERVER_PROTOCOL $server_protocol; | |
uwsgi_param REQUEST_SCHEME $scheme; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Dependencies: | |
pip install django | |
pip install django-storages[s3] | |
pip install python-decouple | |
""" | |
# proj/settings.py | |
from decouple import config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# project/settings.py | |
import os | |
from pathlib import Path | |
from decouple import config | |
BASE_DIR = Path(__file__).resolve().parent.parent | |
DATABASES = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: "3.8" | |
services: | |
app: | |
build: | |
context: . | |
dockerfile: ./compose/production/django/Dockerfile | |
command: ["sh", "-c", "/start-app.sh"] | |
image: django_prod | |
container_name: django_prod |