views:

26

answers:

1

So if I would have to create a Next Button (that links to the next url) AND saves a Timestamp in the database.

How would I create that html code for that?

and how the db?

What would I have to put into the button html code?

e.g.

<form id="form1" name="form1" method="post" action="">
  <label>Next
    <input type="submit" name="button2" id="button2" value="Submit" />
  </label>
</form>

???

Would a hidden form be useful here/standard usage?

And how would the the Database Field in the model to store the Timestamp have to look like?

timestamp = DateTimeField (auto_now or auto_now_add?)

And how would the view have to look like?

???

Thanks for the help.

A: 

I think it depends on whether you want to capture the time the user presses the button or the time that action is registered by the server.

If the latter is sufficient, you can just create the timestamp in the django view: You assign datetime.now() to a DateTimeField of your model in the view that corresponds to your form target. Then you return the next page.

pholz
And what if I want to know whene the user clicked it instead of when it was passed to the server?
MacPython
Then I would use jQuery's `submit()` event handler to calculate the timestamp as soon as the user clicks the button, and then send the form via jQuery's `$.post`
pholz