Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated package version for Django 4 and Python 3 #39

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
04dc07a
updated package version for Django 4 and Python 3
eliuqiong Oct 4, 2023
11e55c1
Update README.md
eliuqiong Oct 4, 2023
8838304
Update README.md
eliuqiong Oct 4, 2023
57cf950
Update README.md
eliuqiong Oct 4, 2023
f37e3a9
Update README.md
eliuqiong Oct 4, 2023
943dfda
Update README.md
eliuqiong Oct 4, 2023
fd958a2
Update views.py
eliuqiong Oct 4, 2023
81ba18a
Update models.py
eliuqiong Oct 4, 2023
45fc2bf
Update settings.py
eliuqiong Oct 4, 2023
1d35314
update for python3.10 django4 and crispy-form
eliuqiong Oct 4, 2023
8ae8c10
Add files via upload
eliuqiong Oct 13, 2023
489237b
Update README.md
eliuqiong Oct 13, 2023
3113ed5
Update README.md
eliuqiong Oct 13, 2023
e997532
Update README.md
eliuqiong Oct 13, 2023
b0dd59d
Update README.md
eliuqiong Oct 13, 2023
4e9e7de
Update README.md
eliuqiong Oct 13, 2023
3b53b22
Update README.md
eliuqiong Oct 13, 2023
8cef23f
Update README.md
eliuqiong Oct 13, 2023
9f0bbc9
Update README.md
eliuqiong Oct 13, 2023
77da12b
Update README.md
eliuqiong Oct 13, 2023
075ef0b
Update README.md
eliuqiong Oct 13, 2023
97c32e5
Update README.md
eliuqiong Oct 13, 2023
623acac
Update README.md
eliuqiong Oct 13, 2023
c3112ef
Update README.md
eliuqiong Oct 13, 2023
5f9674b
Update README.md
eliuqiong Oct 13, 2023
044730a
Update README.md
eliuqiong Oct 13, 2023
6b2615f
Update README.md
eliuqiong Oct 13, 2023
9b05aea
Update README.md
eliuqiong Oct 13, 2023
2c6ba54
Update README.md
eliuqiong Oct 17, 2023
2a87662
Update README.md
eliuqiong Oct 18, 2023
da3ab6c
Update README.md
eliuqiong Oct 18, 2023
b169c5f
Update README.md
eliuqiong Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 165 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Django-Ecommerce
# Django E-commerce.

Ecommerce website built with Django 2.2.3, Python 3.7.3, and AWS
<p align='center'>
<img src="https://img.shields.io/badge/Django-239120?logo=django&logoColor=white" />
<img src="https://img.shields.io/badge/Python-239120?logo=python&logoColor=white" />
<img src="https://img.shields.io/badge/SQL%20Server-CC2927?logo=microsoft-sql-server&logoColor=white" />
<img src="https://img.shields.io/badge/html5-E34F26?logo=html5&logoColor=white" />
<img src="https://img.shields.io/badge/css3-1572B6?logo=css3&logoColor=white" />
<img src="https://img.shields.io/badge/bootstrap-563D7C?logo=bootstrap&logoColor=white" />
<img src="https://img.shields.io/badge/Github-181717?logo=github&logoColor=white" />
<img src="https://img.shields.io/badge/PayPal-000144?logo=paypal&logoColor=white" />
</p>

![image](https://user-images.githubusercontent.com/29988949/65267147-499fc580-dac9-11e9-90e8-eccbc93c7c3a.png)

`Product Slide`
<hr class="dotted">

Ecommerce website built with Django 2.2.3, Python 3.7.3.
Other features include:
- integrated with Stripe payment
- depolyed on AWS (still working on it)

## About this Project:

![image](https://user-images.githubusercontent.com/29988949/65999313-ff67fe00-e451-11e9-9ed9-fc7bce704f17.png)
The repository is a start point for most of my professional projects; for this, I'm using as a part of my portfolio, feel free to use wherever you want. I'll be happy if you provide any feedback or code improvements or suggestions.

`Product Slide`
<img src="https://user-images.githubusercontent.com/29988949/65267147-499fc580-dac9-11e9-90e8-eccbc93c7c3a.png">

`Shop Page`
<img src="https://user-images.githubusercontent.com/29988949/65999313-ff67fe00-e451-11e9-9ed9-fc7bce704f17.png">

![image](https://user-images.githubusercontent.com/29988949/66098968-923f9000-e559-11e9-8691-cd5c2b181ca1.png)

`Product Detail Page`
Expand All @@ -26,18 +46,19 @@ Ecommerce website built with Django 2.2.3, Python 3.7.3, and AWS
`Order Success Page`
![image](https://user-images.githubusercontent.com/29988949/66291657-3e091880-e897-11e9-830b-6cf44e72a995.png)

# Installation
## Installation

`pip install django`

`virtualenv env`

# For Mac/ Linux
```
$ pip install django`
$ virtualenv env`

```
### For Mac/ Linux
```
`source env/bin/activate`

# For Window

```
### For Window
```
`env\scripts\activate`

`pip install -r requirements.txt`
Expand All @@ -47,19 +68,144 @@ Ecommerce website built with Django 2.2.3, Python 3.7.3, and AWS
`python manage.py migrate`

`python manage.py runserver`
```
## For Admin Login

# For Admin Login

```python
```
python manage.py createsuperuser
Username : admin
Password : 12345678
```
# Demo
## Potential Error and solutions
###
django python tried to input http instead of https, but still have the following error: [13/Oct/2023 18:45:36] code 400, message Bad request version ('u|q&L¹°zUÀ\x00"\x13\x01\x13\x03\x13\x02À+À/̨̩À,À0À')
[13/Oct/2023 18:45:36] You're accessing the development server over HTTPS, but it only supports HTTP.

This error indicates that there's an attempt to access the Django development server over HTTPS, but it only supports HTTP. This might be due to a few reasons:
1. **Clear browser cache**: Clear the cache of your browser and try again. Sometimes, the browser remembers that it should access a certain URL via HTTPS and tries to do so every time.


http://djangoecommerce.pythonanywhere.com

# HTML Template

https://colorlib.com/etc/fashe/index.html



## Some technical information:

- Django - 3.1.1
- Django Allauth - 0.42.0
- Django Crispy Forms - 1.9.2
- Django Environ - 0.4.5
- Stripe - 2.51.0


## To Install:

Cloning the Repository:

```
$ git clone https://github.com/fl4viooliveira/django_ecommerce.git

$ cd django_ecommerce

```

Installing the environment control:

```
$ pip install virtualenv

$ virtualenv env

```

Activating the environment:

on Windows:
```
env\Scripts\activate

```
on Mac OS / Linux:
```
$ source env/bin/activate

```

Installing dependencies:

```
$ pip install -r requirements.txt

```

Create a .env file on ecom folder (/ecom/.env) setting all requirements without using space after "=".

Copy and paste on our .env file:

```
DEBUG=
SECRET_KEY=
DEFAULT_FROM_EMAIL=
NOTIFY_EMAIL=
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SANDBOX_SECRET_KEY=
PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_SECRET_KEY=
STRIPE_PUBLIC_KEY=
STRIPE_SECRET_KEY=
STRIPE_WEBHOOK_SECRET=

```

Last commands to start:

```
$ python manage.py makemigrations

$ python manage.py migrate

```
Create a super user:

```
$ python manage.py createsuperuser admin-name

```

Finishing running server:

```
$ python manage.py runserver

```

## Other related topics and solutions
### stripe integration
When testing your e-commerce website, you certainly wouldn't want to make actual payments for each transaction. Thankfully, Stripe provides a testing environment with a set of test API keys that you can use. Here's a general process on how to test Stripe payment functionality:


1. **Get your test API keys**: Go to the Stripe Dashboard and switch the view from "Live" to "Test". You will find publishable and secret API keys for testing. Use these keys in your test environment.

2. **Use test card numbers**: Stripe provides a variety of [test card numbers](https://stripe.com/docs/testing#cards) that you can use to simulate different types of behavior. For example, the card number `4242 4242 4242 4242` simulates a successful payment, while other numbers can simulate different types of failures.

3. **Simulate different scenarios**: In addition to successful payments and payment failures, you can also simulate other scenarios, like refunds, disputes, and subscription changes. Check the [Stripe testing documentation](https://stripe.com/docs/testing) for more details.

4. **Use Stripe's webhook testing**: If your application uses webhooks, you can use Stripe's webhook testing feature to send sample events to your server.

5. **Inspect and monitor**: Use the Stripe Dashboard to view and monitor your test transactions. You can check the details of each transaction, including the associated requests and responses.

Remember to make sure that you only use your test API keys and test card numbers in your test environment, and never in your live environment. Also, make sure to thoroughly test all aspects of your payment functionality, including edge cases and failure scenarios, to ensure that your application handles all possible situations correctly.

### Chrome and other browser show error and changing your http to https
Clear Browsing Data: Sometimes, Chrome stores settings or cookies that force redirection to HTTPS. Clearing them might solve the issue.

## License

<a href="https://github.com/fl4viooliveira/django_ecommerce/blob/master/LICENSE">
<img alt="NPM" src="https://img.shields.io/npm/l/license?style=for-the-badge">
</a>&nbsp;&nbsp;

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/fl4viooliveira/django_ecommerce/blob/master/LICENSE) file for details.
9 changes: 9 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


class Slide(models.Model):
id = models.AutoField(primary_key=True)
caption1 = models.CharField(max_length=100)
caption2 = models.CharField(max_length=100)
link = models.CharField(max_length=100)
Expand All @@ -35,6 +36,7 @@ def __str__(self):
return "{} - {}".format(self.caption1, self.caption2)

class Category(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=100)
slug = models.SlugField()
description = models.TextField()
Expand All @@ -51,6 +53,7 @@ def get_absolute_url(self):


class Item(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=100)
price = models.FloatField()
discount_price = models.FloatField(blank=True, null=True)
Expand Down Expand Up @@ -83,6 +86,7 @@ def get_remove_from_cart_url(self):


class OrderItem(models.Model):
id = models.AutoField(primary_key=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
ordered = models.BooleanField(default=False)
Expand All @@ -108,6 +112,7 @@ def get_final_price(self):


class Order(models.Model):
id = models.AutoField(primary_key=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
ref_code = models.CharField(max_length=20)
Expand Down Expand Up @@ -151,6 +156,7 @@ def get_total(self):


class BillingAddress(models.Model):
id = models.AutoField(primary_key=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.CASCADE)
street_address = models.CharField(max_length=100)
Expand All @@ -168,6 +174,7 @@ class Meta:


class Payment(models.Model):
id = models.AutoField(primary_key=True)
stripe_charge_id = models.CharField(max_length=50)
user = models.ForeignKey(settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL, blank=True, null=True)
Expand All @@ -179,6 +186,7 @@ def __str__(self):


class Coupon(models.Model):
id = models.AutoField(primary_key=True)
code = models.CharField(max_length=15)
amount = models.FloatField()

Expand All @@ -187,6 +195,7 @@ def __str__(self):


class Refund(models.Model):
id = models.AutoField(primary_key=True)
order = models.ForeignKey(Order, on_delete=models.CASCADE)
reason = models.TextField()
accepted = models.BooleanField(default=False)
Expand Down
2 changes: 1 addition & 1 deletion core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .forms import CheckoutForm, CouponForm, RefundForm
from .models import Item, OrderItem, Order, BillingAddress, Payment, Coupon, Refund, Category
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.shortcuts import render

# Create your views here.
import random
Expand Down
3 changes: 2 additions & 1 deletion demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'allauth.socialaccount.providers.google',
'crispy_forms',
'django_countries',
'core'
'core',
'crispy_bootstrap4'
]

MIDDLEWARE = [
Expand Down
Binary file modified requirements.txt
Binary file not shown.