Posts

Showing posts with the label note

A few notes when upgrading my Django project to v1.7 from v1.5

Here are something I want to take notes when upgrading my project to the latest version of Django, v1.7 from v1.5. 1. Model Form and Model Formset: I have to explicitly declare which fields of the model I want to include in or exclude from the form. For example: # all fields of the model class MyForm(ModelForm): class Meta: model = MyModel fields = '__all__' # some fields only class MyForm(ModelForm): class Meta: model = MyModel fields = ('first_field', 'second_field') # or exclude these fields class PtcPeriodForm(ModelForm): class Meta: model = PtcPeriod exclude = ('third_field', 'fourth_field') # formset MyFormSetBase = modelformset_factory( MyModel, extra=0, fields = ('first_field','second_field') ) # inline formset MyInlineFormSetBase = inlineformset_factory( MyModel, MySubModel, can_delete=True, fields=('some_field', 'another_field') ) 2. Default te...

Pseudo-interactive shell using paramiko python module

Just taking note a very interesting example in using paramiko of Jesse Noller (http://jessenoller.com/blog/2009/02/05/ssh-programming-with-paramiko-completely-different)

Notes: comment HTML code in Django Template

Just a small note. When using Django 1.1.1 ,   do not just comment out the HTML blocks in Template, completely delete them or It will raise error (e.g template syntax error, reverse ...). Because of the template parser of Django won't ignore the commentd blocks (<!-- ... -->), so everything in there will be proceeded. Trinh