Beispiel #1
0
def edit(request, title):
    """Process submitted page edits (POST) or display editing form (GET)"""
    if request.POST:
        try:
            page = Wikipage.objects.get(title__exact=title)
        except Wikipage.DoesNotExist:
            # Must be a new one; let's create it
            page = Wikipage(title=title)
        page.content = request.POST['content']
        page.title = request.POST['title']
        page.save()
        return HttpResponseRedirect("/wiki/" + page.title + "/")
    else:
        try:
            page = Wikipage.objects.get(title__exact=title)
        except Wikipage.DoesNotExist:
            # create a dummy page object -- note that it is not saved!
            page = Wikipage(title=title)
            page.body = "<!-- Enter content here -->"
        return render_to_response('edit.html', locals())
from mysite.wiki.models import Wikipage

data=Wikipage(title="HelloWorld", content="This is the famous Hello World!!!")
data.save()