1
0
Fork 0

Reorder files

This commit is contained in:
Vili Sinervä 2024-11-24 16:45:26 +02:00
parent 8f3b1f817a
commit d9a41f82bb
No known key found for this signature in database
GPG key ID: DF8FEAF54EFAC996
16 changed files with 59 additions and 13 deletions

View file

@ -6,7 +6,7 @@ import sys
def main(): def main():
"""Run administrative tasks.""" """Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'notesapp.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
try: try:
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
except ImportError as exc: except ImportError as exc:

3
notes/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
notes/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class NotesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'notes'

View file

3
notes/models.py Normal file
View file

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

3
notes/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View file

@ -1,4 +1,4 @@
"""notesapp URL Configuration """notes URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see: The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/ 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')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.urls import path from django.urls import path
from notesapp import views
from notes import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index'), path('', views.index, name='index'),

View file

@ -4,10 +4,19 @@ from django.contrib.auth import authenticate, login, logout
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.models import User 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() @login_required()
def index(request): 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') return render(request, 'index.html')
def login_view(request): def login_view(request):

0
project/__init__.py Normal file
View file

View file

@ -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``. 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 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() application = get_asgi_application()

View file

@ -1,5 +1,5 @@
""" """
Django settings for notesapp project. Django settings for project project.
Generated by 'django-admin startproject' using Django 3.2.13. 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/ # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # 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! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
'notes.apps.NotesConfig',
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.contenttypes',
@ -49,12 +50,12 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
ROOT_URLCONF = 'notesapp.urls' ROOT_URLCONF = 'project.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [ 'notesapp/templates', ], 'DIRS': [ 'notes/templates/' ],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@ -67,7 +68,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = 'notesapp.wsgi.application' WSGI_APPLICATION = 'project.wsgi.application'
# Database # Database

20
project/urls.py Normal file
View file

@ -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')),
]

View file

@ -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``. 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 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() application = get_wsgi_application()