These are chat archives for django/django

30th
Jun 2017
EvolvedAltair
@EvolvedAltair
Jun 30 2017 03:45
Just dont stress it out
Abhinandan Panigrahi
@chrzrdx
Jun 30 2017 10:40
How do I login as Django Admin via postman?
or curl
John
@flyboy1565
Jun 30 2017 18:11

def send_notification(notification):
    logger.info('send_notification. notification = %s', notification)
    Group("notifications").send({'text': dumps(notification)})


@receiver(post_save, sender=CommunicationsIssue)
def incident_post_save(sender, **kwargs):
    logger.info('Sender = %s', sender)
    instance = serialize('json', [ kwargs['instance'], ])
    send_notification({
        'type': 'post_save',
        'created': kwargs['created'],
        'feature': instance,
    })
when saving record, it doesn't log anything to the console.
Nikhil Allamsetti
@niklul
Jun 30 2017 20:12

Hey, Im trying to connect my angular 4 app with django rest framework but I keep getting an error with cors

Error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://evening-badlands-69939.herokuapp.com/api/auth/token?format=json. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

This is my settings.py

ALLOWED_HOSTS = [u'evening-badlands-69939.herokuapp.com',u'localhost']

CORS_ORIGIN_WHITELIST = (
    'localhost',
    'localhost:4200',
    '127.0.0.1:4200'
)

CORS_ORIGIN_ALLOW_ALL = True

CORS_ALLOW_HEADERS = (
'x-requested-with',
'content-type',
'accept',
'Origin',
'authorization',
'X-CSRFToken',)

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # third party
    'crispy_forms',
    'markdown_deux',
    'pagedown',
    'rest_framework',
    'rest_framework_docs',
    'corsheaders',
    # local apps
    'comments',
    'posts',

]


MIDDLEWARE_CLASSES = [

   'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Can some one help me with this?