Skip to main content

django-fashion-size

PyPI Python Django Release

Django fields for fashion-size.

SizeUnitField stores which size unit a column is (uk-dress-size). Reading it returns a SizeUnit.

SizeField stores the size token (10, 7.5, DD). Pass size_unit_field pointing at a SizeUnitField on this model or a related one ("size_unit", "attribute.size_unit"). Reading it returns a Size; call .convert() on that value.

The source repository is github.com/ababic/django-fashion-size. It depends on fashion-size (CalVer releases on PyPI).

pip install django-fashion-size

Supported Django versions are 6.0 and 6.1 (see django>=6.0,<7 in pyproject.toml). CI runs the test suite against each of those releases and against Django's main branch.

pip install tox
tox

To run a single environment, for example Django 6.0: tox -e py312-django60.

Frontend sources live under frontend/. Lint and build with cd frontend && npm ci && npm run lint && npm run build (then commit any changes under src/django_fashion_size/static/django_fashion_size/). CI runs Ruff in lint.yml and lint/build checks in frontend.yml.

A release is a vX.Y.Z tag matching the version in pyproject.toml. Building the package compiles the size field's CSS and JavaScript from frontend/ into the static files the widget serves. That compile step runs in the release workflow, and it needs Node.js when you build from this repository. An install from PyPI uses the compiled files and does not need Node.

from django.db import models

from django_fashion_size.model_fields import SizeField, SizeUnitField


class Attribute(models.Model):
    size_unit = SizeUnitField()


class AttributeValue(models.Model):
    attribute = models.ForeignKey(Attribute, on_delete=models.CASCADE)
    size = SizeField(size_unit_field="attribute.size_unit")
value = attribute_value.size
from fashion_size.demographics import Demographic

value.convert_to_locale(
    "eu",
    demographic=Demographic(age_group="adult", gender="female"),
)

FashionProductType is a Django TextChoices enum with the same values as fashion_size.product_types.ProductType. Its labels are marked for translation (gettext_lazy), so makemessages can collect them.

FashionProductTypeField stores a product-type slug (shoes). Reading it returns a fashion_size.product_types.ProductType, or None when the value is blank or not a known product type. full_clean rejects values that are not in FashionProductType.values. Its default form field is FashionProductTypeFormField, a select whose options always come from FashionProductType. Passed choices are ignored so the list cannot go stale against fashion-size.

SizeTypeSlug is a Django choices enum with the same values as fashion_size.size_types.SizeTypeSlug.

Importing this package registers Django's get_language as the fashion-size display language and makes Size.display() use it. English lengths render as 32" and 81cm; other languages render as 32 in and 81 cm. UK 10 and DD stay the same in every language. Brand charts ship with fashion-size; pass brand_name and product_type on Size.convert / Size.convert_to_locale. The model fields do not need this package in INSTALLED_APPS.

SizeField's form control is an autocomplete. You type a size and the list shows chart values that start with that text. A short select beside the field chooses the region or unit you are typing (UK, EU, in, cm). A "View conversion chart" link to the right of the field opens the conversion chart. The value saved on the model is the token in size_unit_field (10 when the field stores UK dress sizes, even if you typed EU 38). Add django_fashion_size to INSTALLED_APPS so the widget's CSS and script are found.

The same control is SizeFormField, so a CharField such as AttributeValue.value can use it without becoming a SizeField. Pass the attribute's SizeUnit and the brand and product type you already have. brand_name is the brand's name. product_type_name is the product type's name (Shoes) or slug (shoes). Age group and gender select the chart.

self.fields["value"] = SizeFormField(
    size_unit=attribute.size_unit,
    brand_name=brand_name,
    product_type_name=product_type_name,
    age_group="adult",
    gender="female",
)

Leave those values unset to read them from other fields. A SizeField still passes its size_unit_field. brand_name_field defaults to brand, and product_type_name_field defaults to product_type. Point them at other names when the form uses those:

value = SizeFormField(
    size_unit_field="size_unit",
    brand_name_field="brand_name",
    product_type_name_field="product_type_name",
)

Metadata

Release files for django-fashion-size 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-fashion-size 0.6.0
File Size Uploaded
django_fashion_size-0.6.0.tar.gz 79.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-fashion-size 0.6.0
File Interpreter ABI Platform
django_fashion_size-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 148.1 kB

Release files / django_fashion_size-0.6.0.tar.gz

Download URL django_fashion_size-0.6.0.tar.gz
Size 79.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4104c168abac5f4bfef1639bd625af758ed598b7db28aed0c5928c2c10fccc8a
BLAKE2b-256 checksum
How to use checksums
c7acc229f22d809becff963d8dd93d78e491da50bad861395114bfc2ada51f61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / django_fashion_size-0.6.0-py3-none-any.whl

Download URL django_fashion_size-0.6.0-py3-none-any.whl
Size 69.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a10daef171bd350092b560ec2c6c2dacb6a5be2a7e93696ea2f38ae84ada74b2
BLAKE2b-256 checksum
How to use checksums
f38656da6fbd1ae542a6cf23dd83ef96aa37b35f40041d2e0c93ff9b6f068a58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page