0 errors found. Django version 1.1.1, using settings 'myproject.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. Development server
Models are high level object oriented interfaces for databases where the object schema is defined in model.py Forget about messes with “SELECT * FROM TABLE.. blah blah”
HttpResponse def index(request): def index(request): html = “<h1>Hello Web !</h1>” html = “<h1>Hello Web !</h1>” return HttpResponse(html) return HttpResponse(html) views.py
GET request request def process_get(request): def process_get(request): html = “Not a GET request” html = “Not a GET request” if request.GET.has_key('page_no'): if request.GET.has_key('page_no'): html = “You have requested %d” % html = “You have requested %d” % request.GET['page_no'] request.GET['page_no'] return HttpResponse(html) return HttpResponse(html) Other dictionary objects Other dictionary objects request.POST request.POST request.session request.session
<p> This is a sample page</p> <table> <tr><td>Student</td><td>Roll No</td></tr> {% for name,rollno in student_list.items() %} <tr> <td>{{ name }}</td> <td>{{ rollno }}</td> </tr> {% endfor %} </table> </body> </html>
'Slynux':34 } is static. We can use dynamic content from database from helloweb.student.models import StudentRegister slist = StudentRegister.objects.all() students = {} for s in slist: students[s.name] = s.rollno