Added models in homepage, completed lab 1

parent 7cf8cc6e
Pipeline #2752 failed with stages
SECRET_KEY = 'django-insecure-^uiz9wx8mr&4@%i9$mdsl7djrr#q)l(i937271l87v46&up-=k'
STATIC_ROOT='<folder path of where static items>'
\ No newline at end of file
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'
# Generated by Django 4.1.6 on 2023-02-13 15:29
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
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=50)),
('monthly_listeners', models.IntegerField()),
],
),
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=50)),
('album', models.CharField(max_length=50)),
('song_length', models.IntegerField()),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='About.artist')),
],
),
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=50)),
('description', models.CharField(max_length=100)),
('release_date', models.CharField(max_length=50)),
('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='About.artist')),
],
),
]
from django.db import models
class Artist(models.Model):
artist_name = models.CharField(max_length=50)
monthly_listeners = models.IntegerField()
def __str__(self):
return '{}: {} monthly listeners'.format(self.artist_name, self.monthly_listeners)
def get_absolute_url(self):
return reverse('artist name', args=[str(self.artist_name)])
class Album(models.Model):
album_name = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete = models.CASCADE)
description = models.CharField(max_length=100)
release_date = models.CharField(max_length=50)
def __str__(self):
return '{} by {}. {}. Released On: {}'.format(self.album_name, self.artist, self.description, self.release_date)
def get_absolute_url(self):
return reverse('album name', args=[str(self.album_name)])
class Song(models.Model):
song_title = models.CharField(max_length=50)
artist = models.ForeignKey(Artist, on_delete = models.CASCADE)
album = models.CharField(max_length=50)
song_length = models.IntegerField()
def __str__(self):
return '{} produced by {}, from the album {}. {} is the duration'.format(self.song_title, self.monthly_artist, self.album, self.song_length)
def get_absolute_url(self):
return reverse('song title', args=[str(self.song_title)])
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from .views import index
urlpatterns = [
path('', index, name='index'),
]
app_name = "About"
\ No newline at end of file
from django.http import HttpResponse
def index(request):
return HttpResponse("Hi, I'm Gareth, I am an avid listener of any type of music as long as I like it. It's mostly video game soundtracks though but outside of that, I listen to indie music mostly as pop isn't my thing!")
\ No newline at end of file
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 index
urlpatterns = [
path('', index, name='index'),
]
app_name = "Contact"
\ No newline at end of file
from django.http import HttpResponse
def index(request):
return HttpResponse("Contact Details: Phone Number: 09950985083; Email: gareth.castillo@obf.ateneo.edu")
\ 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'
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 index
urlpatterns = [
path('', index, name='index'),
]
app_name = "Homepage"
\ No newline at end of file
from django.http import HttpResponse
def index(request):
return HttpResponse("Welcome to Gareth's Music Library!")
\ No newline at end of file
Gareth Xerxes Yap Castillo
205828
BS CS-DGDD
Section F
I state that this lab activity was truthfully completed by me in accordance to the DISCS policies.
<sgd> Gareth Xerxes Yap Castillo, February 13, 2023
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'garethcastillo_music.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
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