add: add product and category models
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from .banner import *
|
||||
9
core/apps/shared/admin/banner.py
Normal file
9
core/apps/shared/admin/banner.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from core.apps.shared.models import Banner
|
||||
|
||||
|
||||
@admin.register(Banner)
|
||||
class BannerAdmin(admin.ModelAdmin):
|
||||
list_display = ['id', 'banner']
|
||||
|
||||
@@ -4,3 +4,6 @@ from django.apps import AppConfig
|
||||
class SharedConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'core.apps.shared'
|
||||
|
||||
def ready(self):
|
||||
from . import admin
|
||||
27
core/apps/shared/migrations/0001_initial.py
Normal file
27
core/apps/shared/migrations/0001_initial.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Generated by Django 5.2 on 2025-08-28 16:17
|
||||
|
||||
import uuid
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Banner',
|
||||
fields=[
|
||||
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('banner', models.ImageField(upload_to='shared/banners/')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'banner',
|
||||
'verbose_name_plural': 'bannerlar',
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,2 @@
|
||||
from .base import *
|
||||
from .banner import *
|
||||
11
core/apps/shared/models/banner.py
Normal file
11
core/apps/shared/models/banner.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from django.db import models
|
||||
|
||||
from core.apps.shared.models import BaseModel
|
||||
|
||||
|
||||
class Banner(BaseModel):
|
||||
banner = models.ImageField(upload_to='shared/banners/')
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'banner'
|
||||
verbose_name_plural = 'bannerlar'
|
||||
@@ -6,7 +6,7 @@ from django.db import models
|
||||
|
||||
class BaseModel(models.Model):
|
||||
id = models.UUIDField(primary_key=True, editable=False, unique=True, default=uuid.uuid4)
|
||||
created_at = models.DateTimeField(auto_created=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
22
core/apps/shared/paginations/custom.py
Normal file
22
core/apps/shared/paginations/custom.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
|
||||
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
from rest_framework.response import Response
|
||||
|
||||
class CustomPageNumberPagination(PageNumberPagination):
|
||||
page_size = 10
|
||||
page_query_param = 'page'
|
||||
page_size_query_param = 'page_size'
|
||||
max_page_size = 100
|
||||
|
||||
def get_paginated_response(self, data):
|
||||
return Response({
|
||||
'total': self.page.paginator.count,
|
||||
'page': self.page.number,
|
||||
'page_size': self.get_page_size(self.request),
|
||||
'total_pages': self.page.paginator.num_pages,
|
||||
'has_next': self.page.has_next(),
|
||||
'has_previous': self.page.has_previous(),
|
||||
'results': data
|
||||
})
|
||||
Reference in New Issue
Block a user