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

django migrate error #5

Open
Roddy1219 opened this issue May 21, 2018 · 12 comments
Open

django migrate error #5

Roddy1219 opened this issue May 21, 2018 · 12 comments

Comments

@Roddy1219
Copy link

Roddy1219 commented May 21, 2018

  • Django version: 1.11.2
  • Python version: 3.5
  • Operating System: windows

Description

migrate error
django.db.utils.InternalError: (1426, "Too big precision 100 specified for 'amount'. Maximum is 65.")

Please update code。

@delneg
Copy link
Collaborator

delneg commented May 21, 2018

Hello,
That most likely happens because of DecimalField max_digits
I'll look into it soon

@Roddy1219
Copy link
Author

@delneg change models.py and migrations file ,Thx

@Roddy1219
Copy link
Author

Roddy1219 commented May 21, 2018

Hello ,My page display "the JSON object must be str, not 'bytes'" ,My python version is python 3.5
Change coinpayments.py 64 line to
"return json.loads((response_body.decode(response.info().get_param('charset') or 'utf-8')))" is ok!

@delneg
Copy link
Collaborator

delneg commented May 22, 2018

Hello, i've fixed the initial problem in 200707a

@delneg
Copy link
Collaborator

delneg commented May 22, 2018

Could you please provide additional info on the problem with 'str' no 'bytes', which object does it fail to load?

@krischal
Copy link

krischal commented Jun 18, 2018

Everything worked fine but can u guide me how can i use IPN in this project. After the amount is sent the the address i want my database to be updated from pending to completed. How can i use IPN?

@delneg
Copy link
Collaborator

delneg commented Jun 18, 2018

At this time, IPN is not available. It would be great if someone contributed it, though.
Currently, you have to use tasks/refresh_tx_info periodically

@innocentikart
Copy link

Have got this error when i try to migrate using mysql
below is my code
class Cart(models.Model): user = models.ForeignKey(User, null=True, blank=True) products = models.ManyToManyField(Product, blank=True) subtotal = models.DecimalField(default=0.00, max_digits=100, decimal_places=2) total = models.DecimalField(default=0.00, max_digits=100, decimal_places=2) updated = models.DateTimeField(auto_now=True) timestamp = models.DateTimeField(auto_now_add=True)

_mysql.connection.query(self, query)

django.db.utils.OperationalError: (1426, "Too-big precision 100 specified for 'total'. Maximum is 65.")

@delneg
Copy link
Collaborator

delneg commented Dec 12, 2018

Fill fix that now

@delneg
Copy link
Collaborator

delneg commented Dec 12, 2018

Looks like we've already fixed it but if forgot to roll it on PyPi.
Issued a new release 0.1.3

@innocentikart
Copy link

Fill fix that now

In respect to that,i have change the max_digits... it doesn't work still.

@innocentikart
Copy link

This is the whole thing... It was working just fine when i was using sqlite3. I'm working on this project using django version 1.11, python version 3.6 to build an ecommerce site. i got stocked in the cart where products do not show in the cart but there are created in the admin. well this is the two files responsible for my cart... So i thought, if i migrate my database to mysql, that would work. then i had this error.

_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1426, "Too-big precision 100 specified for 'total'. Maximum is 65.")

==my cart model==
class Cart(models.Model):
user = models.ForeignKey(User, null=True, blank=True)
products = models.ManyToManyField(Product, blank=True)
subtotal = models.DecimalField(default=0.00, max_digits=100, decimal_places=2)
total = models.DecimalField(default=0.00, max_digits=100, decimal_places=2)
updated = models.DateTimeField(auto_now=True)
timestamp = models.DateTimeField(auto_now_add=True)

===models.py===
`def m2m_changed_cart_receiver(sender, instance, action, *args, **kwargs):
if action == 'post_add' or action =='post_remove' or action == 'post_clear':
products = instance.products.all()
total = 0
for x in products:
total += x.price
if instance.subtotal != total:
instance.subtotal = total
instance.save()

m2m_changed.connect(m2m_changed_cart_receiver, sender=Cart.products.through)

def pre_save_cart_receiver(sender, instance, *args, **kwargs):
if instance.subtotal > 0:
instance.total = instance.subtotal + 10
else:
instance.total = 0.00

pre_save.connect(pre_save_cart_receiver, sender=Cart)`

===view.py===
`def cart_home(request):
cart_obj, new_obj = Cart.objects.new_or_get(request)
return render(request, "carts/home.html", {"cart": cart_obj})

def cart_update(request):
product_id = request.POST.get('product_id')
if product_id is not None:
try:
product_obj = Product.objects.get(id=product_id)
except Product.DoesNotExist:
return redirect("cart:home")
cart_obj, new_obj = Cart.objects.new_or_get(request)
if product_obj in cart_obj.products.all():
cart_obj.products.remove(product_obj)
else:
cart_obj.products.add(product_obj)
#return redirect(product_obj.get_absolute_url())
return redirect("cart:home")`

@delneg
Copy link
Collaborator

delneg commented Dec 13, 2018

Seems like you have subtotal & total with 100 max_digits in cart
Also, are you using version 0.1.3 of this package (you can check it using pip freeze

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants