├── .gitignore ├── Procfile ├── README.md ├── app ├── .env ├── __init__.py ├── admin.py ├── apps.py ├── models.py ├── templates │ └── app │ │ ├── student_confirm_delete.html │ │ ├── student_detail.html │ │ ├── student_form.html │ │ └── student_list.html ├── tests.py ├── urls.py └── views.py ├── db.sqlite3 ├── docs ├── 1.PNG ├── 10.PNG ├── 2.PNG ├── 3.PNG ├── 4.PNG ├── 5.PNG ├── 6.PNG ├── 7.PNG ├── 8.PNG └── 9.PNG ├── manage.py ├── rattlesnake ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py └── requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/osx,venv,macos,linux,python,django,pycharm,virtualenv 2 | 3 | ### Django Ignore ### 4 | __pycache__/ 5 | venv/ 6 | static/ 7 | .idea 8 | migrations -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | run: python manage.py makemigrations && python manage.py migrate 2 | web: gunicorn rattlesnake.wsgi -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Django CRUD App With SQLite (Python 3) 2 | ### Codename : Rattlesnake 3 | 4 | Tutorial for building create, retrieve, update and delete website application with Django and SQLite (default django database) 5 | 6 | ## Getting Started 7 | 8 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. 9 | 10 | ### Prerequisites 11 | 12 | Make sure you have installed Python 3 and virtual environment on your device 13 | 14 | ### Project structure 15 | File structure in django by default has a structure like below 16 | ``` 17 | * django-crud-sqlite/ 18 | |--- rattlesnake/ 19 | | |--- app/ 20 | | | |--- migrations/ 21 | | | |--- templates/ 22 | | | |--- __init__.py 23 | | | |--- admin.py 24 | | | |--- apps.py 25 | | | |--- models.py 26 | | | |--- tests.py 27 | | | |--- views.py 28 | | |--- rattlesnake/ 29 | | | |--- __init__.py 30 | | | |--- settings.py 31 | | | |--- urls.py 32 | | | |--- wsgi.py 33 | | |--- manage.py 34 | |--- venv/ 35 | ``` 36 | 37 | ### Step to create django crud 38 | 39 | A step by step series of examples that tell you how to get a development env running 40 | 41 | 1. Create virtual environment and activate inside your `django-crud-sqlite/` directory according the above structure 42 | ``` 43 | virtualenv venv 44 | > On windows -> venv\Scripts\activate 45 | > On linux -> . env/bin/activate 46 | ``` 47 | 2. Install django and start new project inside your `django-crud-sqlite/` directory according the above structure 48 | ``` 49 | pip install django 50 | django-admin startproject rattlesnake 51 | cd rattlesnake 52 | ``` 53 | 3. Create new app, from `rattlesnake/` directory will create create new `app/` to store the collection 54 | ``` 55 | > On Windows -> manage.py startapp app 56 | > On Linux, etc -> ./manage.py startapp app 57 | ``` 58 | 4. Register your app into `rattlesnake` project, the `app` to `INSTALLED_APP` in `rattlesnake/settings.py` 59 | ```python 60 | INSTALLED_APPS = [ 61 | 'django.contrib.admin', 62 | 'django.contrib.auth', 63 | : 64 | 'app', 65 | : 66 | ] 67 | ``` 68 | 5. Create the model to define the table structure of database and save the collection into database `app/models.py` 69 | ```python 70 | from django.db import models 71 | from django.urls import reverse 72 | 73 | # Create your models here. 74 | class Student(models.Model): 75 | name = models.CharField(max_length=200, null=False) 76 | identityNumber = models.CharField(max_length=200, null=False) 77 | address = models.CharField(max_length=200, null=True) 78 | department = models.CharField(max_length=200, null=True) 79 | 80 | def __str__(self): 81 | return self.name 82 | 83 | # The absolute path to get the url then reverse into 'student_edit' with keyword arguments (kwargs) primary key 84 | def get_absolute_url(self): 85 | return reverse('student_edit', kwargs={'pk': self.pk}) 86 | ``` 87 | 6. Every after change `models.py` you need to make migrations into `db.sqlite3` (database) to create the table for the new model 88 | ``` 89 | manage.py makemigrations 90 | manage.py migrate 91 | ``` 92 | 7. Create the views to create app pages on browser, the file is `app/views.py` according the above structure 93 | ```python 94 | from django.http import HttpResponse 95 | from django.shortcuts import render 96 | from django.views.generic import ListView, DetailView 97 | from django.views.generic.edit import CreateView, UpdateView, DeleteView 98 | from django.urls import reverse_lazy 99 | 100 | from .models import Student 101 | 102 | # Create your views here. 103 | 104 | class StudentList(ListView): 105 | model = Student 106 | 107 | class StudentDetail(DetailView): 108 | model = Student 109 | 110 | class StudentCreate(CreateView): 111 | model = Student 112 | # Field must be same as the model attribute 113 | fields = ['name', 'identityNumber', 'address', 'department'] 114 | success_url = reverse_lazy('student_list') 115 | 116 | class StudentUpdate(UpdateView): 117 | model = Student 118 | # Field must be same as the model attribute 119 | fields = ['name', 'identityNumber', 'address', 'department'] 120 | success_url = reverse_lazy('student_list') 121 | 122 | class StudentDelete(DeleteView): 123 | model = Student 124 | success_url = reverse_lazy('student_list') 125 | ``` 126 | 8. Then, create file `app/urls.py` to define app url path (in CI as same as route function) 127 | ```python 128 | from django.urls import path 129 | from . import views 130 | 131 | urlpatterns = [ 132 | path('', views.StudentList.as_view(), name='student_list'), 133 | path('view/', views.StudentDetail.as_view(), name='student_detail'), 134 | path('new', views.StudentCreate.as_view(), name='student_new'), 135 | path('edit/', views.StudentUpdate.as_view(), name='student_edit'), 136 | path('delete/', views.StudentDelete.as_view(), name='student_delete'), 137 | ] 138 | ``` 139 | 9. The `app/urls.py` would not work unless you include that into the main url `rattlesnake/urls.py` 140 | ```python 141 | from django.contrib import admin 142 | from django.urls import path, include 143 | 144 | urlpatterns = [ 145 | : 146 | path('student/', include('app.urls')), 147 | : 148 | ] 149 | ``` 150 | 10. Create the html file to display user interface, you need create directory `app/templates/app/` like below 151 | ``` 152 | * django-crud-sqlite/ 153 | |--- rattlesnake/ 154 | | |--- app/ 155 | | | |--- migrations/ 156 | | | |--- templates/ 157 | | | | |--- app/ 158 | | | |--- __init__.py 159 | | | |--- admin.py 160 | | | |--- apps.py 161 | | | |--- models.py 162 | | | |--- tests.py 163 | | | |--- views.py 164 | | |--- rattlesnake/ 165 | | | |--- __init__.py 166 | | | |--- settings.py 167 | | | |--- urls.py 168 | | | |--- wsgi.py 169 | | |--- manage.py 170 | |--- venv/ 171 | ``` 172 | 11. Create file `app/templates/app/student_list.html` to display or parsing student list data with `ListView` library 173 | ```html 174 |

Student List

175 | Create New Student

176 | 177 | 178 | 179 | 180 | 181 | 182 | {% for student in object_list %} 183 | 184 | 185 | 186 | 191 | 192 | {% empty %} 193 | 194 | {% endfor %} 195 |
NameIdentity NumberAction
{{ student.name }}{{ student.identityNumber }} 187 | Detail 188 | Edit 189 | Delete 190 |
Data is empty! Please, add data first.
196 | ``` 197 | 12. Create file `app/templates/app/student_detail.html` to display or parsing data of each student and will used by `DetailView` library 198 | ```html 199 |

Student Detail

200 |

Name : {{ object.name }}

201 |

Identity Number : {{ object.identityNumber }}

202 |

Address : {{ object.address }}

203 |

Department : {{ object.department }}

204 | ``` 205 | 13. Create file `app/templates/app/student_form.html` to display form input and edit views 206 | ```html 207 |

Student Form

208 |
{% csrf_token %} 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 |
Name:{{ form.name }}
Identity Number:{{ form.identityNumber }}
Department:{{ form.department }}
Address:{{ form.address }}
234 |
235 | ``` 236 | 14. Create file `app/templates/app/student_confirm_delete.html` to display promt or alert confirmation to delete the object view 237 | ```html 238 |
{% csrf_token %} 239 | Are you sure you want to delete "{{ object }}" ? 240 | 241 |
242 | ``` 243 | 15. Test the project 244 | ``` 245 | manage.py runserver 246 | ``` 247 | 248 | ### After change structure of flask project 249 | ``` 250 | * django-crud-sqlite/ 251 | |--- rattlesnake/ 252 | | |--- app/ 253 | | | |--- migrations/ 254 | | | |--- templates/ 255 | | | | |--- app/ 256 | | | | | |--- student_confirm_delete.html 257 | | | | | |--- student_detail.html 258 | | | | | |--- student_form.html 259 | | | | | |--- student_list.html 260 | | | |--- __init__.py 261 | | | |--- admin.py 262 | | | |--- apps.py 263 | | | |--- models.py 264 | | | |--- tests.py 265 | | | |--- urls.py 266 | | | |--- views.py 267 | | |--- rattlesnake/ 268 | | | |--- __init__.py 269 | | | |--- settings.py 270 | | | |--- urls.py 271 | | | |--- wsgi.py 272 | | |--- db.sqlite3 273 | | |--- manage.py 274 | |--- venv/ 275 | ``` 276 | 277 | ### Running service screenshot 278 | 279 | 1. List student page but if list is empty will display `Data is empty! Please add data first.` 280 | 281 | ![Sample 1](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/1.PNG) 282 | 283 | 2. Form input student page, url path `student/new` 284 | 285 | ![Sample 2](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/2.PNG) 286 | 287 | 3. List student page if data inserted 288 | 289 | ![Sample 3](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/3.PNG) 290 | 291 | ![Sample 4](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/4.PNG) 292 | 293 | 4. Student detail page, url path `student/view/` 294 | 295 | ![Sample 5](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/5.PNG) 296 | 297 | ![Sample 6](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/6.PNG) 298 | 299 | 5. Form edit student page, url path `student/edit/ 300 | 301 | ![Sample 7](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/7.PNG) 302 | 303 | ![Sample 8](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/8.PNG) 304 | 305 | 6. Confirmation page if data will remove from collection, url path `student/delete/` 306 | 307 | ![Sample 9](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/9.PNG) 308 | 309 | ![Sample 10](https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/master/docs/10.PNG) 310 | 311 | ## Built With 312 | 313 | * [Python 3](https://www.python.org/download/releases/3.0/) - The language programming used 314 | * [Django 2](https://www.djangoproject.com/) - The web framework used 315 | * [Virtualenv](https://virtualenv.pypa.io/en/latest/) - The virtual environment used 316 | * [SQLite 3](https://www.sqlite.org/index.html) - The database library 317 | 318 | ## Clone or Download 319 | 320 | You can clone or download this project 321 | ``` 322 | > Clone : git clone https://github.com/piinalpin/django-crud-sqlite.git 323 | ``` 324 | 325 | ## Authors 326 | 327 | * **Alvinditya Saputra** - *Initial work* - [DSS Consulting](https://dssconsulting.id/) - [LinkedIn](https://linkedin.com/in/piinalpin) [Instagram](https://www.instagram.com/piinalpin) [Twitter](https://www.twitter.com/piinalpin) 328 | -------------------------------------------------------------------------------- /app/.env: -------------------------------------------------------------------------------- 1 | DATABASE_URL=sqlite:///db.sqlite3 -------------------------------------------------------------------------------- /app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/app/__init__.py -------------------------------------------------------------------------------- /app/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /app/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AppConfig(AppConfig): 5 | name = 'app' 6 | -------------------------------------------------------------------------------- /app/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.urls import reverse 3 | 4 | # Create your models here. 5 | class Student(models.Model): 6 | name = models.CharField(max_length=200, null=False) 7 | identityNumber = models.CharField(max_length=200, null=False) 8 | address = models.CharField(max_length=200, null=True) 9 | department = models.CharField(max_length=200, null=True) 10 | 11 | def __str__(self): 12 | return self.name 13 | 14 | def get_absolute_url(self): 15 | return reverse('student_edit', kwargs={'pk': self.pk}) -------------------------------------------------------------------------------- /app/templates/app/student_confirm_delete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

Student Delete

9 |
{% csrf_token %} 10 | Are you sure you want to delete "{{ object }}" ? 11 | 12 |
13 | 14 | -------------------------------------------------------------------------------- /app/templates/app/student_detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

Student Detail

9 |

Name : {{ object.name }}

10 |

Identity Number : {{ object.identityNumber }}

11 |

Address : {{ object.address }}

12 |

Department : {{ object.department }}

13 | 14 | -------------------------------------------------------------------------------- /app/templates/app/student_form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

Student Form

9 |
{% csrf_token %} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
Name:{{ form.name }}
Identity Number:{{ form.identityNumber }}
Department:{{ form.department }}
Address:{{ form.address }}
35 |
36 | 37 | -------------------------------------------------------------------------------- /app/templates/app/student_list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 |

Student List

9 | Create New Student

10 | 11 | 12 | 13 | 14 | 15 | 16 | {% for student in object_list %} 17 | 18 | 19 | 20 | 25 | 26 | {% empty %} 27 | 28 | {% endfor %} 29 |
NameIdentity NumberAction
{{ student.name }}{{ student.identityNumber }} 21 | Detail 22 | Edit 23 | Delete 24 |
Data is empty! Please, add data first.
30 | 31 | -------------------------------------------------------------------------------- /app/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /app/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | urlpatterns = [ 5 | path('', views.StudentList.as_view(), name='student_list'), 6 | path('view/', views.StudentDetail.as_view(), name='student_detail'), 7 | path('new', views.StudentCreate.as_view(), name='student_new'), 8 | path('edit/', views.StudentUpdate.as_view(), name='student_edit'), 9 | path('delete/', views.StudentDelete.as_view(), name='student_delete'), 10 | ] -------------------------------------------------------------------------------- /app/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponse 2 | from django.shortcuts import render 3 | from django.views.generic import ListView, DetailView 4 | from django.views.generic.edit import CreateView, UpdateView, DeleteView 5 | from django.urls import reverse_lazy 6 | 7 | from .models import Student 8 | 9 | # Create your views here. 10 | 11 | class StudentList(ListView): 12 | model = Student 13 | 14 | class StudentDetail(DetailView): 15 | model = Student 16 | 17 | class StudentCreate(CreateView): 18 | model = Student 19 | fields = ['name', 'identityNumber', 'address', 'department'] 20 | success_url = reverse_lazy('student_list') 21 | 22 | class StudentUpdate(UpdateView): 23 | model = Student 24 | fields = ['name', 'identityNumber', 'address', 'department'] 25 | success_url = reverse_lazy('student_list') 26 | 27 | class StudentDelete(DeleteView): 28 | model = Student 29 | success_url = reverse_lazy('student_list') -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/db.sqlite3 -------------------------------------------------------------------------------- /docs/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/1.PNG -------------------------------------------------------------------------------- /docs/10.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/10.PNG -------------------------------------------------------------------------------- /docs/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/2.PNG -------------------------------------------------------------------------------- /docs/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/3.PNG -------------------------------------------------------------------------------- /docs/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/4.PNG -------------------------------------------------------------------------------- /docs/5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/5.PNG -------------------------------------------------------------------------------- /docs/6.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/6.PNG -------------------------------------------------------------------------------- /docs/7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/7.PNG -------------------------------------------------------------------------------- /docs/8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/8.PNG -------------------------------------------------------------------------------- /docs/9.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/docs/9.PNG -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == '__main__': 6 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rattlesnake.settings') 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError as exc: 10 | raise ImportError( 11 | "Couldn't import Django. Are you sure it's installed and " 12 | "available on your PYTHONPATH environment variable? Did you " 13 | "forget to activate a virtual environment?" 14 | ) from exc 15 | execute_from_command_line(sys.argv) 16 | -------------------------------------------------------------------------------- /rattlesnake/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/piinalpin/django-crud-sqlite/f610a77511b98965cbf483aad8697917703fad5a/rattlesnake/__init__.py -------------------------------------------------------------------------------- /rattlesnake/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for rattlesnake project. 3 | 4 | Generated by 'django-admin startproject' using Django 2.1.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/2.1/ref/settings/ 11 | """ 12 | 13 | import os 14 | import django_heroku 15 | # import dj_database_url 16 | # import dotenv 17 | 18 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 19 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 20 | 21 | # # load environment variables from .env 22 | # dotenv_file = os.path.join(BASE_DIR, ".env") 23 | # if os.path.isfile(dotenv_file): 24 | # dotenv.load_dotenv(dotenv_file) 25 | 26 | # Quick-start development settings - unsuitable for production 27 | # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ 28 | 29 | # SECURITY WARNING: keep the secret key used in production secret! 30 | SECRET_KEY = '-)ir)&2lz9o41=qsd7pbzl+uv%1tgf+$%ddvz9bbw6_(exk)(f' 31 | 32 | # SECURITY WARNING: don't run with debug turned on in production! 33 | DEBUG = True 34 | 35 | ALLOWED_HOSTS = ['localhost', 'django-crud-rattlesnake.herokuapp.com/'] 36 | 37 | 38 | # Application definition 39 | 40 | INSTALLED_APPS = [ 41 | 'django.contrib.admin', 42 | 'django.contrib.auth', 43 | 'django.contrib.contenttypes', 44 | 'django.contrib.sessions', 45 | 'django.contrib.messages', 46 | 'django.contrib.staticfiles', 47 | 'app' 48 | ] 49 | 50 | MIDDLEWARE = [ 51 | 'django.middleware.security.SecurityMiddleware', 52 | 'django.middleware.common.CommonMiddleware', 53 | 'django.middleware.csrf.CsrfViewMiddleware', 54 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 55 | 'django.contrib.messages.middleware.MessageMiddleware', 56 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 57 | ] 58 | 59 | ROOT_URLCONF = 'rattlesnake.urls' 60 | 61 | TEMPLATES = [ 62 | { 63 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 64 | 'DIRS': [], 65 | 'APP_DIRS': True, 66 | 'OPTIONS': { 67 | 'context_processors': [ 68 | 'django.template.context_processors.debug', 69 | 'django.template.context_processors.request', 70 | 'django.contrib.auth.context_processors.auth', 71 | 'django.contrib.messages.context_processors.messages', 72 | ], 73 | }, 74 | }, 75 | ] 76 | 77 | WSGI_APPLICATION = 'rattlesnake.wsgi.application' 78 | 79 | 80 | # Database 81 | # https://docs.djangoproject.com/en/2.1/ref/settings/#databases 82 | 83 | 84 | # Password validation 85 | # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators 86 | 87 | AUTH_PASSWORD_VALIDATORS = [ 88 | { 89 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 90 | }, 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 99 | }, 100 | ] 101 | 102 | 103 | # Internationalization 104 | # https://docs.djangoproject.com/en/2.1/topics/i18n/ 105 | 106 | LANGUAGE_CODE = 'en-us' 107 | 108 | TIME_ZONE = 'UTC' 109 | 110 | USE_I18N = True 111 | 112 | USE_L10N = True 113 | 114 | USE_TZ = True 115 | 116 | 117 | # Static files (CSS, JavaScript, Images) 118 | # https://docs.djangoproject.com/en/2.1/howto/static-files/ 119 | 120 | STATIC_URL = '/static/' 121 | PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) 122 | STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') 123 | django_heroku.settings(locals()) 124 | -------------------------------------------------------------------------------- /rattlesnake/urls.py: -------------------------------------------------------------------------------- 1 | """rattlesnake URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/2.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('student/', include('app.urls')) 22 | ] 23 | -------------------------------------------------------------------------------- /rattlesnake/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for rattlesnake project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | # from whitenoise.django import DjangoWhiteNoise 14 | 15 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rattlesnake.settings') 16 | 17 | application = get_wsgi_application() 18 | # application = DjangoWhiteNoise(application) 19 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | dj-database-url==0.5.0 2 | Django==2.1.5 3 | django-heroku==0.3.1 4 | gunicorn==19.9.0 5 | psycopg2==2.7.7 6 | psycopg2-binary==2.7.7 7 | python-dotenv==0.10.1 8 | pytz==2018.9 9 | whitenoise==4.1.2 10 | --------------------------------------------------------------------------------