cc-bhu / marketplace Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Create a view that showcases products present in database.
The view should be created on home
app and query the database for the products.
Add pagination to the products, so that only 10-20 products can be listed on a page.
We will use the product card to show the products that will done after completing issue #9.
Create a form page in the home app that uploads the product. It will create a product object and saves the product into the database.
References
Update index.html template to beautify the web app UI. Feel free to use bootstrap or any other css framework to build the UI.
Once we are done with creation of home app #1. We have to create a Product Model.
Django uses models as a representation of SQL Schema or we can say the table object.
We have to create a Model for Project, that will contain the following item.
id
: uuid (auto)name
: stringprice
: floatdescription
: string (not required)created_at
: datetime (auto)updated_at
: datetime (auto)product_image
: image (not required)We have to create this model inside the models.py
file of the home app and generate the migrations.
References
There is no product page available on the website. Make the product card clickable that leads it to a new page that list all the details about product, and buying options.
The general template could be like a Amazon product page.
Anyone experienced with bootstrap can improve the UI and fix minor bugs in products grid etc.
Product can have negative price, this is due to float field used in Product model, look for a way to make it positive value.
We can set minimum value in that field or use a PositiveFloatField
if possible
seller
model needs to be linked with user model to get created, for that we will have to redefine the User model and reinitialise it with a set of options.
I have found a couple of good ideas to implement:
Currently Image upload functionality is not available to CC-BHU. Look for a method to host static files and add image upload functionality.
Create a new seller app just like #1 and add a Seller
model that will contain details related to seller.
Here are the attributes of Seller
:
name
: Name of the seller (required)
phone
: Phone no of the seller (required)
email
: Email of the seller (required)
location
: Address of the seller (not required)
We can split a django application into multiple apps like home
, buyer
, and seller
. Let's create a Home app first that contains our homepage, which opens when we visit our /
endpoint.
Open the terminal and navigate to the root directory of your Django project.
Run the following command to create a new Django app called "home":
python manage.py startapp home
You will found a new folder home
is created.
Add the home
app to the INSTALLED_APPS
list in the settings.py
file of your Django project. That will be marketplace.home
.
Create a html template index.html
inside the templates
folder of home
app directory that will contain your home page.
Open the views.py
file in the home
app directory and define a view function to handle the creation of a new product listing. For example:
from django.shortcuts import render
def root(request):
return render(request, 'index.html')
Create a new file called urls.py
in the home
app directory and define the necessary URL patterns for the home
app. For example:
from django.urls import path
from .views import root
app_name = 'home'
urlpatterns = [
path('', root, name='home'),
]
Update urls.py
of project
directory to add these urls.
urlpatterns = [
path("admin/", admin.site.urls),
path("", include("home.urls", namespace="home")),
]
That's it for the creation of new app home
.
Create a product card that will show a product details on the home page. The card will contains few details like product name, type, price and image.
We will need to setup a storage for image as well, so we will look into the details of image later on.
For now create a product template under template and that will be included later on into the index.html or any other template using jinja2 formatting.
References
https://stackoverflow.com/questions/10985950/how-do-you-insert-a-template-into-another-template
https://devsheet.com/include-template-django/
https://docs.djangoproject.com/en/4.2/ref/templates/builtins/
Create a seller registration page in seller
app. Its similar how products are getting created. If required some help look at #11.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.