GithubHelp home page GithubHelp logo

tjking24 / wdc-ecommerce-django-forms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raghureddyram/wdc-ecommerce-django-forms

0.0 1.0 0.0 34 KB

Practice forms using Django Forms and Model Forms

Makefile 3.40% Python 58.20% HTML 38.41%

wdc-ecommerce-django-forms's Introduction

rmotr.com

Ecommerce Django Forms

Setup Instruction

The structure of the whole Django project is built for you. Run the following commands in order to have your local environment up and running.

$ mkvirtualenv -p $(which python3) ecommerce_django_forms
$ pip install -r requirements.txt

You can now run the development server and point the browser to the correct URL:

$ make runserver

You will have a superuser already created (username: admin, password: admin) that you can use when pointing to http://localhost:8080/admin in your browser with the server running. There you can find the Django admin site where you will be able to create, delete and modify objects from your database.

Also there's a not-admin user (username: test, password: test) that will be useful for trying the restricted features that this kind of users have while using the Ecommerce platform.

The database already contains some objects that we have created for you, but feel free to interact with it the way you want.

There's also a LIVE version of the solution so you can try it and check how everything should work:

https://ecommerce-django-forms.herokuapp.com/products/

image

Description

In the previous part of Django Ecommerce project, we've developed a solution based on simple HTML forms with manual validation inside the view for each input.

The idea of this advanced version of the project is to migrate all those HTML forms into Django ModelForms that will simplify a lot the validation and rendering of the templates.

Also we'll add a Session Authentication layer to distinguish different features based on authenticated or not authenticated users, and admin or regular users.

  • Admin users have access to everything. They can create/edit/delete products, mark products as featured and add products to the shopping cart.
  • Regular users can only add products to their cart.
  • Anonymous users (not authenticated) can just view the static products page.

Try all this features with the users credentials and LIVE demo link given above, to make sure how your solution should look like. You can check the code related to the LIVE demo in a branch called solution in this same repository.

Your tasks

Task 1: Django forms

For this task you'll have to implement a Django ModelForm related to the Product model. It'll be inside products/forms.py. This form will be used later in create_product and edit_product views and templates.

Task 2: Templates and views

We've done the login/logout workflow for you as an example. It is just a new /accounts URL that you can check inside ecommerce_django_forms/urls.py and a login.html template under templates/registration/login.html.

Your tasks will be focused on showing/hiding the following buttons in the products page, depending on if user is authenticated or not, and if it has admin permissions or not. Also you'll have to implement the proper view for each button inside products/views.py. More explanatory instructions will be written inside views as comments.

  • Shopping cart button: this button will be available for any authenticated user (admin or not). Views related to this button are add_to_cart and remove_from_cart.

  • Create|Edit|Delete buttons: only admin users can see and use this buttons. Views related are create_product, edit_product and delete_product.

  • Featured star: one more time, admin users are the only ones allowed to toggle a product as featured. The whole featured column in products table should be hide for any other kind of user. Related view is toggle_featured.

Make sure to render de ProductForm inside create_product.html and edit_product.html templates. (HINT: It should be just one single line of code)

wdc-ecommerce-django-forms's People

Contributors

ivanzugnoni avatar tjking24 avatar

Watchers

James Cloos avatar

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.