I have been unable to render Template Tags. even though it is present in my html file it just gets ignored i don't know why
.png?part=0.1&view=1)
what I'm trying to achieve: I'm trying to create dependent dropdowns for my foreign keys. So based on what i select in fl_no the park_bay value shows the corresponding value related to that
i have successfully created the ajax requests but the html that is supposed to load into the dropdown for park_bay is getting ignored
my views.py file:
"
from django.shortcuts import render,redirect
from django.views.generic.base import TemplateView
from status.forms import StatusForm
from status.models import FlightStatus
from django.views.generic import ListView, CreateView, UpdateView
from postlog.models import Flight
from django.urls import reverse_lazy
# Create your views here.
class StatusPageView(CreateView):
template_name = "status/home.html"
model = FlightStatus
form_class = StatusForm
success_url = reverse_lazy('status')
def load_park_bay(request):
flightid = request.GET.get('flight1')
parks = Flight.objects.filter(fl_no='flightid').order_by('park_bay')
context = {'parks': parks}
return render(request, 'status/park_bay_dropdown_list.html', context)
"
my urls.py file:
"
from django.urls import path,include
from . import views
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
path('', views.StatusPageView.as_view(), name='status'),
path('ajax/load-park/', views.load_park_bay, name='ajax_load_park'),
]
"
the page where the form is being rendered home.html:
"
{% extends 'base_template1.html' %}
{% load static from staticfiles %}
{% load crispy_forms_tags %}
<!DOCTYPE html>
{% block title %} Status {% endblock %}
{% block content %}
<button type="button" class="butra button1ra" data-toggle="modal" data-target="#Add_Modal">Add Flight Status</button>
<div class="modal fade" id="Add_Modal" tabindex="-1" role="dialog" aria-labelledby="Add_ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="AddModalLabel">Flight Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form method="post" id="statusForm" data-parks-url="{% url 'ajax_load_park' %}" novalidate>
{% csrf_token %}
{{ form|crispy }}
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Add Details</button>
</div>
</form>
</div>
</div>
</div>
</div>
"
the html template which gets loaded into the park_bay options park_bay_dropdown_list.html:
"
{% load static from staticfiles %}
{% load crispy_forms_tags %}
<option value="">---------</option>
{% for park in parks %}
<option value="{{ park.fl_no }}">{{ park.park_bay }}</option>
{% endfor %}
"
_LI.jpg?part=0.2&view=1)
only this one line gets added
and the rest of the lines present in the html file gets ignored
since they have template tags