django-shellcraft 0.1.0__tar.gz
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.
- django_shellcraft-0.1.0/.coverage +0 -0
- django_shellcraft-0.1.0/.gitignore +9 -0
- django_shellcraft-0.1.0/CLAUDE.md +103 -0
- django_shellcraft-0.1.0/LICENSE +21 -0
- django_shellcraft-0.1.0/PKG-INFO +216 -0
- django_shellcraft-0.1.0/README.md +163 -0
- django_shellcraft-0.1.0/TESTING.md +683 -0
- django_shellcraft-0.1.0/htmlcov/.gitignore +2 -0
- django_shellcraft-0.1.0/htmlcov/class_index.html +223 -0
- django_shellcraft-0.1.0/htmlcov/coverage_html_cb_dd2e7eb5.js +735 -0
- django_shellcraft-0.1.0/htmlcov/favicon_32_cb_c827f16f.png +0 -0
- django_shellcraft-0.1.0/htmlcov/function_index.html +553 -0
- django_shellcraft-0.1.0/htmlcov/index.html +199 -0
- django_shellcraft-0.1.0/htmlcov/keybd_closed_cb_900cfef5.png +0 -0
- django_shellcraft-0.1.0/htmlcov/status.json +1 -0
- django_shellcraft-0.1.0/htmlcov/style_cb_9ff733b0.css +389 -0
- django_shellcraft-0.1.0/htmlcov/z_551002a935bd4fd5_mixins_py.html +237 -0
- django_shellcraft-0.1.0/htmlcov/z_551002a935bd4fd5_printer_py.html +299 -0
- django_shellcraft-0.1.0/htmlcov/z_bec2c885705e5859___init___py.html +99 -0
- django_shellcraft-0.1.0/htmlcov/z_bec2c885705e5859_shellcraft_py.html +194 -0
- django_shellcraft-0.1.0/htmlcov/z_c841b42a74372b7e___init___py.html +99 -0
- django_shellcraft-0.1.0/pyproject.toml +100 -0
- django_shellcraft-0.1.0/shellcraft/__init__.py +1 -0
- django_shellcraft-0.1.0/shellcraft/management/__init__.py +0 -0
- django_shellcraft-0.1.0/shellcraft/management/commands/__init__.py +0 -0
- django_shellcraft-0.1.0/shellcraft/management/commands/shellcraft.py +95 -0
- django_shellcraft-0.1.0/shellcraft/mixins.py +138 -0
- django_shellcraft-0.1.0/shellcraft/printer.py +200 -0
- django_shellcraft-0.1.0/tests/conftest.py +33 -0
- django_shellcraft-0.1.0/tests/test_command.py +265 -0
- django_shellcraft-0.1.0/tests/test_mixins.py +492 -0
- django_shellcraft-0.1.0/tests/test_printer.py +709 -0
- django_shellcraft-0.1.0/tests/test_security.py +413 -0
|
Binary file
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# django-shellcraft
|
|
2
|
+
|
|
3
|
+
## What is this?
|
|
4
|
+
A Django package that brings Rails-style console ergonomics to the Django shell.
|
|
5
|
+
Targets developers migrating from Ruby on Rails to Django who miss the
|
|
6
|
+
`rails console` experience — specifically `awesome_print` style output,
|
|
7
|
+
model shortcuts, and schema inspection.
|
|
8
|
+
|
|
9
|
+
## Package identity
|
|
10
|
+
- PyPI name: `django-shellcraft`
|
|
11
|
+
- Importable name: `shellcraft`
|
|
12
|
+
- INSTALLED_APPS entry: `'shellcraft'`
|
|
13
|
+
- Management command: `python manage.py shellcraft`
|
|
14
|
+
- Author: Siva
|
|
15
|
+
- Python: 3.8+
|
|
16
|
+
- Django: 3.2, 4.0, 4.1, 4.2, 5.0
|
|
17
|
+
|
|
18
|
+
## Dependencies
|
|
19
|
+
- django >= 3.2
|
|
20
|
+
- django-extensions >= 3.0 (handles model auto-loading, we build on top)
|
|
21
|
+
|
|
22
|
+
## Project structure
|
|
23
|
+
django-shellcraft/
|
|
24
|
+
├── shellcraft/
|
|
25
|
+
│ ├── __init__.py # version only
|
|
26
|
+
│ ├── printer.py # awesome_print style renderer
|
|
27
|
+
│ ├── mixins.py # Rails-style shortcuts injected on models
|
|
28
|
+
│ └── management/
|
|
29
|
+
│ └── commands/
|
|
30
|
+
│ └── shellcraft.py # manage.py shellcraft command
|
|
31
|
+
├── tests/
|
|
32
|
+
│ └── test_printer.py
|
|
33
|
+
├── pyproject.toml
|
|
34
|
+
├── README.md
|
|
35
|
+
└── LICENSE
|
|
36
|
+
|
|
37
|
+
## Core features to build
|
|
38
|
+
1. `User.find(1)` → User.objects.get(pk=1)
|
|
39
|
+
2. `User.all()` → User.objects.all() — pretty printed
|
|
40
|
+
3. `User.where(active=True)` → User.objects.filter() — pretty printed
|
|
41
|
+
4. `User.first()` → User.objects.first()
|
|
42
|
+
5. `User.last()` → User.objects.last()
|
|
43
|
+
6. `User.count()` → User.objects.count()
|
|
44
|
+
7. `user.update(email="x")` → instance-level update + save
|
|
45
|
+
8. `user.destroy()` → user.delete() alias
|
|
46
|
+
9. `User.fields()` → schema inspection, colored output
|
|
47
|
+
10. `tables()` → list all models across all apps
|
|
48
|
+
|
|
49
|
+
## printer.py — awesome_print style rules
|
|
50
|
+
Color mapping (ANSI, pure Python — zero dependencies):
|
|
51
|
+
- int, float → blue
|
|
52
|
+
- str → yellow
|
|
53
|
+
- True → green
|
|
54
|
+
- False → red
|
|
55
|
+
- None → red
|
|
56
|
+
- datetime, date → cyan
|
|
57
|
+
- field types → cyan
|
|
58
|
+
- index [0],[1] → gray
|
|
59
|
+
|
|
60
|
+
Single record output:
|
|
61
|
+
#<User:0x001> {
|
|
62
|
+
:id => 1,
|
|
63
|
+
:username => "siva",
|
|
64
|
+
:is_active => true,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Multiple records output:
|
|
68
|
+
[
|
|
69
|
+
[0] #<User:0x001> {
|
|
70
|
+
:id => 1,
|
|
71
|
+
:username => "siva",
|
|
72
|
+
},
|
|
73
|
+
[1] #<User:0x002> {
|
|
74
|
+
:id => 2,
|
|
75
|
+
:username => "kumar",
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
2 records
|
|
79
|
+
|
|
80
|
+
## mixins.py — design decisions
|
|
81
|
+
- Inject methods onto Django base Model class at shell startup only
|
|
82
|
+
- Guard: only activate when running manage.py shellcraft
|
|
83
|
+
- Collision check: warn if injected method name clashes with existing model method
|
|
84
|
+
- Never activate in production — raise SystemExit if DEBUG is False
|
|
85
|
+
|
|
86
|
+
## Key design decision
|
|
87
|
+
Do NOT patch __repr__ globally. Pretty printing only happens through
|
|
88
|
+
our helper methods (User.all(), User.find() etc). Raw User.objects.all()
|
|
89
|
+
still shows Django default output. Intentional — predictable over magic.
|
|
90
|
+
|
|
91
|
+
## Current status
|
|
92
|
+
- [x] pyproject.toml
|
|
93
|
+
- [x] shellcraft/__init__.py
|
|
94
|
+
- [ ] shellcraft/printer.py
|
|
95
|
+
- [ ] shellcraft/mixins.py
|
|
96
|
+
- [ ] shellcraft/management/commands/shellcraft.py
|
|
97
|
+
- [ ] tests/test_printer.py
|
|
98
|
+
- [ ] README.md
|
|
99
|
+
- [ ] LICENSE
|
|
100
|
+
|
|
101
|
+
## Start here
|
|
102
|
+
Begin with printer.py — everything else depends on it.
|
|
103
|
+
Once colors and formatting work, mixins.py becomes straightforward.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Siva
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-shellcraft
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Rails-style console ergonomics for Django — pretty printing, model shortcuts, and schema inspection
|
|
5
|
+
Author-email: Siva <sivanandam03@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Siva
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Keywords: console,developer-tools,django,orm,rails,shell
|
|
29
|
+
Classifier: Development Status :: 3 - Alpha
|
|
30
|
+
Classifier: Framework :: Django
|
|
31
|
+
Classifier: Framework :: Django :: 3.2
|
|
32
|
+
Classifier: Framework :: Django :: 4.0
|
|
33
|
+
Classifier: Framework :: Django :: 4.1
|
|
34
|
+
Classifier: Framework :: Django :: 4.2
|
|
35
|
+
Classifier: Framework :: Django :: 5.0
|
|
36
|
+
Classifier: Intended Audience :: Developers
|
|
37
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
45
|
+
Requires-Python: >=3.8
|
|
46
|
+
Requires-Dist: django>=3.2
|
|
47
|
+
Provides-Extra: dev
|
|
48
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
49
|
+
Requires-Dist: pytest-django>=4.8; extra == 'dev'
|
|
50
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
51
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
# django-shellcraft
|
|
55
|
+
|
|
56
|
+
Rails-style console ergonomics for Django — pretty printing, model shortcuts, and schema inspection.
|
|
57
|
+
|
|
58
|
+
Built for developers migrating from Ruby on Rails who miss the `rails console` experience.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install django-shellcraft
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Add to `INSTALLED_APPS`:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
INSTALLED_APPS = [
|
|
72
|
+
...
|
|
73
|
+
"shellcraft",
|
|
74
|
+
]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python manage.py shellcraft
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
All models are auto-imported into the shell namespace. IPython is used when available, falling back to the standard Python REPL.
|
|
84
|
+
|
|
85
|
+
> **Note:** shellcraft refuses to start when `DEBUG = False` as a production safety guard.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Features
|
|
90
|
+
|
|
91
|
+
### Model shortcuts
|
|
92
|
+
|
|
93
|
+
All shortcuts are injected as classmethods/instance methods at shell startup. Raw `User.objects.all()` is unchanged — pretty printing only happens through shellcraft methods.
|
|
94
|
+
|
|
95
|
+
| Method | Equivalent |
|
|
96
|
+
|---|---|
|
|
97
|
+
| `User.find(1)` | `User.objects.get(pk=1)` |
|
|
98
|
+
| `User.all()` | `User.objects.all()` + pretty print |
|
|
99
|
+
| `User.where(is_active=True)` | `User.objects.filter(...)` + pretty print |
|
|
100
|
+
| `User.first()` | `User.objects.first()` + pretty print |
|
|
101
|
+
| `User.last()` | `User.objects.last()` + pretty print |
|
|
102
|
+
| `User.count()` | `User.objects.count()` |
|
|
103
|
+
| `user.update(email="x@y.com")` | sets attrs + `save()` |
|
|
104
|
+
| `user.destroy()` | `user.delete()` |
|
|
105
|
+
| `User.fields()` | colored schema inspection |
|
|
106
|
+
| `tables()` | list all models across all apps |
|
|
107
|
+
|
|
108
|
+
### Pretty printing
|
|
109
|
+
|
|
110
|
+
Single record:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
#<User:0x7f3a> {
|
|
114
|
+
:id => 1,
|
|
115
|
+
:username => "siva",
|
|
116
|
+
:email => "siva@example.com",
|
|
117
|
+
:is_active => true,
|
|
118
|
+
:created_at => 2024-01-15 10:30:00,
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Multiple records:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
[
|
|
126
|
+
[0] #<User:0x7f3a> {
|
|
127
|
+
:id => 1,
|
|
128
|
+
:username => "siva",
|
|
129
|
+
},
|
|
130
|
+
[1] #<User:0x7f3b> {
|
|
131
|
+
:id => 2,
|
|
132
|
+
:username => "kumar",
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
2 records
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Color mapping:
|
|
139
|
+
|
|
140
|
+
| Type | Color |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `int`, `float` | blue |
|
|
143
|
+
| `str` | yellow |
|
|
144
|
+
| `True` | green |
|
|
145
|
+
| `False`, `None` | red |
|
|
146
|
+
| `datetime`, `date` | cyan |
|
|
147
|
+
| field types | cyan |
|
|
148
|
+
| record index `[0]` | gray |
|
|
149
|
+
|
|
150
|
+
### Schema inspection
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
User.fields()
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
User {
|
|
158
|
+
:id AutoField
|
|
159
|
+
:username CharField
|
|
160
|
+
:email CharField
|
|
161
|
+
:is_active BooleanField
|
|
162
|
+
:created_at DateTimeField
|
|
163
|
+
:group_id ForeignKey null: true
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### List all tables
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
tables()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
auth.User
|
|
175
|
+
auth.Group
|
|
176
|
+
auth.Permission
|
|
177
|
+
myapp.Post
|
|
178
|
+
myapp.Comment
|
|
179
|
+
|
|
180
|
+
5 tables
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Manual pretty printing
|
|
184
|
+
|
|
185
|
+
`ap()` is available directly for any model instance or queryset:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
ap(User.objects.filter(is_staff=True))
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Requirements
|
|
194
|
+
|
|
195
|
+
- Python 3.8+
|
|
196
|
+
- Django 3.2, 4.0, 4.1, 4.2, or 5.0
|
|
197
|
+
- django-extensions >= 3.0
|
|
198
|
+
|
|
199
|
+
Optional: `ipython` for an enhanced shell experience.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Development
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
git clone https://github.com/yourusername/django-shellcraft
|
|
207
|
+
cd django-shellcraft
|
|
208
|
+
pip install -e ".[dev]"
|
|
209
|
+
pytest
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# django-shellcraft
|
|
2
|
+
|
|
3
|
+
Rails-style console ergonomics for Django — pretty printing, model shortcuts, and schema inspection.
|
|
4
|
+
|
|
5
|
+
Built for developers migrating from Ruby on Rails who miss the `rails console` experience.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install django-shellcraft
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Add to `INSTALLED_APPS`:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
INSTALLED_APPS = [
|
|
19
|
+
...
|
|
20
|
+
"shellcraft",
|
|
21
|
+
]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
python manage.py shellcraft
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
All models are auto-imported into the shell namespace. IPython is used when available, falling back to the standard Python REPL.
|
|
31
|
+
|
|
32
|
+
> **Note:** shellcraft refuses to start when `DEBUG = False` as a production safety guard.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
### Model shortcuts
|
|
39
|
+
|
|
40
|
+
All shortcuts are injected as classmethods/instance methods at shell startup. Raw `User.objects.all()` is unchanged — pretty printing only happens through shellcraft methods.
|
|
41
|
+
|
|
42
|
+
| Method | Equivalent |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `User.find(1)` | `User.objects.get(pk=1)` |
|
|
45
|
+
| `User.all()` | `User.objects.all()` + pretty print |
|
|
46
|
+
| `User.where(is_active=True)` | `User.objects.filter(...)` + pretty print |
|
|
47
|
+
| `User.first()` | `User.objects.first()` + pretty print |
|
|
48
|
+
| `User.last()` | `User.objects.last()` + pretty print |
|
|
49
|
+
| `User.count()` | `User.objects.count()` |
|
|
50
|
+
| `user.update(email="x@y.com")` | sets attrs + `save()` |
|
|
51
|
+
| `user.destroy()` | `user.delete()` |
|
|
52
|
+
| `User.fields()` | colored schema inspection |
|
|
53
|
+
| `tables()` | list all models across all apps |
|
|
54
|
+
|
|
55
|
+
### Pretty printing
|
|
56
|
+
|
|
57
|
+
Single record:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
#<User:0x7f3a> {
|
|
61
|
+
:id => 1,
|
|
62
|
+
:username => "siva",
|
|
63
|
+
:email => "siva@example.com",
|
|
64
|
+
:is_active => true,
|
|
65
|
+
:created_at => 2024-01-15 10:30:00,
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Multiple records:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
[
|
|
73
|
+
[0] #<User:0x7f3a> {
|
|
74
|
+
:id => 1,
|
|
75
|
+
:username => "siva",
|
|
76
|
+
},
|
|
77
|
+
[1] #<User:0x7f3b> {
|
|
78
|
+
:id => 2,
|
|
79
|
+
:username => "kumar",
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
2 records
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Color mapping:
|
|
86
|
+
|
|
87
|
+
| Type | Color |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `int`, `float` | blue |
|
|
90
|
+
| `str` | yellow |
|
|
91
|
+
| `True` | green |
|
|
92
|
+
| `False`, `None` | red |
|
|
93
|
+
| `datetime`, `date` | cyan |
|
|
94
|
+
| field types | cyan |
|
|
95
|
+
| record index `[0]` | gray |
|
|
96
|
+
|
|
97
|
+
### Schema inspection
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
User.fields()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
User {
|
|
105
|
+
:id AutoField
|
|
106
|
+
:username CharField
|
|
107
|
+
:email CharField
|
|
108
|
+
:is_active BooleanField
|
|
109
|
+
:created_at DateTimeField
|
|
110
|
+
:group_id ForeignKey null: true
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### List all tables
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
tables()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
auth.User
|
|
122
|
+
auth.Group
|
|
123
|
+
auth.Permission
|
|
124
|
+
myapp.Post
|
|
125
|
+
myapp.Comment
|
|
126
|
+
|
|
127
|
+
5 tables
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Manual pretty printing
|
|
131
|
+
|
|
132
|
+
`ap()` is available directly for any model instance or queryset:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
ap(User.objects.filter(is_staff=True))
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Requirements
|
|
141
|
+
|
|
142
|
+
- Python 3.8+
|
|
143
|
+
- Django 3.2, 4.0, 4.1, 4.2, or 5.0
|
|
144
|
+
- django-extensions >= 3.0
|
|
145
|
+
|
|
146
|
+
Optional: `ipython` for an enhanced shell experience.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
git clone https://github.com/yourusername/django-shellcraft
|
|
154
|
+
cd django-shellcraft
|
|
155
|
+
pip install -e ".[dev]"
|
|
156
|
+
pytest
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
MIT
|