Populated urls, settings, admin, and views py files with bare minimum content...

Populated urls, settings, admin, and views py files with bare minimum content then implemented models for bookshelf
parent 01fd2c76
SECRET_KEY = 'django-insecure-qtwt+6uu6^f)x1^ohp^%-82y4!9fdptuuw4rt7e6phkxd&%c^j'
\ No newline at end of file
from django.contrib import admin
from .models import Author, Books
# Register your models here.
class AuthorAdmin(admin.ModelAdmin):
model = Author
class BooksAdmin(admin.ModelAdmin):
model = Books
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
\ No newline at end of file
# Generated by Django 4.1.6 on 2023-03-28 14:07
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=150)),
('last_name', models.CharField(max_length=80)),
('age', models.IntegerField()),
('nationality', models.CharField(max_length=50)),
('bio', models.TextField(max_length=700)),
],
),
migrations.CreateModel(
name='Books',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=180)),
('publisher', models.CharField(max_length=80)),
('year_published', models.CharField(max_length=4)),
('ISBN', models.IntegerField(max_length=13)),
('blurb', models.TextField(max_length=200)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
# Generated by Django 4.1.6 on 2023-03-28 14:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='books',
name='ISBN',
field=models.CharField(max_length=13),
),
]
from django.db import models
# Create your models here.
class Author(models.Model):
first_name = models.CharField(max_length=150)
last_name = models.CharField(max_length=80)
age = models.IntegerField()
nationality = models.CharField(max_length=50)
bio = models.TextField(max_length=700)
class Books(models.Model):
title = models.CharField(max_length=180)
author = models.ForeignKey(Author, on_delete=models.CASCADE)
publisher = models.CharField(max_length=80)
year_published = models.CharField(max_length=4)
ISBN = models.CharField(max_length=13)
blurb = models.TextField(max_length=200)
from django.urls import path
from .views import bookshelfpageview
urlpatterns = [
path('', bookshelfpageview, name='bookshelf')
]
app_name = "bookshelf"
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def bookshelfpageview(request):
return HttpResponse("Welcome to Matt's Music Library!")
\ No newline at end of file
"""
Django settings for mattarpas_reading project.
Generated by 'django-admin startproject' using Django 4.1.6.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
......@@ -20,7 +12,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-qtwt+6uu6^f)x1^ohp^%-82y4!9fdptuuw4rt7e6phkxd&%c^j'
SECRET_KEY = os.getenv('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
......@@ -37,6 +29,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bookshelf',
]
MIDDLEWARE = [
......
"""mattarpas_reading URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.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
from django.urls import include, path
urlpatterns = [
path('bookshelf/', include('bookshelf.urls', namespace="bookshelf")),
path('admin/', admin.site.urls),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment