Skip to content

Commit

Permalink
new models
Browse files Browse the repository at this point in the history
  • Loading branch information
lnxfsf committed Nov 11, 2023
1 parent 3d20177 commit 6138830
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 4 deletions.
Binary file modified backend/animanga_project/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file modified backend/animanga_project/__pycache__/urls.cpython-311.pyc
Binary file not shown.
6 changes: 5 additions & 1 deletion backend/animanga_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,8 @@
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.AllowAny',
]
}
}


MEDIA_ROOT = 'images/'
MEDIA_URL= 'images/'
1 change: 1 addition & 0 deletions backend/animanga_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from django.contrib import admin
from django.urls import path,include


urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
Expand Down
Binary file modified backend/api/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/serializers.cpython-311.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file modified backend/api/__pycache__/views.cpython-311.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Generated by Django 4.2.7 on 2023-11-11 19:48

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='anime',
name='season',
),
migrations.AddField(
model_name='anime',
name='background_image',
field=models.ImageField(default=None, upload_to=''),
),
migrations.AddField(
model_name='anime',
name='end_date',
field=models.DateField(default=None),
),
migrations.AddField(
model_name='anime',
name='episodes',
field=models.IntegerField(default=0),
),
migrations.AddField(
model_name='anime',
name='genre',
field=models.TextField(default=None),
),
migrations.AddField(
model_name='anime',
name='image',
field=models.ImageField(default=None, upload_to=''),
),
migrations.AddField(
model_name='anime',
name='num_of_fav',
field=models.IntegerField(default=None),
),
migrations.AddField(
model_name='anime',
name='seasons',
field=models.IntegerField(default=None),
),
migrations.AddField(
model_name='anime',
name='start_date',
field=models.DateField(default=None),
),
migrations.AddField(
model_name='anime',
name='studio',
field=models.TextField(default=None),
),
migrations.AddField(
model_name='anime',
name='yt_trailer',
field=models.TextField(default=None),
),
migrations.AlterField(
model_name='anime',
name='description',
field=models.TextField(default=None),
),
]
Binary file not shown.
24 changes: 22 additions & 2 deletions backend/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,28 @@
# Create your models here.
class Anime(models.Model):
title = models.CharField(max_length=250)
season = models.CharField(max_length=250)
description = models.CharField(max_length=100)
genre = models.TextField(default=None)

seasons = models.IntegerField(default=None)

start_date = models.DateField(default=None)
end_date = models.DateField(default=None)

image = models.ImageField(default=None, upload_to='images')
background_image = models.ImageField(default=None, upload_to='images')

num_of_fav = models.IntegerField(default=None)

description = models.TextField(default=None)

studio = models.TextField(default=None)

episodes = models.IntegerField(default=0)

yt_trailer = models.TextField(default=None)




def __str__(self):
return self.title
2 changes: 1 addition & 1 deletion backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class AnimeSerializer(serializers.ModelSerializer):
class Meta:
model = Anime
fields = ('id', 'title', 'description',)
fields = ('id', 'title','genre', 'seasons','start_date', 'end_date', 'image','background_image','num_of_fav','description', 'studio', 'episodes', 'yt_trailer', )
2 changes: 2 additions & 0 deletions backend/api/templates/api/show_image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{% load static %}
<img src="{% get_media_prefix %}{{ image.image }}">
10 changes: 10 additions & 0 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from .models import Anime
from .serializers import AnimeSerializer








class DetailAnime(generics.RetrieveUpdateDestroyAPIView):
queryset = Anime.objects.all()
serializer_class = AnimeSerializer
Expand All @@ -16,3 +23,6 @@ class ListAnime(generics.ListCreateAPIView):
queryset = Anime.objects.all()
serializer_class = AnimeSerializer




Binary file modified backend/db.sqlite3
Binary file not shown.
Binary file added backend/images/images/download.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend/images/images/download_t3tAWrh.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ gunicorn
packaging
whitenoise
djangorestframework
Pillow

0 comments on commit 6138830

Please sign in to comment.