https://htmx.org logo
Join Discord
Powered by
# πŸ”₯-django-htmx
  • b

    bland-coat-6833

    02/17/2022, 9:51 PM
    I was doing quite well with k8s until I realised it’s not that great for non-web apps.
  • b

    bland-coat-6833

    02/17/2022, 9:52 PM
    Or non-web apps that you want exposed using Ingress.
  • p

    plain-kangaroo-26043

    02/17/2022, 9:55 PM
    Yes I think the future is pretty much everything running on k8s (or web-everything anyway) but it will be abstracted away for most developers. Just part of the plumbing that Google/Amazon/whoever you pay to take care of it.
  • b

    bland-coat-6833

    02/17/2022, 10:02 PM
    I do like the idea of k3s. Or whichever one Ubuntu makes. Micro-k8s? Though for single server deploys, Docker Swarm is lovely.
  • f

    fresh-controller-36545

    02/17/2022, 10:04 PM
    Heroku k8s kappa
  • f

    fresh-controller-36545

    02/17/2022, 10:04 PM
    With Heroku Autoscaler
  • f

    fresh-controller-36545

    02/17/2022, 10:04 PM
    Supported by auto-magically simple deploy πŸ€”
  • f

    fresh-controller-36545

    02/17/2022, 10:05 PM
    Isn't Docker Swam a low-configuration alternative to K8S? Or is it mostly used for single server scaling
  • b

    bland-coat-6833

    02/17/2022, 10:06 PM
    It’s a simple version of k8s. You can do multi-server. In many ways it’s a lot easier to use. But support is not guaranteed any more.
  • b

    bland-coat-6833

    02/17/2022, 10:07 PM
    But you can basically use a compose file as your swarm config and have it deploy nicely.
  • b

    bland-coat-6833

    02/17/2022, 10:08 PM
    I think https://tilt.dev also supports it. They support compose at least.
  • f

    fresh-controller-36545

    02/17/2022, 10:09 PM
    Interesting; haven't had an app of that magnitude yet tho to need it
  • f

    fresh-controller-36545

    02/17/2022, 10:09 PM
    and not necessarily looking forward to it either πŸ™ƒ
  • i

    important-winter-64905

    02/18/2022, 7:35 PM
    I'm wondering how to use different colors when I do the swap... in my python function I have something like this:
    Copy code
    if value < 7:
        <<do green swap>
    else:
        <<do red swap>>
    HTML snippet:
    Copy code
    <td class="update_flash" id="abc_this" nowrap="nowrap">
      <input hx-target="#abc_this" hx-swap="outerHTML swap:0s" 
             class="form-control form-control-sm" type="number" 
             name="nameabc" value="0.00" step="0.5" 
             hx-post="/projects/update" hx-trigger="change delay:0.1s">
    </td>
    my CSS:
    Copy code
    td.update_green.htmx-settling {
      background: #36842d;
    }
    
    td.update_red.htmx-settling {
      background: #842d2d;
    }
  • h

    hundreds-camera-24900

    02/18/2022, 9:37 PM
    you want the update_flash class to be the colored section?
  • h

    hundreds-camera-24900

    02/18/2022, 9:37 PM
    say like
  • h

    hundreds-camera-24900

    02/18/2022, 9:38 PM
    Copy code
    if value < 7:
      flash_color = 'update_green'
    else:
      flash_color = 'update_red'
    
    
    -----------------
    template:
    <td class="update_flash {{flash_color}}" id="abc_this" nowrap="nowrap">
      ...
    </td>
  • s

    shy-refrigerator-51928

    02/19/2022, 3:43 AM
    Hello, I have a modal form that swaps a list view with the new item submitted and it works fine when the item does not exist but when it already exists, instead of showing the validation error in the current modal form, it swaps the list view target area with the form showing the validation error. How can I not swap to the hx-target unless form is valid?
  • s

    shy-refrigerator-51928

    02/19/2022, 3:43 AM
    my form html:
  • s

    shy-refrigerator-51928

    02/19/2022, 3:45 AM
    Copy code
    <form hx-post="{% url 'notecards:create' %}" hx-target="#notecards-list-group" hx-indicator=".htmx-indicator" hx-swap="afterbegin">
      <div class="modal-body">
        {% crispy form %}
      </div>
      <div class="modal-footer">
        <input type="submit" class="btn btn-primary"></input>
        <button type="button" class="btn btn-primary" data-bs-dismiss="modal">Cancel</button>
      </div>
    </form>
  • s

    shy-refrigerator-51928

    02/19/2022, 3:45 AM
    my view:
  • s

    shy-refrigerator-51928

    02/19/2022, 3:45 AM
    Copy code
    def notecard_create(request):
        template_name = 'notecards/hx/notecard_create_form_hx.html'
        form = NoteForm(request.POST or None)
    
        if request.method == 'POST':
            if form.is_valid():
                notecard = form.save()
                template_name = 'notecards/hx/notecard_item_hx.html'
                context = {'notecard': notecard}
                return render(request, template_name, context)
    
        context = {'form': form}
        return render(request, template_name, context)
  • b

    blue-gold-89534

    02/19/2022, 1:15 PM
    you can add some error handling code in the template
  • b

    blue-gold-89534

    02/19/2022, 1:16 PM
    Copy code
    html
    {% if form.errors %}   
        {% for error in form.errors %}
            {% if error == "number" %}
                <span class="text-danger">number exists</span>
            {% endif %}
        {% endfor %}
    {% endif %}
    
    {% for error in form.non_field_errors %}
        <span class="text-danger">{{ error }}</span>
    {% endfor %}
  • b

    blue-gold-89534

    02/19/2022, 1:16 PM
    so this is "always there" but if no errors are sent back from django backend the fields are empty/invisible
  • i

    important-winter-64905

    02/20/2022, 8:52 PM
    yes, something like that. As it is right now it has to be initially loaded with
    class="update_flash"
    to start and when I do the HTMX swap it includes the same class which causes the flash to occur. I want to have the option to have it flash for two different colors now though. Green be that the submission was accepted and red meaning the submission was not accepted.
  • h

    hundreds-camera-24900

    02/20/2022, 8:55 PM
    so does
    <td class="update_flash {{flash_color}}" id="abc_this" nowrap="nowrap">
    work?
  • h

    hundreds-camera-24900

    02/20/2022, 8:57 PM
    Also I just want to brag that my django-debug-toolbar pr was merged today: https://github.com/jazzband/django-debug-toolbar/pull/1577
  • h

    hundreds-camera-24900

    02/20/2022, 8:58 PM
    That will work with HTMX so it'll catch and update the toolbar when swapping content in
  • h

    hundreds-camera-24900

    02/20/2022, 8:58 PM
    I'm going to reopen my other pr around boosting links - once we get those merged DJDT should just work with htmx
1...515253...100Latest