Commit bd994527 authored by Gink's avatar Gink

Finalize models and enable database connection with Django

> To initialize, delete db.sqlite3, then run
> python manage.py makemigrations mymusiclist
> python manage.py migrate
> Then you populate db.sqlite3 by sourcing SQL/sqlite3.sql
parent 240264c1
......@@ -3,7 +3,7 @@ mymusiclist.sql
convert
extract.sql
Assuming you have sqlite3 installed,
Assuming you have sqlite3 installed and Django setup with migrations,
While in same directory as db.sqlite3, run:
Sqlite3
......
......@@ -62,8 +62,8 @@ create table tag_entry(
FOREIGN KEY (entry_id) REFERENCES music_entry(id)
);
-- assuming we have featured songs
-- currently unused
create table featured_songs(
song_id int unique,
......
This diff is collapsed.
This diff is collapsed.
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
class user_account(models.Model):
  • Unless there's additional fields aside from username, email, first and last name, no need for this class, the User class is enough

  • i removed both dba

Please register or sign in to reply
id = models.AutoField(primary_key=true)
id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=64)
last_name = models.CharField(max_length=64)
email = models.CharField(max_length=64)
class artist(models.Model):
id = models.AutoField(primary_key=true)
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=64)
description = models.TextField()
class album(models.Model):
id = models.AutoField(primary_key=true)
id = models.AutoField(primary_key=True)
album_name = models.CharField(max_length=64)
year = models.DecimalField(max_digits=4, decimal_places=0)
# FOREIGN KEY artist_id
artist = models.ForeignKey(artist)
class song(models.Model):
id = models.AutoField(primary_key=true)
id = models.AutoField(primary_key=True)
song_name = models.TextField()
genre = models.CharField(max_length=128)
song_length = models.PositiveIntegerField(default=0)
lyrics = models.TextField()
#FOREIGN KEY ARTISTID
#FOREIGN KEY ALBUMID
song_length = models.PositiveIntegerField(default=0, null=True)
lyrics = models.TextField(null=True)
artist = models.ForeignKey(artist)
album = models.ForeignKey(album)
class music_playlist(models.Model):
id = models.AutoField(primary_key=true)
id = models.AutoField(primary_key=True)
playlist_name = models.CharField(max_length=32)
is_public = models.BooleanField(default=false)
#FOREIGN KEY TO user_account
is_public = models.BooleanField(default=False)
user = models.ForeignKey(user_account)
class music_entry(models.Model):
RATING_CHOICES = (
......@@ -47,12 +45,13 @@ class music_entry(models.Model):
(8,'9'),
(9,'10')
)
id = models.AutoField(primary_key=true)
id = models.AutoField(primary_key=True)
order_in_playlist = models.PositiveSmallIntegerField()
rating = models.DecimalField(max_digits=1, decimal_places=0, choices=RATING_CHOICES)
#FOREIGN KEY TO PLAYLIST
#FOREIGN KEY TO SONG
playlist = models.ForeignKey(music_playlist)
song = models.ForeignKey(song)
class tag(models.Model):
id = models.AutoField(primary_key=true)
name = models.CharField(max_length=32)
\ No newline at end of file
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=32)
tag = models.ManyToManyField(music_entry)
......@@ -32,12 +32,13 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'core',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.staticfiles'
]
MIDDLEWARE = [
......
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