Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
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
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

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(',',''))
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda