Skip to content

Instantly share code, notes, and snippets.

View santoshpy's full-sized avatar
🐍
Focusing

Santosh Purbey santoshpy

🐍
Focusing
View GitHub Profile
@santoshpy
santoshpy / django_project_directory_structure.md
Last active March 4, 2020 16:08
Django Project Directory Structure
@santoshpy
santoshpy / project_structure.md
Last active September 15, 2023 06:11
# Django Project Directory Structure

Django Project Structure

  • <virtualenv_name>
  • bin
  • include
  • lib
  • src
  • documents
  • requirements >>>>- - base.txt
@santoshpy
santoshpy / .gitignore
Last active October 27, 2024 17:16
gitignore file for django project
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
@santoshpy
santoshpy / email_authentication_backends.py
Last active September 28, 2017 05:11
Extends default django ModelBackend for both Email Authentication and Username Authentication against settings.AUTH_USER_MODEL. i.e: user can login with either email or username.
# In any authentication related app create new file email_authentication_backends.py
from django.contrib.auth.models import User
from django.contrib.auth.backends import ModelBackend
class EmailAuthBackend(ModelBackend):
"""
Extends default django ModelBackend for both Email Authentication and Username
Authentication against settings.AUTH_USER_MODEL
i.e: user can login with either email or username.
@santoshpy
santoshpy / 0_urllib2.py
Created November 25, 2016 14:23 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@santoshpy
santoshpy / urls.py
Last active June 25, 2016 10:09
Django Project Urls.py Patterns Examples In Django, the matching regex group(s) (ie ?P<month>, ?P<id>, ?P<username>) will be passed as a Keyword Argument (**kwarg) to the matching view.
#urls.py
"""
Django 1.9+ Pattern Syntax
"""
from blog.views import (
ArticleView,
YearArchiveView,
MonthArchiveView,
PostSlugView,