Add demo orders creation scripts
- Created management command for generating demo orders - Added SQL script to create 25 orders with random dates (±15 days) - Added Python runner script for executing SQL - Demo orders include varied statuses, payment methods, and delivery types - Orders distributed across different dates for testing date filter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
24
myproject/run_demo_orders.py
Normal file
24
myproject/run_demo_orders.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
Скрипт для создания демо-заказов напрямую через SQL
|
||||
"""
|
||||
import os
|
||||
import django
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
|
||||
django.setup()
|
||||
|
||||
from django.db import connection
|
||||
|
||||
# Читаем SQL скрипт
|
||||
with open('create_demo_orders.sql', 'r', encoding='utf-8') as f:
|
||||
sql = f.read()
|
||||
|
||||
# Выполняем SQL
|
||||
with connection.cursor() as cursor:
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
print("[OK] SQL script executed successfully!")
|
||||
print("[OK] 25 demo orders created!")
|
||||
except Exception as e:
|
||||
print(f"[ERROR] {e}")
|
||||
raise
|
||||
Reference in New Issue
Block a user