Category: Python


To get previous month – python

$python
>>> from dateutil.relativedelta import *
>>> import datetime
>>> one_month_ago = datetime.datetime.now() - relativedelta(months=1)
>>> one_month_ago
datetime.datetime(2013, 10, 18, 13, 47, 13, 110467)
>>> previous_month = one_month_ago.strftime("%B") 
>>> previous_month
'October'  
Advertisements

comment the following line in settings.py
‘django.middleware.csrf.CsrfViewMiddleware’,

add this in urls.py

(r’^AddressBook/Update/(?P<addressbook_id>\d+)/’, ‘djtest.AddressBook.views.update’),

detail.html should be like this
<a href=”../../Index/”>Go Back</a><br>
<table>
<tr><td>ID</td><td>{{detail_data.id}}</td></tr> <form action=”/Index/New/” method=”post”>
<table>
<tr><td>FirstName</td><td>{{detail_data.firstname}}</td></tr>
<tr><td>LastName</td><td>{{detail_data.lastname}}</td></tr>
<tr><td>Phone</td><td>{{detail_data.phone}}</td></tr>
<tr><td>Address</td><td>{{detail_data.address}}</td></tr>
<tr><td>Date</td><td>{{detail_data.mod_date}}</td></tr>
</table>
</form>

Hi,

Go through the following link for a sample Django project.

http://xxki.com/tutorial/pukiwiki.php?Python%2FDjango%20-%20Sample%20Project

It has some issues i had experience with it and solved that if you can find and solve it and share your experience here.. Otherwise see my post https://suji25.wordpress.com/2013/03/15/solution-for-simple-sample-django-project/

Installing Django on Ubuntu

First, download Django-1.1.tar.gz.  Then:

tar xzvf Django-1.1.tar.gz
cd Django-1.1
sudo python setup.py install

Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.

If you like to learn python first go through the book  byte of python, you can get this book from here