On Oct 6, 1:33 pm, KillaBee <[EMAIL PROTECTED]>
wrote:
> On Oct 6, 1:29 pm, KillaBee <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > On Oct 6, 3:40 am, Daniel Roseman <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Oct 6, 5:48 am, KillaBee <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > I have been trying to add date to my template, but for the life of me
> > > > have not.
>
> > > > I have a field in the MYSQL db, and In my models class but when I put
> > > > the text box it doesn't post to the db.  No field does. And the
> > > > calendar does show anything to debug.
>
> > > > <h1>{{ poll.question }}</h1>Time Sheet
>
> > > > {% if error_message %}<p><strong>{{ error_message }}</strong></p>{%
> > > > endif %}
>
> > > > <table class="cal_month_calendar">
>
> > > > <tr>
>
> > > > {% for day in headers %}
>
> > > > <th>{{ day|date:"D"|slice:":2" }}</hd>
>
> > > > {% endfor %}
>
> > > > </tr>
>
> > > > {% for week in calendar %}
>
> > > > <tr>
>
> > > > {% for day in week %}
>
> > > > <td{% if not day.in_month %} class="cal_not_in_month"{% endif %}>{% if
> > > > day.event %}<a href="/calendar/{{ day.day|date:"Y/m" }}/">{{ day.day|
> > > > date:"j" }}</a>{% else %}{{ day.day|date:"j" }}{% endif %}</td>
>
> > > > {% endfor %}
>
> > > > </tr>
>
> > > > {% endfor %}
>
> > > > </table>
>
> > > > <form action="/timesheets/{{ poll.id }}/vote/" method="post">
>
> > > >   {% for choice in poll.choice_set.all %}
>
> > > >   <label for="choice{{ forloop.counter }}"></label>
>
> > > >   Worked
>
> > > >   <input type="radio" name="choice" value="choice">
>
> > > >   Fedtime
>
> > > >   <input name="fedtime" type="text" id="fedtime">
>
> > > >   <select name="select">
>
> > > >   </select>
>
> > > >   <input type="text" name="textfield">
>
> > > >   <br />
>
> > > > {% endfor %}
>
> > > > <input type="submit" value="submit time" />
>
> > > > </form>
>
> > > > <p>
>
> > > >   <label for="choice{{ forloop.counter }}">{{ choice.choice }}</label>
>
> > > > </p>
>
> > > There's not *nearly* enough information here to even begin answering
> > > the question.
>
> > > Where's your view code? And your models? Please post them somewhere
> > > like dpaste.com so we can actually read them.
> > > What date field are you referring to - is it fedtime? Tell us, rather
> > > than expecting us to guess.
>
> > > Why aren't you using Django's form handling, rather than defining the
> > > fields yourself in HTML?
> > > The way the code is at the moment, you will have multiple input fields
> > > with exactly the same names - choice and fedtime. Is this really what
> > > you want?
> > > --
> > > DR.
>
> > I didn't know about dpaste.com thanks.  I am a newbie and I am getting
> > to the making new fields part and posting data from forms.
>
> >http://dpaste.com/82752/view.py
>
> >http://dpaste.com/82753/models.py
>
> >http://dpaste.com/82755/detail.html
>
> just read the 2nd part.  I want django to take care of it but I don't
> know how to use the forms handler.  I can call it but when I comes to
> using it I am don't know.  All I want is a form posting to  a MYsql db.


Thanks I have read the forms doc. and it helped a great deal.
now I am get this error:'QueryDict' object has no attribute 'method'
at line 12.

view:
from django.http import HttpResponse
from intranet.timesheets.models import Poll
from intranet.timesheets.models import Choice
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
from django.contrib.auth import views
from django.contrib import databrowse
from django.contrib import auth
#from django.contrib.databrowse.plugins.calendars import
CalendarPlugin

def timesheet(request):
    if request.method == 'POST': # If the form has been
submitted..........................
        form = timesheet(request.POST) # A form bound to the POST data
        if form.is_valid(): # All validation rules pass
            # Process the data in form.cleaned_data
            user = form.cleaned_data['user']
            fedtime = form.cleaned_data['fedtime']
            date = form.cleaned_data['date']
            worked = form.cleaned_data['worked']
        else:
            return render_to_response('timesheet.html', {'form':
form, })

    else:
        form = timesheet(request.POST) # An unbound form

        return render_to_response('timesheet.html', {'form': form,
    })

mod:

class timesheet(forms.Form):
    user = forms.CharField()
    fedtime = forms.IntegerField()
    date = forms.DateField()
    worked = forms.CharField()

class Timesheet(models.Model):
    user = models.CharField(max_length=3, blank=True)
    fedtime = models.DecimalField(null=True, max_digits=11,
decimal_places=0, blank=True)
    date = models.DateField(null=True, blank=True)
    worked = models.CharField(max_length=3, blank=True)
    class Meta:
        db_table = u'timesheet'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to