I'm totally new to Stack Overflow and pretty new to Django/Python. I don't have much background in coding (started learning python less than a month ago) but I wanted to learn it and give it a try.
I know HTML and CSS enough to get what I want done, but Python/Django, that's still uncharted territory for me.
So far, I have a pretty basic website, and I'm trying to implement a multi-part 5-star rating system that's customizable and works with my database.
So here's my model:
class listing(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
title = models.CharField(max_length = 100, default="Class Title")
slug = models.SlugField(unique=True)
draft = models.BooleanField(default=False)
publish = models.DateField(auto_now=False, auto_now_add=False)
description = models.TextField(default="Class Description")
prerequisite = models.TextField(default="Class Prerequisites")
university = models.CharField(max_length = 100, default="Choose A University")
department = models.CharField(max_length = 100, default="Choose A Department")
last_updated = models.DateTimeField(auto_now=True, auto_now_add=False)
timestamp = models.DateTimeField(auto_now=False, auto_now_add=True)
image = models.FileField(
upload_to=upload_location,
null=True,
blank=True)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse("listings:detail", kwargs={"slug": self.slug})
Basically, I want to have the ability to give users the option to rate each individual class based on 4 custom criteria that I define. So for example, difficulty_rating, workload_rating, book_rating, attendance_rating.
I would ideally like to have this done where the user can input their decision on a 5-star rating system, that I can customize to make the stars look how I want them to look.
Ideally, in a best case scenario, I'd like it to look like this https://codepen.io/anon/pen/JyZGqd
And I'd like that user decision to be sent to my database, to be then calculated as an average, and then displayed back on my listing_detail view as an integer that I can customize with CSS as well (a little confused on how to do that too).
Here's my listing_detail view:
def listings_detail(request, slug=None):
instance = get_object_or_404(listing, slug=slug)
share_string = quote(instance.description)
context = {
"title": "Detail",
"instance": instance,
"share_string": share_string,
}
return render(request, "class_page.html", context)
Keep in mind I'm still very much a beginner! I'm trying my best to understand as much as I can with Django and Python.
What would be the best way to achieve a multi-part 5-star rating system that's fully customizable in design?
Thank you for your time and help!