[Answer]-Best-practice: django + python analytics

1đź‘Ť

It’s an important point to remember that Django apps are just python code at the end of the day, so if you want to have different virtual environments, you could create a separate python package and manually handle all of the DB work, either through SQLalchemy, something else, or raw dog. If there is code in the Django app you want, and you can just hack up your PYTHONPATH so it knows where your Django project lives. But, you would also need to know how manage.py works behind the scenes because inevitably your custom apps in the repo require settings to be loaded and all the other nice stuff that happens via manage.py.

So what to do? Well, I would just go along the lines of what the commentator above said, just create your analytics app as a new app in your Django repo. But first, you can easily clone the old repo and call it “analytics” and the new one whatever you were calling it. For your analytics app, adjust your requirements.txt, add your analytics app to it and then bam, you have your working analytics app with minimal effort and you still have the nice django orm if you want to use it. You can still have different virtualenvs, just don’t get confused about which one you are in, or you will be in a world of hurt and pain.

You can even get supper fancy and expose your analytics as a service through restful api calls if you wanted!

👤James R

Leave a comment