Saturday, December 8, 2007

Djhango newform

A simple tutorial about basic newform

#create a form


from django import newforms as forms

class LoginForm(forms.Form):
email = forms.CharField()
password = forms.CharField()



# Create a view and make it accessible from the url.py:

# Create your views here.
from django.http import HttpResponse
from django.utils.html import escape
from django.shortcuts import render_to_response
from elearning.modules.login.loginform import LoginForm
from elearning.modules.models import Teacher
from django.http import HttpResponseRedirect
from django import http
#from django.core.exceptions import DoesNotExist
def gotoIndex(form):
return render_to_response('index.html', {'form': form})


def login(request):
r=HttpResponse()
loginform=LoginForm(request.POST)
if loginform.is_valid():

try:
#r.write("'"+str(loginform['email'])+"'")
login=Teacher.objects.get(email=loginform.data['email'])
#login=Teacher.objects.get(email="himu11@yahoo.com")
r.write(login.password)
# Check whether UserName and password mathc
except Teacher.DoesNotExist:
return gotoIndex(loginform)


if login.password !=loginform.data['password']:
return gotoIndex(loginform)

return HttpResponseRedirect('/modules/loginsuccess')


def loginsuccess(request):
return render_to_response('TeacherAdmin.html')



# Now write html:

Sunday, December 2, 2007

django simplified

1. Download django trunk

2. Run:

#django_admin. py startproject projectname

# cd projectname

# python manage.py startapp appname

dont give too much though about project and app. At the the end of the they are just a python package

Tuesday, October 9, 2007

apache-ssl 1.3 problem

mod_unique_id: unable to gethostbyname



In freebsd, edit /etc/hosts file with your hostname/IP entry,

like,

213.23.222.45 domain domain

Sunday, October 7, 2007

Freebsd java, ant

1. install diablo-caffe-freebsd6-i386-1.5.0_07-b01.tar.bz2
2. install apache-ant 1.7

Monday, September 24, 2007

Some commands you might need often

# nohup

#ls -t

#lsof

#libtool

Which CGI is the best?

----------Java/python/perl/php

Java is so far the best choice coupled with Struts, eclipse/Jsp.
Why? One reason, without any template engine you can
still orgainze the large sized JSP.

Tuesday, January 30, 2007

Debian/ubuntu Setting up perl, postgres, apache 5 mins:

Steps:

1. apt-get install apache
2. apt-get install perl
3. apt-get install postgresql
4. apt-get install libapache-mod-perl
5. apt-get install libdbi-perl
6. apt-get install libdbd-pg-perl