Skip to content

Commit

Permalink
model created
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny committed Apr 17, 2021
1 parent c759deb commit 0f1861d
Show file tree
Hide file tree
Showing 32 changed files with 394 additions and 28 deletions.
14 changes: 14 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
shell = "*"
django = "*"
pillow = "*"

[dev-packages]

[requires]
python_version = "3.7"
108 changes: 108 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added shoppinglyx/app/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added shoppinglyx/app/__pycache__/admin.cpython-37.pyc
Binary file not shown.
Binary file added shoppinglyx/app/__pycache__/apps.cpython-37.pyc
Binary file not shown.
Binary file added shoppinglyx/app/__pycache__/models.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added shoppinglyx/app/__pycache__/views.cpython-37.pyc
Binary file not shown.
23 changes: 23 additions & 0 deletions shoppinglyx/app/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
from django.contrib import admin

# Register your models here.
from .models import(
Customer,
Product,
Cart,
OrderPlaced,
)

@admin.register(Customer)
class CustomerModelAdmin(admin.ModelAdmin):
list_display = ['id','user','name','locality','city','zipcode','state']

@admin.register(Product)
class ProductModelAdmin(admin.ModelAdmin):
list_display = ['id','title','selling_price','discount_price','description','brand','category','product_image']

@admin.register(Cart)
class CartModelAdmin(admin.ModelAdmin):
list_display = ['id','user','product','quantity']


@admin.register(OrderPlaced)
class OrderPlacedModelAdmin(admin.ModelAdmin):
list_display = ['id','user','customer','product','quantity','order_date','status']
63 changes: 63 additions & 0 deletions shoppinglyx/app/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Generated by Django 3.2 on 2021-04-16 15:59

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('locality', models.CharField(max_length=100)),
('city', models.CharField(max_length=100)),
('zipcode', models.IntegerField()),
('state', models.CharField(choices=[('Andaman & Nikobar', 'Andaman & Nikobar'), ('Andhra Pradesh', 'Andhra Pradesh'), ('Assam', 'Assam'), ('Bihar', 'Bihar'), ('Chandigarh', 'Chandigarh'), ('Delhi', 'delhi'), ('Punjab', 'Punjab')], max_length=100)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100)),
('selling_price', models.FloatField()),
('discount_price', models.FloatField()),
('description', models.TextField()),
('Brand', models.CharField(max_length=100)),
('category', models.CharField(choices=[('M', 'Mobile'), ('L', 'Leptop'), ('TW', 'Top Wear'), ('BW', 'Bottom Wear')], max_length=2)),
('product_image', models.ImageField(upload_to='productimg')),
],
),
migrations.CreateModel(
name='OrederPlaced',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.PositiveIntegerField(default=1)),
('order_date', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(choices=[('Accepted', 'Accepted'), ('Packed', 'Packed'), ('On The Way', 'On The Way'), ('Delivered', 'delivered'), ('Cancel', 'Cancel')], default='Pending', max_length=50)),
('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.customer')),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.product')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='Cart',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('quantity', models.PositiveIntegerField(default=1)),
('product', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.product')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
24 changes: 24 additions & 0 deletions shoppinglyx/app/migrations/0002_auto_20210416_2150.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2 on 2021-04-16 16:20

from django.conf import settings
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('app', '0001_initial'),
]

operations = [
migrations.RenameModel(
old_name='OrederPlaced',
new_name='OrderPlaced',
),
migrations.RenameField(
model_name='product',
old_name='Brand',
new_name='brand',
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
70 changes: 69 additions & 1 deletion shoppinglyx/app/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,71 @@
from django.db import models
from django.contrib.auth.models import User
from django.core.validators import MaxValueValidator,MinValueValidator
# Create your models here.

# Create your models here.
STATE_CHOICE =(
('Andaman & Nikobar','Andaman & Nikobar'),
('Andhra Pradesh','Andhra Pradesh'),
('Assam','Assam'),
('Bihar','Bihar'),
('Chandigarh','Chandigarh'),
('Delhi','delhi'),
('Punjab','Punjab'),
)

class Customer(models.Model):
user = models.ForeignKey(User, on_delete = models.CASCADE)
name = models.CharField(max_length=100)
locality = models.CharField(max_length=100)
city= models.CharField(max_length=100)
zipcode = models.IntegerField()
state = models.CharField(choices=STATE_CHOICE, max_length=100)

def __str__(self):
return str(self.id)

CATEGORY_CHOICES = (
('M','Mobile'),
('L','Leptop'),
('TW',"Top Wear"),
('BW','Bottom Wear')
)

class Product(models.Model):
title = models.CharField(max_length=100)
selling_price = models.FloatField()
discount_price = models.FloatField()
description = models.TextField()
brand = models.CharField(max_length=100)
category = models.CharField(choices = CATEGORY_CHOICES,max_length=2)
product_image = models.ImageField(upload_to='productimg')

def __str__(self):
return str(self.id)



class Cart(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)

def __str__(self):
return str(self.id)


STATUS_CHOICES = (
('Accepted','Accepted'),
('Packed','Packed'),
('On The Way','On The Way'),
('Delivered','delivered'),
('Cancel','Cancel')
)

class OrderPlaced(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)
order_date = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=50, choices=STATUS_CHOICES, default='Pending')
6 changes: 3 additions & 3 deletions shoppinglyx/app/templates/app/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<link rel="stylesheet" href="{% static 'app/css/style.css' %}">


<title>ShoppingX | {% block title %} {% endblock title %} </title>
<title>e-commerce | {% block title %} {% endblock title %} </title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="/">ShoppingX</a>
<a class="navbar-brand" href="/">E-Commerece</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
Expand Down Expand Up @@ -91,7 +91,7 @@
<footer class="container-fluid bg-dark text-center p-2 mt-5">
<small class="text-white">Copyright &copy; 2021 || Designed By GeekyShows || </small>
<img src="{% static 'app/images/payment.png' %}" alt="" srcset="" class="img-fluid" height="2px">
</footer> <!-- End Footer -->
</footer> <!-- End Footer -->

<!-- Jquery -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
Expand Down
Loading

0 comments on commit 0f1861d

Please sign in to comment.