eventsourcing-django icon indicating copy to clipboard operation
eventsourcing-django copied to clipboard

Django configuration docs

Open zgelp opened this issue 1 year ago • 5 comments

Since I struggled a bit with configuring persistence in Django, I was considering submitting a pull request to improve the documentation for Django integration. I found that if you create an Application object directly in a view or other file in the Django app, the migrations may not be executed yet, which can cause issues. However, I think I figured out the correct way to set it up so that these issues can be avoided.

Let me know if you want PR about this.

zgelp avatar Feb 28 '23 17:02 zgelp

Hey @zgelp! Thanks for raising the issue. Yes it would be great to see what you're thinking about this. Please do submit a PR. I'm looking forward to talking about this with you.

johnbywater avatar Mar 01 '23 13:03 johnbywater

@bibz might also be interested in this :)

johnbywater avatar Mar 01 '23 13:03 johnbywater

Hey @johnbywater , I opened a #17 , I don't know if this is the proper and "Django" way of solving it, but it works on the CI/CD gitlab pipeline and test pass. Feel free to improve or comment how to improve it, if there's any.

zgelp avatar Mar 15 '23 23:03 zgelp

Thank you very much! I am away at the moment but will definitely get back about this soon. Django is being used on one project I am currently involved in, so I will also share what you have done there. Maybe @bibz has some thoughts about this too.

johnbywater avatar Mar 16 '23 01:03 johnbywater

Hey @zgelp,

We evolved from a home-grown message driven system to using eventsourcing and so we did things a bit differently. In short the initiation was tied to the WSGI configuration wsgi.py, with a manual instantiation needed for tests or in Django commands.

Could you not use the approach we use in the test suite here?

It's basically what you did in your PR but without calling migrate in app_ready. I fear that is not a Django best practice at all since running migrations should be a manual operation at the user's discretion.

Did you maybe forget to depend on ("eventsourcing_django, "0001_initial") in your Django app migration? (That is clearly a detail we could add to the documentation.)

bibz avatar Mar 20 '23 21:03 bibz