Recent Comments

Keeping Django Real Reference 1

Listing some quick info that I may forget later


  • Django Redirect a page


    from django.http import HttpResponseRedirect
    return HttpResponseRedirect(’/')

  • Django Check if user logged in

    if not request.user.is_authenticated():

  • Django Generic Views Template

    <ul>
    {% for object in object_list %}
        <li class="project">
            <h3 class="name">{{ object.name }}</h3>
        </li>
    {% endfor %}
    </ul>

  • Include another URL config file, but make the urls be appended to the base URL

    . For example, if I write a registration app and I want site.com/login and site.com/logout to exist, but want to define these urls from within the app

    (r”, include(’registration.urls’)),

    The trick is to make the first parameter an empty string

  • Serve static files only in debug mode from the internal web server

  • if settings.DEBUG:
        urlpatterns += patterns(”,
            (r’^media/(?P<path>.*)$’, ‘django.views.static.serve’, {’document_root’: ‘C:/media’}),
        )

     

  • Add a login/logout bar to your application

    A login bar should be done using a template tag, as it is the same across many pages, but changes state depending on the particular page

  • Django Login using email address

    Don’t waste your time trying to find a better solution. Use the EmailBackend from DjangoSnippets

blog comments powered by Disqus