django-cfg 1.4.11__py3-none-any.whl → 1.4.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. django_cfg/apps/urls.py +120 -108
  2. django_cfg/core/generation/integration_generators/api.py +2 -1
  3. django_cfg/core/integration/url_integration.py +5 -10
  4. django_cfg/models/django/openapi.py +15 -128
  5. django_cfg/modules/django_client/core/archive/manager.py +2 -2
  6. django_cfg/modules/django_client/core/config/config.py +20 -0
  7. django_cfg/modules/django_client/core/config/service.py +1 -1
  8. django_cfg/modules/django_client/core/generator/__init__.py +4 -4
  9. django_cfg/modules/django_client/core/generator/base.py +71 -0
  10. django_cfg/modules/django_client/core/generator/python/__init__.py +16 -0
  11. django_cfg/modules/django_client/core/generator/python/async_client_gen.py +174 -0
  12. django_cfg/modules/django_client/core/generator/python/files_generator.py +180 -0
  13. django_cfg/modules/django_client/core/generator/python/generator.py +182 -0
  14. django_cfg/modules/django_client/core/generator/python/models_generator.py +318 -0
  15. django_cfg/modules/django_client/core/generator/python/operations_generator.py +278 -0
  16. django_cfg/modules/django_client/core/generator/python/sync_client_gen.py +102 -0
  17. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/api_wrapper.py.jinja +25 -2
  18. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client/main_client.py.jinja +24 -6
  19. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client/main_client_file.py.jinja +1 -0
  20. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client/operation_method.py.jinja +3 -1
  21. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client/sub_client.py.jinja +8 -1
  22. django_cfg/modules/django_client/core/generator/python/templates/client/sync_main_client.py.jinja +50 -0
  23. django_cfg/modules/django_client/core/generator/python/templates/client/sync_operation_method.py.jinja +9 -0
  24. django_cfg/modules/django_client/core/generator/python/templates/client/sync_sub_client.py.jinja +18 -0
  25. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/main_init.py.jinja +2 -0
  26. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/models/enum_class.py.jinja +3 -1
  27. django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/models/schema_class.py.jinja +3 -1
  28. django_cfg/modules/django_client/core/generator/python/templates/pyproject.toml.jinja +55 -0
  29. django_cfg/modules/django_client/core/generator/python/templates/utils/retry.py.jinja +271 -0
  30. django_cfg/modules/django_client/core/generator/typescript/__init__.py +14 -0
  31. django_cfg/modules/django_client/core/generator/typescript/client_generator.py +165 -0
  32. django_cfg/modules/django_client/core/generator/typescript/fetchers_generator.py +428 -0
  33. django_cfg/modules/django_client/core/generator/typescript/files_generator.py +207 -0
  34. django_cfg/modules/django_client/core/generator/typescript/generator.py +432 -0
  35. django_cfg/modules/django_client/core/generator/typescript/hooks_generator.py +539 -0
  36. django_cfg/modules/django_client/core/generator/typescript/models_generator.py +245 -0
  37. django_cfg/modules/django_client/core/generator/typescript/operations_generator.py +298 -0
  38. django_cfg/modules/django_client/core/generator/typescript/schemas_generator.py +329 -0
  39. django_cfg/modules/django_client/core/generator/typescript/templates/api_instance.ts.jinja +131 -0
  40. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client/app_client.ts.jinja +1 -1
  41. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client/client.ts.jinja +77 -1
  42. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client/main_client_file.ts.jinja +1 -0
  43. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client/sub_client.ts.jinja +3 -3
  44. django_cfg/modules/django_client/core/generator/typescript/templates/fetchers/fetchers.ts.jinja +45 -0
  45. django_cfg/modules/django_client/core/generator/typescript/templates/fetchers/index.ts.jinja +30 -0
  46. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/main_index.ts.jinja +73 -11
  47. django_cfg/modules/django_client/core/generator/typescript/templates/package.json.jinja +52 -0
  48. django_cfg/modules/django_client/core/generator/typescript/templates/schemas/index.ts.jinja +21 -0
  49. django_cfg/modules/django_client/core/generator/typescript/templates/schemas/schema.ts.jinja +24 -0
  50. django_cfg/modules/django_client/core/generator/typescript/templates/tsconfig.json.jinja +20 -0
  51. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/utils/errors.ts.jinja +3 -1
  52. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/utils/logger.ts.jinja +9 -1
  53. django_cfg/modules/django_client/core/generator/typescript/templates/utils/retry.ts.jinja +175 -0
  54. django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/utils/storage.ts.jinja +54 -10
  55. django_cfg/modules/django_client/management/commands/generate_client.py +5 -0
  56. django_cfg/modules/django_client/pytest.ini +30 -0
  57. django_cfg/modules/django_client/spectacular/__init__.py +3 -2
  58. django_cfg/modules/django_client/spectacular/async_detection.py +187 -0
  59. django_cfg/{dashboard → modules/django_dashboard}/management/commands/debug_dashboard.py +5 -5
  60. django_cfg/modules/django_logging/LOGGING_GUIDE.md +1 -1
  61. django_cfg/modules/django_unfold/callbacks/main.py +6 -6
  62. django_cfg/modules/django_unfold/dashboard.py +6 -6
  63. django_cfg/pyproject.toml +1 -1
  64. {django_cfg-1.4.11.dist-info → django_cfg-1.4.14.dist-info}/METADATA +1 -1
  65. {django_cfg-1.4.11.dist-info → django_cfg-1.4.14.dist-info}/RECORD +100 -78
  66. django_cfg/dashboard/DEBUG_README.md +0 -105
  67. django_cfg/dashboard/REFACTORING_SUMMARY.md +0 -237
  68. django_cfg/modules/django_client/core/generator/python.py +0 -751
  69. django_cfg/modules/django_client/core/generator/typescript.py +0 -872
  70. django_cfg/modules/django_drf_theme/CHANGELOG.md +0 -210
  71. django_cfg/modules/django_drf_theme/EXAMPLE.md +0 -465
  72. django_cfg/modules/django_drf_theme/IMPLEMENTATION.md +0 -232
  73. django_cfg/modules/django_drf_theme/README.md +0 -207
  74. django_cfg/modules/django_drf_theme/TAILWIND_CDN_GUIDE.md +0 -274
  75. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/__init__.py.jinja +0 -0
  76. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/app_init.py.jinja +0 -0
  77. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client/app_client.py.jinja +0 -0
  78. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client/flat_client.py.jinja +0 -0
  79. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/client_file.py.jinja +0 -0
  80. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/models/app_models.py.jinja +0 -0
  81. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/models/enums.py.jinja +0 -0
  82. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/models/models.py.jinja +0 -0
  83. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/utils/logger.py.jinja +0 -0
  84. /django_cfg/modules/django_client/core/generator/{templates/python → python/templates}/utils/schema.py.jinja +0 -0
  85. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/app_index.ts.jinja +0 -0
  86. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client/flat_client.ts.jinja +0 -0
  87. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client/operation.ts.jinja +0 -0
  88. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/client_file.ts.jinja +0 -0
  89. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/index.ts.jinja +0 -0
  90. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/models/app_models.ts.jinja +0 -0
  91. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/models/enums.ts.jinja +0 -0
  92. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/models/models.ts.jinja +0 -0
  93. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/utils/http.ts.jinja +0 -0
  94. /django_cfg/modules/django_client/core/generator/{templates/typescript → typescript/templates}/utils/schema.ts.jinja +0 -0
  95. /django_cfg/{dashboard → modules/django_dashboard}/__init__.py +0 -0
  96. /django_cfg/{dashboard → modules/django_dashboard}/components.py +0 -0
  97. /django_cfg/{dashboard → modules/django_dashboard}/debug.py +0 -0
  98. /django_cfg/{dashboard → modules/django_dashboard}/management/__init__.py +0 -0
  99. /django_cfg/{dashboard → modules/django_dashboard}/management/commands/__init__.py +0 -0
  100. /django_cfg/{dashboard → modules/django_dashboard}/sections/__init__.py +0 -0
  101. /django_cfg/{dashboard → modules/django_dashboard}/sections/base.py +0 -0
  102. /django_cfg/{dashboard → modules/django_dashboard}/sections/commands.py +0 -0
  103. /django_cfg/{dashboard → modules/django_dashboard}/sections/documentation.py +0 -0
  104. /django_cfg/{dashboard → modules/django_dashboard}/sections/overview.py +0 -0
  105. /django_cfg/{dashboard → modules/django_dashboard}/sections/stats.py +0 -0
  106. /django_cfg/{dashboard → modules/django_dashboard}/sections/system.py +0 -0
  107. {django_cfg-1.4.11.dist-info → django_cfg-1.4.14.dist-info}/WHEEL +0 -0
  108. {django_cfg-1.4.11.dist-info → django_cfg-1.4.14.dist-info}/entry_points.txt +0 -0
  109. {django_cfg-1.4.11.dist-info → django_cfg-1.4.14.dist-info}/licenses/LICENSE +0 -0
@@ -1,210 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to the Django DRF Tailwind Theme module will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.0.0] - 2025-01-XX
9
-
10
- ### 🎉 Initial Release
11
-
12
- First production-ready release of the modern Tailwind CSS theme for Django REST Framework Browsable API.
13
-
14
- ### ✨ Added
15
-
16
- #### Design & UI
17
- - Glass morphism design with backdrop-blur effects
18
- - Responsive mobile-first layout
19
- - Custom styled scrollbars
20
- - Smooth CSS transitions (200ms cubic-bezier)
21
- - Gradient color schemes (blue → purple)
22
- - HTTP method badges with color coding
23
- - Status code badges (success/error/warning)
24
-
25
- #### Theme System
26
- - Three-mode theme system (Light/Dark/Auto)
27
- - System preference detection and auto-switching
28
- - Cookie-based theme persistence
29
- - Smooth theme transitions
30
- - Theme dropdown in navbar
31
-
32
- #### Power User Features
33
- - **Command Palette** (⌘K) with quick actions:
34
- - Copy current URL
35
- - Toggle theme
36
- - Show keyboard shortcuts
37
- - **Keyboard Shortcuts**:
38
- - `⌘K` / `Ctrl+K` - Open command palette
39
- - `⌘D` / `Ctrl+D` - Toggle theme
40
- - `⌘C` / `Ctrl+C` - Copy URL
41
- - `?` - Show shortcuts help
42
- - `Esc` - Close dialogs
43
- - Toast notification system with auto-dismiss
44
- - One-click copy for JSON and URLs
45
-
46
- #### Response Viewer
47
- - Tabbed interface (Pretty/Raw/Headers)
48
- - Syntax highlighting with Prism.js
49
- - Copy button for JSON content
50
- - Collapsible JSON tree view
51
- - Character count for responses
52
- - Empty state placeholder
53
-
54
- #### Request Forms
55
- - Content type selector (JSON/Form Data/Multipart/Text)
56
- - JSON formatting and validation
57
- - Character counter for request body
58
- - Quick templates (empty object/array)
59
- - Additional headers support
60
- - Method selector (GET/POST/PUT/PATCH/DELETE)
61
- - Delete confirmation dialog
62
-
63
- #### Filters & Search
64
- - Smart field type detection
65
- - Active filters summary
66
- - One-click clear buttons
67
- - Help text tooltips
68
- - Filter persistence in URL
69
-
70
- #### Pagination
71
- - Clean pagination controls
72
- - Result count display
73
- - Previous/Next navigation
74
-
75
- #### Technical
76
- - Alpine.js v3 for reactivity (replaces jQuery)
77
- - Prism.js v1.29 for syntax highlighting
78
- - Tailwind CSS v4 integration
79
- - Template fallback mechanism
80
- - Full DRF compatibility
81
- - Extends `BrowsableAPIRenderer`
82
-
83
- ### 🔧 Configuration
84
-
85
- - Added `enable_drf_tailwind` field to `DjangoConfig` (default: `True`)
86
- - Added `renderer_classes` field to `DRFConfig`
87
- - Auto-registration in `INSTALLED_APPS` via `InstalledAppsBuilder`
88
- - Zero-configuration setup (works out of the box)
89
-
90
- ### 📊 Performance
91
-
92
- - **88% bundle size reduction** (278 KB → 33 KB)
93
- - CSS: 139 KB → 15 KB (89% reduction)
94
- - JS: 139 KB → 18 KB (87% reduction)
95
- - **+23 Lighthouse score improvement** (72 → 95)
96
- - **66% faster First Contentful Paint** (3.2s → 1.1s)
97
-
98
- ### 📚 Documentation
99
-
100
- - Complete README.md with features and usage
101
- - EXAMPLE.md with code examples
102
- - IMPLEMENTATION.md with technical details
103
- - Inline code documentation
104
- - Keyboard shortcuts help
105
-
106
- ### 🎯 Browser Support
107
-
108
- - Chrome/Edge 90+
109
- - Firefox 88+
110
- - Safari 14+
111
- - iOS Safari 14+
112
- - Chrome Mobile 90+
113
-
114
- ### 🔒 Security
115
-
116
- - No external JavaScript dependencies (CDN only for Alpine.js and Prism.js)
117
- - CSRF token handling
118
- - XSS protection via Django templating
119
- - Secure cookie handling for theme preference
120
-
121
- ---
122
-
123
- ## [Unreleased]
124
-
125
- ### 🚀 Planned Features
126
-
127
- #### Priority 2 (Next Release)
128
- - [ ] Pagination template (`pagination/numbers.html`)
129
- - [ ] Standalone JSON viewer component
130
- - [ ] Search functionality in command palette
131
- - [ ] LocalStorage theme persistence (in addition to cookies)
132
- - [ ] Export/download JSON functionality
133
- - [ ] Response time display
134
- - [ ] Request history
135
-
136
- #### Priority 3 (Future)
137
- - [ ] Unit tests with pytest
138
- - [ ] Integration tests
139
- - [ ] Visual regression tests (Playwright)
140
- - [ ] Accessibility audit (WCAG 2.1 AA compliance)
141
- - [ ] I18n support (multiple languages)
142
- - [ ] Custom color scheme configurator
143
- - [ ] Printable response view
144
- - [ ] API request bookmarks
145
-
146
- ### 🐛 Known Issues
147
-
148
- None currently. Please report issues at [GitHub Issues](https://github.com/your-org/django-cfg/issues).
149
-
150
- ---
151
-
152
- ## Version History
153
-
154
- ### [1.0.0] - 2025-01-XX
155
- - Initial production release
156
-
157
- ---
158
-
159
- ## Migration Guide
160
-
161
- ### From Bootstrap 3 (Standard DRF)
162
-
163
- No migration needed! The Tailwind theme is enabled by default and fully backward compatible.
164
-
165
- **To keep Bootstrap theme:**
166
- ```python
167
- class MyConfig(DjangoConfig):
168
- enable_drf_tailwind: bool = False
169
- ```
170
-
171
- **To use both:**
172
- ```python
173
- drf: DRFConfig = DRFConfig(
174
- renderer_classes=[
175
- 'rest_framework.renderers.JSONRenderer',
176
- 'django_cfg.modules.django_drf_theme.renderers.TailwindBrowsableAPIRenderer',
177
- 'rest_framework.renderers.BrowsableAPIRenderer', # Bootstrap fallback
178
- ]
179
- )
180
- ```
181
-
182
- ### Template Customization
183
-
184
- If you had custom DRF templates:
185
-
186
- **Old location:**
187
- ```
188
- your_app/templates/rest_framework/api.html
189
- ```
190
-
191
- **New location for Tailwind:**
192
- ```
193
- your_app/templates/rest_framework/tailwind/api.html
194
- ```
195
-
196
- Templates automatically fall back to standard DRF templates if not found.
197
-
198
- ---
199
-
200
- ## Credits
201
-
202
- - **Design Inspiration**: VS Code, Raycast, Linear, Vercel
203
- - **Technologies**: Django REST Framework, Tailwind CSS, Alpine.js, Prism.js
204
- - **Built for**: django-cfg package
205
-
206
- ---
207
-
208
- ## License
209
-
210
- Part of django-cfg. See main LICENSE file.
@@ -1,465 +0,0 @@
1
- # 📖 DRF Tailwind Theme - Examples
2
-
3
- ## 🚀 Basic Usage
4
-
5
- ### Default Configuration (Recommended)
6
-
7
- The Tailwind theme is enabled by default. Just create your config:
8
-
9
- ```python
10
- # config.py
11
- from django_cfg import DjangoConfig
12
- from django_cfg.models.api.drf import DRFConfig
13
-
14
- class MyProjectConfig(DjangoConfig):
15
- """My API configuration with Tailwind DRF theme enabled by default."""
16
-
17
- project_name: str = "My Amazing API"
18
- project_version: str = "1.0.0"
19
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
20
-
21
- # DRF is automatically configured with Tailwind theme ✨
22
- drf: DRFConfig = DRFConfig(
23
- page_size=50,
24
- )
25
-
26
- # Usage
27
- config = MyProjectConfig()
28
- settings = config.to_settings()
29
- ```
30
-
31
- **Result**: Beautiful Tailwind DRF Browsable API with glass morphism, dark mode, and keyboard shortcuts! 🎨
32
-
33
- ---
34
-
35
- ## 🎨 Theme Customization
36
-
37
- ### Disable Tailwind Theme
38
-
39
- If you prefer the classic Bootstrap 3 look:
40
-
41
- ```python
42
- class MyProjectConfig(DjangoConfig):
43
- project_name: str = "Classic API"
44
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
45
-
46
- # Disable Tailwind theme
47
- enable_drf_tailwind: bool = False
48
- ```
49
-
50
- ### Custom Renderer
51
-
52
- Use your own renderer while keeping other settings:
53
-
54
- ```python
55
- from django_cfg.models.api.drf import DRFConfig
56
-
57
- class MyProjectConfig(DjangoConfig):
58
- project_name: str = "Custom API"
59
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
60
-
61
- drf: DRFConfig = DRFConfig(
62
- renderer_classes=[
63
- 'rest_framework.renderers.JSONRenderer',
64
- 'my_app.renderers.MyCustomRenderer',
65
- ]
66
- )
67
- ```
68
-
69
- ### Multiple Renderers
70
-
71
- Support both Tailwind and your custom renderer:
72
-
73
- ```python
74
- class MyProjectConfig(DjangoConfig):
75
- project_name: str = "Multi-Renderer API"
76
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
77
-
78
- drf: DRFConfig = DRFConfig(
79
- renderer_classes=[
80
- 'rest_framework.renderers.JSONRenderer',
81
- 'django_cfg.modules.django_drf_theme.renderers.TailwindBrowsableAPIRenderer',
82
- 'rest_framework.renderers.BrowsableAPIRenderer', # Fallback
83
- 'my_app.renderers.PDFRenderer',
84
- ]
85
- )
86
- ```
87
-
88
- ---
89
-
90
- ## 🔧 Advanced Configuration
91
-
92
- ### Full DRF Configuration with Tailwind
93
-
94
- ```python
95
- from django_cfg import DjangoConfig
96
- from django_cfg.models.api.drf import DRFConfig
97
- from django_cfg.models.api.spectacular import SpectacularConfig
98
-
99
- class ProductionAPIConfig(DjangoConfig):
100
- """Production-ready API with Tailwind theme."""
101
-
102
- # Project
103
- project_name: str = "Production API"
104
- project_version: str = "2.0.0"
105
- project_description: str = "High-performance REST API with modern UI"
106
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
107
-
108
- # Environment
109
- debug: bool = False
110
-
111
- # Security
112
- security_domains: list[str] = ["api.example.com", "www.example.com"]
113
-
114
- # DRF with Tailwind
115
- drf: DRFConfig = DRFConfig(
116
- # Authentication
117
- authentication_classes=[
118
- 'rest_framework.authentication.TokenAuthentication',
119
- 'rest_framework.authentication.SessionAuthentication',
120
- ],
121
-
122
- # Permissions
123
- permission_classes=[
124
- 'rest_framework.permissions.IsAuthenticated',
125
- ],
126
-
127
- # Renderers (Tailwind enabled by default)
128
- renderer_classes=[
129
- 'rest_framework.renderers.JSONRenderer',
130
- 'django_cfg.modules.django_drf_theme.renderers.TailwindBrowsableAPIRenderer',
131
- ],
132
-
133
- # Pagination
134
- page_size=100,
135
-
136
- # Throttling
137
- throttle_rates={
138
- 'anon': '100/hour',
139
- 'user': '1000/hour',
140
- },
141
-
142
- # Versioning
143
- default_version='v2',
144
- allowed_versions=['v1', 'v2'],
145
- )
146
-
147
- # API Documentation
148
- spectacular: SpectacularConfig = SpectacularConfig(
149
- title="Production API",
150
- version="2.0.0",
151
- description="Modern REST API with Tailwind Browsable API",
152
- )
153
- ```
154
-
155
- ---
156
-
157
- ## 🎯 ViewSet Examples
158
-
159
- ### Basic ViewSet
160
-
161
- ```python
162
- from rest_framework import viewsets
163
- from rest_framework.permissions import IsAuthenticated
164
- from .models import Product
165
- from .serializers import ProductSerializer
166
-
167
- class ProductViewSet(viewsets.ModelViewSet):
168
- """
169
- API endpoint for products.
170
-
171
- This will automatically use the Tailwind theme for browsable API! 🎨
172
- """
173
- queryset = Product.objects.all()
174
- serializer_class = ProductSerializer
175
- permission_classes = [IsAuthenticated]
176
-
177
- # Tailwind theme will render this beautifully!
178
- ```
179
-
180
- ### ViewSet with Filters
181
-
182
- ```python
183
- from django_filters.rest_framework import DjangoFilterBackend
184
- from rest_framework.filters import SearchFilter, OrderingFilter
185
-
186
- class ProductViewSet(viewsets.ModelViewSet):
187
- """Products with filtering - Tailwind theme shows filters in sidebar!"""
188
-
189
- queryset = Product.objects.all()
190
- serializer_class = ProductSerializer
191
-
192
- # These filters will appear in the beautiful Tailwind sidebar ✨
193
- filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
194
- filterset_fields = ['category', 'price', 'in_stock']
195
- search_fields = ['name', 'description']
196
- ordering_fields = ['created_at', 'price']
197
- ```
198
-
199
- ---
200
-
201
- ## 🌓 Theme Modes
202
-
203
- Your users can switch themes using:
204
-
205
- ### Keyboard Shortcuts
206
- - `⌘D` (Mac) or `Ctrl+D` (Windows/Linux) - Toggle theme
207
-
208
- ### Theme Dropdown
209
- Click the theme icon in the navbar and choose:
210
- - ☀️ Light Mode
211
- - 🌙 Dark Mode
212
- - 💡 Auto Mode (system preference)
213
-
214
- ### Cookie-Based
215
- Theme preference is saved in cookies and persists across sessions!
216
-
217
- ---
218
-
219
- ## ⌨️ Power User Features
220
-
221
- ### Command Palette
222
-
223
- Press `⌘K` or `Ctrl+K` to open:
224
- - 📋 Copy Current URL
225
- - 🌓 Toggle Theme
226
- - ⌨️ Show Keyboard Shortcuts
227
-
228
- ### Keyboard Shortcuts
229
-
230
- ```
231
- ⌘K / Ctrl+K → Open command palette
232
- ⌘D / Ctrl+D → Toggle theme (light/dark/auto)
233
- ⌘C / Ctrl+C → Copy current URL
234
- ? → Show shortcuts help
235
- Esc → Close dialogs
236
- ```
237
-
238
- ---
239
-
240
- ## 📱 Mobile Support
241
-
242
- The Tailwind theme is fully responsive:
243
-
244
- ```python
245
- # Works perfectly on:
246
- # - 📱 Mobile phones (portrait/landscape)
247
- # - 📲 Tablets
248
- # - 💻 Laptops
249
- # - 🖥️ Desktops
250
- # - 📺 Large displays
251
- ```
252
-
253
- No extra configuration needed - it just works! ✨
254
-
255
- ---
256
-
257
- ## 🧪 Testing Your Setup
258
-
259
- ### Quick Test
260
-
261
- 1. Create a simple ViewSet:
262
-
263
- ```python
264
- # views.py
265
- from rest_framework import viewsets
266
- from rest_framework.response import Response
267
-
268
- class TestViewSet(viewsets.ViewSet):
269
- """Test endpoint for Tailwind theme."""
270
-
271
- def list(self, request):
272
- return Response({
273
- 'message': 'Tailwind theme is working! 🎨',
274
- 'features': [
275
- 'Glass morphism design',
276
- 'Dark/Light/Auto modes',
277
- 'Command palette (⌘K)',
278
- 'Keyboard shortcuts',
279
- 'Copy buttons',
280
- 'Syntax highlighting',
281
- ]
282
- })
283
- ```
284
-
285
- 2. Add to URLs:
286
-
287
- ```python
288
- # urls.py
289
- from rest_framework.routers import DefaultRouter
290
- from .views import TestViewSet
291
-
292
- router = DefaultRouter()
293
- router.register('test', TestViewSet, basename='test')
294
-
295
- urlpatterns = router.urls
296
- ```
297
-
298
- 3. Visit `http://localhost:8000/api/test/` and enjoy the beautiful UI! 🎉
299
-
300
- ---
301
-
302
- ## 🎨 Template Override
303
-
304
- ### Override Base Template
305
-
306
- Create your own version at:
307
- ```
308
- your_app/templates/rest_framework/tailwind/base.html
309
- ```
310
-
311
- ### Override Specific Components
312
-
313
- ```
314
- your_app/templates/rest_framework/tailwind/
315
- ├── base.html # Full override
316
- ├── api.html # Content override
317
- └── forms/
318
- ├── raw_data_form.html
319
- └── filter_form.html
320
- ```
321
-
322
- ### Example Custom Base
323
-
324
- ```html
325
- <!-- your_app/templates/rest_framework/tailwind/base.html -->
326
- {% extends "rest_framework/tailwind/base.html" %}
327
-
328
- {% block branding %}
329
- <img src="/static/logo.png" alt="My Logo" class="h-8">
330
- {{ block.super }}
331
- {% endblock %}
332
- ```
333
-
334
- ---
335
-
336
- ## 🔗 Integration Examples
337
-
338
- ### With drf-spectacular
339
-
340
- ```python
341
- from django_cfg import DjangoConfig
342
- from django_cfg.models.api.drf import DRFConfig
343
- from django_cfg.models.api.spectacular import SpectacularConfig
344
-
345
- class MyConfig(DjangoConfig):
346
- project_name: str = "Documented API"
347
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
348
-
349
- # Tailwind theme for browsable API
350
- drf: DRFConfig = DRFConfig()
351
-
352
- # Swagger/ReDoc for API docs
353
- spectacular: SpectacularConfig = SpectacularConfig(
354
- title="My API",
355
- description="Beautiful API with Tailwind UI",
356
- )
357
- ```
358
-
359
- Visit:
360
- - `/api/` - Tailwind Browsable API 🎨
361
- - `/api/schema/swagger-ui/` - Swagger UI 📊
362
- - `/api/schema/redoc/` - ReDoc 📖
363
-
364
- ### With Custom Middleware
365
-
366
- ```python
367
- class MyConfig(DjangoConfig):
368
- project_name: str = "API with Middleware"
369
- secret_key: str = "your-secret-key-here-min-50-chars-long-for-security"
370
-
371
- # Tailwind works with any middleware!
372
- extra_middleware: list[str] = [
373
- 'my_app.middleware.CustomMiddleware',
374
- ]
375
-
376
- drf: DRFConfig = DRFConfig()
377
- ```
378
-
379
- ---
380
-
381
- ## 💡 Tips & Tricks
382
-
383
- ### 1. Dark Mode by Default
384
-
385
- ```python
386
- # Set in your base template or add JavaScript:
387
- document.cookie = 'theme=dark; path=/; max-age=31536000';
388
- ```
389
-
390
- ### 2. Custom Project Name
391
-
392
- ```python
393
- class MyConfig(DjangoConfig):
394
- project_name: str = "🚀 My Awesome API" # Emojis work!
395
- # ...
396
- ```
397
-
398
- ### 3. Disable Specific Features
399
-
400
- ```python
401
- # In your custom template, remove command palette:
402
- # Delete the command palette div in base.html
403
- ```
404
-
405
- ### 4. Add Custom Shortcuts
406
-
407
- ```javascript
408
- // Add to base.html
409
- handleKeyboard(event) {
410
- // Your existing shortcuts
411
-
412
- // Custom shortcut: Ctrl+H for home
413
- if ((event.metaKey || event.ctrlKey) && event.key === 'h') {
414
- window.location.href = '/';
415
- }
416
- }
417
- ```
418
-
419
- ---
420
-
421
- ## 🐛 Troubleshooting
422
-
423
- ### Theme Not Appearing
424
-
425
- **Problem**: Still seeing Bootstrap theme
426
- **Solution**:
427
- ```python
428
- # Check config
429
- config = MyProjectConfig()
430
- print(config.enable_drf_tailwind) # Should be True
431
- print(config.drf.renderer_classes) # Should include TailwindBrowsableAPIRenderer
432
- ```
433
-
434
- ### Tailwind CSS Not Loading
435
-
436
- **Problem**: No styles visible
437
- **Solution**: Make sure `django-tailwind` is configured:
438
- ```bash
439
- python manage.py tailwind install
440
- python manage.py tailwind start # Development
441
- python manage.py tailwind build # Production
442
- ```
443
-
444
- ### Import Error
445
-
446
- **Problem**: `ModuleNotFoundError: No module named 'django_cfg.modules.django_drf_theme'`
447
- **Solution**:
448
- ```python
449
- # Verify module is in INSTALLED_APPS
450
- config = MyProjectConfig()
451
- apps = config.get_installed_apps()
452
- assert 'django_cfg.modules.django_drf_theme' in apps
453
- ```
454
-
455
- ---
456
-
457
- ## 📚 Learn More
458
-
459
- - [README.md](./README.md) - Full documentation
460
- - [IMPLEMENTATION.md](./IMPLEMENTATION.md) - Implementation details
461
- - [@sources/django-tailwind-drf/](../../../../../../../@sources/django-tailwind-drf/) - Design docs
462
-
463
- ---
464
-
465
- Enjoy your beautiful new DRF Browsable API! 🎉✨