admin/
accounts/
[name=‘home’]
entry/ [name=‘index’]
entry/ add/ [name=‘add-entry’]
entry/ list/ [name=‘entries-list’]
entry/ addparty/ [name=‘add-party’]
entry/ party/int:pk [name=‘selected-party’]
masters/
The current path, entry/{% url ‘entry:selected-party’ pk %}, didn’t match any of these.
Unable to fix the error to achieve the expected result. So, request help with a solution or reason for this error. - Thank you!
The reason you’re getting the error is because of this:
I think I understand what you’re trying to do here, you’re trying to generate a different hx-get attribute for each entry of the select list - but that’s not going to work this way. The template is being rendered by Django, but you’re not going to know what ID was selected until a selection is made - and that happens in the browser.
(What’s actually happening here is that that attribute is not being rendered by the rendering engine when that field is being rendered - notice that the url is the literal text supplied in the attribute. You can verify this by examining the HTML that was rendered to the browser. This means that this way of approaching it isn’t going to work for two separate and distinct reasons.)
What I do for situations like this is wrap the select field in a div, and put the hx-get on that div, along with using the hx-params attribute to include the field value as a GET parameter.
It’s not as “clean” as using the url parameters, but it works. (Which means there may be a better solution, but if there is, I’m not aware of it. I’m sure you could probably build something based on handling the configRequest event, but I’m not immediately convinced that would be “better”.)
Notice the URL being issued. Do you have a url definition matching that?
You’re not sending the variable as part of the url any more, it’s a GET variable that you would retrieve in the view.
Thank you Ken, I am about to reach the solution! Now with the modified codes, upon the first ‘Change’ event, i.e. of first selected value from the drop down, the details are brought up as soon as the value is selected.
But not working for any further changes and the following error shows up in console,
It might help if you posted the actual html that was rendered for this, but I’m going to make the guess that you replaced the div having the id selectedParty_DivId with a div not having that id attribute.
And the rendered html is only “partials/SelectedParty.html” which is an include in the above template.
Testing
<br>
Second line
{% comment %} {{ selectedPartyFields.Name }}
{{ selectedPartyFields.City }} {% endcomment %}
{{ form }}
Only the first change event triggers the include part as expected. But the same has to happen for second change and further too, which is not happening.
The actual html is what you’re sending to the browser. It’s the output after the template has been rendered. It’s what you see by examining the page in your browser’s developer tools.