bitter-monkey-50309
03/09/2023, 10:04 PMRequestFactory
doesn't run middleware. https://docs.djangoproject.com/en/4.1/topics/testing/advanced/ "It does not support middleware. Session and authentication attributes must be supplied by the test itself if required for the view to function properly." If possible I'd switch it to use the normal test client, as that runs through the standard request call stack and is more similar to a real request. If you must use RequestFactory
then you can either set the request how you're doing, or manually call the middleware so you know you're testing in a state your middleware provides, but that's a little more effort.bitter-monkey-50309
03/09/2023, 10:05 PM.dockerignore
file is only used when building to ignore adding files into a build context. It can make your builds faster and resulting images smaller, and can also have a security impact if it means you're guaranteed not to have any files with credentials in them stored in your image. It doesn't have any affect on up
or any running containers.alert-grass-16919
03/10/2023, 8:09 AMrefined-waiter-90422
03/10/2023, 8:44 AMrefined-waiter-90422
03/10/2023, 8:47 AMrefined-manchester-67193
03/10/2023, 12:15 PMhx-ext="debug"
is not gonna cause any accidents in production? I remember reading it will only activate if the Django DEBUG
is True
.red-dinner-66239
03/11/2023, 12:50 PMhtml
<a hx-post="printerthermal?id={{ showorder1.id }}" class="btn-imprimer">imprimmer</a>
bitter-monkey-50309
03/11/2023, 5:26 PMhx-target
to pick a new element to swap into. https://htmx.org/attributes/hx-target/magnificent-camera-86904
03/11/2023, 5:29 PMhtml
{% for post in posts %}
{% if forloop.last %}
<div hx-get="{{ url }}?page={{ page_obj.number|add:1 }}" hx-trigger="revealed" hx-swap="afterend" hx-target="this" rel="next">
{% else %}
<div>
{% endif %}
After the user scrolls for awhile (maybe 3-4 pages) I would like to show a 'see more' button and allow the user to scroll to the bottom of the footer.
I've thought about using some kind of counter and doing a += 1 every time hx-revealed
is triggered. After it reaches 3, I stop injecting posts and instead show a 'view more posts' button.magnificent-camera-86904
03/11/2023, 7:21 PMhtml
{% load static %}
{% load post_utils %}
{% for post in posts %}
{% if forloop.last %}
{% if not page_obj.number|divisibleby:"6" %}
<div hx-get="{{ url }}?page={{ page_obj.number|add:1 }}" hx-trigger="revealed" hx-swap="afterend" hx-target="this"
rel="next">
{% else %}
<button id="see-more-btn" hx-get="{{ url }}?page={{ page_obj.number|add:1 }}" hx-trigger="click" hx-swap="outerHTML"
hx-target="this" rel="next">See more</button>
</div>
{% endif %}
{% else %}
<div>
{% endif %}
<p>post content</p>
{% endfor %}
magnificent-camera-86904
03/11/2023, 8:45 PMmagnificent-camera-86904
03/15/2023, 5:34 AMhtml
{% for post in posts %}
{% include "blog/parts/post_card.html" %}
{% if forloop.last %}
{% if page_obj.has_next %}
{% if not page_obj.number|divisibleby:"3" %}
<div hx-get="{{ url }}?page={{ page_obj.number|add:1 }}" hx-trigger="revealed" hx-swap="afterend" hx-target="this" rel="next"></div>
{% endif %}
{% if page_obj.number|divisibleby:"3" %}
<div class="text-center mb-5">
<button class="btn-primary btn" id="see-more-btn" hx-get="{{ url }}?page={{ page_obj.number|add:1 }}" hx-trigger="click" hx-swap="outerHTML" hx-target="this" rel="next">Load More Posts</button>
</div>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
bland-coat-6833
03/17/2023, 11:41 PMrefined-waiter-90422
03/18/2023, 5:51 AMplain-kangaroo-26043
03/18/2023, 6:53 AMplain-kangaroo-26043
03/18/2023, 6:54 AMhx-swap-oob
and I didn't see a mention of Hyperscript/Alpine etc for handling extra dynamic requirementsmammoth-airplane-32618
03/20/2023, 4:06 PMaloof-xylophone-31768
03/23/2023, 7:13 PMhx-trigger
since you can have it respond to event that you sent back with another htmx response. Now in your login case might not be as applicable because you might just be using the built-in login views, but still a great pattern to add to toolkit. In this case I return refreshImages
as an event in a view saving upload images (for example):
return HttpResponse(
status=204,
headers={"HX-Trigger": json.dumps({"refreshImages": None})},
)
<div
hx-trigger="load, refreshImages from:body"
hx-get="{% url 'apps.main:facility_images_render' pk=facility_obj.id %}"
hx-target="this"
>
</div>
aloof-painter-18008
04/09/2023, 5:38 PMaloof-painter-18008
04/09/2023, 5:39 PMsteep-gold-4096
04/12/2023, 12:34 AMmammoth-airplane-32618
04/12/2023, 1:19 AMmammoth-airplane-32618
04/12/2023, 1:19 AMmammoth-airplane-32618
04/12/2023, 1:21 AMmammoth-airplane-32618
04/12/2023, 1:22 AMsteep-gold-4096
04/12/2023, 2:00 AMsteep-gold-4096
04/12/2023, 2:08 AMhtml
<script src="https://unpkg.com/htmx.org@1.9.0"></script>
<!-- have a button POST a click via AJAX -->
<button hx-post="/clicked" hx-swap="outerHTML">
Click Me
</button>
So to use I guess I make a url like:
py
# URLS.py
path('clicked/', test_view, name='clicked'),
Right?
Then a hello world view could be:
py
def test_view(request):
context = 'Hello World!'
return render(request, context)
? Feel like this is right, but when I try this I get a 403 Forbidden Error when I click that button from the example.kind-kite-734
04/12/2023, 2:29 AMsteep-gold-4096
04/12/2023, 2:47 AM