Skip to main content

No project description provided

Project description

django_lookups: Lookup Models for Django Applications

django_lookups provides a LookupModel that many of us have written some variation 100's of times. Most of the applications we write have lookup tables (or should!) and we have boilerplate everywhere to manage constants. The aim of this library is to make working with lookup data in django easier.

You might have a constants repo / package / library that you share between your apps or services. Most of the time, instead of constants, those values really belong in lookup tables. Things like status int fields. If you have a django model with a field like status = models.PositiveIntegerField this library is probably for you!

A trivial example showing how you might interact with an Order Status.

class OrderStatusTypes(django_lookups.LookupModel):
    class Meta:
        app_label = "my_app"
        db_tabel = "my_table"

class Order(models.Model):
    status = models.ForeignKey(OrderStatusTypes)
    address = models.ForeignKey(...)
    created = models.TimestampField()
    changed = models.TimestampField()

    @classmethod
    def new_order(cls):
        return cls.objects.create(
            status=OrderStatusTypes.members.INITIATED.model,
            ...
        )

Once you add this library as a dependency, and have created your first lookup model, you'll need to run a data migration to add the lookup values to your table, or add data to your lookup tables manually. Once the data is there, your code can work with this data by name. No more need to keep constants libraries in sync when you add a new type/status etc!

This library is on pypi so you can run pip install django_lookups to get started or add it with the package manager of your choice.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-lookups-0.1.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_lookups-0.1.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file django-lookups-0.1.3.tar.gz.

File metadata

  • Download URL: django-lookups-0.1.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.5 Darwin/19.6.0

File hashes

Hashes for django-lookups-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9e6791811967fbb204a06e63fc03d0169273c8db84bbba8ad227060ecc5550d2
MD5 a2aae0943488b5bbb9bd2c8e754a6744
BLAKE2b-256 3188965149d8840d15a2543d9478c41d700736ed0a246eb7f9dd33c060064cb3

See more details on using hashes here.

File details

Details for the file django_lookups-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_lookups-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.7.5 Darwin/19.6.0

File hashes

Hashes for django_lookups-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ada89629f7dc2673eaf0e71c5fd43ef19c69a6b35a498598cb70d6d53c753bdc
MD5 8b5b2e114a3e776ce583682b73b321f7
BLAKE2b-256 ff24eb5b12445ebe763d0fe48d1a587d83c43b9b4db82187616b4a748ada6077

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page