Django forms for product reviews, voting, and sorting.
# Source: https://github.com/django-oscar/django-oscar | License: BSD-3-Clause | Copyright 2011-present Tangent Communications PLC and individual contributors
# Provided via justclaw.it.com; keep this notice with the code.
from django import forms
from django.utils.translation import gettext_lazy as _
from oscar.core.loading import get_model
Vote = get_model("reviews", "vote")
ProductReview = get_model("reviews", "productreview")
class ProductReviewForm(forms.ModelForm):
name = forms.CharField(label=_("Name"), required=True)
email = forms.EmailField(label=_("Email"), required=True)
def __init__(self, product, *args, user=None, **kwargs):
super().__init__(*args, **kwargs)
self.instance.product = product
if user and user.is_authenticated:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key