Package: django-simplify
IntroductionDjango simplify provides Ruby on Rails-like command line functionalities, models and helper functions so you can focus on development and removes the pain of repeating frequent actions.RequirementsPython3.6and aboveDjango (tested with 3.1, probably works with any version that supportsPython 3)Installationdjango-simplifycan be installed via pip.$pipinstalldjango-simplifyThen just addsimplifyto yourINSTALLED_APPS.Below are several example commands you can run.$pythonmanage.pycreate_app<app_name>Featurestimestamp for every modelalphabetic filter for adminmodel, view, template and url route generatorautomatic importManagement commands1. create_appautomatically adds aurls.pyfile after app is created.adds newly created app in the settings.py file underINSTALLED_APPScreatesindex,edit,createanddetailview and respective templatesadds the app route to your project’surls.pyfileUsage$pythonmanage.pycreate_app<app_name>2. create_modelCreates a model and their respective fields. the following types maps to respective Django model fields. It will also add the app to the django admin too.121, o2o or set -> OneToOneFieldbool -> BooleanFielddate -> DateFielddatetime or dt -> DateTimeFielddict or m2m -> ManyToManyFieldemail -> EmailFieldfile -> FileFieldlist or fk -> ForeignKeyfloat -> FloatFielddec -> DecimalFieldimg or image -> ImageFieldint -> IntegerFieldstr or char -> CharFieldtxt or text -> TextFieldUsage$pythonmanage.pycreate_app<app_name><model_name>field_name:typefield_name:type...an example$pythonmanage.pycreate_appmemberMemberfirst_name:textlast_name:textage:intwill generate the following code in themember/models.pyfileclassMember(models.Model):first_name=models.CharField(max_length=50)last_name=models.CharField(max_length=50)age=models.IntegerField(default=0)created_at=models.DateTimeField(auto_now_add=True)updated_at=models.DateTimeField(auto_now=True)def__str__(self):returnself.first_nameNoteThe command uses the first specified field as the__str__default.Specifying relationshipsSpecifyingForeignKey,OneToOneFieldorManyToManyFieldis quite easy. just add an=<related_model>. See example$pythonmanage.pycreate_app<app_name><model_name>field_name:type=related_model# an example
# if the related model is in the same models.py file, specify it as app_name.Model$pythonmanage.pycreate_appauthorAuthorname:charbooks:fk=Book# or$pythonmanage.pycreate_appauthorAuthorname:charbooks:fk=author.Book# if in a different app. (say book model)
# obviously you should be able to substitute fk with m2m, o2o, 121$pythonmanage.pycreate_appauthorAuthorname:charbooks:fk=book.Bookwill create the followingclassAuthor(models.Model):name=models.CharField(max_length=50)books=models.ForeignKey('book.Book',on_delete=models.CASCADE)created_at=models.DateTimeField(auto_now_add=True)updated_at=models.DateTimeField(auto_now=True)def__str__(self):returnself.name3. create_viewCreates a view, generate its respective template and adds the path in the urls.py fileUsage$pythonmanage.pycreate_view<app_name><view_name>an example$pythonmanage.pycreate_viewmemberMemberDetailHelpermodels################-simplify.utils.TimeBasedModel-Providesthe`created_at`and`updated_at`fieldsfortimestamp-simplify.utils.NamedTimeBasedModel-Providesthe`name`,`created_at`and`updated_at`fields.-simplify.utils.AlphaNumericFilterAdmin-whensubclassed,itallowstheitemstobefilteredalphabeticallybyeitherA-Zor0-9-**Note**:forthistowork,youmustspecifyvaluesfor`alphanumeric_filter`inthemodeladmin.Usage######..code-block::python# models.pyfromsimplify.utilsimportTimeBasedModel,NamedTimeBasedModelclassMyModel(TimeBasedModel):extra_fields=......code-block::python# admin.pyfromsimplify.utilsimportAlphaNumericFilterAdminclassMemberAdmin(AlphaNumericFilterAdmin):alphanumeric_filter=["first_name","last_name",'age']# this part is what creates the filterlist_filter=['age']list_display=['first_name','last_name',]Todoadd more helper functionsadd documentationNoteThis is still in early development mode. might have bugs. It works fine if you write good code and follow the django style of development. Please fork the project to make contributionsAcknowledgementsI’d like to say a big thank you to God without which this wouldn’t be possible. I would also like to say thanks to everyone who has and will contribute to this in the future.