django channels consumers
Hi there. i want to send a message though WebSocket protocol after a user disconnected from the channel. the consumer codes is located on this link. https://paste.ubuntu.com/p/GND7tqVB6q/ the main function that sends a message to the group after a user disconnected is `chat_leave` function. the problem here is this function could not called at all. what wrong with the code? thanks for your attention -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d381969b-952b-4a9b-ba75-b02b359ce50fo%40googlegroups.com.
confusing about running some codes in django
Hi . when i read the django docs,it suggested that running some code but it does not note that where to write this piece of code . the code is : from django.contrib.auth.models import User u = User.objects.get(username='john') u.set_password('new password') u.save() i know that i can run it in django shell (manage.py shell) but i want to write these in a file(its some confusing that every code in views.py should return a http response but this type of commands does not return any respone) where should i put this code ?? thanks for your attention. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b5f90e07-d69e-42e4-ad1f-2a801b3c6114%40googlegroups.com.
Re: confusing about running some codes in django
Thanks -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cd44c70e-20f3-4e99-8ca8-e24d7c91fd71%40googlegroups.com.
Re: confusing about running some codes in django
But when I put this code in model.py, when I run the server it returns an error about constraints failed but the user was added in Django admin users. Why this happen?? On Aug 29, 2019 5:54 PM, "Mario R. Osorio" wrote: > That code is meant for you to type it in the python console however, you > could also include it pretty much anywhere in your code. > > > On Wednesday, August 28, 2019 at 9:15:20 AM UTC-4, Vahid Asadi wrote: >> >> Hi . >> when i read the django docs,it suggested that running some code but it >> does not note that where to write this piece of code . the code is : >> >> from django.contrib.auth.models import User >> >> u = User.objects.get(username='john') >> >> u.set_password('new password') >> >> u.save() >> >> >> i know that i can run it in django shell (manage.py shell) >> >> but i want to write these in a file(its some confusing that every code in >> views.py should return a http response but this type of commands does not >> return any respone) >> >> where should i put this code ?? >> >> thanks for your attention. >> >> -- > 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 view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/b6b3b24e-b34e-42e6-b637-3e6a30ca2823%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/b6b3b24e-b34e-42e6-b637-3e6a30ca2823%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAE-JtS84v9Jd%2BwEp2j7kqF2cPg%2BNtvO02WunQkSDneWMbHc6_g%40mail.gmail.com.
UNIQUE constraint failed on adding a new model field
HI . when i want to add a new field called "slug" to my "Post" model, the migrate command will raise UNIQUE constraint failed: new__chat_post.slug after that i remove that field from my model but the problem still exists. why?? and how to resolve this problem without deleting my whole table datas. thanks .. the model: class Post(models.Model): title = models.TextField(max_length=100) context = models.TextField(max_length=255) creation_date = models.DateTimeField(default = timezone.now) author = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete = models. CASCADE) slug = models.SlugField(default=["title"],unique=True) -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be29e076-3727-469e-9621-b4ca09dc7c6b%40googlegroups.com.