Commit 1ed648cb authored by KaoruSawade's avatar KaoruSawade

Fixed implementation of bookshelf app (updated settings, views, urls), created...

Fixed implementation of bookshelf app (updated settings, views, urls), created Author and Books admin panels, and migrated
parent 4669fb24
from django.contrib import admin
from .models import Author,Books
class AuthorAdmin(admin.ModelAdmin):
model = Author
class BooksAdmin(admin.ModelAdmin):
model = Books
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
# Register your models here.
# Generated by Django 4.1.7 on 2023-03-27 09:50
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(default='', max_length=300)),
('last_name', models.CharField(default='', max_length=300)),
('age', models.IntegerField(default='')),
('nationality', models.CharField(default='', max_length=300)),
('bio', models.CharField(default='', max_length=700)),
],
),
migrations.CreateModel(
name='Book',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(default='', max_length=300)),
('publisher', models.CharField(default='', max_length=300)),
('year_published', models.DateField(default='', null=True)),
('ISBN', models.IntegerField(default='', null=True, unique=True)),
('blurb', models.TextField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bookshelf.author')),
],
),
]
# Generated by Django 4.1.7 on 2023-03-27 09:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('bookshelf', '0001_initial'),
]
operations = [
migrations.RenameModel(
old_name='Book',
new_name='Books',
),
]
......@@ -15,7 +15,7 @@ class Books(models.Model):
author = models.ForeignKey(Author, on_delete=models.CASCADE)
publisher = models.CharField(max_length=300, default="")
year_published = models.DateField(null=True, default="")
ISBN = models.IntegerField(max_length=13, unique=True, null=True, default="")
ISBN = models.IntegerField(unique=True, null=True, default="")
blurb = models.TextField()
def __str__(self):
......
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "bookshelf"
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse('test')
\ No newline at end of file
......@@ -40,6 +40,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bookshelf',
]
MIDDLEWARE = [
......
......@@ -14,8 +14,9 @@ Including another URLconf
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