Created
October 1, 2019 16:18
-
-
Save sonu275981/5ac240c2c00419ec9871e37aa05abbe1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
<component name="TestRunnerService"> | |
<option name="PROJECT_TEST_RUNNER" value="Unittests" /> | |
</component> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="InspectionProjectProfileManager"> | |
<settings> | |
<option name="USE_PROJECT_PROFILE" value="false" /> | |
<version value="1.0" /> | |
</settings> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" /> | |
<component name="PyCharmProfessionalAdvertiser"> | |
<option name="shown" value="true" /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/Ecomwebsite.iml" filepath="$PROJECT_DIR$/.idea/Ecomwebsite.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ChangeListManager"> | |
<list default="true" id="6f82bf18-49c3-4298-b12d-43c0d47741f1" name="Default Changelist" comment="" /> | |
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | |
<option name="SHOW_DIALOG" value="false" /> | |
<option name="HIGHLIGHT_CONFLICTS" value="true" /> | |
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | |
<option name="LAST_RESOLUTION" value="IGNORE" /> | |
</component> | |
<component name="FileTemplateManagerImpl"> | |
<option name="RECENT_TEMPLATES"> | |
<list> | |
<option value="Python Script" /> | |
<option value="HTML File" /> | |
</list> | |
</option> | |
</component> | |
<component name="ProjectId" id="1RIBZfL4fR6PoYkBeUS0h8uAF5s" /> | |
<component name="PropertiesComponent"> | |
<property name="DefaultHtmlFileTemplate" value="HTML File" /> | |
<property name="settings.editor.selected.configurable" value="configurable.group.project" /> | |
</component> | |
<component name="RunDashboard"> | |
<option name="ruleStates"> | |
<list> | |
<RuleState> | |
<option name="name" value="ConfigurationTypeDashboardGroupingRule" /> | |
</RuleState> | |
<RuleState> | |
<option name="name" value="StatusDashboardGroupingRule" /> | |
</RuleState> | |
</list> | |
</option> | |
</component> | |
<component name="SvnConfiguration"> | |
<configuration>C:\Users\HCL\AppData\Roaming\Subversion</configuration> | |
</component> | |
<component name="TaskManager"> | |
<task active="true" id="Default" summary="Default task"> | |
<changelist id="6f82bf18-49c3-4298-b12d-43c0d47741f1" name="Default Changelist" comment="" /> | |
<created>1569344786992</created> | |
<option name="number" value="Default" /> | |
<option name="presentableId" value="Default" /> | |
<updated>1569344786992</updated> | |
</task> | |
<servers /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django settings for Ecomwebsite project. | |
Generated by 'django-admin startproject' using Django 2.2.5. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/2.2/topics/settings/ | |
For the full list of settings and their values, see | |
https://docs.djangoproject.com/en/2.2/ref/settings/ | |
""" | |
import os | |
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
# Quick-start development settings - unsuitable for production | |
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ | |
# SECURITY WARNING: keep the secret key used in production secret! | |
SECRET_KEY = '@1uj=^ghhr^i@034ha@d=eejni++x_%ux(0z(is)xo5b!(in9q' | |
# SECURITY WARNING: don't run with debug turned on in production! | |
DEBUG = True | |
ALLOWED_HOSTS = [] | |
# Application definition | |
INSTALLED_APPS = [ | |
'eshop.apps.EshopConfig', | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'myblog', | |
] | |
MIDDLEWARE = [ | |
'django.middleware.security.SecurityMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.common.CommonMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
] | |
ROOT_URLCONF = 'Ecomwebsite.urls' | |
TEMPLATES = [ | |
{ | |
'BACKEND': 'django.template.backends.django.DjangoTemplates', | |
'DIRS': ['Ecomwebsite/templates'], | |
'APP_DIRS': True, | |
'OPTIONS': { | |
'context_processors': [ | |
'django.template.context_processors.debug', | |
'django.template.context_processors.request', | |
'django.contrib.auth.context_processors.auth', | |
'django.contrib.messages.context_processors.messages', | |
], | |
}, | |
}, | |
] | |
WSGI_APPLICATION = 'Ecomwebsite.wsgi.application' | |
# Database | |
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
} | |
} | |
# Password validation | |
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators | |
AUTH_PASSWORD_VALIDATORS = [ | |
{ | |
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | |
}, | |
] | |
# Internationalization | |
# https://docs.djangoproject.com/en/2.2/topics/i18n/ | |
LANGUAGE_CODE = 'en-us' | |
TIME_ZONE = 'UTC' | |
USE_I18N = True | |
USE_L10N = True | |
USE_TZ = True | |
# Static files (CSS, JavaScript, Images) | |
# https://docs.djangoproject.com/en/2.2/howto/static-files/ | |
STATIC_URL = '/static/' | |
# managing media | |
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | |
MEDIA_URL = '/media/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<title>Welcome to My Awesome Cart</title> | |
</head> | |
<body> | |
<div class="jumbotron"> | |
<h1 class="display-4">Welcome to Apni Dhukaan</h1> | |
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p> | |
<hr class="my-4"> | |
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p> | |
<a class="btn btn-primary btn-lg" href="/eshop" role="button">Go To Shop</a> | |
<a class="btn btn-primary btn-lg" href="/myblog" role="button">Go To Blog</a> | |
</div> | |
<!-- Optional JavaScript --> | |
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.urls import path, include | |
from django.conf import settings | |
from django.conf.urls.static import static | |
from . import views | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path("eshop/", include("eshop.urls")), | |
path("myblog/", include("myblog.urls")), | |
path('', views.index) | |
]+static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from django.http import HttpResponse | |
def index(request): | |
return render(request, 'index.html') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
WSGI config for Ecomwebsite project. | |
It exposes the WSGI callable as a module-level variable named ``application``. | |
For more information on this file, see | |
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ | |
""" | |
import os | |
from django.core.wsgi import get_wsgi_application | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Ecomwebsite.settings') | |
application = get_wsgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
# Register your models here. | |
from .models import Product, Contact, Orders, OrderUpdate | |
admin.site.register(Product) | |
admin.site.register(Contact) | |
admin.site.register(Orders) | |
admin.site.register(OrderUpdate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
class EshopConfig(AppConfig): | |
name = 'eshop' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-09-25 11:44 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
initial = True | |
dependencies = [ | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Product', | |
fields=[ | |
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | |
('product_name', models.CharField(max_length=50)), | |
('desc', models.CharField(max_length=300)), | |
('pub_date', models.DateField()), | |
], | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-09-25 14:21 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('eshop', '0001_initial'), | |
] | |
operations = [ | |
migrations.AddField( | |
model_name='product', | |
name='category', | |
field=models.CharField(default='', max_length=50), | |
), | |
migrations.AddField( | |
model_name='product', | |
name='image', | |
field=models.ImageField(default='', upload_to='eshop/images'), | |
), | |
migrations.AddField( | |
model_name='product', | |
name='price', | |
field=models.IntegerField(default='0'), | |
), | |
migrations.AddField( | |
model_name='product', | |
name='subcategory', | |
field=models.CharField(default='', max_length=50), | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-09-27 11:26 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('eshop', '0002_auto_20190925_1951'), | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Contact', | |
fields=[ | |
('msg_id', models.AutoField(primary_key=True, serialize=False)), | |
('name', models.CharField(max_length=50)), | |
('email', models.CharField(default='', max_length=70)), | |
('phone', models.CharField(default='', max_length=70)), | |
('desc', models.CharField(default='', max_length=500)), | |
], | |
), | |
migrations.AlterField( | |
model_name='product', | |
name='desc', | |
field=models.CharField(max_length=3000), | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-09-27 11:41 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('eshop', '0003_auto_20190927_1656'), | |
] | |
operations = [ | |
migrations.AlterField( | |
model_name='product', | |
name='desc', | |
field=models.CharField(max_length=300), | |
), | |
migrations.AlterField( | |
model_name='product', | |
name='price', | |
field=models.IntegerField(default=0), | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-09-28 08:12 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('eshop', '0004_auto_20190927_1711'), | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Orders', | |
fields=[ | |
('order_id', models.AutoField(primary_key=True, serialize=False)), | |
('items_json', models.CharField(max_length=5000)), | |
('name', models.CharField(max_length=90)), | |
('email', models.CharField(max_length=111)), | |
('address', models.CharField(max_length=111)), | |
('city', models.CharField(max_length=111)), | |
('state', models.CharField(max_length=111)), | |
('zip_code', models.CharField(max_length=111)), | |
('phone', models.CharField(default='', max_length=111)), | |
], | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-09-28 10:55 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('eshop', '0005_orders'), | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='OrderUpdate', | |
fields=[ | |
('update_id', models.AutoField(primary_key=True, serialize=False)), | |
('order_id', models.IntegerField(default='')), | |
('update_desc', models.CharField(max_length=5000)), | |
('timestamp', models.DateField(auto_now_add=True)), | |
], | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
# Create your models here. | |
class Product(models.Model): | |
product_id = models.AutoField | |
product_name = models.CharField(max_length=50) | |
category = models.CharField(max_length=50, default="") | |
subcategory = models.CharField(max_length=50, default="") | |
price = models.IntegerField(default=0) | |
desc = models.CharField(max_length=300) | |
pub_date = models.DateField() | |
image = models.ImageField(upload_to='eshop/images', default="") | |
def __str__(self): | |
return self.product_name | |
class Contact(models.Model): | |
msg_id = models.AutoField(primary_key=True) | |
name = models.CharField(max_length=50) | |
email = models.CharField(max_length=70, default="") | |
phone = models.CharField(max_length=70, default="") | |
desc = models.CharField(max_length=500, default="") | |
def __str__(self): | |
return self.name | |
class Orders(models.Model): | |
order_id = models.AutoField(primary_key=True) | |
items_json = models.CharField(max_length=5000) | |
name = models.CharField(max_length=90) | |
email = models.CharField(max_length=111) | |
address = models.CharField(max_length=111) | |
city = models.CharField(max_length=111) | |
state = models.CharField(max_length=111) | |
zip_code = models.CharField(max_length=111) | |
phone = models.CharField(max_length=111, default="") | |
class OrderUpdate(models.Model): | |
update_id = models.AutoField(primary_key=True) | |
order_id = models.IntegerField(default="") | |
update_desc = models.CharField(max_length=5000) | |
timestamp = models.DateField(auto_now_add=True) | |
def __str__(self): | |
return self.update_desc[0:7] + "..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is file for my shop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block title%}About Us{% endblock %} | |
{% block body %} | |
<main role="main"> | |
<!-- Main jumbotron for a primary marketing message or call to action --> | |
<div class="jumbotron"> | |
<div class="container"> | |
<h1 class="display-3">My Awesome Cart!</h1> | |
<p>Apni Dhukaan Pvt Ltd. is an Indian electronic commerce company based in Bengaluru, India. Founded by Sachin Bansal and Binny Bansal in 2007, the company initially focused on book sales, before expanding into other product categories such as consumer electronics, fashion, and lifestyle products. | |
The service competes primarily with Amazon' s Indian subsidiary, and the domestic rival Snapdeal.[5][6] as of March 2017, Flipkart held a 39.5% market share of India's e-commerce industry.[7] Flipkart is significantly dominant in the sale of apparel (a position that was bolstered by its acquisitions of Myntra and Jabong.com), and was described as being "neck and neck" with Amazon in the sale of electronics and mobile phones.[8] Flipkart also owns PhonePe, a mobile payments service based on the Unified Payments Interface (UPI). | |
In August 2018, U.S.-based retail chain Walmart acquired a 77% controlling stake in Flipkart for US$16 billion, valuing it at $22 billion.</p> | |
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p> | |
</div> | |
</div> | |
<div class="container"> | |
<!-- Example row of columns --> | |
<div class="row"> | |
<div class="col-md-4"> | |
<h2>Heading</h2> | |
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p> | |
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p> | |
</div> | |
<div class="col-md-4"> | |
<h2>Heading</h2> | |
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p> | |
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p> | |
</div> | |
<div class="col-md-4"> | |
<h2>Heading</h2> | |
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> | |
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p> | |
</div> | |
</div> | |
<hr> | |
</div> <!-- /container --> | |
</main> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> | |
<title>{% block title%} {% endblock %}</title> | |
<style> | |
{% block css %} {% endblock %} | |
</style> | |
</head> | |
<body> | |
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | |
<a class="navbar-brand" href="#">Apni Dhukaan</a> | |
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | |
<span class="navbar-toggler-icon"></span> | |
</button> | |
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | |
<ul class="navbar-nav mr-auto"> | |
<li class="nav-item active"> | |
<a class="nav-link" href="/eshop">Home <span class="sr-only">(current)</span></a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop/about">About Us</a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop/tracker">Tracker</a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop/contact">Contact Us</a> | |
</li> | |
</ul> | |
<form class="form-inline my-2 my-lg-0"> | |
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> | |
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> | |
</form> | |
<button type="button" class="btn btn-secondary mx-2" id="popcart" data-container="body" data-toggle="popover" data-placement="bottom" data-html="true" data-content="Vivamus | |
sagittis lacus vel augue laoreet rutrum faucibus."> | |
cart(<span id="cart">0</span>) | |
</button> | |
</div> | |
</nav> | |
{% block body %} {% endblock %} | |
<!-- Optional JavaScript --> | |
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> | |
{% block js %} {% endblock %} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block title%} Checkout - My Awesome Cart{% endblock %} | |
{% block body %} | |
<div class="container"> | |
<div class="col my-4"> | |
<h2>Step 1 -Apni Dhukaan - Review Your Cart Items</h2> | |
<div class="my-4"> | |
<ul class="list-group" id="items"> | |
</ul> | |
</div> | |
</div> | |
<div class="col my-4"> | |
<h2>Step 2 - Enter Address & Other Details:</h2> | |
<form method="post" action="/eshop/checkout/">{% csrf_token %} | |
<input type="hidden" name="itemsJson" id="itemsJson"> | |
<div class="form-row"> | |
<div class="form-group col-md-6"> | |
<label for="inputname">Name</label> | |
<input type="text" class="form-control" id="name" name="name" placeholder="Name"> | |
</div> | |
<div class="form-group col-md-6"> | |
<label for="inputEmail4">Email</label> | |
<input type="email" class="form-control" id="email" name="email" placeholder="Email"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label for="inputAddress">Address</label> | |
<input type="text" class="form-control" id="address1" name="address1" placeholder="1234 Main St"> | |
</div> | |
<div class="form-group"> | |
<label for="inputAddress2">Address line 2</label> | |
<input type="text" class="form-control" id="address2" name="address2" placeholder="Apartment, studio, or floor"> | |
</div> | |
<div class="form-row"> | |
<div class="form-group col-md-6"> | |
<label for="inputCity">City</label> | |
<input type="text" class="form-control" id="city" name="city"> | |
</div> | |
<div class="form-group col-md-4"> | |
<label for="inputState">State</label> | |
<input type="text" class="form-control" id="state" name="state" placeholder="Enter State"> | |
</div> | |
<div class="form-group col-md-2"> | |
<label for="inputZip">Zip</label> | |
<input type="text" class="form-control" id="zip_code" name="zip_code"> | |
</div> | |
</div> | |
<div class="form-group"> | |
<label for="inputZip">Phone Number</label> | |
<input type="tel" class="form-control" id="phone" name="phone"> | |
</div> | |
<button type="submit" class="btn btn-primary">Place Order</button> | |
</form> | |
</div> | |
</div> | |
{% endblock %} | |
{% block js %} | |
<script> | |
if (localStorage.getItem('cart') == null) { | |
var cart = {}; | |
} else { | |
cart = JSON.parse(localStorage.getItem('cart')); | |
} | |
console.log(cart); | |
var sum = 0; | |
if ($.isEmptyObject(cart)) { | |
//if object is empty | |
mystr = `<p>Your cart is empty, please add some items to your cart before checking out!</p>` | |
$('#items').append(mystr); | |
} else { | |
for (item in cart) { | |
let name = cart[item][1]; | |
let qty = cart[item][0]; | |
sum = sum + qty; | |
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center"> | |
${name} | |
<span class="badge badge-primary badge-pill">${qty}</span> | |
</li>` | |
$('#items').append(mystr); | |
} | |
} | |
document.getElementById('cart').innerHTML = sum; | |
$('#itemsJson').val(JSON.stringify(cart)); | |
{% if thank %} | |
alert('Thanks for ordering with us. Your order is is {{id}}. Use it to track your order using our order tracker'); | |
localStorage.clear(); | |
document.location = "/eshop"; | |
{% endif %} | |
</script> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block title%} Contact Us - Apni Dhukaan{% endblock %} | |
{% block body %} | |
<div class="container my-3"> | |
<h3>Contact Us</h3> | |
<form action="/eshop/contact/" method="post">{% csrf_token %} | |
<div class="form-group"> | |
<label for="name">Name</label> | |
<input type="text" class="form-control" id="name" name='name' placeholder="Enter Your Name"> | |
</div> | |
<div class="form-group"> | |
<label for="name">Email</label> | |
<input type="email" class="form-control" id="email" name='email' placeholder="Enter Your Email"> | |
</div> | |
<div class="form-group"> | |
<label for="name">Phone</label> | |
<input type="tel" class="form-control" id="phone" name='phone' placeholder="Enter Your Phone Number"> | |
</div> | |
<div class="form-group"> | |
<label for="desc">How May We Help You?</label> | |
<textarea class="form-control" id="desc" name='desc' rows="3"></textarea> | |
</div> | |
<button type="submit" class="btn btn-success">Submit</button> | |
</form> | |
</div> | |
{% endblock %} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block css %} | |
.col-md-3 | |
{ | |
display: inline-block; | |
margin-left:-4px; | |
} | |
.carousel-indicators .active { | |
background-color: blue; | |
} | |
.col-md-3 img{ | |
max-width: 200px; | |
height: 200px; | |
} | |
body .carousel-indicator li{ | |
background-color: blue; | |
} | |
body .carousel-indicators{ | |
bottom: 0; | |
} | |
body .carousel-control-prev-icon, | |
body .carousel-control-next-icon{ | |
background-color: blue; | |
} | |
body .no-padding{ | |
padding-left: 0, | |
padding-right: 0; | |
} | |
{% endblock %} | |
{% block body %} | |
{% load static %} | |
<div class="container"> | |
<h3 class="my-4">Flash sale- {{product.0.category}}recommended</h3> | |
<div class="row"> | |
<div id="demo{{forloop.counter}}" class="col carousel slide my-3" data-ride="carousel"> | |
<ul class="carousel-indicators"> | |
<li data-target="#demo{{forloop.counter}}" data-slide-to="0" class="active"></li> | |
{% for i in range %} | |
<li data-target="#demo{{forloop.parentloop.counter}}" data-slide-to="{{i}}" ></li> | |
{% endfor %} | |
</ul> | |
<!--Slideshow starts here --> | |
{% for product, range, nSlides in allprods %} | |
<div class="container carousel-inner no-padding"> | |
<div class="carousel-item active"> | |
{% for i in product%} | |
<div class="col-xs-3 col-sm-3 col-md-3"> | |
<div class="card align-items-center" style="width: 18rem;"> | |
<img src='/media/{{i.image}}' class="card-img-top" alt="..."> | |
<div class="card-body"> | |
<h5 class="card-title">{{i.product_name}}</h5> | |
<p class="card-text">{{i.desc|slice:"0:53"}}...</p> | |
<button id="pr{{i.id}}" class="btn btn-primary cart">Add To Cart</button> | |
<a href="/eshop/products/{{i.id}}"><button id="qv{{i.id}}" class="btn btn-primary cart">QuickView</button></a> | |
</div> | |
</div> | |
</div> | |
{% if forloop.counter|divisibleby:4 and forloop.counter > 0 and not forloop.last %} | |
</div><div class="carousel-item"> | |
{% endif %} | |
</div> | |
{% endfor %} | |
</div> | |
</div> | |
</div> | |
<!-- left and right controls for the slide --> | |
<a class="carousel-control-prev" href="#demo{{forloop.counter}}" data-slide="prev"> | |
<span class="carousel-control-prev-icon"></span> | |
</a> | |
<a class="carousel-control-next" href="#demo{{forloop.counter}}" data-slide="next"> | |
<span class="carousel-control-next-icon"></span> | |
</a> | |
{% endfor %} | |
</div> | |
{% endblock %} | |
{% block js %} | |
<script> | |
// Find out the cart items from localStorage | |
if (localStorage.getItem('cart') == null) { | |
var cart = {}; | |
} else { | |
cart = JSON.parse(localStorage.getItem('cart')); | |
updateCart(cart); | |
} | |
// If the add to cart button is clicked, add/increment the item | |
//$('.cart').click(function() { | |
$('.divpr').on('click', 'button.cart', function(){ | |
var idstr = this.id.toString(); | |
if (cart[idstr] != undefined) { | |
cart[idstr] = cart[idstr] + 1; | |
} else { | |
cart[idstr] = 1; | |
} | |
updateCart(cart); | |
}); | |
//Add Popover to cart | |
$('#popcart').popover(); | |
updatePopover(cart); | |
function updatePopover(cart) { | |
console.log('We are inside updatePopover'); | |
var popStr = ""; | |
popStr = popStr + "<h5> Cart for your items in my shopping cart </h5><div class='mx-2 my-2'>"; | |
var i = 1; | |
for (var item in cart) { | |
popStr = popStr + "<b>" + i + "</b>. "; | |
popStr = popStr + document.getElementById('name' + item).innerHTML.slice(0, 19) + "... Qty: " + cart[item] + '<br>'; | |
i = i + 1; | |
} | |
popStr = popStr + "</div> <a href='/eshop/checkout'><button class='btn btn-primary' id ='checkout'>Checkout</button></a> <button class='btn btn-primary' onclick='clearCart()' id ='clearCart'>Clear Cart</button> " | |
console.log(popStr); | |
document.getElementById('popcart').setAttribute('data-content', popStr); | |
$('#popcart').popover('show'); | |
} | |
function clearCart() { | |
cart = JSON.parse(localStorage.getItem('cart')); | |
for (var item in cart) { | |
document.getElementById('div' + item).innerHTML = '<button id="' + item + '" class="btn btn-primary cart">Add To Cart</button>' | |
} | |
localStorage.clear(); | |
cart = {}; | |
updateCart(cart); | |
} | |
function updateCart(cart) { | |
var sum = 0; | |
for (var item in cart) { | |
sum = sum + cart[item]; | |
document.getElementById('div' + item).innerHTML = "<button id='minus" + item + "' class='btn btn-primary minus'>-</button> <span id='val" + item + "''>" + cart[item] + "</span> <button id='plus" + item + "' class='btn btn-primary plus'> + </button>"; | |
} | |
localStorage.setItem('cart', JSON.stringify(cart)); | |
document.getElementById('cart').innerHTML = sum; | |
console.log(cart); | |
updatePopover(cart); | |
} | |
// If plus or minus button is clicked, change the cart as well as the display value | |
$('.divpr').on("click", "button.minus", function() { | |
a = this.id.slice(7, ); | |
cart['pr' + a] = cart['pr' + a] - 1; | |
cart['pr' + a] = Math.max(0, cart['pr' + a]); | |
document.getElementById('valpr' + a).innerHTML = cart['pr' + a]; | |
updateCart(cart); | |
}); | |
$('.divpr').on("click", "button.plus", function() { | |
a = this.id.slice(6, ); | |
cart['pr' + a] = cart['pr' + a] + 1; | |
document.getElementById('valpr' + a).innerHTML = cart['pr' + a]; | |
updateCart(cart); | |
}); | |
</script> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block title%} {{product.product_name}}my - cart{% endblock %} | |
{% block body %} | |
<div class="container my-4"> | |
<div class="row"> | |
<div class="col-md-4"> | |
<div class="row"> | |
<img SRC="/media/{{product.image}}" width="233px" height="385px"> | |
</div> | |
<div class="row"> | |
<button class="btn btn-primary my-2 mx-3">Buy Now</button> | |
<button class="btn btn-primary my-2">Add To Cart</button> | |
</div> | |
</div> | |
<div class="col-md-8"> | |
<h5>{{product.product_name}} </h5> | |
<p><b>Mrp Rs.</b>{{product.price}} </p> | |
<p>{{product.desc}} </p> | |
</div> | |
</div> | |
</div> | |
{% endblock %} | |
{% block js %} | |
<script> | |
console.log('working'); | |
if(localStorage.getItem('cart') == null){ | |
var cart = {}; | |
} | |
else | |
{ | |
cart = JSON.parse(localStorage.getItem('cart')); | |
document.getElementById('cart').innerHTML = Object.keys(cart).length; | |
} | |
$('.cart').click(function(){ | |
console.log('clicked'); | |
var idstr = this.id.toString(); | |
console.log(idstr); | |
if (cart[idstr] !=undefined){ | |
cart[idstr] = cart[idstr] + 1; | |
} | |
else | |
{ | |
cart[idstr] = 1; | |
} | |
console.log(cart); | |
localStorage.setItem('cart', JSON.stringify(cart)); | |
document.getElementById('cart').innerHTML = Object.keys(cart).length; | |
}); | |
$('#popcart').popover(); | |
document.getElementById("popcart").setAttribute('data-content', '<h5>Cart for your items in my shopping cart</h5>') | |
</script> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block title%} Title of search{% endblock %} | |
{% block body %} This is body {% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'eshop/basic.html' %} | |
{% block title%} Apni Dhukaan Tracker{% endblock %} | |
{% block body %} | |
<div class="container"> | |
<div class="col my-4"> | |
<h2>Enter your Order Id and Email address to track your order</h2> | |
<form method="post" action="#" id="trackerForm">{% csrf_token %} | |
<div class="form-row"> | |
<div class="form-group col-md-6"> | |
<label for="inputname">Order Id</label> | |
<input type="text" class="form-control" id="orderId" name="orderId" placeholder="Order Id"> | |
</div> | |
<div class="form-group col-md-6"> | |
<label for="inputEmail4">Email</label> | |
<input type="email" class="form-control" id="email" name="email" placeholder="Email"> | |
</div> | |
<button type="submit" class="btn btn-primary">Track Order</button> | |
</div> | |
</div> | |
<div class="col my-4"> | |
<h2>Your Order Status</h2> | |
<div class="my-4"> | |
<ul class="list-group" id="items"> | |
Enter your order Id and Email and click Track Order to find details about your order! | |
</ul> | |
</div> | |
<h2>Your Order Details</h2> | |
<div class="my-4"> | |
<ul class="list-group" id="citems"> | |
</ul> | |
</div> | |
</div> | |
</div> | |
{% endblock %} | |
{% block js %} | |
<script> | |
$('#trackerForm').submit(function(event) { | |
$('#items').empty(); | |
var formData = { | |
'orderId': $('input[name=orderId]').val(), | |
'email': $('input[name=email]').val(), | |
'csrfmiddlewaretoken': $('input[name=csrfmiddlewaretoken]').val() | |
}; | |
$.ajax({ | |
type: 'POST', | |
url: '/shop/tracker/', | |
data: formData, | |
encode: true | |
}) | |
.done(function(data) { | |
console.log(data) | |
data = JSON.parse(data); | |
updates = data[0]; | |
if (updates.length > 0 & updates != {}) { | |
for (i = 0; i < updates.length; i++) { | |
let text = updates[i]['text']; | |
let time = updates[i]['time']; | |
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center"> | |
${text} | |
<span class="badge badge-primary badge-pill">${time}</span> | |
</li>` | |
$('#items').append(mystr); | |
} | |
} else { | |
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center"> | |
Sorry, We are not able to fetch this order id and email. Make sure to type correct order Id and email</li>` | |
$('#items').append(mystr); | |
} | |
// Fill in the order details | |
cart = JSON.parse(data[1]); | |
console.log(cart); | |
for (item in cart) { | |
let name = cart[item][1]; | |
let qty = cart[item][0]; | |
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center"> | |
${name} | |
<span class="badge badge-primary badge-pill">${qty}</span> | |
</li>` | |
$('#citems').append(mystr); | |
} | |
}); | |
event.preventDefault(); | |
}); | |
</script> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from . import views | |
urlpatterns = [ | |
path('', views.index, name = "eShopHome"), | |
path('about/', views.about, name = "AboutUs"), | |
path('contact/', views.contact, name = "ContactUs"), | |
path('tracker/', views.tracker, name = "trackingStatus"), | |
path('search/', views.search, name = "Search"), | |
path('products/<int:myid>', views.productview, name = "ProductView"), | |
path('checkout/', views.checkout, name = "Checkout"), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from django.http import HttpResponse | |
from .models import Product, Contact, Orders, OrderUpdate | |
from math import ceil | |
import json | |
# Create your views here. | |
def index(request): | |
allProds = [] | |
catprods = Product.objects.values('category', 'id') | |
cats = {item['category'] for item in catprods} | |
for cat in cats: | |
prod = Product.objects.filter(category=cat) | |
n = len(prod) | |
nSlides = n // 4 + ceil((n / 4) - (n // 4)) | |
allProds.append([prod, range(1, nSlides), nSlides]) | |
params = {'allprods': allProds} | |
return render(request, "eshop/index.html", params) | |
def about(request): | |
return render(request, "eshop/About.html") | |
def contact(request): | |
if request.method == "POST": | |
name = request.POST.get('name', '') | |
email = request.POST.get('email', '') | |
phone = request.POST.get('phone', '') | |
desc = request.POST.get('desc', '') | |
contact = Contact(name=name, email=email, phone=phone, desc=desc) | |
contact.save() | |
return render(request, "eshop/contact.html") | |
def tracker(request): | |
if request.method == "POST": | |
orderId = request.POST.get('orderId', '') | |
email = request.POST.get('email', '') | |
try: | |
order = Orders.objects.filter(order_id=orderId, email=email) | |
if len(order) > 0: | |
update = OrderUpdate.objects.filter(order_id=orderId) | |
updates = [] | |
for item in update: | |
updates.append({'text': item.update_desc, 'time': item.timestamp}) | |
response = json.dumps([updates, order[0].items_json], default=str) | |
return HttpResponse(response) | |
else: | |
return HttpResponse('{}') | |
except Exception as e: | |
return HttpResponse('{}') | |
return render(request, "eshop/tracker.html") | |
def search(request): | |
return render(request, "eshop/search.html") | |
def productview(request, myid): | |
# fatch the product using the id | |
product = Product.objects.filter(id=myid) | |
return render(request, "eshop/prodview.html", {'product ': product[0]}) | |
def checkout(request): | |
if request.method == "POST": | |
items_json = request.POST.get('itemsJson', '') | |
name = request.POST.get('name', '') | |
email = request.POST.get('email', '') | |
address = request.POST.get('address1', '') + " " + request.POST.get('address2', '') | |
city = request.POST.get('city', '') | |
state = request.POST.get('state', '') | |
zip_code = request.POST.get('zip_code', '') | |
phone = request.POST.get('phone', '') | |
order = Orders(items_json=items_json, name=name, email=email, address=address, city=city, | |
state=state, zip_code=zip_code, phone=phone) | |
order.save() | |
update = OrderUpdate(order_id = order.order_id, update_desc = "your is placed") | |
thank = True | |
id = order.order_id | |
return render(request, 'eshop/checkout.html', {'thank': thank, 'id': id}) | |
return render(request, 'eshop/checkout.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Django's command-line utility for administrative tasks.""" | |
import os | |
import sys | |
def main(): | |
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Ecomwebsite.settings') | |
try: | |
from django.core.management import execute_from_command_line | |
except ImportError as exc: | |
raise ImportError( | |
"Couldn't import Django. Are you sure it's installed and " | |
"available on your PYTHONPATH environment variable? Did you " | |
"forget to activate a virtual environment?" | |
) from exc | |
execute_from_command_line(sys.argv) | |
if __name__ == '__main__': | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
# Register your models here. | |
from .models import Blogpost | |
admin.site.register(Blogpost) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import AppConfig | |
class MyblogConfig(AppConfig): | |
name = 'myblog' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by Django 2.2.5 on 2019-10-01 12:55 | |
from django.db import migrations, models | |
class Migration(migrations.Migration): | |
initial = True | |
dependencies = [ | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Blogpost', | |
fields=[ | |
('post_id', models.AutoField(primary_key=True, serialize=False)), | |
('title', models.CharField(max_length=50)), | |
('head0', models.CharField(default='', max_length=500)), | |
('chead0', models.CharField(default='', max_length=5000)), | |
('head1', models.CharField(default='', max_length=500)), | |
('chead1', models.CharField(default='', max_length=5000)), | |
('head2', models.CharField(default='', max_length=500)), | |
('chead2', models.CharField(default='', max_length=5000)), | |
('pub_date', models.DateField()), | |
('thumbnail', models.ImageField(default='', upload_to='eshop/images')), | |
], | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
# Create your models here. | |
class Blogpost(models.Model): | |
post_id = models.AutoField(primary_key=True) | |
title = models.CharField(max_length=50) | |
head0 = models.CharField(max_length=500, default="") | |
chead0 = models.CharField(max_length=5000, default="") | |
head1 = models.CharField(max_length=500, default="") | |
chead1 = models.CharField(max_length=5000, default="") | |
head2 = models.CharField(max_length=500, default="") | |
chead2 = models.CharField(max_length=5000, default="") | |
pub_date = models.DateField() | |
thumbnail = models.ImageField(upload_to='eshop/images', default="") | |
def __str__(self): | |
return self.title | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this is file for my blog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> | |
<title>{% block title%} {% endblock %}</title> | |
<style> | |
{% block css %} {% endblock %} | |
</style> | |
</head> | |
<body> | |
<nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | |
<a class="navbar-brand" href="/shop">My Awesome Cart</a> | |
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | |
<span class="navbar-toggler-icon"></span> | |
</button> | |
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | |
<ul class="navbar-nav mr-auto"> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop">Home <span class="sr-only">(current)</span></a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop/about">About Us</a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop/tracker">Tracker</a> | |
</li> | |
<li class="nav-item active"> | |
<a class="nav-link" href="/myblog/blogPost/">Blog</a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" href="/eshop/contact">Contact Us</a> | |
</li> | |
</ul> | |
<form class="form-inline my-2 my-lg-0"> | |
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> | |
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> | |
</form> | |
<button type="button" class="btn btn-secondary mx-2" id="popcart" data-container="body" data-toggle="popover" data-placement="bottom" data-html="true" data-content="Vivamus | |
sagittis lacus vel augue laoreet rutrum faucibus."> | |
Cart(<span id="cart">0</span>) | |
</button> | |
</div> | |
</nav> | |
{% block body %} {% endblock %} | |
<!-- Optional JavaScript --> | |
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | |
<script src="https://code.jquery.com/jquery-3.3.1.js" | |
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" | |
crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script> | |
{% block js %} {% endblock %} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'myblog/basic.html' %} | |
{% block body %} | |
<div class="container"> | |
<div class="row mt-4"> | |
<div class="col-md-8 blog-main"> | |
<h3 class="pb-4 mb-4 font-italic border-bottom"> | |
{{post.title}} | |
</h3> | |
<div class="blog-post"> | |
<h2 class="blog-post-title">{{post.heading0}}</h2> | |
<p class="blog-post-meta">January 1, 2014 by <a href="#">Mark</a></p> | |
<p>{{post.chead0}}</p> | |
<h2>{{post.head1}}</h2> | |
<p>{{post.chead1}}</p> | |
<h2>{{post.head2}}</h2> | |
<p>{{post.chead2}}</p> | |
<img src={{post.Thumbnail}}> | |
</div><!-- /.blog-post --> | |
</div><!-- /.blog-main --> | |
<aside class="col-md-4 blog-sidebar"> | |
<div class="p-4 mb-3 bg-light rounded"> | |
<h4 class="font-italic">About</h4> | |
<p class="mb-0">My Awesome Cart <em>started out as a small project and is now</em> the fastest growing e-commerce stores of all times in india and abroad.</p> | |
</div> | |
<div class="p-4"> | |
<h4 class="font-italic">Elsewhere</h4> | |
<ol class="list-unstyled"> | |
<li><a href="#">GitHub</a></li> | |
<li><a href="#">Twitter</a></li> | |
<li><a href="#">Facebook</a></li> | |
</ol> | |
</div> | |
</aside><!-- /.blog-sidebar --> | |
</div> | |
</div> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'myblog/basic.html' %} | |
{% block body %} | |
<div class="container"> | |
<div class="row my-2"> | |
<div class="col-md-6"> | |
<div | |
class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative"> | |
<div class="col p-4 d-flex flex-column position-static"> | |
<strong class="d-inline-block mb-2 text-primary">World</strong> | |
<h3 class="mb-0">Featured post</h3> | |
<div class="mb-1 text-muted">Nov 12</div> | |
<p class="card-text mb-auto">This is a wider card with supporting text below as a natural lead-in to | |
additional content.</p> | |
<a href="#" class="stretched-link">Continue reading</a> | |
</div> | |
<div class="col-auto d-none d-lg-block"> | |
<svg class="bd-placeholder-img" width="200" height="250" xmlns="http://www.w3.org/2000/svg" | |
preserveAspectRatio="xMidYMid slice" focusable="false" role="img" | |
aria-label="Placeholder: Thumbnail"> | |
<title>Placeholder</title> | |
<rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef" | |
dy=".3em">Thumbnail</text> | |
</svg> | |
</div> | |
</div> | |
</div> | |
<div class="col-md-6"> | |
<div | |
class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-relative"> | |
<div class="col p-4 d-flex flex-column position-static"> | |
<strong class="d-inline-block mb-2 text-success">Design</strong> | |
<h3 class="mb-0">Post title</h3> | |
<div class="mb-1 text-muted">Nov 11</div> | |
<p class="mb-auto">This is a wider card with supporting text below as a natural lead-in to | |
additional content.</p> | |
<a href="#" class="stretched-link">Continue reading</a> | |
</div> | |
<div class="col-auto d-none d-lg-block"> | |
<svg class="bd-placeholder-img" width="200" height="250" xmlns="http://www.w3.org/2000/svg" | |
preserveAspectRatio="xMidYMid slice" focusable="false" role="img" | |
aria-label="Placeholder: Thumbnail"> | |
<title>Placeholder</title> | |
<rect width="100%" height="100%" fill="#55595c"></rect><text x="50%" y="50%" fill="#eceeef" | |
dy=".3em">Thumbnail</text> | |
</svg> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.urls import path | |
from . import views | |
urlpatterns = [ | |
path('', views.index, name = "myblogHome"), | |
path('blogPost/<int:id>', views.blogPost, name = "blogPost"), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render | |
from django.http import HttpResponse | |
from .models import Blogpost | |
# Create your views here. | |
def index(request): | |
return render(request, "myblog/index.html") | |
def blogPost(request, id): | |
post = Blogpost.objects.filter(post_id = id)[0] | |
return render(request, "myblog/blogPost.html", | |
{'post': post}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment