Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
neilocampo_music
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Christianneil Emmanuel Ocampo
neilocampo_music
Commits
ebf32282
Commit
ebf32282
authored
Feb 13, 2023
by
Christianneil Emmanuel Ocampo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated string representaion of About App models.
parent
1f633198
Pipeline
#2721
canceled with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
models.cpython-39.pyc
neilocampo_music/homepage/__pycache__/models.cpython-39.pyc
+0
-0
models.py
neilocampo_music/homepage/models.py
+7
-3
No files found.
neilocampo_music/homepage/__pycache__/models.cpython-39.pyc
View file @
ebf32282
No preview for this file type
neilocampo_music/homepage/models.py
View file @
ebf32282
from
django.db
import
models
from
django.db
import
models
from
django.urls
import
reverse
from
django.urls
import
reverse
# Create your models here
class
Artist
(
models
.
Model
):
class
Artist
(
models
.
Model
):
artist_name
=
models
.
CharField
(
max_length
=
100
)
artist_name
=
models
.
CharField
(
max_length
=
100
)
monthly_listeners
=
models
.
IntegerField
()
monthly_listeners
=
models
.
IntegerField
()
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}
'
.
format
(
self
.
artist_name
)
return
'{}
with {} monthly listeners'
.
format
(
self
.
artist_name
,
self
.
monthly_listeners
)
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'artist_detail'
,
args
=
[
str
(
self
.
artist_name
)])
return
reverse
(
'artist_detail'
,
args
=
[
str
(
self
.
artist_name
)])
...
@@ -19,11 +20,13 @@ class Album(models.Model):
...
@@ -19,11 +20,13 @@ class Album(models.Model):
release_date
=
models
.
DateField
()
release_date
=
models
.
DateField
()
def
__str__
(
self
):
def
__str__
(
self
):
return
'{} by {}'
.
format
(
self
.
album_name
,
self
.
artist
)
return
'{} by {} released on {}. {}'
.
format
(
self
.
album_name
,
self
.
artist
,
self
.
release_date
,
self
.
description
)
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'album_detail'
,
args
=
[
str
(
self
.
album_name
)])
return
reverse
(
'album_detail'
,
args
=
[
str
(
self
.
album_name
)])
class
Song
(
models
.
Model
):
class
Song
(
models
.
Model
):
song_title
=
models
.
CharField
(
max_length
=
100
)
song_title
=
models
.
CharField
(
max_length
=
100
)
artist
=
models
.
ForeignKey
(
Artist
,
on_delete
=
models
.
CASCADE
)
artist
=
models
.
ForeignKey
(
Artist
,
on_delete
=
models
.
CASCADE
)
...
@@ -31,7 +34,8 @@ class Song(models.Model):
...
@@ -31,7 +34,8 @@ class Song(models.Model):
song_length
=
models
.
DurationField
()
song_length
=
models
.
DurationField
()
def
__str__
(
self
):
def
__str__
(
self
):
return
'{} from {} by {}'
.
format
(
self
.
song_title
,
self
.
album
,
self
.
artist
)
return
'{} from {} by {} is {} long'
.
format
(
self
.
song_title
,
self
.
album
,
self
.
artist
,
self
.
song_length
)
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
reverse
(
'song_detail'
,
args
=
[
str
(
self
.
song_title
)])
return
reverse
(
'song_detail'
,
args
=
[
str
(
self
.
song_title
)])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment