[Answer]-Django Test Creating Forms with New IDs

1👍

I would look into using text fixtures rather than creating and deleting the data every time. This is pretty easy to do in Django. In your tests.py it would look something like this

class BlogTest(TestCase):
    fixtures = ['core/fixtures/test.json']

When you do this django will build you a test database, load the fixture into it, run your tests, and then blow away the database after the tests are done. If you want to even use a different database engine (we do this to have our tests use sqlite because it is fast) you can throw something like this into your settings.py

This will make it so the ID’s are the same every single time which would fix your problem.

Leave a comment