Django Generator#
This module generates Django code using Jinja2 templates based on BUML models.
- class besser.generators.django.django_generator.DjangoGenerator(model: DomainModel, project_name: str, app_name: str, gui_model: GUIModel = None, containerization: bool = False, module: Module = None, output_dir: str = None)[source]#
Bases:
GeneratorInterface
DjangoGenerator is responsible for generating Django executable code based on input B-UML and GUI models. It implements the GeneratorInterface and facilitates the creation of a Django web application structure.
- Parameters:
model (DomainModel) – The B-UML model representing the application’s domain.
project_name (str) – The name of the Django project.
app_name (str) – The name of the Django application.
gui_model (GUIModel) – The GUI model instance containing necessary configurations.
main_page (Screen) – The main page of the web application.
containerization (bool, optional) – Whether to enable containerization
False. (support. Defaults to) –
module (Module, optional) – Represents a specific module within the application, typically grouping related screens and functionalities.
output_dir (str, optional) – Directory where generated code will be saved. Defaults to None.
- _abc_impl = <_abc._abc_data object>#
- create_file_from_template(template_name, output_name)[source]#
Create a file from a Jinja2 template.
- generate_base_pages()[source]#
Generate HTML files for each screen in the module, using a Jinja template. Each HTML file is saved in the output directory, named based on the screen’s name.
- generate_form_html_pages(one_to_one, many_to_many, fkeys)[source]#
Generate HTML files for each screen in the module, using a Jinja template. Each HTML file is saved in the output directory, named based on the screen’s name_form.
- generate_forms(one_to_one, many_to_many, fkeys)[source]#
Generates the Django Forms file for a web application based on the provided B-UML and GUI models and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.
- Returns:
None, but stores the generated code as a file named forms.py.
- generate_home_page()[source]#
Generates the Home Page Template code for a Django application based on the provided GUI model and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.
- Returns:
None, but stores the generated code as a file named main.dart.
- generate_list_html_pages(one_to_one, many_to_many, fkeys)[source]#
Generate List HTML files for each screen in the module, using a Jinja template. Each HTML file is saved in the output directory, named based on the screen’s name_list.
- generate_models()[source]#
Generates Django models code based on the provided B-UML model and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.
- Returns:
None, but stores the generated code as a file named models.py.
- generate_project_urls()[source]#
Generates the Django project URLs file based on the provided GUI model and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.
- Returns:
None, but stores the generated code as a file named project_urls.py.
- generate_urls()[source]#
Generates the Django URLs file for a web application based on the provided B-UML and GUI models and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.
- Returns:
None, but stores the generated code as a file named urls.py.
- generate_views()[source]#
Generates the Django views file for a web application based on the provided B-UML and GUI models and saves it to the specified output directory. If the output directory was not specified, the code generated will be stored in the <current directory>/output folder.
- Returns:
None, but stores the generated code as a file named views.py.
- property gui_model: GUIModel#
Get the instance of the GUIModel class representing the GUI model.
- Type:
- static is_model_element(value)[source]#
Check if the given value is an instance of DataSourceElement class.
- static is_primitive_data_type(value)[source]#
Check if the given value is an instance of PrimitiveDataType class.