diff --git a/ecommerce/__pycache__/settings.cpython-38.pyc b/ecommerce/__pycache__/settings.cpython-38.pyc index 8fbe03f..7e09dde 100644 Binary files a/ecommerce/__pycache__/settings.cpython-38.pyc and b/ecommerce/__pycache__/settings.cpython-38.pyc differ diff --git a/ecommerce/settings.py b/ecommerce/settings.py index 80f2d34..366a279 100644 --- a/ecommerce/settings.py +++ b/ecommerce/settings.py @@ -31,6 +31,7 @@ # Application definition INSTALLED_APPS = [ + 'ecommerce_site.apps.EcommerceSiteConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -129,3 +130,6 @@ os.path.join(BASE_DIR, 'static') ] STATIC_ROOT = os.path.join(BASE_DIR, 'assets') + +MEDIA_URL='/media/' +MEDIA_ROOT =os.path.join(BASE_DIR,'media') \ No newline at end of file diff --git a/ecommerce_site/__pycache__/admin.cpython-38.pyc b/ecommerce_site/__pycache__/admin.cpython-38.pyc new file mode 100644 index 0000000..54439f3 Binary files /dev/null and b/ecommerce_site/__pycache__/admin.cpython-38.pyc differ diff --git a/ecommerce_site/__pycache__/apps.cpython-38.pyc b/ecommerce_site/__pycache__/apps.cpython-38.pyc new file mode 100644 index 0000000..fc57564 Binary files /dev/null and b/ecommerce_site/__pycache__/apps.cpython-38.pyc differ diff --git a/ecommerce_site/__pycache__/models.cpython-38.pyc b/ecommerce_site/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000..cc830de Binary files /dev/null and b/ecommerce_site/__pycache__/models.cpython-38.pyc differ diff --git a/ecommerce_site/__pycache__/views.cpython-38.pyc b/ecommerce_site/__pycache__/views.cpython-38.pyc index 607c2e7..97db886 100644 Binary files a/ecommerce_site/__pycache__/views.cpython-38.pyc and b/ecommerce_site/__pycache__/views.cpython-38.pyc differ diff --git a/ecommerce_site/migrations/0001_initial.py b/ecommerce_site/migrations/0001_initial.py new file mode 100644 index 0000000..2bd0830 --- /dev/null +++ b/ecommerce_site/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 2.2.5 on 2021-04-14 10:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='shopData', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('size', models.CharField(max_length=50)), + ('price', models.IntegerField()), + ('img', models.ImageField(upload_to='images')), + ], + ), + ] diff --git a/ecommerce_site/migrations/__pycache__/0001_initial.cpython-38.pyc b/ecommerce_site/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000..3877e6e Binary files /dev/null and b/ecommerce_site/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/ecommerce_site/migrations/__pycache__/__init__.cpython-38.pyc b/ecommerce_site/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..636194e Binary files /dev/null and b/ecommerce_site/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/ecommerce_site/models.py b/ecommerce_site/models.py index 71a8362..bbe9fa3 100644 --- a/ecommerce_site/models.py +++ b/ecommerce_site/models.py @@ -1,3 +1,8 @@ from django.db import models # Create your models here. +class shopData(models.Model): + name = models.CharField(max_length=50) + size = models.CharField(max_length=50) + price=models.IntegerField() + img = models.ImageField(upload_to='images') \ No newline at end of file diff --git a/ecommerce_site/views.py b/ecommerce_site/views.py index 4e0229f..8aa01eb 100644 --- a/ecommerce_site/views.py +++ b/ecommerce_site/views.py @@ -1,10 +1,47 @@ -from django.shortcuts import render - +from django.shortcuts import render, redirect +from django.contrib import messages +from django.contrib.auth.models import User, auth # Create your views here. def toLogin(request): - return render(request, 'my.html') + if request.method == 'POST': + username = request.POST['username'] + password = request.POST['password'] + user = auth.authenticate(username=username, password=password) + + if user is not None: + auth.login(request, user) + return redirect("/") + else: + messages.info(request, 'invalid credentials') + return redirect('login') + else: + return render(request, 'login.html') def toRegister(request): - return render(request, 'register.html') + if request.method == 'POST': + first_name = request.POST['first_name'] + last_name = request.POST['last_name'] + username = request.POST['username'] + password1 = request.POST['password1'] + password2 = request.POST['password2'] + email = request.POST['email'] + if password1 == password2: + if User.objects.filter(username=username).exists(): + messages.info(request, 'UserName Taken') + return redirect('register.html') + elif User.objects.filter(email=email).exists(): + messages.info(request,'Email taken') + else: + user = User.objects.create_user(username=username, password = password1, email=email, first_name =first_name, last_name=last_name) + user.save() + messages.info(request,'user created') + return redirect('login.html') + else: + messages.info(request, 'password does not match....') + return render(request, 'register.html') + return redirect('/') + else: + return render(request,'register.html') + def toShopSingle(request): return render(request,'shop-single.html') def toShop(request): diff --git a/templates/login.html b/templates/login.html index 42e7aeb..1f95a77 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,22 +1,267 @@ +{%load static%} +
- - - -