Django version 5.1.5
HTMX 2.0
Setup:
Django project has 2 apps:
console_app - this app initially calls a view.py function console_view and displays a page named base_console_ap.html. This page is basically a dashboard. Along 1 side of this dashboard is a summary list of turnover_log entries.
turnover_app - this app initially calls a view.py function turnover_index and displays a page named index.html. This app basically allows the creation and editing of turnover_log entries.
Goal:
To select a turnover_log entry from dashboard (console_app) summary and have it go to the turnover_app function turnover_index and load the index.html. page. Ultimately pass the record id(pk) and load that distinct record selected from the dashboard. But I cannot even get it to load the static index.html page properly, so until I can do that no reason to add complexity of passing a pk value.
What happens:
If I use:
<a href="{% url 'turnover_app:turnover_index' %}">TurnOver Log</a>
works fine loads index.html page all good. But of course does not pass a value (pk) my ultimate goal. just a test here.
If I use:
<button type="button" id="btn"
class="btn btn-outline-success"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'turnover_app:turnover_index' %}">
TurnOver Log
</button>
it does call the view.py function turnover_index and loads the index.html page . What happens is the current console_app (dashboard) base_console_ap.html. stays loaded and visible and the other page turnover_app (index.html) page loads over and under around the current page (base_console_ap.html). of course it’s all messed up.
Remember the code above is just test code to see if I can load the static index.html page from another app. Not trying to pass (pk) value yet. I’m sure I’m missing something stupid but that’s learning.
I did put entries in both urls.py apps reference both ways.
console_app/urls.py (partial)
path('turnover_index/', views.turnover_index, name='turnover_index'),
turnover_app/urls.py (partial)
path('turnover_index/', views.turnover_index, name='turnover_index'),
NOTE:
The reason I’m trying to use an HTMX control is to use hx-include to maybe pass a value. I would like the option of using for example something like myvar = request.GET.get(‘my_val’) back to an HTML entity in another app, if that’s even possible? even tried having a function in console_app call the turnover_index function in turnover_app and still the same results.
As usual all support helps and I’m thankful.