Skip to main content

wagtail-gunsnprices

PyPI Tests License

StreamField blocks for gun and ammo content in Wagtail: a caliber table, a cost per round calculator, a spec table built from a product title, and a caliber field for your own models.

Editors type what they already have, a store's product title or a box price, and the blocks fill in the rest: brand, model, caliber, magazine capacity, barrel length, rounds per box, cost per round. The parsing is done by the gunsnprices package, the title parser behind GunsNPrices, a price comparison site for 40+ US gun and ammo stores. The caliber list (293 calibers) is the one the site uses, so every caliber can link to its price comparison page.

No network requests, no API key. Works with Wagtail 6, 7 and 8, Django 4.2 to 6.1, Python 3.9 to 3.13.

Install

pip install wagtail-gunsnprices
INSTALLED_APPS = [
    ...
    "wagtail_gunsnprices",
]

The app only provides templates; it has no models and no migrations.

Blocks

from wagtail.fields import StreamField
from wagtail.models import Page

from wagtail_gunsnprices.blocks import CaliberTableBlock, CostPerRoundBlock, FirearmSpecsBlock


class ArticlePage(Page):
    body = StreamField([
        ("caliber_table", CaliberTableBlock()),
        ("cost_per_round", CostPerRoundBlock()),
        ("firearm_specs", FirearmSpecsBlock()),
    ])

Render them as usual with {% include_block block %}. Each block has its own template under wagtail_gunsnprices/blocks/; override it in your project to change the markup. The tables carry gnp-* CSS classes and no styles of their own.

CaliberTableBlock

The editor picks calibers from a list grouped by type (handgun, rifle, rimfire, shotgun, muzzleloader, airgun) and gets a table:

Caliber Type Prices
9×19mm Parabellum Handgun Compare prices
.45 ACP Handgun Compare prices

Fields: heading (optional), calibers, show_type, link_prices. The template gets rows, a list with name, type, type_label and url for each caliber.

CostPerRoundBlock

Fields: title (an ammo listing title, optional), price, rounds (optional) and currency (default $). When rounds is empty it is read from the title: 50rd, Box of 20, 1000 Rounds, 20/25 all work. The caliber is read from the title too. Saving fails with a clear message when no round count can be found.

Ammo            Federal 9mm 115gr FMJ 50rd
Caliber         9×19mm Parabellum
Price           $18.99
Rounds          50
Cost per round  $0.38

FirearmSpecsBlock

Fields: title (the product title as a store writes it), optional brand, mpn (part number), price, currency and link_prices. The template gets specs.rows, each with label, value and url:

Glock 19 Gen 5 MOS 9mm 4.02in 15rd Pistol
Type            Firearm
Brand           Glock
Model           Glock 19 Gen 5 MOS
Configuration   MOS
Caliber         9×19mm Parabellum  (linked to the price page)
Capacity        15 rounds
Barrel          4.02"

Models are recognized for 50 brands (Glock, Sig Sauer, Smith & Wesson, Ruger, Springfield, Mossberg, Remington, Savage, CZ, Beretta, Benelli, Taurus, Kimber, Walther, HK, FN, Colt, Henry, Marlin, Tikka, Winchester and more); other brands still get caliber, capacity and barrel length. Ammo titles work too and add rounds per box and cost per round. A title with nothing recognizable in it is rejected when the page is saved.

Caliber choice blocks

from wagtail_gunsnprices.blocks import CaliberChoiceBlock, CaliberMultipleChoiceBlock

("caliber", CaliberChoiceBlock()),                       # one caliber, all 293
("calibers", CaliberMultipleChoiceBlock(types=["handgun", "rimfire"])),

Values are caliber ids such as 9x19mmparabellum. Unlike a plain ChoiceBlock, these blocks reference their own class when deconstructed, so the 293 choices are not copied into every migration.

Caliber field

from django.db import models
from wagtail_gunsnprices.fields import CaliberField


class Firearm(models.Model):
    name = models.CharField(max_length=100)
    caliber = CaliberField()                   # all calibers
    backup = CaliberField(blank=True, types=["handgun"])

CaliberField is a CharField with the caliber list as grouped choices, so the admin shows a select and get_caliber_display() returns the name. It also adds get_caliber_caliber(), which returns the gunsnprices.Caliber with id, name, type and the price page url. The choices stay out of migrations.

For plain Django forms there is wagtail_gunsnprices.fields.CaliberChoiceField.

Helpers

Everything the blocks compute is available as plain functions, for your own views, templates and snippets:

from wagtail_gunsnprices.calibers import caliber_choices, calibers, get_caliber
from wagtail_gunsnprices.specs import caliber_rows, cost_per_round_data, firearm_specs

get_caliber("9mm Luger").url          # 'https://gunsnprices.com/ammo/handgun-ammo/9-19mm-parabellum'
caliber_choices(types="rifle")        # [('17hornet', '.17 Hornet'), ...]
cost_per_round_data("18.99", title="Federal 9mm 115gr FMJ 50rd").cost_per_round_display   # '$0.38'
firearm_specs("Sig Sauer P365 XL 9mm 3.7in 12+1").rows   # [SpecRow(key='kind', label='Type', value='Firearm'), ...]

Development

pip install -e . build twine
python runtests.py            # Wagtail test project in tests/, Django test runner
python -m build && twine check dist/*

Tests run on Wagtail 6.4, 7.4 and 8.1 with Django 4.2, 5.2 and 6.1 in CI.

License

MIT. The caliber and model data come from the gunsnprices package (CC BY 4.0, attribution: GunsNPrices).

Questions, corrections and missing models: open an issue or write to app@gunsnprices.com.

Metadata

Release files for wagtail-gunsnprices 0.1.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 wagtail-gunsnprices 0.1.0
File Size Uploaded Provenance Actions
wagtail_gunsnprices-0.1.0.tar.gz 17.7 kB With provenance Details for wagtail_gunsnprices-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-gunsnprices 0.1.0
File Interpreter ABI Platform Actions
wagtail_gunsnprices-0.1.0-py3-none-any.whl Python 3 none any Details for wagtail_gunsnprices-0.1.0-py3-none-any.whl

Total release size: 32.2 kB

Release files / wagtail_gunsnprices-0.1.0.tar.gz

Download URL wagtail_gunsnprices-0.1.0.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bea083d2467cf0d743e3622b3ce6edae05d4a5e8486fa420f8842cc2ffa6d9b0
BLAKE2b-256 checksum
How to use checksums
74308bf9d552e12b89681367429f2ac828f84595d665d8caed113c9531491179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Release files / wagtail_gunsnprices-0.1.0-py3-none-any.whl

Download URL wagtail_gunsnprices-0.1.0-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0aa7a88534983117068a6a7dcc1a646b3a0752c228ad8783109763ffc0db1083
BLAKE2b-256 checksum
How to use checksums
649eccf86e237201280f2e4c0178c8ea27bdc5031faeccfac9de7411bfb9a78d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 30, 2026.

Transparency log

Security for wagtail-gunsnprices 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wagtail_gunsnprices-0.1.0.tar.gz

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 Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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