Reputation: 2500
I'm get this
AttributeError("'WSGIRequest' object has no attribute 'args'",)
when I try and make this call
GET /sign_s3/?s3_object_type=image/jpeg&s3_object_name=default_name
Am I missing something?
Do I need to include *args, **kwargs
in addition to request?
Here's the traceback:
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
break
if response is None:
wrapped_callback = self.make_view_atomic(callback)
try:
response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
except Exception as e:
# If the view raised an exception, run it through exception
# middleware, and if the exception middleware returns a
# response, use that. Otherwise, reraise the exception.
for middleware_method in self._exception_middleware:
response = middleware_method(request, e)
the view:
@login_required()
def sign_s3(request):
object_name = request.args.get('s3_object_name')
Upvotes: 1
Views: 8636
Reputation: 305
And in the same with this erreur : except User.DoesNotExist: Attribute Error: 'function' object has no attribute 'DoesNotExist'
class UserPosts(generic.ListView):
model = models.Post
template_name = 'posts/user_post_list.html'
def get_queryset(self):
try:
self.post_user = User.objects.prefetch_related("posts").get(
username__iexact=self.kwargs.get("username")
)
except User.DoesNotExist:
raise Http404
else:
return self.post_user.posts.all()
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["post_user"] = self.post_user
return context
am solve it by :
from django.contrib.auth import get_user_model
User = get_user_model()
Upvotes: 0
Reputation: 1078
HttpRequest object has dictionary-like object id doesn't have args attribute
If key is mandatory and exist in request object you can use:
request.GET['s3_object_name']
This will return a value of a if key exists. If not then an Exception
If your keys are optional:
request.GET.get('s3_object_name')
Upvotes: 0
Reputation: 11534
HttpRequest
object doesn't have args
attribute.
You should use
request.GET.get('s3_object_name')
to get s3_object_name value
.
Django documentation has an excellent section on HttpRequest
.
Upvotes: 5