Skip to content

Commit

Permalink
Отправка сообщения в ws сервис
Browse files Browse the repository at this point in the history
  • Loading branch information
Sawa Demidenko committed Dec 15, 2018
1 parent 109cbfd commit 7f9c477
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion questions/models.py
Expand Up @@ -3,8 +3,11 @@

from datetime import datetime

import requests
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver


class User(AbstractUser):
Expand All @@ -19,7 +22,7 @@ def __str__(self):


class Question(models.Model):
author = models.ForeignKey(User)
author = models.ForeignKey(User, on_delete=models.CASCADE)

title = models.CharField(max_length=120, verbose_name=u"Заголовок вопроса")
text = models.TextField(verbose_name=u"Полное описание вопроса")
Expand All @@ -35,3 +38,8 @@ def __str__(self):

class Meta:
ordering = ['-create_date']

@receiver(post_save, sender=Question)
def renewal(sender, instance, created, **kwargs):
if created:
requests.post("http://localhost:8006/create/message", data={"message": instance.id})

0 comments on commit 7f9c477

Please sign in to comment.