Skip to content

Instantly share code, notes, and snippets.

View yeazin's full-sized avatar
🇵🇸
Palestine Shall be Free

Md. N. Islam Yeasin yeazin

🇵🇸
Palestine Shall be Free
View GitHub Profile
@yeazin
yeazin / decorators.py
Last active September 24, 2021 09:42
Django REST Framework Custom Decorators
'''
Resources
Simple JWT Token bearer authentication : https://gist.github.com/ridvanaltun/6e3a7513519f998bd3f770c117e18f07
custom Decorators : https://docs.djangoproject.com/en/2.2/topics/class-based-views/intro/#decorating-the-class
'''
from django.http import response
from functools import wraps
## is authenticated
def IsLogin(func):
@yeazin
yeazin / erd.MD
Last active November 30, 2021 05:38
Generating ERD for Django Applications

Generate ERD from Django Models


Install Dependicies

Installing django extensions

  #for windows
  pip install django-extensions
  # for mac/linux
  pip3 install django-extensions

@yeazin
yeazin / login.html
Last active September 26, 2021 06:30
Django Multiple Username Field
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
@yeazin
yeazin / fileformat.py
Created November 30, 2021 05:36
Custom File Input Validation in Django
from django.core.exceptions import ValidationError
'''
Custom file validation function
'''
def ValidFile(value):
'''
1 mb = 1,048,576 bytes
15 mb = 15728640 bytes
'''
@yeazin
yeazin / current_request.py
Created December 1, 2021 04:47
Get the Current Request in Django/Django Rest Framework
'''
This file contains custom Middilware Functionality
'''
from threading import current_thread
from django.utils.deprecation import MiddlewareMixin
#underscore remove
_requests = {}