A fair bit of this is Javascript, which, strictly speaking, is outside the
scope of Django.

>From what you're saying, it sounds like your button does two things: make a
backend database change and make a frontend display change. Ultimately, the
action starts with a Javascript event handler. On button click, do work.

On the Django side, you want a view that will capture the change. There's
more than a few ways to do this, but if you're just talking about a
one-and-done like this and you don't want a bunch of extra libraries, I'd
make a simple, dedicated view that takes whatever parameters you need to
specify the correct boolean field on POST and returns a JSON response to
the effect of {success: [true|false], reason: 'failure reason, if any'}.
Don't forget to update your urls.py to reflect the new view.

On the Javascript side, in the registered function, you write code that
both posts to your Django view in an Ajax call and, if successful, makes
the display change.

On Wed, Jul 22, 2015 at 5:35 PM, Jake Rudolph <jidrudo...@gmail.com> wrote:

> I am trying to make a button on the index page that changes the boolean
> field of my object, and then displays that object in a different place on
> the page. I am not sure what to put as the action for this button, and
> where to put and call the function that will actually change the value in
> the database.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/564ecb34-8176-474a-8175-eb1c5b134522%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/564ecb34-8176-474a-8175-eb1c5b134522%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bv0ZYVrTGogQ8vd4eY9NcCy2Xn0KskAcybNJSTSZLEpr0j-FA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to