Traceback (most recent call last):
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\viewsets.py", line 114, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\views.py", line 505, in dispatch
response = self.handle_exception(exc)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\views.py", line 465, in handle_exception
self.raise_uncaught_exception(exc)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception
raise exc
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\views.py", line 502, in dispatch
response = handler(request, *args, **kwargs)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\mixins.py", line 54, in retrieve
instance = self.get_object()
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\rest_framework\generics.py", line 83, in get_object
queryset = self.filter_queryset(self.get_queryset())
File "C:\Users\User\Desktop\GitHub\Test-Chat\backend\community\api\views.py", line 42, in get_queryset
queryset = Contact.objects.all().annotate(
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\query.py", line 1116, in annotate
clone.query.add_annotation(annotation, alias, is_summary=False)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\sql\query.py", line 1018, in add_annotation
annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None,
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\aggregates.py", line 48, in resolve_expression
c.filter = c.filter and c.filter.resolve_expression(query, allow_joins, reuse, summarize)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\query_utils.py", line 103, in resolve_expression
clause, joins = query._add_q(
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\sql\query.py", line 1377, in _add_q
child_clause, needed_inner = self.build_filter(
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\sql\query.py", line 1292, in build_filter
self.check_related_objects(join_info.final_field, value, join_info.opts)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\sql\query.py", line 1119, in check_related_objects
self.check_query_object_type(value, opts, field)
File "C:\Users\User\Desktop\GitHub\Test-Chat\env\lib\site-packages\django\db\models\sql\query.py", line 1100, in check_query_object_type
raise ValueError(
Exception Type: ValueError at /api/v1/contact/1/
Exception Value: Cannot query "admin": Must be "AddRequest" instance.
class ContactDetailSerializer(serializers.ModelSerializer):
'''Выводит профиль пользователя'''
user = UserDetailSerializer()
is_friend = serializers.BooleanField()
num_friends = serializers.IntegerField()
current_user = serializers.BooleanField()
is_sent = serializers.BooleanField()
friends = ContactFriendsSerializer(many=True)
class Meta:
model = Contact
fields = '__all__'
CSRF_COOKIE_NAME = 'csrftoken'
import axios from 'axios'
axios.defaults.xsrfHeaderName = 'X-CSRFToken';
axios.defaults.CookieName = 'csrftoken';
const addItemToBasket = async (item, amount = 1) => {
const data = { uid: item.id, amount: amount, email: store.get('email') }
const options = {
method: 'POST',
url: "http://localhost:8000/cart/add",
data: qs.stringify(data)
}
await axios(options)
.then((response) => {
if (response.data !== 'added') {
store.set('email', response.data)
}
addItemToBasketSuccess(item, amount)
setFlag()
})
.catch((error) => {
console.log(error);
});
}