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%} + - - - - Document + Zay Shop - Contact + + + + + + + + + + + + + + + + + + -
- {%csrf_token%} -
-
- -
-
- {%for message in messages%} -

{{message}}

- {%endfor%} + + + + + + + + + + + + + + + +
+
+
+ {%csrf_token%} +
+ + +
+
+ + + {%for message in messages%} + + {%endfor%} +
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/my.html b/templates/my.html deleted file mode 100644 index db9d79a..0000000 --- a/templates/my.html +++ /dev/null @@ -1,264 +0,0 @@ -{%load static%} - - - - - Zay Shop - Contact - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- {%csrf_token%} -
- - -
-
- - -
-
-
- -
-
-
-
-
- - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/templates/my2.html b/templates/my2.html new file mode 100644 index 0000000..42e7aeb --- /dev/null +++ b/templates/my2.html @@ -0,0 +1,22 @@ + + + + + + + Document + + +
+ {%csrf_token%} +
+
+ +
+
+ {%for message in messages%} +

{{message}}

+ {%endfor%} +
+ + \ No newline at end of file diff --git a/templates/register.html b/templates/register.html index cf2b32e..e0e525b 100644 --- a/templates/register.html +++ b/templates/register.html @@ -136,12 +136,14 @@
-
+ {%csrf_token%} +
+ - +
@@ -158,11 +160,14 @@
- +
- + + {%for message in messages%} + + {%endfor%}
diff --git a/templates/shop-single.html b/templates/shop-single.html index 5f89066..d9739a7 100644 --- a/templates/shop-single.html +++ b/templates/shop-single.html @@ -1,3 +1,4 @@ +{%load static%} @@ -6,20 +7,20 @@ - - + + - - - + + + - + - - + + @@ -154,17 +155,17 @@ @@ -176,17 +177,17 @@ @@ -198,17 +199,17 @@ @@ -330,7 +331,7 @@

Related Products

- +
  • @@ -368,7 +369,7 @@

    Related Products

    - +
    • @@ -406,7 +407,7 @@

      Related Products

      - +
      • @@ -444,7 +445,7 @@

        Related Products

        - +
        • @@ -482,7 +483,7 @@

          Related Products

          - +
          • @@ -520,7 +521,7 @@

            Related Products

            - +
            • @@ -558,7 +559,7 @@

              Related Products

              - +
              • @@ -596,7 +597,7 @@

                Related Products

                - +
                • @@ -634,7 +635,7 @@

                  Related Products

                  - +
                  • @@ -672,7 +673,7 @@

                    Related Products

                    - +
                    • @@ -710,7 +711,7 @@

                      Related Products

                      - +
                      • @@ -748,7 +749,7 @@

                        Related Products

                        - +
                        • @@ -887,15 +888,15 @@

                          Further Info

                          - - - - - + + + + + - +