Skip to main content

Generate Django code from PlantUML class diagrams.

Project description

uml2django is a tool for generate Django code from PlantUML class diagrams. It able to generate:

  • Models

  • Forms

  • Class Based Views

  • Templates

  • Tests

Quick start

Installation

  • Install via pip:

    pip install uml2django
  • Download from github:

    git clone https://github.com/J-hanks/uml2django

Running

  • From command line:

    uml2django --puml my_plant_uml_class_diagram.puml
  • Import as script:

    from uml2django.settings import settings
    from uml2django import objects
    from uml2django import load_data_from
    
    PLANT_UML_FILE = "school_management_project.puml"
    load_data_from(plantuml_file_path=PLANT_UML_FILE)
    for django_model in objects.DJANGO_MODELS:
        django_model.generate_model_python_file()
        if not django_model.is_abstract:
            django_model.generate_rest_api()
            django_model.generate_model_forms()
            django_model.generate_class_based_views()
            django_model.generate_cbv_urls_routing()
            django_model.generate_templates()

Syntax

Apps

  • To represent an Django App, use the PlantUML package tag.

  • The app name must follow pep8: Modules and packages should have short, all-lowercase names. Underscores can be used if it improves readability, although the use of underscores is discouraged.:

    @startuml
        package exampledjangoapp {
    
        }
        package example_django_app {
    
        }
    @enduml

Models

  • Use PlantUML class tag to represent an Django Model.

  • The Model name must follow pep8 : where stands that class names should normally use the CapWords convention.

  • All classes defined MUST BE inside an package, like models inside Django apps.:

    @startuml
        package exampledjangoapp {
            class MyFirstModel {
    
            }
        }
        package example_django_app {
            class MySecondModel {
    
            }
        }
    @enduml

Models Inheritance

Models Relashionships

Model Fields

  • Use PlantUML {field} tag to represent an Django model field.

  • If the field type is not informed, uml2django define it as CharField.:

    @startuml
        package exampledjangoapp {
            class MyFirstModel {
                {field} char_field : CharField(max_length=30)
                {field} other_char_field
            }
        }
        package example_django_app {
            class MySecondModel {
                {field} integer_field : IntegerField()
            }
        }
    @enduml

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

uml2django-0.0.8.tar.gz (64.3 kB view details)

Uploaded Source

Built Distribution

uml2django-0.0.8-py3-none-any.whl (36.7 kB view details)

Uploaded Python 3

File details

Details for the file uml2django-0.0.8.tar.gz.

File metadata

  • Download URL: uml2django-0.0.8.tar.gz
  • Upload date:
  • Size: 64.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for uml2django-0.0.8.tar.gz
Algorithm Hash digest
SHA256 47ed6626777c7a7b78ea39956e42464eed4cf4a2534020adf400a6ea77d475f2
MD5 1db88ae77fed9b7c8ddbe5ffe4a41c69
BLAKE2b-256 487df2170c63e2a68de58a50803401d5bec2e0c8993a0ba5ee41ad0fc0eb9d89

See more details on using hashes here.

File details

Details for the file uml2django-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: uml2django-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 36.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for uml2django-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6b77cfaeabda187125132d6154de4562afd6bac3d472d44b308d4011bf684860
MD5 659fb0b71199092f4233f3c9c9d59b1a
BLAKE2b-256 a73bedc062b13b7fa29df2ff2efc49fb3425436a133c09fbfad500ebd61a3aae

See more details on using hashes here.

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