Skip to main content

Django scaffold like in Ruby on Rails

Project description

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.

INSTALLED_APPS = (
    ...
    'rest_framework',
    'scaffold',
    ...
)

Usage

To create multiple apps at once, run the following command, where args are future app names:

$ python manage.py scaffold-app app1 app2 ...

To create models, serializers, views, urls, run the following command:

$ 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 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:

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"]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manny-0.1.4.tar.gz (7.2 kB view hashes)

Uploaded Source

Built Distribution

manny-0.1.4-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page