How can i add one point to user after to press the button?

20 views
Skip to first unread message

Mike Ru

unread,
Apr 20, 2017, 3:18:24 PM4/20/17
to Django users
I have Model.
class UserProfile(models.Model):
    user = models.OneToOneField(User, related_name='userprofile')
    points = models.IntegerField(default=0)
    city = models.CharField(max_length=30, blank=True)
    about = models.TextField(blank=True)
    avatar = models.ImageField(upload_to='avatars/', verbose_name='Изображения', blank=True)

For example, if the user(authenticated) presses the button in an HTML file he wiil add one point.
How can I do it?

ludovic coues

unread,
Apr 21, 2017, 2:58:31 PM4/21/17
to django...@googlegroups.com
You can use ajax to create a request to a view that will add one point
when the user click on the button.
You can put the button in an iframe, make the iframe go to a view that
will add one point and display the button.
You can make the user go to a view that will add one point then go
back to the previous page.
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/97ba4189-7d02-4d8d-9be9-7e93ea52a2fb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Ludovic Coues
+33 6 14 87 43 42
Reply all
Reply to author
Forward
0 new messages