npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

django-form-component

v1.1.4

Published

Web component wrapper for Django forms.

Readme

django-form-component

django-form is a Web Component wrapper for Django Forms

django-form uses js fetch to submit the forms to your api endpoint of choice instead of the traditional django forms functionality of submitting the entire page.

This allows you have the benefits of modern responsive web pages but keep the dependency and security of Django forms.

Install

npm install django-form-component

Usage

index.js

import "django-form-component";

index.html

<django-form
  action="api/send/"
  method="post"
  button="send"
  success-message="success"
>
  {{ send_form.as_p }}
</django-form>

Attributes

action

the url/api you are sending the form to

method

default - post

the request type you'd such as post get put

button

default - Add

the text that will be on the submit button

success-message

default - Saved

the text shown on successful form submission

Extending

Styling

The built in relevant style tags are as follow:

  • .django-form__field-error
  • django-form::part(django-form)
  • django-form::part(django-form__submit-button)
  • django-form::part(django-form__success-message)
  • django-form::part(django-form__fallback-errors)

Note that elements that are in the slot use classes and ones in the shadowDom have ::part attributes.

If want to extend and add styling to the form, you can use lit-element to add a styles method.

import { css } from "lit-element";
import { DjangoForm } from "django-form-component";

export class ReviewForm extends DjangoForm {
  static get styles() {
    return css`
      slotted(p) {
        color: red;
      }
      form {
        display: flex;
      }
    `;
  }
}

customElements.define("review-form", ReviewForm);

This component also supports ::part, so you can do something like this in your .css file:

.django-form__field-error {
  color: red;
}

django-form::part(django-form__submit-button) {
  background-color: aquamarine;
}

Response handling

Say your backend sends back some data on success and you want to do something with that. You can override the sendForm method to get the response of which you can do with what you want

import { DjangoForm } from "django-form-component";

export class ReviewForm extends DjangoForm {
  sendForm() {
    let res = super.sendForm();
    alert(`Backend says: ${res.data}`);
  }
}

customElements.define("review-form", ReviewForm);