Hi schwim,

Welcome to Django!  Glad to have you. ;-)

You probably receive the same page again because there were errors in
the form, most probably because you didn't include all the fields
required (as you suspect).  To see specifically what errors there
were, please refer to:

http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#customizing-the-form-template

It is usually wise to simply iterate through all fields (if you
require a custom form layout, otherwise you can just do ``{{ form }}``
or ``{{ form.as_* }}``) than to manually write up every field directly
in the HTML.  This means that all fields that exist in the form will
be exhausted and printed on the page.  Then you will only have to
change the form to make a change to the form's HTML if you add, change
or remove a field.

http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#looping-over-the-form-s-fields

Note that if you want to declare a ``pub_date`` without having to
enter the date explicitely in the form (having it default to when it
is updated or created), use ``auto_now`` or ``auto_now_add``.

http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield

Regards,
Friðrik Már

On Dec 21, 7:02 am, schwim <gsch...@gmail.com> wrote:
> OK, I'm a total newbie. I ran through the tutorial on the django site,
> and decided to extend the poll system a bit just to learn more.  I
> figured quite a bit out, but on this one I'm stuck.
>
> I want to provide a page at polls/new to add a new poll.  I'm trying
> to use the generic.create_update.create_object generic view to provide
> the form, which works, but when I submit the post, it doesn't follow
> the post_save_redirect I specify.  I think I know why, but first,
> here's my urlconf:
>
>      (r'^new/$', 'django.views.generic.create_update.create_object',
> dict({'model': Poll}, post_save_redirect="../")),
>
> I've no idea if that is right, but I stopped getting errors with it,
> and my template will display.  Here's the template I'm using:
>
>      <form method="post" action=".">
>      <p><label for="id_newpoll">New Poll:</label> {{ form.question }}
>      <input type="submit" />
>
> This generates the expected form. When I click submit, I get returned
> to the same page, no errors.  I'm pretty sure this is happening
> because I have NOT NULL in the pub_date field, and I'm trying to
> insert a new record without a date.  Makes sense to me, but how do I
> get there?  Like I said, I'm a total newbie to this - bash me if you
> want. ;)
>
> So, what am I doing wrong, and more important to the long term, how
> the heck do I debug something like this? I'm getting no errors.
>
> TIA
> schwim
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to