Package: cli-django-builder
Django BuilderA Django application for building project's application using the Django command line interfaceThecli-django-builderapplication is designed to enable developers save time on development by providing automation or
routine django application building process.Thecli-django-builderapplication enables developers to save time by automating routine Django application building
processes. This application integrates with the Django commands and provides thebuildcommand to create RESTful APIs
using DRF, views, and templates from the command interface. Developers can also seed the existing database of their
application using thebuildcommand.Add the name 'builder' to your Djangosettings.pyINSTALLED_APPSto use this application.This application assumes that model naming conventions as specified
byDjango Frameworkis
adopted for the target application.MotivationDjango framework provides a rich set of tools to build complex web projects. A project may comprise one or more
applications working together as a unit. In many scenarios, developers end up repeating a set of tasks such as:Create applicationCreate application modelsCreate application files such as views.py, serializers.py, urls.py and HTML templates. These tasks can be automated to
provide a skeletal system that the developer can then modify to meet target business logic. Thecli-django-builderautomates tasks in line with the Django DRY philosophy.Descriptioncli-django-builderconsists of a set of thebuildcommand and a set of command flags that specifies build configuration
by data entered as texts.To use thecli-django-builder, add the application as a Django application in your project. Then using the Django command
interface call the build command as a Django command:$ python manage.py build views <view_name>Ensure you are at the directory of the target application. Thus, if you wish to build a view file for theemployerapplication, navigate to theemployerdirectory before callingbuild.For the set of commands and flags available, see the table below.CommandFlagTypeDescriptionbuild-m, --models [Specify model name as text]textThe model class name provided as string without quotesbuild--model_formtextThe type of Django Rest Framework serializer that will be extended by the application in generating forms for modelsbuild-a, --apptextThe name of the target Django application where the generated files will be stored and where the specified model was definedbuild--fieldstextList of model fields for the model serializer. Defaults to all model fieldsbuild--viewsettextThe type of Django Rest Framework viewset that will be extended by the application. Example,ModelViewSetbuild--managertextThe model field serving as default Model Manager for the named modelbuild--serializertextThe type of rest_framework serializer that will be extended by the application or the model serializer defined in application. Example,ModelSerializerbuild--persmissionstextList of permissions provided as string. Used for specify access control for DRF api end pointsbuild--routertextThe type of rest_framework router that will be used for generating urls. Example,DefaultRouterbuild--importtextFlag to enable import of dependencies for target build. Example, this flag will import dependencies when creatingviews.pyif such were specified. Default action flag for this function is set to TRUEbuild--capture_typetextThe data type to be captured in the Urlconf. Used only when building URLs example,urls.pybuild--pk_fieldtextThe name of the view parameter or identifier used for selection of instancebuild--make, make_filetextName of the file to generate. The name should be provided without the file extension. Exampleapi,viewswill generateapi.pyandviews.pyfor target app directorybuild--excludetext [Comma separated list of field names]Flag to exclude selected model fields from view. Current build excludes model field names:pk,id,uuid,slug,is_public,is_shareableare removeddbseed--modeltextName of the target model for which seed data is to be generateddbseed--recordsintegerNumber of records to generatedbseed--apptextName of the target application for the listed modeldbseed--relatedtextComma separated list of related models provided as<app>.<model>. Command will throw error if target model is linked (has foreign key fields) to other models and related models are not specifiedApplication Template FilesTemplates for generating application files can be modified. To view or modify a template file, edit the respective file in
path<django_builder_directory>/management/commands/templates/<template_file>.pyWARNING!!Modifying template files may break application logic or raise error. Ensure you know what you are doing when modifying files.DependenciesThedjango_buiildrequiresdjangoinstalled on target machine. The target Python for current implementation is
Python 3.8Build StatusVersion: 0.1.0Current development ofdjango_buildis version 0.1.0. This is considered the Alpha Edition. Future releases will
support import of model specification as YAML or JSON files.FeaturesCurrent build features include:Build model serializers as serializer.pyBuild Django views as views.pyBuild Django templates as <template_name>.html. Templates are created and stored in directory following the
convention:templates/<app_name>/<template_name>.html. The various template files that can be generated include:Entity/Model list template to list all entries of a given model. The list view can be generated as a paginated or
single-page list depending on the flags provided.Entity/Model update template to update a selected instance identified by a parameter such as .Entity/Model detail template to view detail of a given instance identified by a parameter such as .Entity/Model delete template to request user's confirmation before deleting an instance identified by .Entity/Model create a template to collect form data for creating a new record of a given entity.Sample Usagecli-django-buildercan be used to generate application files for DRF or simply generate files for a Django application.Sample test run:$ python manage.py dbseed --app util --model BaseUser --records 5
$ python manage.py build --make views --app util
$ python manage.py build --make serializer --app util --model BaseUserContributingPlease visit application repo for further information on extending project. Ideas and comments will be reasonably
appreciated.AuthorCurrent development is by Aniefiok Friday@frier17.LicenseMIT Licensehttps://mit-license.org/For details read license contracthereCopyright 2021 @frier17Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may
obtain a copy of the License athttps://mit-license.org/Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.