diff --git a/manage.py b/manage.py index 890ee80..ce48c52 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ import sys def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'notesapp.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/notesapp/__init__.py b/notes/__init__.py similarity index 100% rename from notesapp/__init__.py rename to notes/__init__.py diff --git a/notes/admin.py b/notes/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/notes/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/notes/apps.py b/notes/apps.py new file mode 100644 index 0000000..832dd3f --- /dev/null +++ b/notes/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class NotesConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'notes' diff --git a/notes/migrations/__init__.py b/notes/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notes/models.py b/notes/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/notes/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/notesapp/templates/index.html b/notes/templates/index.html similarity index 100% rename from notesapp/templates/index.html rename to notes/templates/index.html diff --git a/notesapp/templates/login.html b/notes/templates/login.html similarity index 100% rename from notesapp/templates/login.html rename to notes/templates/login.html diff --git a/notes/tests.py b/notes/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/notes/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/notesapp/urls.py b/notes/urls.py similarity index 93% rename from notesapp/urls.py rename to notes/urls.py index 5bcdbe1..c95de96 100644 --- a/notesapp/urls.py +++ b/notes/urls.py @@ -1,4 +1,4 @@ -"""notesapp URL Configuration +"""notes URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.2/topics/http/urls/ @@ -14,7 +14,8 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.urls import path -from notesapp import views + +from notes import views urlpatterns = [ path('', views.index, name='index'), diff --git a/notesapp/views.py b/notes/views.py similarity index 74% rename from notesapp/views.py rename to notes/views.py index 86f17ee..fca147d 100644 --- a/notesapp/views.py +++ b/notes/views.py @@ -4,10 +4,19 @@ from django.contrib.auth import authenticate, login, logout from django.shortcuts import render, redirect from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.models import User -from django.db import transaction +from django.db import transaction, connection + +# from notes.models import Note @login_required() def index(request): + user = request.user + +# notes = Note.objects.filter(owner=user) +# notes_list = [ { 'time' : note.time, 'body' : note.body } for note in notes ] +# notes_list.sort(key=lambda note: note['time']) + +# return render(request, 'index.html', { 'notes' : notes_list}) return render(request, 'index.html') def login_view(request): diff --git a/project/__init__.py b/project/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notesapp/asgi.py b/project/asgi.py similarity index 73% rename from notesapp/asgi.py rename to project/asgi.py index 47e2093..314b3d2 100644 --- a/notesapp/asgi.py +++ b/project/asgi.py @@ -1,5 +1,5 @@ """ -ASGI config for notesapp project. +ASGI config for project project. It exposes the ASGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'notesapp.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') application = get_asgi_application() diff --git a/notesapp/settings.py b/project/settings.py similarity index 91% rename from notesapp/settings.py rename to project/settings.py index 8b2d878..fe96eea 100644 --- a/notesapp/settings.py +++ b/project/settings.py @@ -1,5 +1,5 @@ """ -Django settings for notesapp project. +Django settings for project project. Generated by 'django-admin startproject' using Django 3.2.13. @@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-qv7dimrj38uypn7ai4*58#85#ptpz)5w#jvukdknra$3venf7k' +SECRET_KEY = 'django-insecure-)10v6d=(_iu)19nfuzz9jc6#$1lw=-)33s(%nv*#dsa6tibt1!' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'notes.apps.NotesConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -49,12 +50,12 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = 'notesapp.urls' +ROOT_URLCONF = 'project.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ 'notesapp/templates', ], + 'DIRS': [ 'notes/templates/' ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -67,7 +68,7 @@ TEMPLATES = [ }, ] -WSGI_APPLICATION = 'notesapp.wsgi.application' +WSGI_APPLICATION = 'project.wsgi.application' # Database diff --git a/project/urls.py b/project/urls.py new file mode 100644 index 0000000..b98d27b --- /dev/null +++ b/project/urls.py @@ -0,0 +1,20 @@ +"""project URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.2/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.urls import path, include + +urlpatterns = [ + path('', include('notes.urls')), +] diff --git a/notesapp/wsgi.py b/project/wsgi.py similarity index 73% rename from notesapp/wsgi.py rename to project/wsgi.py index c647d07..c080663 100644 --- a/notesapp/wsgi.py +++ b/project/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for notesapp project. +WSGI config for project project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'notesapp.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings') application = get_wsgi_application()