Posts

Showing posts with the label alpine.js

How to create custom form widgets with Django, AlpineJS and TailwindCSS

Image
  In this short guide, you will learn how to create a custom form widget for your Django app. Prerequisites Basic knowledge of Django forms and views How to use AlpineJS, TailwindCSS with Django -  see this post here LEVEL - 💻 💻 Intermediate to advanced - Basic knowledge of Django forms and templates is assumed. The problem You have ditched javascript for your forms, and are using  HTMX  . Your forms are sleek, 100% Django views and forms, no page reloads on submission but your widgets still look like this. Create a new widget The form above is based on a basic user model with at least the following fields. Authentication is out of the scope of this article. If you need more information about user models visit  this  section in the docs. users/models.py class User(AbstractUser): name = models.Charfield(_( "Display Name" ), blank = True , max_length =255) avatar = models.ImageField( upload_to = "images) username = models.Charfield(_(" username"...