These are chat archives for django/django

20th
Feb 2017
Miracle Ayodele
@iammiracle
Feb 20 2017 12:05
hi guys, i need your opinion on this
i used update_help = proof.objects.get(user_id=request.user.user_id) and this only works if proof object is not empty
but i need my template to load even when the object is empty
Ali
@Qurus
Feb 20 2017 13:44
hi
I have a VPS installed centos and cpanel. Is that possible I can deploy django and run on server?
Theofanis Despoudis
@theodesp
Feb 20 2017 14:40
@koderNeptune Why do you want to use get if there is a chance that you will get an exception? Why not use filter and check with exists()?
Miracle Ayodele
@iammiracle
Feb 20 2017 14:53
@theodesp can i update a record using filter?
H├ęctor Alvarez
@monobot
Feb 20 2017 14:53
update are cast on querysets ... so yes, you can filter and the update all of them in the queryset
Theofanis Despoudis
@theodesp
Feb 20 2017 14:55
filter is for retrieving data. Use update or save and yes you can do it in one line
Miracle Ayodele
@iammiracle
Feb 20 2017 14:59
@theodesp update_help = provideHelp.objects.filter(help_id=help_id) keeps returning QuerySet' object has no attribute '_meta'
helpupdate = UpdateProvideHelp(request.POST, request.FILES, instance=update_help)
this line keeps returning error
Theofanis Despoudis
@theodesp
Feb 20 2017 15:07
What is this provideHelp? Does it inherit models.Model?
Maxym Mazurok
@MIRAMAXED
Feb 20 2017 15:12

Greetings! I have a question:
I have a frontend app on Vue.js and a backend app on Django + Django REST Framework.
I am trying to make authentication using django-rest-auth.
However, the CSRF Token doesn't save in cookies.
When I try to connect to /rest-auth/user after authorization, I get an error: "detail": "Credentials were not provided."

Could you kindly advise on what I should do in this case?

Miracle Ayodele
@iammiracle
Feb 20 2017 15:18
@theodesp yes
it does
Theofanis Despoudis
@theodesp
Feb 20 2017 15:22
can you post the traceback error so some other people here can help you?
Miracle Ayodele
@iammiracle
Feb 20 2017 15:46
AttributeError at /dashboard/
'QuerySet' object has no attribute '_meta'
Borislav Kovacev
@bkovacev
Feb 20 2017 16:25
@koderNeptune
try:
    update_help = Proof.objects.get(user_id=request.user.user_id)
except Proof.DoesNotExist:
    raise Http404
You can change the raise to any other statement you'd like. Also there is a built in get_object_or_404 which replaces this statement. You can import it from from django.shortcuts import get_object_or_404
Borislav Kovacev
@bkovacev
Feb 20 2017 16:30
@MIRAMAXED Hi Maxym, you have to do a POST request with data containing proper credentials most likely in the terms of { "username": "john", "password": "doe"}
@koderNeptune Also, provide us with your template on gist or github. The error is most likely in your template. And show us your model or serializer.
Miracle Ayodele
@iammiracle
Feb 20 2017 16:57
@bkovacev i have a list of items, each with different ids
but i need to update the records based on the item that is clicked on
when i use update_help = get_object_or_404(provideHelp, help_id=help_id)
i get No provideHelp matches the given query.
Borislav Kovacev
@bkovacev
Feb 20 2017 21:02
how do you get your help_id variable? self.request.data? @koderNeptune also, please put your code on github or post relevant snippet on gist.github.com :) After that I'll be able to help
@cs89gr Hi, I can help you - where are you stuck at? Also, are you sure you need to do it in memory? What are you trying to achieve? Edit the picture before you save it?