Adding Reviews to your django app.
Project description
DJANGO REVIEWS & RATING
Add reviews and ratings functionalities to your dango app.
Installation
pip install djreviews
Usage
Extending functionality in models
from django.db import models
from djreviews.models import BaseReviewModel, BaseReviewedModel
class ProductReview(BaseReviewModel):
"""
Product Reviews
"""
class Product(BaseReviewedModel):
name = models.CharField(max_length=20)
description = models.TextField()
objects = models.Manager()
# important
REVIEW_MODEL = ProductReview
usage in views
product = Product.objects.get(pk=product_pk)
customer = Customer.objects.get(pk=customer_pk)
product.add_review(
content=review_text,
rating=rating_score,
reviewer=customer,
)
# OR
ProductReview.objects.add_review(
content=review_text,
rating=rating_score,
reviewed_object=product,
reviewer_object=customer,
)
in templates
{% for review in object.reviews.all|dictsortreversed:"id" %}
<div>
<p>{{ review.reviewer }}</p>
<p>rating: {{ review.rating }}</p>
<p>review: {{ review.content }}</p>
</div>
{% empty %}
<p>No reviews</p>
{% endfor %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
djreviews-0.0.1.tar.gz
(3.0 kB
view details)
Built Distribution
File details
Details for the file djreviews-0.0.1.tar.gz
.
File metadata
- Download URL: djreviews-0.0.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ef66cb6cd3593280e6333958adc8e4ad53ac09b9c25900a0fd0ee8288f9267 |
|
MD5 | 294591cab32dbf6983cd51045d492c59 |
|
BLAKE2b-256 | fb47579c8dc0116910108c232278b8cee7016c767a2d96a0f3c17e788e3ba970 |
File details
Details for the file djreviews-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: djreviews-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bd48bea33c86739d623b4561ddd873e5680a35413acc88723f26832ee678536 |
|
MD5 | 54b4a5dd65fbbfd84a3668a2238c6c07 |
|
BLAKE2b-256 | cb9b6c4c85f86dd0b7f04b098ef222e5fdb24b695ed683ca2e0ecd3a5e62be2d |