Skip to main content

django-view-table

Plugin to create view table in Django.
This plugin enable you to create view table in Django model.

Support Database

  • SQLite3
  • PostgreSQL
  • MySQL
  • (TBC)Oracle Database

Installation & Setup

pip install django-view-table

After install, you can set your INSTALLED_APPS

INSTALLED_APPS = [
    'viewtable',
]

Usage

Create model

You need the three step.

  • Import view_table module
  • Inherit ViewTable
  • Impliment get_query method

The method get_query should return select sql statement.
You can write sql statement as raw sql or django model object.

This is a simple example.

from django.db import models
from view_table.models import ViewTable


# Base table
class Book(models.Model):
    name = models.CharField(max_length=100)
    category = models.CharField(max_length=100)


# View table
class Books(ViewTable):
    category = models.CharField(max_length=100)
    count = models.IntegerField()

    # You must implement get_query method.
    @classmethod
    def get_query(self):
        return Book.objects.values('category').annotate(count=models.Count('category')).query
        # You can also write:
        # return 'SELECT "polls_book"."category", COUNT("polls_book"."category") AS "count" FROM "polls_book" GROUP BY "polls_book"."category"' 

Run command

After Django migration, you can create view tables the below command.

python manage.py createviewtable

Development

I prepare application for this plugin application.

License

MIT

Metadata

Release files for django-view-table 1.0.1

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-view-table 1.0.1
File Size Uploaded Provenance
django-view-table-1.0.1.tar.gz 2.6 kB Without provenance Details

Release files / django-view-table-1.0.1.tar.gz

Download URL django-view-table-1.0.1.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2992220533285b8356c14758de1a80b8a27d934132ca9ec9eac5a7ae8c0ea773
BLAKE2b-256 checksum
How to use checksums
c77a40dbb9df976f8fde30971e57d48fb7bdc8dfeaf9b0e0d196bb289545087b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.1

Security for django-view-table 1.0.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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