I have a query in mind, currently it works as expected in shell with the Django ORM:
>>> Place.objects.all()[0].images.filter(order=0)[0].filename
'y5IUMPyv.jpg'
But I don't know how to implement it with DRF's SerializerMethodField. This is what I'm using in the meantime until I can figure it out:
class CardSerializer(serializers.Serializer):
image = serializers.SerializerMethodField()
#staticmethod
def get_image(obj):
for d in obj.images.all():
if d.order == 0:
return d.filename
This is the "ideal" method that doesn't work, and I don't know why:
#staticmethod
def get_image(obj):
return obj.images.filter(order=0)[0].filename
Traceback (most recent call last):
File "/home/admin/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/home/admin/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/admin/env/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/home/admin/env/lib/python3.4/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/home/admin/env/lib/python3.4/site-packages/rest_framework/views.py", line 466, in dispatch
response = self.handle_exception(exc)
File "/home/admin/env/lib/python3.4/site-packages/rest_framework/views.py", line 463, in dispatch
response = handler(request, *args, **kwargs)
File "/home/admin/env/lib/python3.4/site-packages/rest_framework/generics.py", line 201, in get
return self.list(request, *args, **kwargs)
File "/home/admin/env/lib/python3.4/site-packages/rest_framework/mixins.py", line 45, in list
return self.get_paginated_response(serializer.data)
File "/home/admin/env/lib/python3.4/site-packages/serpy/serializer.py", line 134, in data
self._data = self.to_value(self.instance)
File "/home/admin/env/lib/python3.4/site-packages/serpy/serializer.py", line 123, in to_value
return [serialize(o, fields) for o in instance]
File "/home/admin/env/lib/python3.4/site-packages/serpy/serializer.py", line 123, in <listcomp>
return [serialize(o, fields) for o in instance]
File "/home/admin/env/lib/python3.4/site-packages/serpy/serializer.py", line 107, in _serialize
result = getter(self, instance)
File "/home/admin/src/places/serializers.py", line 72, in get_image
return obj.images.filter(order=0)[0].filename
File "/home/admin/env/lib/python3.4/site-packages/django/db/models/query.py", line 297, in __getitem__
return list(qs)[0]
IndexError: list index out of range
As the iron maiden #anderson-lima has pointed out, this is a problem with your data rather than your code. You do not have an image with order = 0 and your first method handles that situation correct if not optimally.
#staticmethod
def get_image(obj):
for d in obj.images.all():
if d.order == 0:
return d.filename
# returns None here if an object with order = 0
# does not exist in the database.
However in your second approach you are taking a slice but fetching an object that does not exist. Hence the execption, and which in turn tells us that what you need is a just a try except block.
#staticmethod
def get_image(obj):
try:
return obj.images.filter(order=0)[0].filename
except IndexError:
return None
Related
i have created this serializer to validate on the presence of a record with these column combination`
class CampaignServicesValidation(serializers.Serializer):
campaign_id = serializers.IntegerField(required=True)
service_id = serializers.IntegerField(required=True)
def validate(self, data):
try:
campaign_service = CampaignServices.objects.get(campaign_id=data['campaign_id'],
service_id=data['service_id'])
print("found"+str(campaign_service.id))
except Exception:
raise serializers.ValidationError(detail='Campaign Service does not exist')
return campaign_service
and it is called in my viewSet like this:
campaign_service = CampaignServicesValidation(data={'campaign_id': request.data['campaign_id'], 'service_id': pk})
if not campaign_service.is_valid():
return RestResponse(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, serializer_error=campaign_service.errors)
when the combination is not found it raises an exception and works well, but when it passes validation and enters the is_valid() function in the if condition it produces this error
Traceback (most recent call last):
File "D:\RightsHero\collector-management\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "D:\RightsHero\collector-management\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\RightsHero\collector-management\venv\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
raise exc
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "D:\RightsHero\collector-management\collectors_management\views.py", line 157, in update_campaign_service_frequency
serializer.save()
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\serializers.py", line 207, in save
self.instance = self.update(self.instance, validated_data)
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\serializers.py", line 993, in update
info = model_meta.get_field_info(instance)
File "D:\RightsHero\collector-management\venv\lib\site-packages\rest_framework\utils\model_meta.py", line 35, in get_field_info
opts = model._meta.concrete_model._meta
AttributeError: 'CampaignServicesValidation' object has no attribute '_meta'
I have tried changing serializer.Serializer to ModelSerialzier but nothing changed
Since Serializer does not have a _meta attribute, it does not have the is_valid() method. Instead, you should check the serializer.errors attribute of the serializer after calling validate().
I don't understand this error one bit, I'm trying to do a basic create method but I get a KeyError what am i doing wrong
This is serializer.py code
class GradeCreateSerializer(serializers.ModelSerializer):
grade = serializers.ChoiceField(choices=GRADES, source="get_grade_display")
class Meta:
model = Grade
fields = ["grade"]
# ordering = ['-created_date']
def create(self, validated_data):
user = None
request = self.context.get("request")
if request and hasattr(request, "user"):
user = request.user
try:
perms = Perm.objects.get(user=user)
except:
perms = None
if user.role in ['OWNER', 'PARTNER']:
school = user.owns.first()
elif perms is not None:
if user.role == 'STAFF' and perms.can_crt_grade_class:
school = user.works
instance = Grade.objects.create(
grade=validated_data['grade'],
school=school,
)
instance.save()
return instance
what am I doing wrong??
I have added the error traceback as requested
error traceback
Traceback (most recent call last):
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\django\views\generic\base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
raise exc
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\generics.py", line 190, in post
return self.create(request, *args, **kwargs)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\mixins.py", line 19, in create
self.perform_create(serializer)
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\mixins.py", line 24, in perform_create
serializer.save()
File "F:\Projects\SchoolProject\main\Abugida\lib\site-packages\rest_framework\serializers.py", line 212, in save
self.instance = self.create(validated_data)
File "F:\Projects\SchoolProject\main\Classes\serializers.py", line 45, in create
grade=validated_data['grade'],
KeyError: 'grade'
it says that grade=validated_data['grade'], this the problem but i don't get it.
I have found a solution to my issue, it was because of grade = serializers.ChoiceField(choices=GRADES, source="get_grade_display") this means when using a ChoiceField to define your field you don't need to pass the source="" as the field uses the choice to determine it
So changing
grade = serializers.ChoiceField(choices=GRADES, source="get_grade_display")
to
grade = serializers.ChoiceField(choices=GRADES)
did the trick
I get a name error: pk is not defined although I can see that the pk is passed to the view from the url.
urls.py:
from django.conf.urls import url
from cashflow.views import cashflowView, SelectAccountView, CashflowEditView
from django.urls import path
app_name = 'cashflow'
urlpatterns = [
url(r'^select_account', SelectAccountView.as_view(), name="select_account"),
url(r'^$', cashflowView.as_view(), name="cashflow_processing"),
path('edit/<pk>/', CashflowEditView.as_view(), name="cashflow_editing"),
]
views.py:
class CashflowEditView(UpdateView):
model = ttransactions
template_name = 'cashflow/cashflow_processing.html'
form_class = CashflowForm
success_url = 'cashflow'
def get_form_kwargs(self):
kwargs = super(CashflowEditView, self).get_form_kwargs()
kwargs['request'] = self.request
return kwargs
def get_queryset(self, **kwargs):
transaction = ttransactions.objects.filter(pk=pk)
transaction_lines = transaction_lines.objects.filter(transaction=transaction.id)
return transaction, transaction_lines
I get the error on the line transaction = ttransactions.objects.filter(pk=pk)
When I run in debug I can see that pk is send to the view but when I use it on the object I get the error.
I will appreciate help to resolve the problem for me.
I added the print(kwargs) as specified and got this in the terminal:
Internal Server Error: /cashflow/edit/42/
Traceback (most recent call last):
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\core\handlers\exception.py", line 4
7, in inner
response = get_response(request)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\core\handlers\base.py", line 179, i
n _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\base.py", line 70, in
view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\base.py", line 98, in
dispatch
return handler(request, *args, **kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\edit.py", line 189, i
n get
self.object = self.get_object()
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\detail.py", line 30,
in get_object
queryset = self.get_queryset()
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\aberni\cashflow\views.py", line 274, in get_queryset
transaction = ttransactions.objects.filter(pk=pk)
NameError: name 'pk' is not defined
[06/Jan/2021 16:01:25] "GET /cashflow/edit/42/ HTTP/1.1" 500 86062
Internal Server Error: /favicon.ico/
Traceback (most recent call last):
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\fields\__init__.py", line
1774, in get_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'favicon.ico'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\core\handlers\exception.py", line 4
7, in inner
response = get_response(request)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\core\handlers\base.py", line 179, i
n _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\base.py", line 70, in
view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\base.py", line 98, in
dispatch
return handler(request, *args, **kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\detail.py", line 106,
in get
self.object = self.get_object()
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\views\generic\detail.py", line 36,
in get_object
queryset = queryset.filter(pk=pk)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\query.py", line 942, in f
ilter
return self._filter_or_exclude(False, *args, **kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\query.py", line 962, in _
filter_or_exclude
clone._filter_or_exclude_inplace(negate, *args, **kwargs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\query.py", line 969, in _
filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\sql\query.py", line 1358,
in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\sql\query.py", line 1377,
in _add_q
child_clause, needed_inner = self.build_filter(
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\sql\query.py", line 1319,
in build_filter
condition = self.build_lookup(lookups, col, value)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\sql\query.py", line 1165,
in build_lookup
lookup = lookup_class(lhs, rhs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\lookups.py", line 24, in
__init__
self.rhs = self.get_prep_lookup()
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\lookups.py", line 76, in
get_prep_lookup
return self.lhs.output_field.get_prep_value(self.rhs)
File "C:\Users\94ber\PycharmProjects\pythonProject\dev\venv\lib\site-packages\django\db\models\fields\__init__.py", line
1776, in get_prep_value
raise e.__class__(
ValueError: Field 'id' expected a number but got 'favicon.ico'.
[06/Jan/2021 16:01:26] "GET /favicon.ico/ HTTP/1.1" 500 138586
transaction = ttransactions.objects.filter(pk=pk)
Where are you getting the variable pk from? Are you expecting it to come from kwargs? If so then it should be:
transaction = ttransactions.objects.filter(pk=kwargs['pk'])
You have to fetch pk value from kwargs dictionary.
Try this:
def get_queryset(self, **kwargs):
pk = int(kwargs['pk'])
transaction = ttransactions.objects.filter(pk=pk)
transaction_lines = transaction_lines.objects.filter(transaction=transaction.id)
return transaction, transaction_lines
I am using django-rest-auth registration api, I overridden that by using my own SERIALIZER and model. So I am getting error.
I have tried by setting active at the time user created. But that is not working.
Let me know how to resolve this type of problem.
[12/Jan/2019 17:24:06] "POST /rest-auth/registration/ HTTP/1.1" 400 68
Internal Server Error: /rest-auth/registration/
Traceback (most recent call last):
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/utils/decorators.py", line 45, in _wrapper
return bound_method(*args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_auth/registration/views.py", line 46, in dispatch
return super(RegisterView, self).dispatch(*args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_framework/views.py", line 495, in dispatch
response = self.handle_exception(exc)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_framework/views.py", line 455, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_framework/views.py", line 492, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_framework/generics.py", line 192, in post
return self.create(request, *args, **kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_auth/registration/views.py", line 65, in create
user = self.perform_create(serializer)
File "/Users/test/project/vblah/lib/python3.6/site-packages/rest_auth/registration/views.py", line 81, in perform_create
None)
File "/Users/test/project/vblah/lib/python3.6/site-packages/allauth/account/utils.py", line 183, in complete_signup
signal_kwargs=signal_kwargs)
File "/Users/test/project/vblah/lib/python3.6/site-packages/allauth/account/utils.py", line 133, in perform_login
return adapter.respond_user_inactive(request, user)
File "/Users/test/project/vblah/lib/python3.6/site-packages/allauth/account/adapter.py", line 454, in respond_user_inactive
reverse('account_inactive'))
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/urls/base.py", line 90, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/Users/test/project/vblah/lib/python3.6/site-packages/django/urls/resolvers.py", line 622, in _reverse_with_prefix
raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'account_inactive' not found. 'account_inactive' is not a valid view function or pattern name.```
this exception happend because in your User model
is_active = False .
so set True and migrate
in models.py set is_active = True
and migrate the tables
this is my view.py
#list_route(methods=["post"])
def created_in_range(self, request):
response = {}
data = request.POST
start = dateutil.parser.parse(data['start'])
end = dateutil.parser.parse(data['end'])
page_no = data['page_no']
tweets = Tweet.get_created_in_range(start, end, int(page_no))
serializer = TweetSerializer(tweets, many= True)
response["data"] = serializer.data
return Response(response, status= status.HTTP_200_OK)
this is my class method of models.py
#classmethod
def get_created_in_range(cls, start, end, page_no):
"""
Returns all the tweets between start and end.
"""
tweets = cls.objects.filter(created_at__level__gte = start, created_at__level__lt=end )
paginator = Paginator(tweets, 5)
return paginator.page(page_no)
this is the error i get
Internal Server Error: /api/twitter/created_in_range/
Traceback (most recent call last):
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/rest_framework/viewsets.py", line 95, in view
return self.dispatch(request, *args, **kwargs)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/rest_framework/views.py", line 494, in dispatch
response = self.handle_exception(exc)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/rest_framework/views.py", line 454, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/rest_framework/views.py", line 491, in dispatch
response = handler(request, *args, **kwargs)
File "/home/kethan/Desktop/twitter_env/twitter_app/api/views.py", line 67, in created_in_range
tweets = Tweet.get_created_in_range(start, end, int(page_no))
File "/home/kethan/Desktop/twitter_env/twitter_app/api/models.py", line 143, in get_created_in_range
tweets = cls.objects.filter(created_at__level__gte = start, created_at__level__lt=end )
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/query.py", line 836, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/query.py", line 854, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1253, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1277, in _add_q
split_subq=split_subq,
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1215, in build_filter
condition = self.build_lookup(lookups, col, value)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1069, in build_lookup
lhs = self.try_transform(lhs, name)
File "/home/kethan/Desktop/twitter_env/lib/python3.5/site-packages/django/db/models/sql/query.py", line 1115, in try_transform
(name, lhs.output_field.__class__.__name__))
django.core.exceptions.FieldError: Unsupported lookup 'level' for DateTimeField or join on the field not permitted.
[25/Feb/2018 02:19:25] "POST /api/twitter/created_in_range/ HTTP/1.1" 500 19151
this above is the response in the server
i dont know why there's such a big deal with date time fields
can someone help me resolving the issue, i am fighting for this for a while now
i dont understand where i am going wrong
please help solving this....
For the tweets in 2 date range, you just need the code below and level is not required.
tweets = cls.objects.filter(created_at__gte = start, created_at__lte=end )
Tweets created date should be greater than start date and lesser than the end date.
I faced this issue, when I mistakenly wrote three underscores instead of two like
___gte instead of __gte