N
N
nurzhannogerbek2017-03-20 13:06:35
Django
nurzhannogerbek, 2017-03-20 13:06:35

Is it possible to update a list using Django Channels?

There is a Project model with a members field. The list of participants with their roles in the project is displayed on a separate page. I wanted to add asynchrony to the project using Django Сhannels. When adding participants to the project, the list would be updated with new participants without reloading. Is this possible with Django channels?
models.py :

class Project(models.Model):
    members = models.ManyToManyField(User, through='Member', help_text=_('Members'))

class Member(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    project = models.ForeignKey(Project, on_delete=models.CASCADE)
    role = models.CharField(max_length=20, choices=ROLE_CHOICES
)
project_detail.html :
{% for member  in project.member_set.all %}
     {{ member.user }}
     {{ member.role }}
{% endfor %}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2017-03-20
@sim3x

use ajax

D
devel787, 2017-03-22
@devel787

> Is this possible with Django channels?
Yes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question