inchidi
sorry again, its ALLOWED_HOSTS
inchidi
okay
Tushar
still same error
Abhi
from rest_framework.response import Response from rest_framework.decorators import api_view``from updater.models import Update from .serializers import UpdateSerializers from rest_framework import status from django.http import JsonResponse from rest_framework import serializers
Tushar
@DimasInchidi whats ur next guess
Abhi
@Tusharmalik62 tried adding * ?
Tushar
where
Tushar
ALLOWED_HOSTS
inchidi
ALLOWED_HOSTS
hmm just realize if the problem is allowed hosts then its must bad request and yours is bad gateway
inchidi
ez fix is turn on debug = true
Tushar
it already on
Tushar
website is working with ip 139.59.28.131
Tushar
when u click ip u will be redirected to the website
inchidi
i think this domain not redirect to your ip
Tushar
Problem solved after i restart my guncorn
Tushar
It was the problem of ALLOWED_HOST only
Tushar
thanks
inchidi
update = Update.objects.get(unique_key=unique_key) return JsonResponse(serializers.serialize('json', update), safe=False)
am not sure but from your code looks like you want to use django.core.serializers not the drf one
Abhi
@DimasInchidi it is showing that object is not iterable
inchidi
@DimasInchidi it is showing that object is not iterable
you have 2 choices returning serializers.serialize with HttpResponse or returning dict with JsonResponse
inchidi
both gonna give same result
Abhi
i have used JsonResponse
Abhi
update = Update.objects.get(unique_key=unique_key)
Abhi
this was my query
Abhi
then this is serialisation
Abhi
return JsonResponse(serializers.serialize('json', update), safe=False)
inchidi
inchidi
and serializers.serialize() returning json too
inchidi
if you are insist using jsonresponse you can convert serialized data with import json data = json.loads(serializers.serialize('json', update)
Abhi
i think it's done
Abhi
thanks @DimasInchidi
inchidi
then return JsonResponse(data,safe=False) gonna work
inchidi
but still using HttpResponse wiser
Abhi
but i have used @api_view[] for returning data
Abhi
i am just geting a json instead of that what is looks like in django rest framework
inchidi
should be no problem. they return same thing
inchidi
maybe you wanna do print(type(data)) to better insight
Abhi
TypeError: 'Update' object is not iterable
Abhi
in this line data = json.loads(serializers.serialize('json', update))
inchidi
Abhi
okay
Abhi
i am getting something like this
Abhi
"[{\"model\": \"updater.update\", \"pk\": 1, \"fields\": {\"update_msg\": \"testingthing\", \"version_no\": \"0\", \"datetime\": \"2017-08-22\", \"target_os\": \"ubuntu\", \"internal_msg\": \"thikhai\", \"unique_key\": \"001\"}}]"
Tushar
do i need to do makemigrations and migrate on server or not
Abhi
yes, you have to
Tushar
ok
Abhi
@DimasInchidi bug has been fixed :)
Abhi
thanks ;)
Abhi
well anyone has made django app, something like this
Abhi
i will share a invitation link to my friend and if he click and registrer through that link, i will get benefit
inchidi
cool, nice
Abhi
i am asking
Abhi
is there any package that will be helpful ?:
inchidi
oh you mean referal thingy?
Abhi
yeah
inchidi
found this but never using it https://github.com/byteweaver/django-referral
Abhi
i think tracking the users will be tough
inchidi
not really, you can use user IP
inchidi
but yeah its gonna be tough
Abhi
okay
Django Bot
>> Blogs - DjangoCon 2017 Recap
Abhi
does making a local_setting,py make django auto_detect which file is to be used locally and which settings.py to be used on production ?
Anonymous
Nope
Anonymous
But you can make some logic for it though
inchidi
does making a local_setting,py make django auto_detect which file is to be used locally and which settings.py to be used on production ?
you must tell your os.environ which file is your DJANGO_SETTINGS_MODULE. default is at your manage.py
Abhi
okay
Abhi
you are always helpfull @DimasInchidi
inchidi
thanks
Anonymous
Your profile picture when: I use :shell
Anonymous
And not :q or :q!
Anonymous
I have a problem in storing date field
Anonymous
I am using a model form. And there is date field in it.
Anonymous
But the format it works is
Anonymous
M-D-Y
Anonymous
And similar, but I want it to be d-m-y and similar. To changed it to d-m-y in the corresponding form class. And it works and saves properly. But the problem is when I retrieve the date back. It retrieves in m-d-y
Anonymous
So, what can I do to solve this?
Sehrob
Try to give the same input_formats to your models DateField too.