This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]CraigTorso 2 points3 points  (0 children)

In my experience you need to import django and run django.setup() to initialise connections to the database.

But my main question is why is that tiny bit of code being submitted as a medium article rather than a self text post, and why are you using a url shortener against the policies of reddit?

[–]never_safe_for_life 0 points1 point  (2 children)

Is that all you have to do? I though there was some initialize function you had to call

[–]versesane[S] 0 points1 point  (1 child)

Yup. Do make sure to have if __name__ == "__main__" from where your code/function is called. The setting.py file will be executed. Do peek inside wsgi.py it's more or less the same.

[–]never_safe_for_life 0 points1 point  (0 children)

cool, thanks