Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Not able to install virtual environment in python
I was trying to install virtual environment in python-django project. But, I am getting this error: Could not find a version that satisfies the requirement virtualenv (from versions: ) No matching distribution found for virtualenv Please help. Thank you! -
Is there a risk in my design User in Django?
I am creating the extend User like bellow: class User(AbstractUser): username = models.CharField(max_length=16) password = models.CharField(max_length=40) # sha1加密 real_name = models.CharField(max_length=12, null=True, blank=True) phone = models.CharField(max_length=11) # 手机号码 email = models.EmailField(blank=True, null=True) qq = models.CharField(max_length=10, null=True, blank=True) address = models.CharField(max_length=64, blank=True, null=True) # 地址 nickname = models.CharField(max_length=16, blank=True, null=True) is_staff = True is_superuser = False You see there are two fields here: is_staff = False is_superuser = False So, when I create the AdminUser, if there is a risk? Because the hacker may use : AdminUser(xxxxx, is_staff=True, is_superuser=True, xxx) to create a superuser. Or whether my User model is complete wrong? -
The already checked items gets appended in a list
script: function checkCount(elm) { var checkboxes = document.getElementsByClassName("checkbox-btn"); var selected = []; for (var i = 0; i < checkboxes.length;i++) { if(checkboxes[i].checked){ selected.push(checkboxes[i].value); alert(selected); } } var uniqueNames = []; html: {% for alertDict in alertnamefile %} {% for alertnames in alertDict.alertname %} {% if alertnames in alertDict.alertPresentFile %} <li><input type="checkbox" value={{alertnames}} class='checkbox-btn' checked onchange='checkCount(this.value)'>{{alertnames}}<br></li> {% endif %} {% if alertnames not in alertDict.alertPresentFile %} <li><input type="checkbox" value={{alertnames}} class='checkbox-btn' onchange='checkCount(this.value)'>{{alertnames}}<br></li> {% endif %} {% endfor %} {% endfor %} $.each(selected, function(i, el){ if($.inArray(el, uniqueNames) === -1) uniqueNames.push(el); }); document.getElementById("alert_selected").value = uniqueNames.join(); } //I have certain items which are checked already.But while appending it in on list.If we uncheck the item it gets unchecked.But in the list selected the old values too get appened. ex:suppose we have a,b,c,d,e items in a checkbox :a,b are checked.So when the loop executes and we uncheck a.The result comes as b,a,b.If we uncheck b now it will be like a,b -
Django template : {% if %} tag can't get it to work
I am looking for a way in order my templates can recognize an attribute from my extended userprofile, specifically if he is an affiliate and show different content in the templates whether he is an affiliate or not. Is there an other approach to this like to build an decorator? i have worked with other {%if%} tags like this built-in auth request {% if request.user.is_authenticated %} models.py project/useprofile/ , the book is in an other app project/book class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) affiliate = models.BooleanField(default=False) add_book.html {%extends 'base.html' %} {% load i18n %} {% load crispy_forms_tags %} {% block content1 %} {% if userprofile.profile.affiliate = True %} <h1>New post</h1> <form method="POST" class="post-form"> {% csrf_token %} {{ form|crispy }} <button type="submit" class="save btn btn-primary">Save</button> </form> {% endif %} {% endblock %} urls.py url(r'^book/add/$', 'book.views.addbook', name='addbook'), views.py def addbook(request): if request.method == "POST": form = BookForm(request.POST) if form.is_valid(): book = form.save(commit=False) book.save() return redirect('home') else: form = BookForm() return render(request, 'add_book.html', {'form':form, }) -
Why filtering django with icontains is case sensitive?
I want to filter a queryset with icontains because I don't want the filtration to be case sensitive: some_title = "Foo" result = Article.objects.filter(title__icontains=some_title) articles with the title "foo" are not within the result. why? I am using Django (1.9.12). -
Django_Filter - Only Allowing Certain ForeignKey Options to Be Selected
I'm using django_filters for users to filter through campaigns. I have different groups and users within those groups. I have the view set-up fine so that only the campaigns for the group will show up and the respective users within that group can view them. For the filter, though, there is an option for filtering by User, the foreign key. It lists every user. I want it to only list users within the group of the current, request.user. I was able to do it on ModelForm but not on django_filters. filters.py class CampaignFilter(django_filters.FilterSet): #def group(self): # user = self.request.user # print user # group = Group.objects.get(user=user) # users = User.objects.filter(groups=group) # return users #sender = django_filters.ModelChoiceFilter(queryset=group) @staticmethod def __init__(self, group, *args, **kwargs): super(CampaignFilter, self).__init__(*args, **kwargs) # populates the post self.form.fields['sender'].queryset = User.objects.filter(groups=group) title = django_filters.CharFilter(lookup_expr='icontains') date = django_filters.DateFromToRangeFilter( label='Date', widget=django_filters.widgets.RangeWidget(attrs={'placeholder': 'Date'})) class Meta: model = Campaign fields = ['title', 'sender', 'template', 'send_time', 'date', ] views.py def campaigns(request): user = request.user group = Group.objects.get(user=user) q = request.GET.get('q') if q: campaigns = Campaign.objects.filter(sender_group=group) results = campaigns.objects.filter( Q(title__icontains=q)) else: campaigns = Campaign.objects.filter(sender_group=group) results = campaigns.all().order_by('-date') if request.method == 'GET' and 'filter' in request.GET: filter = CampaignFilter(request.GET, group=group, queryset=Campaign.objects.filter(sender_group=group)) campaignTable = CampaignTable(filter.qs) RequestConfig(request, paginate={'per_page': … -
How to filter by range of specific hours in Django Orm?
I have a queryset below, that allows me to get objects that where created at last 14 days: qs_1 = Model.objects.filter(datetime_created__gte=datetime.now()-timedelta(days=14)) What I want is to create a new queryset that will allow me to get objects for last 14 days and filter them by range from 11 pm to 9am. How can I do that ? -
Over-ride DRF custom exception response
I want to send error_codes while sending the response back to the client, in case of an error!! So, I've a form where params a and b is required. If any of the param is not POSTed, then DRF serializer sends back a response saying This field is required. I want to add the error code to the response as well for the client to identify. Different errors different error codes. So, I wrote my own custom exception handler. It goes like this. response = exception_handler(exc, context) if response is not None: error = { 'error_code': error_code, # Need to identify the error code, based on the type of fail response. 'errors': response.data } return Response(error, status=http_code) return response The problem I'm facing is that I need to identify the type of exception received, so that I can send the error_code accordingly. How can I achieve this? -
Dead letter Queue for Sqs and Celery
I'm trying to push tasks to a dead letter queue after celery throws MaxRetriesExceededError. I'm using celery 4.1 and Aws SQS as Broker in my Django project. I found a solution for RabbitMQ here, Celery: how can I route a failed task to a dead-letter queue. For some reason my code is not creating a new dlq or use exiting queue in SQS. Following is my code, I've removed exchange and routing keys part in my code from the given link: class DeclareDLQ(bootsteps.StartStopStep): """ Celery Bootstep to declare the DL exchange and queues before the worker starts processing tasks """ requires = {'celery.worker.components:Pool'} def start(self, worker): app = worker.app # Declare DLQ dead_letter_queue = Queue( 'local-deadletterqueue') with worker.app.pool.acquire() as conn: dead_letter_queue.bind(conn).declare() default_queue = Queue( app.conf.task_default_queue) # Inject the default queue in celery application app.conf.task_queues = (default_queue,) # Inject extra bootstep that declares DLX and DLQ app.steps['worker'].add(DeclareDLQ) def onfailure_reject(requeue=False): """ When a task has failed it will raise a Reject exception so that the message will be requeued or marked for insertation in Dead Letter Exchange """ def _decorator(f): @wraps(f) def _wrapper(*args, **kwargs): try: return f(*args, **kwargs) except TaskPredicate: raise # Do not handle TaskPredicate like Retry or Reject except Exception … -
django url not calling corresponding view and going back to the calling view
This is the project structure of my project. The below code is the url configuration in course/urls. from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.views.static import serve from django.views.generic import TemplateView from .views import course_list_of_faculty, course_detail_view urlpatterns = [ url(r'^list/$', course_list_of_faculty, name='course_list_of_faculty'), url(r'^(?P<pk>.+)/$', course_detail_view, name='course_detail_view'), ] From course_detail_view I am calling url course_material_upload in coursematerial app. from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.views.static import serve from django.views.generic import TemplateView # app_name = 'coursematerial' from .views import course_material_upload, files_list, download urlpatterns = [ url(r'^upload/$', course_material_upload, name='course_material_upload'), url(r'^files_list/$', files_list, name='course_material_view'), ] The below is the template of course_detail_view {% extends 'base.html' %} {% block content %} <p><a width="30%" align="center" href="{% url 'coursematerial:course_material_upload' pk=pk %}">Upload Course Material</a></p> <p><a width="30%" align="center" href="{% url 'coursematerial:course_material_view' pk=pk %}">View Course Material</a></p> {% endblock %} Here I am calling a url from coursematerial/urls. My problem is it is going to /faculty/course/coursename/upload but not going into its views 'course material upload' and repeating the current course_detail_view. The below is all my project urls from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.views.static import serve from . import views … -
Messaging App With Django
I'm trying to build a messaging app, here's my model, class Message(models.Model): sender = models.ForeignKey(User, related_name="sender") receiver = models.ForeignKey(User, related_name="receiver") ... created_at = models.DateTimeField(auto_now_add=True) I wants to order the Users based upon who sent a message to request.user & to whom request.user sent a message most recently! As we see on social networks. This is what I tried, users = User.objects.filter(Q(sender__receiver=request.user) | Q(receiver__sender=request.user)).annotate(Max('receiver')).order_by('-receiver__max') This code is working fine only when request.user sends someone a message (It re-orders their name & place it to the top). But, It's not changing the order of users in case if someone sends a message to request.user. I also tried, users = Message.objects.filter(Q(sender=request.user) | Q(receiver=request.user)).order_by("created_at") But, I could't filter out the distinct users. It's showing equal number of users as messages. Also, I have to use {{ users.sender }} OR {{ users.receiver }} in order to print the users name which is a problem itself in case of ordering & distinct users. Please help me, how can I do that? -
How to pass JavaScript variables to React component
I'm somewhat new to React and I'm having some trouble passing some variables from my Django server to my React components. Here's what I have: The server is Django, and I have a url mydomain.com/testview/ that gets mapped to a views.py function testview: def testview(request): now = datetime.datetime.now() return render(request, 'testview.html', { 'foo': '%s' % str(now), 'myVar': 'someString' }) In other words, running testview will render the template file testview.html and will use the variables foo and myVar. The file testview.html inherits from base.html which looks like this: <!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> </head> <body> {% block main %}{% endblock %} </body> </html> The file test.html basically inserts the needed code into block main: testview.html: {% extends "base.html" %} {% load render_bundle from webpack_loader %} {% block main %} <script type="text/javascript"> var foo = {{ foo }}; var myVar = {{ myVar }}; </script> <div id="App"></div> {% render_bundle 'vendors' %} {% render_bundle 'App' %} {% endblock %} Note that just before the div id="App", I created a couple of javascript variables foo and myVar and set them to the values from Django. Now to REACT: my file App.jsx looks like this: import React from … -
Django: Can you format DateTimeField in annotate?
I have Customer and Order models and I would like to get the last order date of each customer and format it. I have the following code in views: customers = ( User.objects .prefetch_related('orders', 'addresses') .select_related('default_billing_address', 'default_shipping_address') .annotate( num_orders=Count('orders', distinct=True), last_order=Max('orders', distinct=True), last_order_date=Max('orders__created', distinct=True), gross_sales=Sum('orders__total_net'))) last_order_date is returning date in this format: Nov. 1, 2017, 11:39 p.m. I would like to update it so it returns 11/01/2017 only. How can I achieve this? I tried this: last_order_date=Max(('orders__created').strftime("%d/%m/%Y"), distinct=True), but it turns out ('orders__created') is already returning an str, I got this error: 'str' object has no attribute 'strftime' I also tried creating a method in orders that will return a formatted created field: def get_day_created(self): self.created.strftime("%d/%m/%Y") but i'm not sure if I can call it in annotate and how to properly do it. 'orders__get_day_created()' is giving me the error: Cannot resolve keyword 'get_day_created()' into field. Please advise :) Thank you -
Need to get data from News APIs into a django application, run it through an algorithm and store the same in a database
I am trying to make a news summarizing application. Although my algorithm seems to be working, I am having trouble making the web application. -
django how to authenticate user until verify email
How to authenticate user until he verify the email? In my sign up process, I create the User, which means he can login even without verify email. Is there a build-in method to set a un-verified status on a User? -
Django - Cannot assign "'Biography test'": "User.biography" must be a "Biography" instance
I have extended the user model with an extra field - biography. It appears in the admin panel as a new section. Here's a picture: Here's the new model: class Biography(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) biography = models.TextField(max_length=500, blank=True) Here's the profile view: def profile(request, username): user = get_object_or_404(User, username=username) products = Product.objects.filter(user=user) if not request.user == user: return render(request, 'no.html') else: return render(request, 'profile.html', {'user':user,'products': products}) I'm using a form to edit the profile - here's the view: def edit_profile(request): user = request.user products = Product.objects.filter(user=user) form = EditProfileForm(request.POST or None, initial={'first_name':user.first_name, 'last_name':user.last_name, 'biography':user.biography}) if request.method == 'POST': if form.is_valid(): user.first_name = request.POST['first_name'] user.last_name = request.POST['last_name'] user.biography = request.POST['biography'] user.save() return render(request, 'profile.html', {'user':user, 'products':products}) context = {"form": form} return render(request, "edit_profile.html", context) ...and here's the form: class EditProfileForm(forms.Form): first_name = forms.CharField(label='First Name') last_name = forms.CharField(label='Last Name') biography = forms.CharField(label='Biography', widget=Textarea(attrs={'rows': 5})) Here's a screenshot of the error message: I'm mixing something up but I can't figure out what. Doesn't help that I'm new to this ...still trying! -
Using React with Django, do I need react-router
Suppose I have an existing Django webapp with a bunch of urls in urls.py. Now suppose I want to add a number of webpages to this Django app, where the new webpages are built using React. From what I understand, React has its own routing capability (in react-router) so that if I go to mydomain.com/page1/ it will serve one thing and if O go to mydomain.com/page2/ it will serve something else. But what if I don't want to use react-router? In other words, if I have say 10 new pages to add and each page will have its own URL, then why can't I just set this up in Django's urls.py file? Currently in urls.py I have a url defined like this: url(r'^testview/', views.testview), In views.py I define testview like this: def testview(request): return render(request, 'testview.html', {}) My Django templates are stored in a folder BASE_DIR/myproject/templates/ and I set the TEMPLATES variable inside BASE_DIR/myproject/settings.py so Django knows where to find the templates. So in my view method above, "testview.html" refers to BASE_DIR/myproject/templates/testview.html. The contents of that file are: {% extends "base.html" %} {% load render_bundle from webpack_loader %} {% block main %} <div id="App1"></div> {% render_bundle 'vendors' %} {% render_bundle … -
What is the best way to increment an integer at a certain rate over time using a Django powered site and SQLite?
I am trying to display a number that will increment over time that is called from a very, very simple Django database. It will be called using jinja2 templating and the number is a simple IntegerField(). However, I would like for that number to autoincrement, live without refreshing the page, multiple times throughout the day. Also, I would like for every time that the number is refreshed, for the new value to be added to the same database recording the time and date. What is the best combo or group of languages/frameworks to achieve this? I'm starting to think that Django and Jinja2 alone are not enough to achieve this effect. -
i want to use manage.py in c9
i want to use django at c9.io but i try python manage.py migrate (or makemigrations) :~/workspace (master) $ python manage.py migrate Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 350, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 342, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 398, in execute self.check() File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 426, in check include_deployment_checks=include_deployment_checks, File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 75, in run_checks new_errors = check(app_configs=app_configs) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 10, in check_url_config return check_resolver(resolver) File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 19, in check_resolver for pattern in resolver.url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in get res = instance.dict[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in get res = instance.dict[self.name] = self.func(instance) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module return import_module(self.urlconf_name) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/ubuntu/workspace/gettingstarted/urls.py", line 18, in url(r'^', include('hello.urls')), File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/init.py", line 52, in include urlconf_module = import_module(urlconf_module) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name) File "/home/ubuntu/workspace/hello/urls.py", line 2, in from . import views File "/home/ubuntu/workspace/hello/views.py", line 9, in from . import connect_apiai,papago File "/home/ubuntu/workspace/hello/connect_apiai.py", line 8, in import urllib.request ImportError: No module named request -
django annotate weird behavavior (group by model.id)
In my DRF API, I have a view like this class ActivityAPI(viewsets.ModelViewSet): authentication_classes = (SessionAuthentication, TokenAuthentication) serializer_class = ActivitySerializer queryset = Activity.objects.order_by('-id').all() filter_backends = (DjangoFilterBackend,) filter_class = ActivityFilter filter_fields = ('name', 'ack', 'developer', 'ack_date', 'ack_by', 'verb') def get_count(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_queryset()) if CASE_1: queryset = queryset.values('verb').annotate(count=Count('verb')) if CASE_2: queryset = Activity.objects.values('verb').annotate(count=Count('verb')) return Response(data=queryset) In CASE_2, I got what i expected which is equivalent to SQL query SELECTactivity_activity.verb, COUNT(activity_activity.verb) AScountFROMactivity_activityGROUP BYactivity_activity.verbORDER BY NULL But when it's comes to CASE_1, the annotate feature groups the queryset by activity.id , that is SELECTactivity_activity.verb, COUNT(activity_activity.verb) AScountFROMactivity_activityGROUP BYactivity_activity.idORDER BYactivity_activity.idDESCNOTE I need url based filtered data for both API and Aggregation -
Django conflict with Conda
This the error that am getting when am running my server begin snippet: js hide: false console: true babel: false BASH language: lang-python --> Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x102994bf8> Traceback (most recent call last): File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper fn(*args, **kwargs) File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run autoreload.raise_last_exception() File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/utils/autoreload.py", line 250, in raise_last_exception six.reraise(*_exception) File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper fn(*args, **kwargs) File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/Users/sriharikapu/anaconda/lib/python3.6/site-packages/django/apps/config.py", line 94, in create module = import_module(entry) File "/Users/sriharikapu/anaconda/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked end snippet -
Context processors - behind the scenes
I can't believe there is no other thread on that subject. Even the documentation seems really unclear to me. So here it is: What is the mechanics behind context processors in Django? I have used them before, but if someone asks me to teach them what context processors are about, I probably could not answer. This is from Django documentation: context_processors is a list of dotted Python paths to callables that are used to populate the context when a template is rendered with a request. These callables take a request object as their argument and return a dict of items to be merged into the context. Can someone elaborate on this. How does that works behind the scene ? -
Django Rest Framework ModelSerializer create if not exists
I'm using Django Rest Framework 3.6.3. I'm trying to write nested create serializers for one optional argument and one required argument inside a child. I know that I need to override create in the base serializer to tell DRF how to create the nested children - http://www.django-rest-framework.org/api-guide/relations/#writable-nested-serializers. However, I can't figure out how to get it to parse the object information without telling it what the nested child serializer is defined as. Doing that then causes DRF to use it to parse the children objects, which then returns a validation error that I have no control over because the child serializer doesn't call its create method. Base Specification(many=True) OptionalField RequiredField The information I pass in is a JSON object: { base_id: 1, base_info: 'blah' specifications: [ { specification_id: 1, optional_info: { optional_id: 1, optional_stuff: 'blah' }, required_info: { required_id: 1, required_stuff: 'required', } } ] } The BaseCreationSerializer calls it's create method. I know that I need to pull out the rest of the information and create it manually. However, I can't figure out how to get the BaseCreationSerializer to parse the data into validated_data without defining specification = SpecificationCreationSerializer(), which then tries to parse that and throws an error. … -
Django Models: The default value for booleanfield did not get set in MariaDB
Django: 11.1 MariaDB: 10.2.6 In models.py, I set a boolean field as follows: class myClassName(models.Model): class Meta: db_table = 'mytablename' verbose_name = 'name' verbose_name_plural = 'names' ordering = ['myid'] (several fields defined here...) myField = models.BooleanField(verbose_name='name', default=True, help_text='some help here') def __str__(self): return str(self.myid) Then, do 'makemigrations' and 'migrate' Afterwards, I can see the table well defined in MariaDB, however default values are not set for the BooleanFields. The fields are defined as tinyint(1), Default=NULL. Do I need to set some other value in the field definition, in order to properly configure the default value in the database? -
Django, ajax upload file with extra data
I have a little question, I want to upload a file with some extra data. So what I'm doing now is: JS file: $(document).on('submit', '.upload-file', function(e){ e.preventDefault(); var form_data = new FormData($(this)); //I dont know why, but it used to return None //so I append file and some extra data form_data.append( 'file', ($(this).find('[type=file]')[0].files[0]) ); form_data.append( 'expire', ($(this).find('.document-id').val()) ); form_data.append( 'document', ($(this).find('[type=datetime-local]').val()) ); $.ajax({ type : 'POST', url : 'some_url', data : form_data, cache: false, processData: false, contentType: false, }).done(function(data) { console.log(data); }); }); Views.py def upload_file(request): if request.method =='POST': data = request.POST.get('data') file = request.FILES print('File ->', file) #this one prints File print('Data ->', data) #this one prints None return HttpResponse() Printed data: File -> <MultiValueDict: {'file': [<InMemoryUploadedFile: MyFile.docx (application/vnd.openxmlformats-officedocument.wordprocessingml.document)>]}> Data -> None So, I need to send file to external Server, which requeres some extra information, but I have no idea how to combine this data... Thnx everyone!