ROOT_URLCONF Error When Creating a Django Project From a Template

Django has a nifty feature that lets you create an entire project from a template. For example, check out the Two Scoops template. The biggest problem with this approach is its difficult to debug.

I was getting a ROOT_URLCONF error when running startproject. Turns out the source of this error was I accidentally put a url tag in a template using the normal Django syntax:

<a href="{% url 'account_logout'  %}">Log Out</a>

However, since the template is really a template of a template, I should have done this:

<a href="{% templatetag openblock %} url 'account_logout' {% templatetag closeblock %}">Log Out</a>

Evidently the system was trying to resolve the URL, which is why it needed ROOT_URLCONF.

 

Advertisements

Django: Login Using Email and the AllAuth Package

I just started using Django-AllAuth. I chose it because it supports “normal” login as well as Oauth based login.

For “normal” login, I have switched to using email address as the username. In general, people do not like having to think up a username and they do not remember it. Email is already unique and easier to remember because the user uses it all the time.

AllAuth says it can do email based logins. But how? Turns out its just a setting:

ACCOUNT_AUTHENTICATION_METHOD  = “email”

fabric, local and virtualenvwrapper

Fabric is a great tool for running system commands on a remote machine. It also has functionality for running commands locally. If all you needed to do is run local commands, then there probably are better options.

Since I needed to do both, I thought one fabfile with local and remote commands would be simplest. Unfortunately the “local” command and virtualenvwrapper do not play well together. Here is the magic to get them to work together:

local('source /usr/local/bin/virtualenvwrapper.sh && mkvirtualenv my_env', shell='/bin/bash')

Also, it is important to note that with fabric, the “local” command is not just a local version of the “run” command. The context manager (prefix) does not work with “local”. Neither does the “cd” command (use lcd).

I suppose I should also mention that you should not run this fabfile from inside a virtualenv. mkvirtulenv changes the virtualenv which leads to errors like:

/home/me/.virtualenvs/meta/bin/python: No module named virtualenvwrapper