Commit 4d1e39d9 authored by RJC's avatar RJC

added models and endpoints for about, homepage, and contact modules

parent 685836ed
Pipeline #2645 canceled with stages
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AboutConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'about'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import about
urlpatterns = [
path('', about, name='about'),
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def about(request):
return HttpResponse("I like Polyphia and music that sounds like them")
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ContactConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'contact'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import contact
urlpatterns = [
path('', contact, name='contact'),
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def contact(request):
payload = {
"DieSachbearbeiter\n"
"Choriner Straße 49\n"
"10435 Berlin\n"
"E - Mail: moinsen2 @ blindtextgenerator.com"
}
return HttpResponse(payload)
\ No newline at end of file
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class HomepageConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'homepage'
# Generated by Django 3.2 on 2023-02-13 09:59
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Album',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('album_name', models.CharField(max_length=255, null=True)),
('description', models.TextField(blank=True, null=True)),
('release_date', models.DateField(blank=True, null=True)),
],
),
migrations.CreateModel(
name='Artist',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('artist_name', models.CharField(max_length=255, null=True)),
('monthly_listeners', models.IntegerField(null=True)),
],
),
migrations.CreateModel(
name='Song',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(max_length=255, null=True)),
('album', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='song', to='homepage.album')),
('artist', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='song', to='homepage.artist')),
],
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='album', to='homepage.artist'),
),
]
from django.db import models
from django.db.models.base import Model
# Create your models here.
class Artist(models.Model):
artist_name = models.CharField(max_length=255, null=True)
monthly_listeners = models.IntegerField(null=True)
class Album(models.Model):
album_name = models.CharField(max_length=255, null=True)
artist = models.ForeignKey(Artist, related_name='album', on_delete=models.CASCADE, null=True)
description = models.TextField(blank=True, null=True)
release_date = models.DateField(blank=True, null=True)
class Song(models.Model):
song_title = models.CharField(max_length=255, null=True)
artist = models.ForeignKey(Artist, related_name='song', on_delete=models.CASCADE, null=True)
album = models.ForeignKey(Album, related_name='song', on_delete=models.CASCADE, null=True)
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import homepage
urlpatterns = [
path('', homepage, name='homepage'),
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def homepage(request):
return HttpResponse("Welcome to RJ's Music")
...@@ -40,6 +40,10 @@ INSTALLED_APPS = [ ...@@ -40,6 +40,10 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'about',
'homepage',
'contact',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -14,8 +14,11 @@ Including another URLconf ...@@ -14,8 +14,11 @@ 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.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('homepage/', include(('homepage.urls', 'homepage'), namespace="homepage")),
path('about/', include(('about.urls', 'about'), namespace="about")),
path('contact/', include(('contact.urls', 'contact'), namespace="contact")),
] ]
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