Commit d71e0ec1 authored by Lance Cedric Tan's avatar Lance Cedric Tan

Accomplished Contact and About apps

parent 5999e1a6
No preview for this file type
# Generated by Django 3.2 on 2023-02-16 12:49
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)),
('description', models.CharField(max_length=255)),
('release_date', models.CharField(max_length=255)),
],
),
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)),
('monthly_listeners', models.IntegerField()),
],
),
migrations.CreateModel(
name='SongInfo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(max_length=255)),
('song_length', models.IntegerField()),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='About.album')),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='About.artist')),
],
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='About.artist'),
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
from django.db import models
from django.urls import reverse
class Artist(models.Model):
artist_name = models.CharField(max_length=255)
monthly_listeners = models.IntegerField()
def __str__(self):
return artist_name
def get_absolute_url(self):
return reverse('artist', args=[str(self.artist_name)])
class Album(models.Model):
album_name = models.CharField(max_length=255)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE
)
description = models.CharField(max_length=255)
release_date = models.CharField(max_length=255)
def __str__(self):
return album_name
def get_absolute_url(self):
return reverse('album', args=[str(self.album_name)])
class SongInfo(models.Model):
song_title = models.CharField(max_length=255)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE
)
album = models.ForeignKey(
Album,
on_delete=models.CASCADE
)
song_length = models.IntegerField()
def __str__(self):
return song_title
def get_absolute_url(self):
return reverse('song', args=[str(self.song_title)])
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name= "About"
from django.shortcuts import render from django.shortcuts import render
# Create your views here. # Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hi, I'm Lance, and I'm a big fan of J-Rock and J-Metal!")
\ No newline at end of file
# Generated by Django 3.2 on 2023-02-16 12:48
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)),
('description', models.CharField(max_length=255)),
('release_date', models.CharField(max_length=255)),
],
),
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)),
('monthly_listeners', models.IntegerField()),
],
),
migrations.CreateModel(
name='SongInfo',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(max_length=255)),
('song_length', models.IntegerField()),
('album', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Contact.album')),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Contact.artist')),
],
),
migrations.AddField(
model_name='album',
name='artist',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Contact.artist'),
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
from django.db import models
from django.urls import reverse
class Artist(models.Model):
artist_name = models.CharField(max_length=255)
monthly_listeners = models.IntegerField()
def __str__(self):
return artist_name
def get_absolute_url(self):
return reverse('artist', args=[str(self.artist_name)])
class Album(models.Model):
album_name = models.CharField(max_length=255)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE
)
description = models.CharField(max_length=255)
release_date = models.CharField(max_length=255)
def __str__(self):
return album_name
def get_absolute_url(self):
return reverse('album', args=[str(self.album_name)])
class SongInfo(models.Model):
song_title = models.CharField(max_length=255)
artist = models.ForeignKey(
Artist,
on_delete=models.CASCADE
)
album = models.ForeignKey(
Album,
on_delete=models.CASCADE
)
song_length = models.IntegerField()
def __str__(self):
return song_title
def get_absolute_url(self):
return reverse('song', args=[str(self.song_title)])
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name= "Contact"
from django.shortcuts import render from django.shortcuts import render
# Create your views here. # Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("You can contact me at: fake@example.com, or text 09080000000000")
\ No newline at end of file
No preview for this file type
...@@ -44,6 +44,8 @@ INSTALLED_APPS = [ ...@@ -44,6 +44,8 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'Homepage', 'Homepage',
'About',
'Contact',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
......
...@@ -17,6 +17,8 @@ from django.contrib import admin ...@@ -17,6 +17,8 @@ from django.contrib import admin
from django.urls import include, path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path('About', include('About.urls', namespace="About")),
path('Contact', include('Contact.urls', namespace="Contact")),
path('Homepage', include('Homepage.urls', namespace="Homepage")), path('Homepage', include('Homepage.urls', namespace="Homepage")),
path('admin/', admin.site.urls), 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