I am new to Django and server side scripting, but I'm trying to get a handle on how it all works.
Using some Django templates I successfully set up the simplest of simple pages:
from django.shortcuts import render
from django.http import HttpResponse
import sys
from django.http import HttpRequest
from django.template import RequestContext, loader
def index(request):
return HttpResponse("response")
# Create your views here.
What I'd like to know, and what I've been trying to do with to no avail is set it up somehow so that I can change the request. For example I'd like to be able to request "cat" and get response "cat".
For the life of me I can't figure out how to properly pass strings to the server as requests. I looked at the Django documentation for urls, but it doesn't appear that that's what I want.
When I go to http://localhost:8000/page/
I get "response". Let me explain what I've thought so far:
- It appeared briefly to me that the correct way to send a request to the server would be
http://localhost:8000/page/request
with "request" being the string I wanted to pass. However with the urls I could not find a way to prepare it to receive a string of any length. I couldn't find a way to capture this string and work with it, either. - Now I think I need to use some combination of HttpRequest and HttpResponse but can't figure it out. Any help?
Basically all I want to do is set it up so I can send a string to the server, play with it, and send it back.
OH, and the file above is views.py.
EDIT: It looks like I may be looking for a way to pass a "query_string" and then access it?