content-type

Content-Type in for individual files in python requests

Content-Type in for individual files in python requests Question: I want to request to my server running in python flask with file and some meta information. Hence my request content-Type will be ‘multipart/form-data. Is there a way i can set the content type of file like image/jpg, image/gif etc… How do i set the content-type …

Total answers: 2

How can I obtain the model's name or the content type of a Django object?

How can I obtain the model's name or the content type of a Django object? Question: Let’s say I am in the save code. How can I obtain the model’s name or the content type of the object, and use it? from django.db import models class Foo(models.Model): … def save(self): I am here….I want to …

Total answers: 3

What's the difference of ContentType and MimeType

What's the difference between ContentType and MimeType? Question: As far as I know, they are absolute equal. However, browsing some django docs, I’ve found this piece of code: HttpResponse.__init__(content=”, mimetype=None, status=200, content_type=’text/html’) which surprise me the two getting along each other. The official docs was able to solve the issue in a practical manner: content_type …

Total answers: 4

Where's my JSON data in my incoming Django request?

Where's my JSON data in my incoming Django request? Question: I’m trying to process incoming JSON/Ajax requests with Django/Python. request.is_ajax() is True on the request, but I have no idea where the payload is with the JSON data. request.POST.dir contains this: [‘__class__’, ‘__cmp__’, ‘__contains__’, ‘__copy__’, ‘__deepcopy__’, ‘__delattr__’, ‘__delitem__’, ‘__dict__’, ‘__doc__’, ‘__eq__’, ‘__ge__’, ‘__getattribute__’, ‘__getitem__’, ‘__gt__’, …

Total answers: 13

How do you send a HEAD HTTP request in Python 2?

How do you send a HEAD HTTP request in Python 2? Question: What I’m trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http://somedomain/foo/ will return an HTML document or a JPEG image for example. Thus, I …

Total answers: 11