Skip to content Skip to sidebar Skip to footer

Django Save Error

for *** : try: xx = A( a=x, b=y ) xx.save() except: pass here is my question: once one of the 'xx' saved error, others will not

Solution 1:

You catch every exception with this statement:

except:
   pass

GeneratorExit is just an exception. This should not be caught. Please catch only the exceptions, you expect.

Solution 2:

You shouldn't catch GeneratorExit. If you want to catch all exceptions inherited from Exception rather then from BaseException you should change your code for:

for *** :
   try:
       xx = A(
          a=x,
          b=y
       )
       xx.save()
   except Exception:
     pass

Post a Comment for "Django Save Error"