🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #15863

[Django] Forms

#15863
From: Piotr 'piter' Hlawski
Date: Fri, 23 Jun 2006 07:51
68 lines
2392 bytes
Witam,

Nie mam już siły. Czy ktoś mnie może oświecić czemu tak prosty przykład nie
działa:

from django.shortcuts import render_to_response
from soaw2.satysfakcja.models import Rekordy
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django import forms

def main(request):
    current = 'rekordy'

    manipulator = Rekordy.AddManipulator()

    # Tutaj całe jada-jada z dodawaniem rekordu

    form = FormWrapper(manipulator, data, errors)
    return render_to_response('rekordy.html', {'form': form, 'current':
current})



i Szablon:

<html>
<body>
    <form method="post" action="/dodaj">
    {{ form.kierunek }} {{ form.telefon }}
    <input type="submit" />
    </form>
</body>
</html>

A tutaj klasa Rekordy:

class Rekordy(models.Model):
    kierunek = models.IntegerField()
    telefon = models.IntegerField()
    doradca_tc = models.TextField()

    def __str__(self):
        return str(self.kierunek) + str(self.telefon)

    class Meta:
        db_table = 'rekordy'

    class Admin:
        pass


Czym się objawia nie działanie? Ano tym, że szablon kompletnie olewa
przekazany form

Zrobiłem w settings.py:

if DEBUG:
    TEMPLATE_STRING_IF_INVALID = ':empty variable:'

I widzę te :empty variable: za każdym razem jak przekazuje ten form do
szablonu. Czy ktoś mi może wyjaśnić co robię źle?

Django SVN revision 3195

-- 
.:: Piter // phlawski$gmail,com // gg: 4534287 ::.
Kiedy Chuck Norris wpada do wody, Chuck Norris nie robi się mokry. Woda robi
się Chuck Norrisowa.
Technical Details
Message-ID: <3426801.z3NH0pVyTe@zatoichi.homeunix.org>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
From: Piotr 'piter' Hlawski <phlawski@cut_this_crap.gmail.com>
Newsgroups: pl.comp.lang.python
Subject: [Django] Forms
Date: Fri, 23 Jun 2006 09:51:23 +0200
Organization: UAC
Lines: 69
Message-ID: <3426801.z3NH0pVyTe@zatoichi.homeunix.org>
NNTP-Posting-Host: gw202.internetdsl.tpnet.pl
Mime-Version: 1.0
X-Trace: atlantis.news.tpi.pl 1151049110 25533 80.53.74.202 (23 Jun 2006 07:51:50 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Fri, 23 Jun 2006 07:51:50 +0000 (UTC)
User-Agent: KNode/0.10.2
X-OS: FreeBSD 6.1-STABLE
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit