├── auctions ├── __init__.py ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── 0002_winner.cpython-38.pyc │ │ ├── 0001_initial.cpython-38.pyc │ │ ├── 0004_watchlist.cpython-38.pyc │ │ ├── 0003_winner_user.cpython-38.pyc │ │ ├── 0010_auctionlist_user.cpython-38.pyc │ │ ├── 0003_auto_20200727_1651.cpython-38.pyc │ │ ├── 0003_auto_20200730_2321.cpython-38.pyc │ │ ├── 0004_auto_20200730_2322.cpython-38.pyc │ │ ├── 0004_auto_20200731_1615.cpython-38.pyc │ │ ├── 0005_remove_bids_title.cpython-38.pyc │ │ ├── 0006_auto_20200730_2052.cpython-38.pyc │ │ ├── 0007_auto_20200730_2055.cpython-38.pyc │ │ ├── 0008_auto_20200730_2137.cpython-38.pyc │ │ ├── 0009_auto_20200730_2139.cpython-38.pyc │ │ ├── 0011_auto_20200730_2158.cpython-38.pyc │ │ ├── 0012_auto_20200730_2159.cpython-38.pyc │ │ ├── 0013_auto_20200730_2313.cpython-38.pyc │ │ ├── 0014_auto_20200730_2314.cpython-38.pyc │ │ ├── 0014_auto_20200730_2317.cpython-38.pyc │ │ ├── 0015_auto_20200730_2315.cpython-38.pyc │ │ ├── 0015_auto_20200730_2318.cpython-38.pyc │ │ ├── 0016_auto_20200730_2316.cpython-38.pyc │ │ ├── 0017_merge_20200730_2323.cpython-38.pyc │ │ ├── 0002_auctionlist_bids_comments.cpython-38.pyc │ │ └── 0002_auctionlist_bids_comments_watchlist.cpython-38.pyc │ ├── 0003_winner_user.py │ ├── 0002_winner.py │ ├── 0004_auto_20200731_1615.py │ └── 0001_initial.py ├── tests.py ├── apps.py ├── __pycache__ │ ├── admin.cpython-38.pyc │ ├── urls.cpython-38.pyc │ ├── views.cpython-38.pyc │ ├── models.cpython-38.pyc │ └── __init__.cpython-38.pyc ├── static │ └── auctions │ │ └── styles.css ├── templates │ └── auctions │ │ ├── login.html │ │ ├── register.html │ │ ├── category.html │ │ ├── create.html │ │ ├── winnings.html │ │ ├── index.html │ │ ├── watchlist.html │ │ ├── layout.html │ │ └── listingpage.html ├── admin.py ├── urls.py ├── models.py └── views.py ├── commerce ├── __init__.py ├── __pycache__ │ ├── urls.cpython-38.pyc │ ├── wsgi.cpython-38.pyc │ ├── __init__.cpython-38.pyc │ └── settings.cpython-38.pyc ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── .gitattributes ├── db.sqlite3 ├── dem_img ├── 1.PNG └── 2.PNG ├── test.py ├── manage.py └── README.md /auctions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /commerce/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /auctions/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /auctions/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /dem_img/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/dem_img/1.PNG -------------------------------------------------------------------------------- /dem_img/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/dem_img/2.PNG -------------------------------------------------------------------------------- /auctions/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AuctionsConfig(AppConfig): 5 | name = 'auctions' 6 | -------------------------------------------------------------------------------- /auctions/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /commerce/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/commerce/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /commerce/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/commerce/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /commerce/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/commerce/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /commerce/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/commerce/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0002_winner.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0002_winner.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0004_watchlist.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0004_watchlist.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0003_winner_user.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0003_winner_user.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0010_auctionlist_user.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0010_auctionlist_user.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0003_auto_20200727_1651.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0003_auto_20200727_1651.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0003_auto_20200730_2321.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0003_auto_20200730_2321.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0004_auto_20200730_2322.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0004_auto_20200730_2322.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0004_auto_20200731_1615.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0004_auto_20200731_1615.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0005_remove_bids_title.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0005_remove_bids_title.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0006_auto_20200730_2052.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0006_auto_20200730_2052.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0007_auto_20200730_2055.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0007_auto_20200730_2055.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0008_auto_20200730_2137.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0008_auto_20200730_2137.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0009_auto_20200730_2139.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0009_auto_20200730_2139.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0011_auto_20200730_2158.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0011_auto_20200730_2158.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0012_auto_20200730_2159.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0012_auto_20200730_2159.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0013_auto_20200730_2313.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0013_auto_20200730_2313.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0014_auto_20200730_2314.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0014_auto_20200730_2314.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0014_auto_20200730_2317.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0014_auto_20200730_2317.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0015_auto_20200730_2315.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0015_auto_20200730_2315.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0015_auto_20200730_2318.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0015_auto_20200730_2318.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0016_auto_20200730_2316.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0016_auto_20200730_2316.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0017_merge_20200730_2323.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0017_merge_20200730_2323.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0002_auctionlist_bids_comments.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0002_auctionlist_bids_comments.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/migrations/__pycache__/0002_auctionlist_bids_comments_watchlist.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joel-jaimon/Auctions-Django-Project/HEAD/auctions/migrations/__pycache__/0002_auctionlist_bids_comments_watchlist.cpython-38.pyc -------------------------------------------------------------------------------- /auctions/static/auctions/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 10px; 3 | text-align: center; 4 | } 5 | .message{ 6 | background-color: #15317E; 7 | color: white; 8 | padding: 2vw; 9 | } 10 | 11 | .nav{ 12 | margin-top: 2.5vw; 13 | } 14 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import auctions.models 2 | 3 | al = auctions.models.auctionlist.objects.all() 4 | 5 | def info(): 6 | for item in al: 7 | print(item.title) 8 | print(item.desc) 9 | print(item.starting_bid) 10 | print(item.image_url) 11 | print(item.category + "\n") 12 | 13 | info() -------------------------------------------------------------------------------- /commerce/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for commerce project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'commerce.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /commerce/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for commerce project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'commerce.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /auctions/migrations/0003_winner_user.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-30 21:04 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('auctions', '0002_winner'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='winner', 15 | name='user', 16 | field=models.CharField(default=None, max_length=64), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'commerce.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /auctions/migrations/0002_winner.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-30 21:01 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('auctions', '0001_initial'), 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='winner', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('bid_win_list', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='auctions.auctionlist')), 19 | ], 20 | ), 21 | ] 22 | -------------------------------------------------------------------------------- /auctions/migrations/0004_auto_20200731_1615.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-31 10:45 2 | 3 | from django.db import migrations, models 4 | import django.db.models.deletion 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('auctions', '0003_winner_user'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AddField( 15 | model_name='auctionlist', 16 | name='active_bool', 17 | field=models.BooleanField(default=True), 18 | ), 19 | migrations.AlterField( 20 | model_name='winner', 21 | name='bid_win_list', 22 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auctions.auctionlist'), 23 | ), 24 | ] 25 | -------------------------------------------------------------------------------- /auctions/templates/auctions/login.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 | 5 |

Login

6 | 7 | {% if message %} 8 |
{{ message }}
9 | {% endif %} 10 | 11 |
12 | {% csrf_token %} 13 |
14 | 15 |
16 |
17 | 18 |
19 | 20 |
21 | 22 | Don't have an account? Register here. 23 | 24 | {% endblock %} -------------------------------------------------------------------------------- /auctions/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import * 3 | 4 | class auction(admin.ModelAdmin): 5 | list_display = ("id" , "user", "active_bool","title" , "desc" , "starting_bid" , "image_url" , "category") 6 | 7 | class watchl(admin.ModelAdmin): 8 | list_display = ("id", "watch_list" , "user") 9 | 10 | class bds(admin.ModelAdmin): 11 | list_display = ("id","user","listingid","bid") 12 | 13 | class comme(admin.ModelAdmin): 14 | list_display = ("id","user", "comment", "listingid") 15 | 16 | class win(admin.ModelAdmin): 17 | list_display = ("id","user", "bid_win_list") 18 | 19 | # Register your models here. 20 | admin.site.register(auctionlist, auction) 21 | admin.site.register(bids, bds) 22 | admin.site.register(comments, comme) 23 | admin.site.register(watchlist, watchl) 24 | admin.site.register(winner, win) -------------------------------------------------------------------------------- /commerce/urls.py: -------------------------------------------------------------------------------- 1 | """commerce URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import include, path 18 | 19 | urlpatterns = [ 20 | path("admin/", admin.site.urls), 21 | path("", include("auctions.urls")) 22 | ] -------------------------------------------------------------------------------- /auctions/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | 3 | from . import views 4 | 5 | urlpatterns = [ 6 | path("", views.index, name="index"), 7 | path("login", views.login_view, name="login"), 8 | path("logout", views.logout_view, name="logout"), 9 | path("register", views.register, name="register"), 10 | path("create", views.create, name="create"), 11 | path("auctions/", views.listingpage, name="listingpage"), 12 | path("watchlist/", views.watchlistpage, name = "watchlistpage"), 13 | path("added", views.addwatchlist, name = "addwatchlist"), 14 | path("delete", views.deletewatchlist, name = "deletewatchlist"), 15 | path("bidlist", views.bid, name="bid"), 16 | path("comments", views.allcomments, name="allcomments"), 17 | path("win_ner", views.win_ner, name="win_ner"), 18 | path("winnings", views.winnings, name="winnings"), 19 | path("cat_list", views.cat_list, name="cat_list"), 20 | path("categories/", views.cat, name="cat"), 21 | ] 22 | 23 | -------------------------------------------------------------------------------- /auctions/templates/auctions/register.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 | 5 |

Register

6 | 7 | {% if message %} 8 |
{{ message }}
9 | {% endif %} 10 | 11 |
12 | {% csrf_token %} 13 |
14 | 15 |
16 |
17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 |
25 | 26 |
27 | 28 | Already have an account? Log In here. 29 | 30 | {% endblock %} -------------------------------------------------------------------------------- /auctions/templates/auctions/category.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 |

All Categories

5 |
6 | {% for list in cat_list %} 7 | 10 | {% endfor %} 11 |
12 | 13 | 52 | {% endblock %} 53 | 54 | 55 | -------------------------------------------------------------------------------- /auctions/models.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.models import AbstractUser 2 | from django.db import models 3 | 4 | class User(AbstractUser): 5 | pass 6 | 7 | class auctionlist(models.Model): 8 | user = models.CharField(max_length=64) 9 | title = models.CharField(max_length=64) 10 | desc = models.TextField() #CharField cannot be left without giving a max_length, Textfield can 11 | starting_bid = models.IntegerField() 12 | image_url = models.CharField(max_length=228, default = None, blank = True, null = True) 13 | category = models.CharField(max_length=64) 14 | active_bool = models.BooleanField(default = True) 15 | 16 | class bids(models.Model): 17 | user = models.CharField(max_length=30) 18 | listingid = models.IntegerField() 19 | bid = models.IntegerField() 20 | 21 | 22 | class comments(models.Model): 23 | user = models.CharField(max_length=64) 24 | comment = models.TextField() 25 | listingid = models.IntegerField() 26 | 27 | 28 | class watchlist(models.Model): 29 | watch_list = models.ForeignKey(auctionlist, on_delete=models.CASCADE) 30 | user = models.CharField(max_length=64) 31 | 32 | class winner(models.Model): 33 | bid_win_list = models.ForeignKey(auctionlist, on_delete = models.CASCADE) 34 | user = models.CharField(max_length=64, default = None) -------------------------------------------------------------------------------- /auctions/templates/auctions/create.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 |

Create Listing

5 |
6 |
7 | {% csrf_token %} 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 | 43 | {% endblock %} 44 | 45 | 46 | -------------------------------------------------------------------------------- /auctions/templates/auctions/winnings.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 |

Your Winnings

5 |
6 | {% for list in user_winlist %} 7 |
8 | {{list.bid_win_list.title}} 9 | {{list.bid_win_list.category}} 10 | {% if list.bid_win_list.image_url %} 11 | 12 | {% else %} 13 | No image Provided 14 | {% endif %} 15 |

{{ list.bid_win_list.desc }}

16 |
This bid was listed by {{ list.bid_win_list.user }}.
17 |
18 | {% endfor %} 19 |
20 | 21 | 58 | {% endblock %} 59 | 60 | 61 | -------------------------------------------------------------------------------- /auctions/templates/auctions/index.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 |

Active Listings

5 | {% if messages %} 6 | {% for message in messages %} 7 |
{{ message }}
8 | {% endfor %} 9 | {% endif %} 10 |
11 | {% for list in a1 %} 12 |
13 | {{list.title}} 14 | {{list.category}} 15 | {% if list.image_url %} 16 | 17 | {% else %} 18 | No image Provided 19 | {% endif %} 20 | 21 |

{{ list.desc }}

22 | Starting Bid: {{ list.starting_bid }} $ 23 | View Bid 24 |
25 | {% endfor %} 26 |
27 | 28 | 66 | 67 | 68 | 69 | {% endblock %} 70 | 71 | 72 | -------------------------------------------------------------------------------- /auctions/templates/auctions/watchlist.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 |

Watch List

5 |
6 | {% for list in user_watchlist %} 7 | {% if list.watch_list.active_bool == True %} 8 |
9 | {{list.watch_list.title}} 10 | {{list.watch_list.category}} 11 | {% if list.watch_list.image_url %} 12 | 13 | {% else %} 14 | No image Provided 15 | {% endif %} 16 | Current Price: {{ list.watch_list.starting_bid }} $ 17 | View Bid 18 | 19 |
20 | 21 |
22 | {% endif %} 23 |
24 | {% endfor %} 25 |
26 | 27 | 64 | {% endblock %} 65 | 66 | 67 | -------------------------------------------------------------------------------- /auctions/templates/auctions/layout.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | {% block title %}Auctions{% endblock %} 7 | 8 | 9 | 10 | 11 | 12 |

Auctions

13 |
14 | {% if user.is_authenticated %} 15 | Signed in as {{ user.username }}. 16 | {% else %} 17 | Not signed in. 18 | {% endif %} 19 |
20 | 56 |
57 | {% block body %} 58 | {% endblock %} 59 | 60 | 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auctions-Django 2 | Design of a proper functional eBay-like e-commerce auction site that will allow users to post auction listings, place bids on listings, comment on those listings, and add listings to a “watchlist”. 3 | 4 |

Django Admin Credentials:

5 |
  • UserID : "joel__jaimon"
  • 6 |
  • Password : "12345678rr"
  • 7 | 8 |

    Homepage

    9 | 10 |

    List Page

    11 | 12 | 13 |

    Specifications:

    14 | 15 |

    Create Listing Page:

    16 |
  • 17 | Users will be able to visit a page to create a new listing. They will be able to specify a title for the listing, a text-based description, and what the starting bid should be. Users can also optionally add an URL for an image for the listing and/or a category (e.g. Fashion, Toys, Electronics, Home, etc.). 18 |
  • 19 | 20 |

    Active Listings Page:

    21 |
  • 22 | The default route let users view all of the currently active auction listings. For each active listing, this page display the title, description, current price, and photo (if one exists for the listing). 23 |
  • 24 | 25 |

    Listing Page:

    26 |
  • 27 | Clicking on a listing take users to a page specific to that listing. On that page, users will be able to view all details about the listing, including the current price for the listing. 28 |
  • If the user is signed in, the user will be able to add the item to their “Watchlist.” If the item is already on the watchlist, the user will be able to remove it.
  • 29 |
  • If the user is signed in, the user will be able to bid on the item. The bid must be at least as large as the starting bid, and must be greater than any other bids that have been placed (if any). If the bid doesn’t meet those criteria, the user will be presented with an error.
  • 30 |
  • If the user is signed in and is the one who created the listing, the user have the ability to “close” the auction from this page, which makes the highest bidder the winner of the auction and makes the listing no longer active.
  • 31 |
  • Users who are signed in will be able to add comments to the listing page. The listing page displays all comments that have been made on the listing.
  • 32 | 33 | 34 |

    Watchlist:

    35 |
  • 36 | Users who are signed in will be able to visit a Watchlist page, which displays all of the listings that a user has added to their watchlist. Clicking on any of those listings take the user to that listing’s page. 37 |
  • 38 | 39 |

    Categories:

    40 |
  • 41 | Users will be able to visit a page that displays a list of all listing categories. Clicking on the name of any category takes the user to a page that displays all of the active listings in that category. 42 |
  • 43 | 44 |

    Django Admin Interface:

    45 |
  • 46 | Via the Django admin interface, a site administrator will be able to view, add, edit, and delete any listings, comments, and bids made on the site. 47 |
  • 48 | 49 | -------------------------------------------------------------------------------- /commerce/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for commerce project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.0.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.0/ref/settings/ 11 | """ 12 | 13 | import os 14 | 15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '6ps8j!crjgrxt34cqbqn7x&b3y%(fny8k8nh21+qa)%ws3fh!q' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'auctions', 35 | 'django.contrib.admin', 36 | 'django.contrib.auth', 37 | 'django.contrib.contenttypes', 38 | 'django.contrib.sessions', 39 | 'django.contrib.messages', 40 | 'django.contrib.staticfiles', 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'commerce.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [], 59 | 'APP_DIRS': True, 60 | 'OPTIONS': { 61 | 'context_processors': [ 62 | 'django.template.context_processors.debug', 63 | 'django.template.context_processors.request', 64 | 'django.contrib.auth.context_processors.auth', 65 | 'django.contrib.messages.context_processors.messages', 66 | ], 67 | }, 68 | }, 69 | ] 70 | 71 | WSGI_APPLICATION = 'commerce.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 81 | } 82 | } 83 | 84 | AUTH_USER_MODEL = 'auctions.User' 85 | 86 | # Password validation 87 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators 88 | 89 | AUTH_PASSWORD_VALIDATORS = [ 90 | { 91 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 92 | }, 93 | { 94 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 95 | }, 96 | { 97 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 98 | }, 99 | { 100 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 101 | }, 102 | ] 103 | 104 | 105 | # Internationalization 106 | # https://docs.djangoproject.com/en/3.0/topics/i18n/ 107 | 108 | LANGUAGE_CODE = 'en-us' 109 | 110 | TIME_ZONE = 'UTC' 111 | 112 | USE_I18N = True 113 | 114 | USE_L10N = True 115 | 116 | USE_TZ = True 117 | 118 | 119 | # Static files (CSS, JavaScript, Images) 120 | # https://docs.djangoproject.com/en/3.0/howto/static-files/ 121 | 122 | STATIC_URL = '/static/' 123 | -------------------------------------------------------------------------------- /auctions/templates/auctions/listingpage.html: -------------------------------------------------------------------------------- 1 | {% extends "auctions/layout.html" %} 2 | 3 | {% block body %} 4 | {{list.title}}
    5 | {{list.category}} 6 | {% if messages %} 7 | {% for message in messages %} 8 |
    {{ message }}
    9 | {% endfor %} 10 | {% endif %} 11 |
    12 |
    13 | {% if list.image_url %} 14 | 15 | {% else %} 16 | No image Provided 17 | {% endif %} 18 | 19 |

    {{ list.desc }}

    20 |
    Present Bid: {{ present_bid}} $
    21 |
    Listed By: {{ list.user }}
    22 | 23 | 24 |
    25 | 26 | 27 |
    28 |
    29 |
    30 | 31 |
    32 |
    33 |
    34 | 35 | 36 |
    37 |

    Comments

    38 |
    39 | 44 |
    45 | 46 |
    47 | 48 | 49 |
    50 |
    51 | {% if list.user == user.username %} 52 |
    53 | 54 |
    55 | {% endif %} 56 |
    57 |
    58 | 59 | 60 |
    61 | 62 | 63 | 132 | {% endblock %} 133 | 134 | 135 | -------------------------------------------------------------------------------- /auctions/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0.8 on 2020-07-30 20:59 2 | 3 | import django.contrib.auth.models 4 | import django.contrib.auth.validators 5 | from django.db import migrations, models 6 | import django.db.models.deletion 7 | import django.utils.timezone 8 | 9 | 10 | class Migration(migrations.Migration): 11 | 12 | initial = True 13 | 14 | dependencies = [ 15 | ('auth', '0011_update_proxy_permissions'), 16 | ] 17 | 18 | operations = [ 19 | migrations.CreateModel( 20 | name='auctionlist', 21 | fields=[ 22 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 23 | ('user', models.CharField(max_length=64)), 24 | ('title', models.CharField(max_length=64)), 25 | ('desc', models.TextField()), 26 | ('starting_bid', models.IntegerField()), 27 | ('image_url', models.CharField(blank=True, default=None, max_length=228, null=True)), 28 | ('category', models.CharField(max_length=64)), 29 | ], 30 | ), 31 | migrations.CreateModel( 32 | name='bids', 33 | fields=[ 34 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 35 | ('user', models.CharField(max_length=30)), 36 | ('listingid', models.IntegerField()), 37 | ('bid', models.IntegerField()), 38 | ], 39 | ), 40 | migrations.CreateModel( 41 | name='comments', 42 | fields=[ 43 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 44 | ('user', models.CharField(max_length=64)), 45 | ('comment', models.TextField()), 46 | ('listingid', models.IntegerField()), 47 | ], 48 | ), 49 | migrations.CreateModel( 50 | name='watchlist', 51 | fields=[ 52 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 53 | ('user', models.CharField(max_length=64)), 54 | ('watch_list', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auctions.auctionlist')), 55 | ], 56 | ), 57 | migrations.CreateModel( 58 | name='User', 59 | fields=[ 60 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 61 | ('password', models.CharField(max_length=128, verbose_name='password')), 62 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), 63 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), 64 | ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), 65 | ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), 66 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), 67 | ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), 68 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), 69 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), 70 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), 71 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), 72 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), 73 | ], 74 | options={ 75 | 'verbose_name': 'user', 76 | 'verbose_name_plural': 'users', 77 | 'abstract': False, 78 | }, 79 | managers=[ 80 | ('objects', django.contrib.auth.models.UserManager()), 81 | ], 82 | ), 83 | ] 84 | -------------------------------------------------------------------------------- /auctions/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import authenticate, login, logout 2 | from django.db import IntegrityError 3 | from django.http import HttpResponse, HttpResponseRedirect 4 | from django.shortcuts import render, redirect 5 | from django.urls import reverse 6 | from .models import * 7 | from django.contrib.auth.decorators import login_required 8 | from django.contrib import messages 9 | 10 | 11 | def index(request): 12 | return render(request, "auctions/index.html",{ 13 | "a1": auctionlist.objects.filter(active_bool = True), 14 | }) 15 | 16 | 17 | def login_view(request): 18 | if request.method == "POST": 19 | 20 | # Attempt to sign user in 21 | username = request.POST["username"] 22 | password = request.POST["password"] 23 | user = authenticate(request, username=username, password=password) 24 | 25 | # Check if authentication successful 26 | if user is not None: 27 | login(request, user) 28 | return HttpResponseRedirect(reverse("index")) 29 | else: 30 | return render(request, "auctions/login.html", { 31 | "message": "Invalid username and/or password." 32 | }) 33 | else: 34 | return render(request, "auctions/login.html") 35 | 36 | 37 | def logout_view(request): 38 | logout(request) 39 | return HttpResponseRedirect(reverse("index")) 40 | 41 | 42 | def register(request): 43 | if request.method == "POST": 44 | username = request.POST["username"] 45 | email = request.POST["email"] 46 | 47 | # Ensure password matches confirmation 48 | password = request.POST["password"] 49 | confirmation = request.POST["confirmation"] 50 | if password != confirmation: 51 | return render(request, "auctions/register.html", { 52 | "message": "Passwords must match." 53 | }) 54 | 55 | # Attempt to create new user 56 | try: 57 | user = User.objects.create_user(username, email, password) 58 | user.save() 59 | except IntegrityError: 60 | return render(request, "auctions/register.html", { 61 | "message": "Username already taken." 62 | }) 63 | login(request, user) 64 | return HttpResponseRedirect(reverse("index")) 65 | else: 66 | return render(request, "auctions/register.html") 67 | 68 | 69 | @login_required(login_url='login') 70 | def create(request): 71 | if request.method == "POST": 72 | m = auctionlist() 73 | m.user = request.user.username 74 | m.title = request.POST["create_title"] 75 | m.desc = request.POST["create_desc"] 76 | m.starting_bid = request.POST["create_initial_bid"] 77 | m.image_url = request.POST["img_url"] 78 | m.category = request.POST["category"] 79 | # m = auctionlist(title = title, desc=desc, starting_bid = starting_bid, image_url = image_url, category = category) 80 | m.save() 81 | return redirect("index") 82 | return render(request, "auctions/create.html") 83 | 84 | 85 | 86 | def listingpage(request, bidid): 87 | biddesc = auctionlist.objects.get(pk = bidid, active_bool = True) 88 | bids_present = bids.objects.filter(listingid = bidid) 89 | 90 | return render(request, "auctions/listingpage.html",{ 91 | "list": biddesc, 92 | "comments" : comments.objects.filter(listingid = bidid), 93 | "present_bid": minbid(biddesc.starting_bid, bids_present), 94 | }) 95 | 96 | 97 | @login_required(login_url='login') 98 | def watchlistpage(request, username): 99 | 100 | # present_w = watchlist.objects.get(user = "username") 101 | list_ = watchlist.objects.filter(user = username) 102 | return render(request, "auctions/watchlist.html",{ 103 | "user_watchlist" : list_, 104 | }) 105 | 106 | 107 | @login_required(login_url='login') 108 | def addwatchlist(request): 109 | nid = request.GET["listid"] 110 | 111 | # below line of code will select a table of watchlist that has my name, then 112 | # when we loop in this watchlist, there r two fields present, to browse watch_list 113 | # watch_list.id == auctionlist.id, similar for all 114 | 115 | list_ = watchlist.objects.filter(user = request.user.username) 116 | 117 | # when you below line, you shld convert id to int inorder to compare or else == wont work 118 | 119 | for items in list_: 120 | if int(items.watch_list.id) == int(nid): 121 | return watchlistpage(request, request.user.username) 122 | 123 | newwatchlist = watchlist(watch_list = auctionlist.objects.get(pk = nid), user = request.user.username) 124 | newwatchlist.save() 125 | # this message remains untill u reload 126 | messages.success(request, "Item added to watchlist") 127 | 128 | return listingpage(request, nid) 129 | 130 | 131 | @login_required(login_url='login') 132 | def deletewatchlist(request): 133 | rm_id = request.GET["listid"] 134 | list_ = watchlist.objects.get(pk = rm_id) 135 | 136 | # this message remains untill u reload 137 | messages.success(request, f"{list_.watch_list.title} is deleted from your watchlist.") 138 | list_.delete() 139 | 140 | # you cannot call a fuction from views as a return value 141 | return redirect("index") 142 | 143 | 144 | # this function returns minimum bid required to place a user's bid 145 | def minbid(min_bid, present_bid): 146 | for bids_list in present_bid: 147 | if min_bid < int(bids_list.bid): 148 | min_bid = int(bids_list.bid) 149 | return min_bid 150 | 151 | 152 | @login_required(login_url='login') 153 | def bid(request): 154 | bid_amnt = request.GET["bid_amnt"] 155 | list_id = request.GET["list_d"] 156 | bids_present = bids.objects.filter(listingid = list_id) 157 | startingbid = auctionlist.objects.get(pk = list_id) 158 | min_req_bid = startingbid.starting_bid 159 | min_req_bid = minbid(min_req_bid, bids_present) 160 | 161 | if int(bid_amnt) > int(min_req_bid): 162 | mybid = bids(user = request.user.username, listingid = list_id , bid = bid_amnt) 163 | mybid.save() 164 | messages.success(request, "Bid Placed") 165 | return redirect("index") 166 | 167 | messages.warning(request, f"Sorry, {bid_amnt} is less. It should be more than {min_req_bid}$.") 168 | return listingpage(request, list_id) 169 | 170 | 171 | # shows comments made by different user and allows to add comments 172 | @login_required(login_url='login') 173 | def allcomments(request): 174 | comment = request.GET["comment"] 175 | username = request.user.username 176 | list_id = request.GET["listid"] 177 | new_comment = comments(user = username, comment = comment, listingid = list_id) 178 | new_comment.save() 179 | return listingpage(request, list_id) 180 | 181 | 182 | # shows message abt winner when bid is closed 183 | def win_ner(request): 184 | bid_id = request.GET["listid"] 185 | bids_present = bids.objects.filter(listingid = bid_id) 186 | biddesc = auctionlist.objects.get(pk = bid_id, active_bool = True) 187 | max_bid = minbid(biddesc.starting_bid, bids_present) 188 | try: 189 | # checks if anyone other than list_owner win the bid 190 | winner_object = bids.objects.get(bid = max_bid, listingid = bid_id) 191 | winner_obj = auctionlist.objects.get(id = bid_id) 192 | win = winner(bid_win_list = winner_obj, user = winner_object.user) 193 | winners_name = winner_object.user 194 | 195 | except: 196 | #if no-one placed a bid, and if bid is closed by list_owner, owner wins the bid 197 | winner_obj = auctionlist.objects.get(starting_bid = max_bid, id = bid_id) 198 | win = winner(bid_win_list = winner_obj, user = winner_obj.user) 199 | winners_name = winner_obj.user 200 | 201 | #Check Django Documentary for Updating attributes based on existing fields. 202 | biddesc.active_bool = False 203 | biddesc.save() 204 | 205 | # saving winner details 206 | win.save() 207 | messages.success(request, f"{winners_name} won {win.bid_win_list.title}.") 208 | return redirect("index") 209 | 210 | # checks winner 211 | def winnings(request): 212 | try: 213 | your_win = winner.objects.filter(user = request.user.username) 214 | except: 215 | your_win = None 216 | 217 | return render(request, "auctions/winnings.html",{ 218 | "user_winlist" : your_win, 219 | }) 220 | 221 | #shows lists that are present in a specific category 222 | def cat(request, category_name): 223 | category = auctionlist.objects.filter(category = category_name) 224 | return render(request, "auctions/index.html",{ 225 | "a1" : category, 226 | }) 227 | 228 | #shows all categories in which object is listed 229 | def cat_list(request): 230 | 231 | # unlike filter that takes a values of object_name in model, to 232 | # display objectname use .values('name of section from your object') 233 | # and when you add distinct() along with it 234 | # it shows only unique names, omits duplicates 235 | 236 | category_present = auctionlist.objects.values('category').distinct() 237 | return render(request, "auctions/category.html",{ 238 | "cat_list" : category_present, 239 | }) 240 | 241 | --------------------------------------------------------------------------------