djangodjango-modelsdjango-commands

Creation of a django model instance not working on a custom management command


I'm trying to create a new instance of one of my Django models. When I do it in my python shell it works fine and the object is indeed created.

However, when I do it in one of my custom management commands' script using the exact same code, there is no error but the object is never created!!

Any ideas?


Solution

  • ok, solved it.

    I used a keyboard interrupt to exit the script, and I'm guessing the script needs to exit correctly in order to finish the db transaction. I let it exit on itself and the objects were created.