class User(AbstractUser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.progress = ""
...
def set_progress(self, value):
self.progress = value
@property
def get_progress(self):
return f"{self.progress}"
...
<div class="submit-row">
<input type="submit" value=" {{ btn_label }} "/>
</div>
<p><div hx-get="/hx_usr_progress" hx-trigger="every 1s"></div></p>
def hx_usr_progress(request):
progress = request.user.progress
print(f"\n{progress} ... {request.user}")
return HttpResponse(mark_safe(f"<p>... {progress}</p>"))
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/020a98ef-4a10-4560-afdd-0a8b065e7235n%40googlegroups.com.
Not sure if it's related, but you've got a div inside a p element there:
<p><div hx-get="/hx_usr_progress" hx-trigger="every 1s"></div></p>
That'll probably get corrected by the browser to:<p></p> <div hx-get="/hx_usr_progress" hx-trigger="every 1s"></div> <p></p>
Another thing is, it doesn't look like there's anything linking the submit button click to the initial htmx
request, and there's no htmx in the response.
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% if form.non_field_errors %}
{{ form.non_field_errors }}
{% endif %}
<div class="indent5">
<table>
{% for field in form %}
<tr>
<td width="=10%"> </td>
<td width="90%"class="nobullets">{{ field }}</td>
</tr>
{% if field.help_text %}
<tr>
<td colspan="2">{{ field.help_text }}</td>
</tr>
{% endif %}
{% endfor %}
<tr>
<td width="10%"><p> </p></td>
<td width="90%">
{% if not result %}
<p><div class="g-recaptcha" data-sitekey={{ sitekey }}></div></p>
<p>
<div class="submit-row">
<div hx-get="/hx_usr_progress" hx-target="#progress" hx-trigger="click">
<input type="submit" value=" {{ btn_label }} "/>
</div>
</div>
</p>
{% else %}
<p> </p>
<p>
<div class="submit-row">
<div hx-get="/hx_usr_progress_stop" hx-target="#progress" hx-trigger="every 1s">
<input type="submit" value=" More "/>
</div>
</p>
{% endif %}
<div id="progress"></div>
</td>
</tr>
</table>
</form>
</div>
</div>
<p>{{ result }}</p>
</div>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/020a98ef-4a10-4560-afdd-0a8b065e7235n%40googlegroups.com.
-- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public key you can automatically decrypt my signature and be sure it came from me. Your email software can handle signing.
Can I just check I understand the broader requirements here:
* The user completes the form, which includes a list of items, and clicks submit
* For each item in the list you want Django to create a new object and save it to the database* It tends to be a very long list and/or each item takes a long time to process
* The user should see a progress bar while the server is working its way through the list* When all items have been processed the progress bar should be replaced with a done message
If that's the case
I think you should think about using Celery
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2155bccd-11c3-4560-97ab-809ccbe2d2c4n%40googlegroups.com.
I'm now thinking/wondering if a htmx timed execution - say every one or two seconds - might call a view which monitors a singleton being updated by the main view kicked off by the form's submit button.
What pushes me in that direction is that a singleton could be updated with number processed which would be needed if it ever gets to become a progress bar.