Display Django Version

Posted: June 18th, 2010 | Author: Davo | Filed under: Django | Tags: | No Comments »

Ever wondered how to detect which version of Django you are actually running?
Well it is as simple as this:

>>> import django
>>> django.VERSION
(1, 2, 1, 'final', 0)
>>> django.get_version()
u'1.2.1 SVN-13348'
>>>

Use javascript, css in admin

Posted: June 2nd, 2010 | Author: Davo | Filed under: Django | Tags: , , , | 1 Comment »

Ever wanted to use your own JavaScript OR CSS inside the built in Django admin?
Well… it is possible!

All you need to do is the following:
1)
Add a admin.py (if you don’t already have yet…) for your app

from django.db import models
from django.contrib import admin

from myapp.hotels.models import Hotel

class HotelAdmin(admin.ModelAdmin):
    ...
    class Media:
        js = ("/media/javascript/yourjs.js",)

admin.site.register(Hotel, HotelAdmin)

2) Create a file yourjs.js under /media/javascript

(function($) {
    $(document).ready(function($) {
         // you can now use jquery / javascript here...
         alert('It worked.');
    });
})(django.jQuery);

3) Open the admin for your application and you should see the ‘It worked’ message.


Increment/Decrement Field value

Posted: May 26th, 2010 | Author: Davo | Filed under: Django | Tags: | No Comments »

Incrementing or decrementing field values can be done by using the F() function.
UPDATE FIELD = FIELD + 1 WHERE… ?

from django.db.models import F

# views.py ...
offer = Offer.objects.get(...)
# SQL: UPDATE field_to_increment = field_to_increment + 1 ...
offer.field_to_increment = F('field_to_increment') + 1
offer.save()

Django hosting

Posted: May 14th, 2010 | Author: Davo | Filed under: Django | No Comments »

After a month of hard work we are proud to announce that our new django hosting service is up and running!

Django Hosting
The main features include :

  • Live logs
  • manage.py
  • Money back guanrantee
  • Django version switcher
  • Your own domain name
  • 500Mb file storage
  • 100Mb database storage
  • Import code from SVN or GIT

Django Foo hosting


Django paypal sandbox

Posted: May 14th, 2010 | Author: Davo | Filed under: Django | Tags: | No Comments »

When using the django-paypal pluggable app there is not really a settings to specify if you want to interact with the sandbox or with the normal site.
To do this you need to call the the form like this

{{ form.sandbox }}

instead of

{{ form.render }}