Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
invalid literal for int() with base 10: '1,303'

I get get error invalid literal for int() with base 10: '1,303' and it shows the blow code at fault. The old data works fine, its just for new stuff i add to the database. Any ideas?

    def get(self, request, *args, **kwargs):
    cart = self.get_object()
    item_id = request.GET.get("item")
    delete_item = request.GET.get("delete", False)
    flash_message = ""
    item_added = False
    if item_id:
                    item_instance = get_object_or_404(Variation, id=item_id) ...
        qty = request.GET.get("qty", 1)
        try:
            if int(qty) < 1:
                delete_item = True
        except:
            raise Http404
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is why you should use django forms instead of pulling data direct off request.GET or request.POST. Django forms provide you with data validation which helps you avoid this kind of thing. The problem is the extra ',' in your supposed int.

int('1,303')

Will produce the error above. The following will not:

int('1,303'.replace(',',''))

So the obvious remedy then is to pass your int through such a filter.

item_instance = get_object_or_404(Variation, id=int(item_id.replace(',',''))
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!