Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/q0w/manny
Generate apps, models, serializers, views, urls using cli
https://github.com/q0w/manny
django scaffold
Last synced: 25 days ago
JSON representation
Generate apps, models, serializers, views, urls using cli
- Host: GitHub
- URL: https://github.com/q0w/manny
- Owner: q0w
- License: mit
- Created: 2020-10-13T14:53:14.000Z (about 4 years ago)
- Default Branch: django-based
- Last Pushed: 2020-12-08T16:57:18.000Z (almost 4 years ago)
- Last Synced: 2024-10-12T07:28:52.480Z (about 1 month ago)
- Topics: django, scaffold
- Language: Python
- Homepage:
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Manny
Django cli add-on for generating apps, models, serializers, views, urls
## Installation
Install with pip:
```
$ pip install manny
```
Then add it to your INSTALLED_APPS.
```python
INSTALLED_APPS = (
...
'rest_framework',
'scaffold',
...
)
```
## Usage
To create multiple apps at once, run the following command, where args are future app names:
```python
$ python manage.py scaffold-app app1 app2 ...
```
To create models, serializers, views, urls, run the following command:
```python
$ python manage.py scaffold {app_name} {options}
```
| Option | |
| ------ | ------ |
| -m, --model {fields} | Add a model with specific fields. Default fields: update_date, create_date|
| -s, --serializers {model_names} | Add a new serializer for the specific model; by default for all models |
| -vi, --views {model_names} | Add a view for the specific model; by default for all models |
| -u | Add urls for all models |To create models, use the following syntax:
```python
$ python manage.py scaffold {app_name} -m {model_name} title:Char:255 books:Foreign::CASCADE
```
To specify a field, you must pass the arguments in this order:
```
NAME:FIELD_TYPE:FIELD_OPTIONS(only required)
```
Field options are optional because there are default values.
Result:
```python
class Book(models.Model):
title = models.CharField(max_length=255)
books = models.ForeignKey("self", on_delete=models.CASCADE)
update_date = models.DateTimeField(auto_now=True)
create_date = models.DateTimeField(auto_now_add=True)class Meta:
ordering = ["-id"]
```