Django view for querying data
Project description
Django view for querying data
Installation
To get the latest stable release from PyPi
pip install django-query-view
Usage
Set up models
class TaggedThing(TaggedItemBase):
content_object = models.ForeignKey('Thing', on_delete=models.CASCADE)
class Thing(models.Model):
name = models.CharField(max_length=200)
is_good = models.BooleanField()
tags = TaggableManager(through=TaggedThing, blank=True)
def __str__(self):
return self.name
# Subclass TagType
class ActorTag(TagType):
pass
# Create your tagged model like this
ActorTaggedThing = make_tag_type_tagged_model('ActorTaggedThing', ActorTag, Thing, app_label='testproject')
# Or like this
class ActorTaggedThing(TaggedItemBase):
tag = models.ForeignKey(
ActorTag,
related_name="%(app_label)s_%(class)s_items",
on_delete=models.CASCADE,
)
content_object = models.ForeignKey(Thing, on_delete=models.CASCADE)
class Meta:
unique_together = ['tag', 'content_object']
Create a typed tagged item
t = Tag.objects.get(name='clint eastwood')
ActorTaggedThing.objects.create(content_object=thing, tag=t.actortag)
Run the test project
python manage.py migrate
python manage.py loaddata testproject/fixtures/tag_thing.json
python manage.py runserver
Dump fixture
python manage.py dumpdata --indent 4 testproject.Thing testproject.TaggedThing taggit.Tag testproject.LanguageTag testproject.LanguageTaggedThing testproject.DirectorTag testproject.DirectorTaggedThing testproject.ActorTag testproject.ActorTaggedThing --output testproject/fixtures/tag_thing.json
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
Built Distribution
Close
Hashes for django_query_view-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 943bb682560b3b9fc7619ca239b8f734486a5a59859cc0cfc1a622f8a6976889 |
|
MD5 | 64a8ea51de4526e7f3215f516bd0ffca |
|
BLAKE2b-256 | 2afc8c4449531e8e86349c9d4215b2a34800ff407c59bba1ab8503d94edb780b |