Giter VIP home page Giter VIP logo

rogers_park_free_store's People

Contributors

eevelweezel avatar katbait avatar

Watchers

 avatar

rogers_park_free_store's Issues

Categories functionality

Right now, we have this URL to display products by category:
path('search/<slug:category_slug>/', views.category_list, name='category_list'),

Instead of making categories a separate page, let's add a dynamic list of categories to the home page template (below the "about us" section, and any photos/logos we decide to add), that will link to /products/?category=cat-food

Add a '/products/' URL

The root URL is currently pointed at a route named "all_products." This view is querying products, but it's just serving the home page template. Let's leave the homepage at root, and add a separate /products/ url that shows a list of available products.

We'll want this to have the ability to filter by category (and eventually a search feature)... so, we'll need make /products/ take a "categories" param (i.e., '/products/?category=cat-food'). For UI, we'll want this page to show titles & pictures, and link to the product detail for each.

I'd like products to use a class-based view, so we can use methods and define behavior by verb (GET, POST, PUT, etc.). For example:

...
from django.template.response import TemplateResponse
from django.views.generic.base import View

class ProjectView(View):

def get(self, request, *args, **kwargs):
    # there's a couple way to parse args... this isn't necessarily the best.
    cat = request.GET.get('category')
    data = Products.objects.filter(status='active', category=cat)
    context = {'products': data}
    return TemplateResponse(
               request,
               'template.html',
               context=context,
               status=200)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.