Saturday, March 13, 2010

Django Model Values as Dict

This is pretty easy to do but I always forget
obj_dict = MyModel.Objects.filter(id__gt=0).values()
And you can also add MyModel.objects.filter(id__gt=0).values_list('COLUMN',flat=True)

Friday, February 26, 2010

Hylafax 6.0 Debian Lenny T38modem 1.2.0 Asterisk 1.6

After fighting with t38modem for a week I finally found versions of opal and ptlib that work with t38modem 1.2 for sending faxes (have not tested receiving yet). ptlib-2.6.6 opal-3.6.7 t38modem-1.2.0 I am using most of the other instructions from this how to below. Hylafax 6.0 Debian (or Ubuntu) T38modem 1.0 Asterisk 1.6

Thursday, February 25, 2010

Debian Backports copy paste

echo 'deb http://www.backports.org/debian lenny-backports main contrib non-free' >> /etc/apt/sources.list
apt-get update && apt-get install debian-backports-keyring --force-yes && apt-get update
instructions [Debian Backports]: "deb http://www.backports.org/debian lenny-backports main contrib non-free"

Monday, February 15, 2010

Django | User authentication in Django | Django documentation

Django auth doesn't have all the urls listed anywhere so here they are:
    (r'^accounts/login/$', 'django.contrib.auth.views.login'),
    (r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
    (r'^accounts/password_change/$', 'django.contrib.auth.views.password_change'),
    (r'^accounts/password_change_done/$', 'django.contrib.auth.views.password_change_done'),
    (r'^accounts/password_reset/$', 'django.contrib.auth.views.password_reset'),
    (r'^accounts/accounts/password_reset/done/$', 'django.contrib.auth.views.password_reset_done'),
    (r'^accounts/reset/(?P[0-9A-Za-z]+)-(?P.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
    (r'^accounts/reset/done/$', 'django.contrib.auth.views.password_reset_complete'),  
Django | User authentication in Django | Django documentation

Friday, January 29, 2010

Django | Generic views | Django documentation

Took me forever to figure this out with generi views, but the I just don't read well. Here is an example template:
<p class=\"paginator\">
 <span class=\"step-links\">
  {% if page_obj.has_previous %}
   <a href=\"?page={{ page_obj.previous_page_number }}\"><</a>
  {% endif %}

  <span class=\"current\">
   Page <span class=\"this-page\">{{ page }}</span> of {{ paginator.num_pages }}
  </span>

  {% if page_obj.has_next %}
   <a href=\"?page={{ page_obj.next_page_number }}\">></a>
  {% endif %}
 </span>
</p>

"If the results are paginated, the context will contain these extra variables: paginator: An instance of django.core.paginator.Paginator. page_obj: An instance of django.core.paginator.Page." Django Generic views object_list:

Thursday, January 28, 2010

Dynamic Inlines Built into Django Admin in 1.2

So I was talking at a Django round table last night and talking about the fixes I did to the dynamic inlines for the admin. And someone mentioned that a)jquery is now included in Django 1.2 and b) dynmaic inlines are built in as well. /django/trunk/django/contrib/admin/media/js/inlines.js

Sunday, January 24, 2010

Friday, January 22, 2010

Django snippets: jQuery Double Click Edit ManyToMany in Admin

Take a look at my code on django snippets. Just drop this into your templates/admin/change_form.html and any select for a foreign key or many to many will allow a double click to pop up and edit

Django snippets: jQuery Double Click Edit ManyToMany in Admin