Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0bcd890
added pipfiles
Dec 4, 2018
737d6d2
Day 1 -halfway
Dec 4, 2018
2299a2c
Decouple
Dec 4, 2018
4671293
Added Admin User
Dec 5, 2018
a849ad9
Migration w/ New Fields
Dec 5, 2018
6dcd5b1
Added personal notes migration
Dec 5, 2018
ea7ef2e
User/PersonalNote Class
Dec 5, 2018
ed8fe7e
Installed the REST Framework
Dec 5, 2018
bbc1b97
Exposed the PersonalNotes Model
Dec 5, 2018
c2afc3b
Added Routes
Dec 5, 2018
45be69e
Added the Required user Field
Dec 5, 2018
1456af3
Filter Results by User
Dec 5, 2018
658d33c
Set up Cors
Dec 5, 2018
4407d56
Set up Token Authentication
Dec 5, 2018
d127cf5
Day 4
Dec 5, 2018
2b6ab10
Added info to .env
Dec 5, 2018
0c13820
Added Desirable
Dec 7, 2018
acf59d6
Heroku
Dec 7, 2018
1897772
debug
Dec 7, 2018
ce2f513
Debug
Dec 7, 2018
039b90c
Debug
Dec 7, 2018
44b0a5c
debug
Dec 7, 2018
0572ac7
Debug
Dec 7, 2018
90c5f1b
debug
Dec 7, 2018
750e8b1
debug
Dec 7, 2018
38fb547
Trying stuff
Dec 7, 2018
f1272c2
Trying 2
Dec 7, 2018
a9cf56c
Debug
Dec 7, 2018
dff212d
Finished
Dec 7, 2018
a16ed3c
Heroku login
Dec 7, 2018
36fdbfd
Heroku final
Dec 7, 2018
bf6b01c
Messing with heroku
Dec 8, 2018
59f9382
Heroku para funsies
Dec 8, 2018
32db49d
Able to create superuser
Dec 8, 2018
c03d440
FrontPage
Dec 8, 2018
a3b13b5
Spell
Dec 8, 2018
5f20358
Working on html
Dec 8, 2018
6338a2c
url for html
Dec 8, 2018
324d5f5
Rollback
Dec 8, 2018
e1fcae9
Test
Dec 8, 2018
08247cb
bug
Dec 8, 2018
6e1c946
Reverting if html doesnt render
Dec 8, 2018
165d1c8
render_to_response attempt
Dec 8, 2018
75dd9b5
httpresponse
Dec 8, 2018
042c3fe
typo
Dec 8, 2018
0512fde
revert
Dec 8, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "/Users/Huff/.local/share/virtualenvs/Intro-Django-N-_rix2Y/bin/python"
}
19 changes: 19 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "*"
python-decouple = "*"
djangorestframework = "*"
gunicorn = "*"
"psycopg2-binary" = "*"
dj-database-url = "*"
whitenoise = "*"
django-cors-headers = "*"

[dev-packages]

[requires]
python_version = "3.7"
119 changes: 119 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
web: gunicorn djorg.wsgi --log-file -

db_init: python db/manage.py version_control
db_version: python db/manage.py db_version
migrate: python db/manage.py upgrade
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ Fork this repo to use for your projects this week.
* Add a Django front end to the data.
* Brainstorm a list of 10 additional features users would find useful.
* Implement the brainstormed list.


Added additional code to settings.py to connect table on heroku.

in settings.py (at end of file)
-----
if 'DATABASE_URL' in os.environ:
import dj_database_url
DATABASES = {'default': dj_database_url.config()}

in requirements.txt
------
dj-database-url
psycopg2
Empty file added djorg/__init__.py
Empty file.
151 changes: 151 additions & 0 deletions djorg/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
"""
Django settings for djorg project.

Generated by 'django-admin startproject' using Django 2.1.4.

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
from decouple import config



# 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 = 'bx8pxy42p4r9h3ysw($hp-j%jlt#w#ir&z^dj^==d(l5r8j&mm'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['notes-huthman.herokuapp.com']


# Application definition

INSTALLED_APPS = [
'notes',
'quotes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_framework.authtoken',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'corsheaders.middleware.CorsMiddleware',
'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',
]

CORS_ORIGIN_ALLOW_ALL = True

ROOT_URLCONF = 'djorg.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 = 'djorg.wsgi.application'

REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
}


# 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'),
'USER': 'admin4',
'PASSWORD': '123itworks',
}
}



# 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/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

if 'DATABASE_URL' in os.environ:
import dj_database_url
DATABASES = {'default': dj_database_url.config()}
37 changes: 37 additions & 0 deletions djorg/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""djorg 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, include, re_path
from rest_framework import routers
from rest_framework.authtoken import views
from notes.api import PersonalNoteViewSet
from quotes.api import PersonalQuoteViewSet
from notes.views import index

router = routers.DefaultRouter()
router.register(r'notes', PersonalNoteViewSet)
router.register(r'quotes', PersonalQuoteViewSet)

urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include(router.urls)),
re_path(r'^api-token-auth/', views.obtain_auth_token),
path('api-token-auth/', views.obtain_auth_token),
path('', index),
]



16 changes: 16 additions & 0 deletions djorg/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for djorg 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', 'djorg.settings')

application = get_wsgi_application()
15 changes: 15 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djorg.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)
Empty file added notes/__init__.py
Empty file.
Loading