Skip to content Skip to sidebar Skip to footer

Model Instance Settings || Reverse For '' With Arguments '('',)' Not Found. 1 Pattern(s) Tried

I currently have an app that is meant to generate documents based on user-set settings. The settings are supposed to be read by the program based on the class's instance settings s

Solution 1:

To solve the error in the title, first you need to fix the usage of url in the template and pass the primary key of the SettingsClass instance with:

{% url 'printReports' x.pk %}

So:

{% for x in model %}
    <ahref="{% url 'printReports' x.pk %}"class="list-group-item list-group-item-action" >{{ x.Complex }} Reports</a>
{% endfor %}

And then in your view, you don't need to use a form to access the attributes from your SettingsClass instance, so you can just do something like:

defprintReports(request , reports_pk):
    settings_instance = get_object_or_404(SettingsClass , pk=reports_pk)

    complexName = settings_instance.Complex

    #CHECKING TRIAL BALANCE SETTINGSif settings_instance.Trial_balance_Year_to_date == True:
        ...

Solution 2:

You are not passing the "reports" variable to context. that's why the PK value is empty. check the view that's rendering reportsHome.html and apply the necessary, variable to template eg:

defview_func(request)
......
return render(request, '<template_name>.html', {"report": report }) 

Post a Comment for "Model Instance Settings || Reverse For '' With Arguments '('',)' Not Found. 1 Pattern(s) Tried"