Fix Django migration issues and add missing URLs

- Create missing templates app urls.py
- Fix REST_FRAMEWORK pagination settings
- Add DEFAULT_AUTO_FIELD configuration
- Create migration files for all apps
- Fix auto-generated model warnings
- Verify database setup with test project
This commit is contained in:
Poker Design Developer
2026-05-31 16:01:00 +08:00
parent e7f7b8abf3
commit 3aa2eadc52
29 changed files with 125 additions and 1 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,69 @@
# Generated by Django 5.1.4 on 2026-05-31 07:59
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Project',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('name', models.CharField(max_length=100)),
('template_id', models.CharField(default='classic', max_length=50)),
('card_width', models.IntegerField(default=750)),
('card_height', models.IntegerField(default=1050)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('export_resolution', models.CharField(default='standard', max_length=20)),
('export_include_back', models.BooleanField(default=True)),
],
options={
'ordering': ['-updated_at'],
},
),
migrations.CreateModel(
name='CardLayer',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('card_type', models.CharField(max_length=20)),
('card_key', models.CharField(max_length=30)),
('layer_name', models.CharField(max_length=50)),
('layer_type', models.CharField(max_length=20)),
('visible', models.BooleanField(default=True)),
('locked', models.BooleanField(default=False)),
('opacity', models.FloatField(default=1.0)),
('z_index', models.IntegerField(default=0)),
('properties', models.JSONField(default=dict)),
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='layers', to='projects.project')),
],
options={
'ordering': ['card_key', 'z_index'],
},
),
migrations.CreateModel(
name='Asset',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('asset_type', models.CharField(max_length=20)),
('asset_key', models.CharField(max_length=50)),
('file_path', models.CharField(max_length=255)),
('file_name', models.CharField(max_length=100)),
('width', models.IntegerField(null=True)),
('height', models.IntegerField(null=True)),
('uploaded_at', models.DateTimeField(auto_now_add=True)),
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assets', to='projects.project')),
],
options={
'ordering': ['-uploaded_at'],
},
),
]

View File

@@ -0,0 +1,44 @@
# Generated by Django 5.1.4 on 2026-05-31 07:59
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='CardTemplate',
fields=[
('id', models.CharField(max_length=50, primary_key=True, serialize=False)),
('name', models.CharField(max_length=100)),
('description', models.TextField()),
('preview_image', models.ImageField(null=True, upload_to='templates/previews/')),
('color_spade', models.CharField(default='#000000', max_length=20)),
('color_heart', models.CharField(default='#FF0000', max_length=20)),
('color_club', models.CharField(default='#000000', max_length=20)),
('color_diamond', models.CharField(default='#FF0000', max_length=20)),
('color_background', models.CharField(default='#FFFFFF', max_length=20)),
('default_assets', models.JSONField(default=dict)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
options={
'ordering': ['name'],
},
),
migrations.CreateModel(
name='SuitSymbol',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('suit_name', models.CharField(max_length=20)),
('svg_path', models.TextField()),
('color', models.CharField(max_length=20)),
('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='suit_symbols', to='templates.cardtemplate')),
],
),
]

View File

@@ -0,0 +1,9 @@
from django.urls import path
from .views import template_list, template_detail
app_name = 'templates'
urlpatterns = [
path('templates/', template_list, name='template-list'),
path('templates/<str:pk>/', template_detail, name='template-detail'),
]

BIN
backend/db.sqlite3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -61,6 +61,8 @@ TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_TZ = True
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
STATIC_URL = 'static/'
MEDIA_URL = '/media/'
@@ -74,6 +76,6 @@ CORS_ALLOWED_ORIGINS = [
CORS_ALLOW_CREDENTIALS = True
REST_FRAMEWORK = {
'DEFAULT_PAGINATION': 'rest_framework.pagination.PageNumberPagination',
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 20,
}