Hi,
I’m trying to get some data from a bootstrap range slider, but it is returning None. this only happens in {% elif request.user.profile.status == 'Actor' %}
section, when running the same line of code in {% if request.user.profile.status == 'Admin' %}
is returns the data as expected.
Am I missing something here?
HTML:
The data I would like to retrieve
<input name="m_slider" type="range" class="form-range" id="id_m_slider">
Full HTML section:
<form method="POST">
{% csrf_token %}
<div class="field">
<Fieldset class="form-group">
{% if request.user.profile.status == 'Admin' %}
<div class="container">
<div class="row">
<div class="col-md-6 mb-4 offset-md-3">
<div class="row">
<div class="col">
<select name="status" class="select form-control" id="id_status">
<option value="Pending" selected="">Pending</option>
<option value="Awaiting Review">Awaiting Review</option>
<option value="Complete">Complete</option>
<option value="Needs Updating">Needs Updating</option>
</select>
<input name="m_slider" type="range" class="form-range" id="id_m_slider">
</div>
<button class="btn btn-outline-info" id="submit">Submit</button>
</div>
</div>
</div>
</div>
{% elif request.user.profile.status == 'Actor' %}
<input name="m_slider" type="range" class="form-range" id="id_m_slider">
<div class="control has-icons-left has-icons-right" style="margin-top: 1rem">
<audio id="audio_recorder" class="video-js vjs-default-skin"></audio>
</div>
<button class="btn btn-primary" id="submit">Submit</button>
{% endif %}
</Fieldset>
</div>
</form>
View:
def form_valid(self, form) -> HttpResponse:
if self.request.user.profile.status == 'Actor':
self.object.author = self.request.user
self.object.date_created = timezone.now()
print(self.request.POST.get("m_slider"))
self.object.audio_recording = self.request.FILES.get("recorded_audio")
self.object.status = 'Awaiting Review'
self.object.save()
return JsonResponse({
"url": self.get_success_url(),
"success": True,
})
elif self.request.user.profile.status == 'Admin':
self.object.status = self.request.POST.get("m_slider")
print(self.request.POST.get("username"))
self.object.save()
return super().form_valid(form)