Coding exercise - building a Django rating & reviews web app
This is an web application that allows visitors add, rate and leave reviews for beers
pip install -r requirements.txt
within command prompt or terminal (if not, check out How to install python & pip )python manage.py createsuperuser
python manage.py runserver
Note: On your browser, go to http://127.0.0.1:8000/admin to access admin
Upon visiting the site, you shall be presented a view of the highest rated items, as well as a view of the most recently rated/reviewed items. This page also shows the name, number of reviews and overall rating for each beer. This page includes a heading as well as all featured breweries added by admin
Navigating to a beer returns a detailed view of it (i.e. beer name, brewery, style, ABV, description & overall rating) as well as any reviews (rating, username of reviewer, time of comment & comments left) that have been written for it.
Each product detail includes the number of review, but when there is no review yet, it shows “No Review Yet”.
When viewing a beer, you have an option leave a review for that beer. When reviewing, you would provide a 1 to 5 rating for the beer as well as an optional comment section below.
While viewing highest rated or recently reviewed items, you can add new items for rating and review. When adding new beers, you would be prompted to fill out details about the beer and then to submit or close form.
Only an administrator can add Breweries. An administrator can also add, modify or delete beers and beer reviews.
Project Name: bv_exercise
, App Name: rankings
Preloaded data: beerlist.json
bv_exercise/rankings/rankings/templates
bv_exercise/rankings/rankings/css
bv_exercise/rankings/rankings/products_img
class ReviewView(TemplateView)
class ProductView(TemplateView)
class Brewery(models.Model)
class Beer(models.Model)
class Review(models.Model)
review.html
product.html
ProductForm
ReviewForm
Used these URL pattern to the views
urlpatterns = [
url(r'^$', views.ReviewView.as_view(), name='review'),
url(r'^view-product/(?P<beer_id>[0-9]+)/$', views.ProductView.as_view(), name='view-product'),
]
In the future, it would be possible to add beer avatars by including a file input and render the address of the image to HTML template. In the meantime, I used an generic avatar/default for all Beers. Also, as the database expands, I’ve included an inactive footer pagination as an HTML comment.
Focus outline of clickable elements have been designed to aid with accessibility.