Author Archives: Matthew Farver

Django Common App (Part 1)

Posted on by Matthew Farver

Here at Tivix we’ve created a number of open source apps that are available for use.

In this post we’re going to talk specifically about the django-common app, which provides functionality commonly needed in a django application (in case it wasn’t obvious).


WWWRedirectMiddleware

WWWRedirectMiddleware redirects requests to make sure they are on the www subdomain or off the www subdomain, depending on your settings.  Besides adding ‘django_common.middleware.WWWRedirectMiddleware‘ to MIDDLEWARE_CLASSES, you need to set DOMAIN_NAME in the settings, either with www or not.  You need to also set IS_PROD to true, as you don’t want to redirect on localhost.


SSLRedirectMiddleware and NoSSLRedirectMiddleware

SSLRedirectMiddleware redirects requests to make sure that they are under https.  NoSSLRedirectMiddleware makes sure they are under http.


ssl_required decorator

If you don’t need ssl across the entire site (you oftentimes don’t) you can simply use the ssl_required decorator on the specific view that requires https.


disable_for_loaddata decorator

This decorator is used to wrap signals instead of views.  It disables signals from being fired when the loaddata command is run.  See: https://code.djangoproject.com/ticket/8399


EmailBackend

The EmailBackend is an authentication backend that works like the default ‘django.contrib.auth.backends.ModelBackend‘ except it finds users by email instead of username.  To use it simply add ‘django_common.auth_backends.EmailBackend‘ to AUTHENTICATION_BACKENDS in the settings.

These are just a few features available in the django_common app.  Stay posted for more posts on the django_common app, but of course the best way to find out all the functionality is to check out the app itself!

Tagged , , | Leave a comment

Tivix

A full service boutique design and technology firm specializing in developing dynamic solutions which help organizations to engage consumers, and build relationships in unique, powerful new ways.

What We Do... why we're different!

We build high-engagement web, mobile, and social apps. We build them for startups, established brands, nonprofits, and organizations of all kinds. The Tivix team brings a unique combination of savvy designers, rock-solid engineers, and deep business experience.

Facebook