Latest Updates: django RSS

  • Articles

    Django tests fail on a new project

    Stii 12:16 am on October 16, 2009 | Comments: 4 Permalink | Reply
    Tags: django, , tdd, unittest

    This might be slightly confusing at first, but actually makes perfect sense if you think about it. If you have a brand new Django project and you run the tests it fails with a number of errors.

    # python manage.py test
    Creating test database...
    Creating table auth_permission
    Creating table auth_group
    Creating table auth_user
    Creating table auth_message
    Creating table django_content_type
    Creating table django_session
    Creating table django_site
    Installing index for auth.Permission model
    Installing index for auth.Message model
    EE..E...EEEEEEE..................
    ======================================================================
    ERROR: test_password_change_fails_with_invalid_old_password (django.contrib.auth.tests.views.ChangePasswordTest)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Library/Python/2.6/site-packages/django/contrib/auth/tests/views.py", line 156, in test_password_change_fails_with_invalid_old_password
        'new_password2': 'password1',
      File "/Library/Python/2.6/site-packages/django/test/client.py", line 313, in post
        response = self.request(**r)
      File "/Library/Python/2.6/site-packages/django/core/handlers/base.py", line 92, in get_response
        response = callback(request, *callback_args, **callback_kwargs)
      File "/Library/Python/2.6/site-packages/django/contrib/auth/decorators.py", line 78, in __call__
        return self.view_func(request, *args, **kwargs)
      File "/Library/Python/2.6/site-packages/django/contrib/auth/views.py", line 160, in password_change
        }, context_instance=RequestContext(request))
      File "/Library/Python/2.6/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
        return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
      File "/Library/Python/2.6/site-packages/django/template/loader.py", line 103, in render_to_string
        t = get_template(template_name)
      File "/Library/Python/2.6/site-packages/django/template/loader.py", line 81, in get_template
        source, origin = find_template_source(template_name)
      File "/Library/Python/2.6/site-packages/django/template/loader.py", line 74, in find_template_source
        raise TemplateDoesNotExist, name
    TemplateDoesNotExist: registration/password_change_form.html
    ...
    

    In total 10 tests failed. At first I thought this was wrong. There must be something wrong with my Django installation. I consulted the Django documentation on testing Django apps and all I could pick up was that when you run python manage.py test it runs the tests of all your INSTALLED_APPS in the settings.py file.

    After a bit of searching, I saw a ticket was created for this and was closed with a wontfix resolution. It made sense since it is test cases that was not implemented yet. Doh! Test Driven Development.

    I do think it could be useful if they added this to the Django docs as a note for n00bs like me.

    Welcome back! You should subscribe to my RSS feed here.
    You should follow me on Twitter here
    You should follow me on Gatorpeeps here.

    Save Cape Town City Ballet
     
  • Articles

    Call me anal, but I really like Django templates

    Stii 11:58 am on October 2, 2009 | Comments: 9 Permalink | Reply
    Tags: django, html, , ,

    For all the wrong reasons, but still! I just love the fact that it actually uses a .html extension. Am I weird? I do feel a bit weird that I like something so arb. So the template files use the extension of what it actually contains? Wow, I love that. Revolutionary. Don’t ask me why I just thought of that… I cannot answer that truthfully :P Feels like I’m being anal, since it doesn’t seem to matter to anyone else. Most other web development frameworks uses other file extensions. For example in PHP frameworks, the template files have a .php extension. Must be this glorious Rocktober day in Cape Town that is doing this to me!

    django-logo-positive

    Save Cape Town City Ballet
     
  • Articles

    Django with apache and mod_wsgi issues

    Stii 8:47 pm on April 14, 2009 | Comments: 1 Permalink | Reply
    Tags: , django, mod_wsgi,

    I ran into a fairly common error while setting up Django with mod_wsgi and Apache on Debian. What irritates me about it is that I didn’t pick it up right away, but I’ll blame the long Easter weekend for that. :P

    django-logo-positive

    ImportError: Could not import settings 'mysite.settings'
    (Is it on sys.path? Does it have syntax errors?):
    No module named mysite.settings
    

    My wsgi file looked like this:

    import os, sys
    sys.path.append('/home/djangoprojects/mysite/')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
    
    import django.core.handlers.wsgi
    
    _application = django.core.handlers.wsgi.WSGIHandler()
    
    def application(environ, start_response):
        if environ['wsgi.url_scheme'] == 'https':
            environ['HTTPS'] = 'on'
        return _application(environ, start_response)
    

    Like an idiot, I was looking everywhere for the issue, accept the glaring obvious reason. I checked permissions, created a .pth file for the project in the /site-packages/ directory in the Python library. Trust me, I did everything, but the obvious thing.

    See, here is that obvious reason:

    I append the directory “/home/djangoprojects/mysite” to my sys.path which is wrong. Python then looks for the module “mysite” in the directory /home/djangoprojects/mysite which in fact doesn’t exist. Obvious, no?

    To fix this problem, you need to append the directory “/home/djangoprojects/” to your sys.path and it will find the module mysite.settings no problem and it will run smooth.

    Long weekend, surf on the brain. That’s what is wrong!

    Save Cape Town City Ballet
     
  • Articles

    Back on Wordpress

    Stii 10:48 am on November 14, 2008 | Comments: 5 Permalink | Reply
    Tags: django, lifestyle,

    Okay, right, I feel bit stupid doing this, but due to some massive changes in my life the past couple of months I had to reconsider my priorities and get my ducks in a row. I have not been blogging in two months now, which is quite shocking! I started to feel like I’m neglecting something very important in my life… and I have!

    Wordpress Gone fishing

    Therefore, I’m putting my Django blog on the back-burner for now as I dearly love it, but at the same time I simply do not have time to tinker. I will tinker in future if and only if there is spare time. Of which there is none.

    I came to the realisation that it is much more important at the moment to write/blog than what it is to tinker with Django. Afrigator has become a very serious “project” all of a sudden, thus I cannot simply tinker as I feel anymore. I need to focus and need to communicate.

    Fortunately for me, I’m still very much busy with Python stuff on the Afrigator back-end, so I’m not COMPLETELY miffed about it! In fact, I’m loving it…

    Oh and if you wondered about the picture and where the hell it fits in with all this, forget about it… I just like the pic as I’m proud of my son’s catch. Not everything in life HAS to make sense now, does it?

    Save Cape Town City Ballet
     

About Me

Software developer at Afrigator.com Love Python, do PHP.
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
esc
cancel