views:

38

answers:

2

I have been working on forms only recently and I am still puzzeld by them.

What I want are standard Forms:

  1. Next Button

  2. Submit Data to Db

  3. Timestamp

  4. Clickable Images with Regions defined where when I click I get to the next page

And

I would like to combine these.

E.g. have a next button + Record the Timestamp. or E.g. Click into an Image + Next + Timestamp

If anybody could give me some examples for code that can achieve that or a good online resource on where to get info on that, that would be awesome.

Thanks for the time!!

A: 

This really isn't a question, I'm not exactly sure what you're trying to accomplish.

If you want to use Django forms, start here, or here.

I assume the stuff you mention about a timestamp should probably be an auto_now field in a model. Take a look at this.

The stuff you mention about buttons and click-able images is really just HTML and has nothing to do with Django. I would try Google for that.

Matthew J Morrison
A: 

I'm a little unclear about what you're trying to accomplish, but if you're trying to move data from an HTML form to the database, I'd suggest looking at how to use ModelForms. In a nutshell, you create a model class, like this:

class MyModel(models.Model):
    field1 = models.CharField(max_length=50)

Then you create a ModelForm class that references that model:

class MyModelForm(forms.ModelForm):
    class Meta:
        model = MyModel

You can render an instance of MyModelForm in a view function. Inside of a POST request in that view, you bind the POST data to the form, validate it, and call save() on it to commit it to the database:

if request.method == 'POST':
    form = MyModelForm(request.POST)
    if form.is_valid():
        model_instance = form.save()
Jim McGaw
Exactly what I was looking for. Thank you so much for that. I will try to implement that immediately!!
MacPython