Compare commits
8 Commits
3285a1f7a1
...
c48e1ee928
Author | SHA1 | Date |
---|---|---|
Jason Zhu | c48e1ee928 | |
Jason Zhu | 42d7e3491c | |
Jason Zhu | 6c0d450a5b | |
Jason Zhu | cec7e99fd8 | |
Jason Zhu | cf9df791ea | |
Jason Zhu | 9ae517bb43 | |
Jason Zhu | 1cbffd0b45 | |
Jason Zhu | 4c97db3c09 |
|
@ -0,0 +1,7 @@
|
|||
[flake8]
|
||||
exclude=settings.py, wsgi.py, manage.py, */migrations/*
|
||||
ignore = B950, D104, D105, D106, D400, E203, E266, E501, N803, N806, W503
|
||||
max-complexity = 10
|
||||
max-line-length = 60
|
||||
select = B, B9, C, D, E, F, N, W
|
||||
ignore-names = setUp, tearDown, setUpClass, tearDownClass, setUpTestData
|
|
@ -0,0 +1,7 @@
|
|||
[alias]
|
||||
prev = checkout HEAD^
|
||||
next = !git checkout `git rev-list HEAD..$(git branch --contains | tail -1) | tail -1`
|
||||
ci = commit
|
||||
co = checkout
|
||||
st = status
|
||||
ll = log --oneline
|
|
@ -0,0 +1,108 @@
|
|||
.docker-env
|
||||
.vscode
|
||||
|
||||
# https://github.com/github/gitignore/blob/master/Python.gitignore
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
|
@ -0,0 +1,12 @@
|
|||
[settings]
|
||||
balanced_wrapping=true
|
||||
combine_as_imports=true
|
||||
force_add=true
|
||||
force_grid_wrap=0
|
||||
include_trailing_comma=true
|
||||
indent=' '
|
||||
line_length=60
|
||||
multi_line_output=3
|
||||
not_skip=__init__.py
|
||||
known_third_party = django, django_extensions, environ, factory, faker, pytz, rest_framework, test_plus
|
||||
known_first_party = blog, config, contact, organizer, suorganizer
|
|
@ -0,0 +1,34 @@
|
|||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v2.0.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
args: [--maxkb=500]
|
||||
- id: check-byte-order-marker
|
||||
- id: check-case-conflict
|
||||
- id: check-json
|
||||
- id: check-merge-conflict
|
||||
- id: check-symlinks
|
||||
- id: debug-statements
|
||||
- id: detect-private-key
|
||||
- id: end-of-file-fixer
|
||||
- id: mixed-line-ending
|
||||
args: [--fix=lf]
|
||||
- id: requirements-txt-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/pre-commit/mirrors-isort
|
||||
rev: v4.3.4
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/ambv/black
|
||||
rev: 18.9b0
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.6
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: flake8
|
||||
entry: flake8
|
||||
language: system
|
||||
name: flake8
|
||||
types: [python]
|
49
README.md
49
README.md
|
@ -1,3 +1,52 @@
|
|||
# Read Me
|
||||
|
||||
This is repository to practise Python + Django following **Web Development in Python with Django: Building Backend Web Applications and APIs with Django**
|
||||
|
||||
## Add app in django
|
||||
|
||||
* add in `config/settings.py`
|
||||
|
||||
## Models
|
||||
|
||||
Project Features
|
||||
|
||||
* Basic blogs with Blog Posts
|
||||
* Categorize startup businesses using Startup and Tags
|
||||
* Link to news articles about a specific startup (NewsLinks)
|
||||
* All objects appear in site URL:URIs necessitate slugs
|
||||
|
||||
Tag objects:
|
||||
* name
|
||||
* e.g.: Web Development, Django
|
||||
* slug (to identity)
|
||||
* e.g.: web-development, django
|
||||
|
||||
Startup Objects:
|
||||
* name
|
||||
* slug
|
||||
* description
|
||||
* date founded
|
||||
* contact
|
||||
* website link
|
||||
|
||||
News Link Objects:
|
||||
* title
|
||||
* slug
|
||||
* date published
|
||||
* link to article
|
||||
* startup
|
||||
|
||||
Blog Post Objects:
|
||||
* title
|
||||
* slug
|
||||
* text
|
||||
* date published
|
||||
|
||||
Object Relations:
|
||||
* One-To-One
|
||||
* One-To-Many
|
||||
* Many-To-One: NewsLink refers to a single Startup
|
||||
* Many-To-Many:
|
||||
* Tags and Startups
|
||||
* Blog Posts and Tags
|
||||
* Blog Posts and Startups
|
|
@ -0,0 +1,3 @@
|
|||
[tool.black]
|
||||
line-length = 60
|
||||
py36 = true
|
|
@ -0,0 +1,37 @@
|
|||
appdirs==1.4.4
|
||||
asgiref==3.2.10
|
||||
aspy.yaml==1.3.0
|
||||
attrs==20.2.0
|
||||
cached-property==1.5.2
|
||||
cfgv==3.2.0
|
||||
distlib==0.3.1
|
||||
Django==2.1.15
|
||||
django-extensions==3.0.9
|
||||
django-test-plus==1.1.1
|
||||
djangorestframework==3.12.1
|
||||
factory-boy==2.11.1
|
||||
Faker==0.9.2
|
||||
filelock==3.0.12
|
||||
flake8==3.5.0
|
||||
flake8-bugbear==18.2.0
|
||||
flake8-docstrings==1.3.0
|
||||
flake8-polyfill==1.0.2
|
||||
identify==1.5.6
|
||||
importlib-metadata==2.0.0
|
||||
mccabe==0.6.1
|
||||
nodeenv==1.5.0
|
||||
pep8-naming==0.7.0
|
||||
pre-commit==1.10.4
|
||||
pycodestyle==2.3.1
|
||||
pydocstyle==5.1.1
|
||||
pyflakes==1.6.0
|
||||
python-dateutil==2.8.1
|
||||
pytz==2018.5
|
||||
PyYAML==5.3.1
|
||||
six==1.15.0
|
||||
snowballstemmer==2.0.0
|
||||
sqlparse==0.4.1
|
||||
text-unidecode==1.2
|
||||
toml==0.10.1
|
||||
virtualenv==20.0.35
|
||||
zipp==3.3.1
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BlogConfig(AppConfig):
|
||||
name = 'blog'
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
@ -0,0 +1,126 @@
|
|||
"""
|
||||
Django settings for config project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 2.1.15.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.1/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'm7blhl1br5-$k_t@$o_g&m(t#fcck&a6gs5+9)27teta2e#qda'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
# first party
|
||||
'blog.apps.BlogConfig',
|
||||
'organizer.apps.OrganizerConfig',
|
||||
# 3rd party
|
||||
'rest_framework',
|
||||
'django_extensions',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
|
@ -0,0 +1,21 @@
|
|||
"""config URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.1/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
WSGI config for config project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
|
||||
application = get_wsgi_application()
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class OrganizerConfig(AppConfig):
|
||||
name = 'organizer'
|
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in New Issue