Organizing Django unit tests

From version 1.6 of Django, the test discovery mechanism changed. You no longer need to import everything from tests/__init__.py, but now you have to make sure that all your files containing tests match the pattern test*.py. So, instead of having app/tests/models.py and app/tests/views.py, now you should have app/tests/test_models.py and app/tests/test_views.py. You could also create a … Read more

Django, SESSION_COOKIE_DOMAIN with multiple domains

If you set your session cookie domain to start with a “.” character it will let you handle wildcard sub-domains and share a session cookie (login session) across multiple subdomains. In settings.py: SESSION_COOKIE_DOMAIN=”.stackoverflow.com” The above would allow a cookie to be shared across user1.stackoverflow.com and user2.stackoverflow.com. If you really do want the url’s to be … Read more