Package: django-problem
Django ProblemA Django application to report a problem / bug in your app.
A problem is a text description linked to an user and a page.
A problem can be marked as resolved.FeaturesLink custom data to your problemAdmin interface to search and filter through all problemsCompatible with django rest frameworkAutomatically create a timestamp when a problem is reported and when a problem is marked as resolvedInstallationInstall the app withpip install django-problemAddproblemto yourINSTALLED_APPSinsettings.pyINSTALLED_APPS=[...,'problem',...,]Insettings.pyadd the pages of your applicationPROBLEM={'PAGES':(('Home Page','Home Page'),('Settings','Settings'),)}Run the migrationpython manage.py migrateUsageThe application provide 3 simple templatesproblem_form.html : A form to create a problemproblem_detail.html : Detail view of a problemproblem_list.html : List view of all problemsYou can override them by creating a file with the same name intemplates/problemin your app.To use the application out-of-the-box you can include urls inurls.pylike thisurlpatterns += [
    path('problem/', include('problem.urls')),
]If you want to link custom data to your problem, you can follow the steps below.Create a model to link custom dataCreate a link class in yourmodels.pyfromproblem.modelsimportProblemclassProblemLink(models.Model):problem=models.OneToOneField(Problem,on_delete=models.CASCADE)mymodel=models.ForeignKey(MyModel,on_delete=models.SET_NULL,null=True)Create an inline formsetfromproblem.modelsimportProblemfrom.modelsimportProblemLinkclassProblemLinkForm(forms.ModelForm):classMeta:model=ProblemLinkfields='__all__'ProblemLinkFormSet=inlineformset_factory(Problem,ProblemLink,form=ProblemLinkForm,extra=1,can_delete=False)Create a custom viewCreate a subclass of the CreateProblem view and overrideadd_formset_to_contextandvalidate_formsetmethods. Then in problem_form.html you can display the problem_link_formset formadd_formset_to_contextis called during theget_context_datamethod.validate_formsetis called during theform_validmethod, after the Problem object has been saved.fromprobem.viewsimportCreateProblemfrom.formsimportProblemLinkFormSetclassCreateProblemLink(CreateProblem):defadd_formset_to_context(self,context):context['problem_link_formset']=ProblemLinkFormSet()defvalidate_formset(self,request,instance):problem_relation_form=ProblemLinkFormSet(request.POST,instance=instance)ifproblem_relation_form.is_valid():problem_relation_form.save()In problem_detail.html and problem_list you can simply accessProblemLinkto display the linked data.Custom adminYou can add your custom model as an inline in the admin interface.fromproblem.adminimportProblemAdminfromproblem.modelsimportProblemfrom.modelsimportProblemLinkclassProblemLinkInline(admin.StackedInline):model=ProblemLinkclassCustomizedProblemAdmin(ProblemAdmin):inlines=(ProblemLinkInline,)# Unregister the Problem model, to replace it with yoursadmin.site.unregister(Problem)admin.site.register(Problem,CustomizedProblemAdmin)With django-rest-frameworkA serializer is provided, you can use it to .fromproblem.serializersimportProblemSerializerfromproblem.modelsimportProblemfrom.modelsimportProblemLinkclassProblemLinkSerializer(ModelSerializer):problem=ProblemSerializer()classMeta:model=ProblemLinkfields=['mymodel','problem']defcreate(self,validated_data):problem=validated_data.pop('problem')problem=Problem.objects.create(**problem)problem_link=ProblemLink.objects.create(**validated_data,problem=problem)returnproblem_link