When I am running python manage.py make migrate there is an overflow error so which is causing an error
When I am running python manage.py makemigrations it worked but when I am running python manage.py migrate it is raising an overflow error
# from email.policy import default
# from pyexpat import model
from django.db import models
# from unicodedata import decimal
from shortuuid.django_fields import ShortUUIDField
from django.utils.html import mark_safe
from userauths.models import CustomUser
STATUS_CHOICE=(
("process","Processing"),
("shipped","Shipped"),
("delevered","Delevered"),
)
STATUS=(
("draft","Draft"),
("disable","Disable"),
("rejected","Rejected"),
("In_review","In Review"),
("published","Published"),
)
RATING=(
(1,"⭐☆☆☆☆"),
(2,"⭐⭐☆☆☆"),
(3,"⭐⭐⭐☆☆"),
(4,"⭐⭐⭐⭐☆"),
(5,"⭐⭐⭐⭐⭐"),
)
# Create your models here.
def user_directory_path(instance,filename):
return 'user_{0}/{1}'.format(instance.user.id, filename)
class Category(models.Model):
cid=ShortUUIDField(length=10,max_length=100,prefix="cat",alphabet="abcdef")
title=models.CharField(max_length=100,default="Food")
image=models.ImageField(upload_to="category",default="category.jpg")
class Meta:
verbose_name_plural="Categories"
def catagory_image(self):
return mark_safe('<img src="%s" width="50" height="50"/>'%(self.image.url))
def __str__(self):
return self.title
class Tags(models.Model):
pass
class Vendor(models.Model):
vid=ShortUUIDField(length=10,max_length=100,prefix="ven",alphabet="abcdef")
title=models.CharField(max_length=100,default="Nest")
image=models.ImageField(upload_to=user_directory_path,default="vendor.jpg")
description=models.TextField(null=True, blank=True,default="Normal Vendorco")
address=models.CharField(max_length=100, default="6,Dum Dum Road")
contact=models.CharField(max_length=100, default="+91")
chat_resp_time=models.CharField(max_length=100,default="100")
shipping_on_time=models.CharField(max_length=100,default="100")
authenticate_rating=models.CharField(max_length=100,default="100")
days_return=models.CharField(max_length=100,default="100")
warranty_period=models.CharField(max_length=100,default="100")
user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True)
class Meta:
verbose_name_plural="Vendors"
def Vendor_image(self):
return mark_safe('<img src="%s" width="50" height="50"/>'%(self.image.url))
def __str__(self):
return self.title
class Product(models.Model):
pid=ShortUUIDField(length=10,max_length=100,prefix="prd",alphabet="abcdef")
user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True)
cagtegory=models.ForeignKey(Category, on_delete=models.SET_NULL ,null=True)
title=models.CharField(max_length=100,default="Apple")
image=models.ImageField(upload_to=user_directory_path,default="product.jpg")
description=models.TextField(null=True, blank=True,default="This is a product")
price = models.DecimalField(max_digits=10, decimal_places=2, default=1.99)
old_price = models.DecimalField(max_digits=10, decimal_places=2, default=2.99)
specifications=models.TextField(null=True, blank=True)
tags=models.ForeignKey(Tags, on_delete=models.SET_NULL ,null=True)
product_status=models.CharField(choices=STATUS, max_length=10,default="In_review")
status=models.BooleanField(default=True)
in_stock=models.BooleanField(default=True)
featured=models.BooleanField(default=False)
digital=models.BooleanField(default=False)
sku=ShortUUIDField(length=10,max_length=100,prefix="sku",alphabet="abcdef")
date=models.DateTimeField(auto_now_add=True)
updated=models.DateTimeField(null=True,blank=True)
class Meta:
verbose_name_plural="Products"
def product_image(self):
return mark_safe('<img src="%s" width="50" height="50"/>'%(self.image.url))
def __str__(self):
return self.title
def get_percentage(self):
new_price=(self.price/self.old_price) * 100
return new_price
class ProductImages(models.Model):
images=models.ImageField(upload_to="product-image",default="product.jpg")
product=models.ForeignKey(Product, on_delete=models.SET_NULL ,null=True)
date=models.DateTimeField(auto_now_add=True)
class Meta:
verbose_name_plural="Product Images"
######################################################Care,Order,CartItemsand Address###########################
class CartOrder(models.Model):
user=models.ForeignKey(CustomUser,on_delete=models.CASCADE)
price= models.DecimalField(max_digits=10, decimal_places=2,default="1.99")
paid_status=models.BooleanField(default=False)
order_date=models.DateTimeField(auto_now_add=True)
product_status=models.CharField(choices=STATUS_CHOICE, max_length=30,default="prodcessing")
class Meta:
verbose_name_plural="Cart Order"
class CartOrderItems(models.Model):
order=models.ForeignKey(CartOrder,on_delete=models.CASCADE)
invoice_num = models.BigIntegerField(blank=True,null=True)
product_status=models.CharField(max_length=200)
item=models.CharField(max_length=100)
image=models.CharField(max_length=100)
qty=models.BigIntegerField(default=0)
price= models.DecimalField(max_digits=12, decimal_places=2,default="15")
total= models.DecimalField(max_digits=12, decimal_places=2,default="20")
class Meta:
verbose_name_plural="Cart Order Items"
def oder_img(self):
return mark_safe('<img src="/media/%s" width="50" height="50"/>'%(self.image))
###########################Product Revew, wishlist, Address############################################
class ProductReview(models.Model):
user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True)
product=models.ForeignKey(Product, on_delete=models.SET_NULL ,null=True)
review=models.TextField()
rating = models.BigIntegerField(choices=RATING, default=3)
date=models.DateTimeField(auto_now_add=True)
class Meta:
verbose_name_plural="Product Reviews"
def __str__(self):
return self.product.title
def get_rating(self):
return self.rating
class wishlist(models.Model):
user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True)
product=models.ForeignKey(Product, on_delete=models.SET_NULL ,null=True)
date=models.DateTimeField(auto_now_add=True)
class Meta:
verbose_name_plural="wishlists"
def __str__(self):
return self.product.title
class Address(models.Model):
user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True)
address=models.CharField(max_length=100, null=True)
status=models.BooleanField(default=False)
class Meta:
verbose_name_plural="Address"
so I am getting this error
System check identified some issues:
WARNINGS:
?: (urls.W005) URL namespace 'userauths' isn't unique. You may not be able to reverse all URLs in this namespace
Operations to perform:
Apply all migrations: admin, auth, contenttypes, core, sessions
Running migrations:
Applying core.0002_category_tags_alter_product_options_and_more...Traceback (most recent call last):
File "C:\Users\Sagarmoy Sadhukhan\Desktop\django ecom web\ecomprj\manage.py", line 22, in <module>
main()
File "C:\Users\Sagarmoy Sadhukhan\Desktop\django ecom web\ecomprj\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
utility.execute()
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\core\management\commands\migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\migration.py", line 132, in apply
operation.database_forwards(
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\migrations\operations\fields.py", line 108, in database_forwards
schema_editor.add_field(
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\sqlite3\schema.py", line 316, in add_field
self._remake_table(model, create_field=field)
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\sqlite3\schema.py", line 145, in _remake_table
self.effective_default(create_field)
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\base\schema.py", line 463, in effective_default
return field.get_db_prep_save(self._effective_default(field), self.connection)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\models\fields\__init__.py", line 1818, in get_db_prep_save
return connection.ops.adapt_decimalfield_value(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\base\operations.py", line 584, in adapt_decimalfield_value
return utils.format_number(value, max_digits, decimal_places)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sagarmoy Sadhukhan\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\db\backends\utils.py", line 322, in format_number
context.prec = max_digits
^^^^^^^^^^^^
OverflowError: Python int too large to convert to C ssize_t
Please check my code. This is models in django... 1st code is in models.py and seccond code is in admin.py Is something is wrong in the classes?