Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
reactjs/redux + django CSRF protection
I am trying to make an AJAX request from my reactjs frontend to my django backend but I am getting this error upon POST. I'm not sure how to properly pass CSRF tokens around for my form POST to work properly Forbidden (CSRF token missing or incorrect.): /api/contact [05/Nov/2016 03:43:14] "POST /api/contact HTTP/1.1" 403 2502 I created a react component and added it into my form CSRF component import React from 'react'; import $ from 'jquery'; function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie !== '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = $.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) === (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } const Csrf = () => { let csrfToken = getCookie('csrftoken'); return ( <input type="hidden" name="csrfmiddlewaretoken" value={ csrfToken } /> ); }; export default Csrf; Contact form component: const ContactForm = ({ formOnChange, onFormSubmit, isFullNameValid, isEmailValid, isMsgValid }) => { let rows = 10; let tabindex = 8; let isSubmitDisabled = !(isFullNameValid && isEmailValid && isMsgValid); return( <div className="form-wrapper"> <form … -
How to Create a Reminder Notification Django?
Hi I have this problem: My web app is for tracking goals of the user, every goal has reminders, so when a reminder has expired the app must alert the user. Example, Mark has a goal: "Run a marathon on december" and this goal has a reminder in every saturday at 15:00. So If Mark is using the app at 15:00 on a saturday, the browser must alert him. This is for my university so if the solution is simple, better ! I'm trying with django-notify-x https://github.com/v1k45/django-notify-x I can show the notification only if I refresh the browser. What can I do ? -
Media files not loading in email in Django
I have a Django project deployed on Apache web server. I am serving my media files in folder /var/www/media/. My media files load okay when I am on my web application. I have a feature which sends email to different people. In that email those media files should load, but they show 404 error in console. This is what I added in my apache2.conf file: WSGIScriptAlias / /home/search/egeirn/project/egeirn/wsgi.py WSGIPythonPath /home/search/egeirn/project:/home/search/virtualenvs/egerin/lib/python2.7/site-packages Alias /media/ /var/www/media/ Alias /static/ /var/www/static/ <Directory /var/www/static> Require all granted </Directory> <Directory /var/www/media> Require all granted </Directory> <Directory /home/search/egeirn/project/egeirn> <Files wsgi.py> Require all granted </Files> </Directory> This is my base.py file: ... STATIC_URL = '/static/' STATIC_ROOT = '/var/www/static/' MEDIA_URL = '/media/' MEDIA_ROOT = '/var/www/media/' ... This is my production.py file which is loaded in manage.py and wsgi.py: from .base import * DEBUG = False ALLOWED_HOSTS = ['iro.egerin.com'] MEDIA_URL = 'http://iro.egerin.com/media/' Please tell what I should do to load my media files out of the application like in email? Just to give an idea this is the error in the console: -
How can I store time based data in a Django model?
I am building a web application in Django. I have a system that will send a signal every minute to the application of how many people are in a building. I then want to be able to acess the data of a building (model) to e.g. display it in a graph (amount of people in the building during the course of an hour), or look up how many people there were e.g. at 5.30pm last wednesday. How can I build this into a model where I can look up data based on date/time? Thanks. -
Is it possible to build a django front end view with bootstrap only minus django views?
I want to build a django app minus using django views... Is it possible because I only want to concentrate on only bootstrap and python minus the django views.. And if I may get any added advantages of using views?! -
Django Cannot Import Name
Whenever I run in terminal server, I'm always getting "cannot import name hours-ahead" even though I defined it and called it. Here is my views.py from django.http import HttpResponse import datetime def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is nose %s. </body></html>" % now return HttpResponse(html) def hours_ahead(request, offset): offset = int(offset) dt = datetime.datetime.now() + datetime.timedelta(hours=offset) html = "<html><body>In %s hour(s), it will be %s.</body></html>" % (offset, dt) return HttpResponse(html) and here is my urls.py that is supposed to call it but getting error for hours_ahead from django.http import HttpResponse from django.contrib import admin from mysite.views import current_datetime, hours_ahead urlpatterns = patterns('', (r'^time/$', current_datetime), (r'^time/plus/(\d{1,2})/$', hours_ahead), ) -
Loading a Django form with initial values upon construction
I'm attempting to load a Django "Clothes_Form" with multiple initial values through one of my view functions. Specifically, I want to set the "gender" field and designate choices for the "clothing_type" field. I've included relevant code below: models.py class Clothes_Item(models.Model): user = models.ForeignKey(User) gender = models.CharField(max_length=14) #Removed Code clothing_choices = [(" ", " ")] #default values set later through view clothing_type = models.CharField(choices=clothing_choices, max_length=14) views.py def profile(request, username): user = request.user context = {} if user.is_authenticated(): #Removed Code male_form = Clothes_Form([ {'gender': 'male', 'choices' : (('Tops', 'Tops'), ('Bottoms', 'Bottoms'), ('Shoes', 'Shoes'), ('Accessories', 'Accessories'),('Costumes', 'Costumes'), ('Other', 'Other')) } ]) female_form = Clothes_Form([ {'gender': 'female', 'choices' : (('Tops', 'Tops'), ('Bottoms', 'Bottoms'), ('Dresses', 'Dresses'), ('Shoes', 'Shoes'), ('Accessories', 'Accessories'),('Costumes', 'Costumes'), ('Other', 'Other'))} ]) context = {'username': username, 'clothes': clothes, 'male_form' : male_form, "female_form" : female_form, "favorite_clothes": favorite_clothes, "favorite_clothes_ids": favorite_clothes_ids} return render(request, 'profile.html', context) forms.py class Clothes_Form(forms.ModelForm): class Meta: model = Clothes_Item fields = ['name', 'description','size', 'price', 'image', 'gender', 'clothing_type'] def getChoices(self): return self.fields['clothing_type'].choices def __init__(self, *args, **kwargs): super(Clothes_Form, self).__init__(*args, **kwargs) self.fields['gender'] = args[0] self.fields['clothing_type'].choices = args[1] I know that I'm doing something wrong as I'm passing data from the view to init in the forms class, as I am getting a "tuple index out … -
Can I indirectly use a form in Django?
In my django app I am trying to generate a question from a set of objects, then when that is answered create a result object that has a score based on how much of the answer the user got correct. I have split up my set of question objects into the appropriate parts to iterate through to generate a form. What I would like to know is how to calculate the total number of checkboxes on a page and the number of check boxes selected and pass that to django so I can calculate and set the score attribute of a result object in a view. From what I have seen of ModelForms, they only work by directly inputting data into the database rather than submitting it to the backend for further computation. Furthermore it seems that the ModelForm is generated from the model type that you want to create, whereas I want to create a result as a result of a form generated from another model. -
How to generate a file upload (test) request with Django REST Framework's APIRequestFactory?
I have developed an API (Python 3.5, Django 1.10, DRF 3.4.2) that uploads a video file to my media path when I request it from my UI. That part is working fine. I try to write a test for this feature but cannot get it to run successfully. #views.py import os from rest_framework import views, parsers, response from django.conf import settings class FileUploadView(views.APIView): parser_classes = (parsers.FileUploadParser,) def put(self, request, filename, format=None): file_obj = request.data['file'] handle_uploaded_file(file_obj, filename) return response.Response(status=204) def handle_uploaded_file(file_obj, filename): dir_name = settings.MEDIA_ROOT new_filename = 'myvid.mp4' if not os.path.exists(dir_name): os.makedirs(dir_name) file_path = os.path.join(dir_name, new_filename) with open(file_path, 'wb+') as destination: for chunk in file_obj.chunks(): destination.write(chunk) and #test.py import tempfile import os from django.test import TestCase from django.conf import settings from django.core.files import File from django.core.files.uploadedfile import SimpleUploadedFile from rest_framework.test import APIRequestFactory from myapp.views import FileUploadView class UploadVideoTestCase(TestCase): def setUp(self): settings.MEDIA_ROOT = tempfile.mkdtemp(suffix=None, prefix=None, dir=None) def test_video_uploaded(self): """Video uploaded""" filename = 'vid' file = File(open('media/testfiles/vid.mp4', 'rb')) uploaded_file = SimpleUploadedFile(filename, file.read(), 'video') factory = APIRequestFactory() request = factory.put('file_upload/'+filename, {'file': uploaded_file}, format='multipart') view = FileUploadView.as_view() response = view(request, filename) print(response) dir_name = settings.MEDIA_ROOT new_filename = 'myvid.mp4' file_path = os.path.join(dir_name, new_filename) self.assertTrue(os.path.exists(file_path)) In this test, I need to use an existing video file ('media/testfiles/vid.mp4') … -
django username-related URL resolution fails when username has odd characters
So, the default Django User model allows usernames to have a few weird characters - e.g. I can make a user called '@.+-_'. However, I've made a user profile page whose url is dependent on username. I'd like to use the username instead of user_id because it's more readable: url(r'^public_profile/(?P<username>[\w\d]+)$', views.public_profile, name='public_profile'), This works fine for most users, but when a user with a funky name - e.g. '@.+-_' is looked up, the public_profile page fails with a Reverse for 'public_profile' with arguments '('@.+-_',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['public_profile/(?P<username>[\\w\\d]+)$'] error. --> So, I figured I could add a 'slug' field to the User model, and use that plus the user_id in the url (so slugs don't accidentally collide), but I'm not sure how to modify the User model since it's part of django. Any ideas on how to do this? Thanks -
rauth: the JSON object must be str, not 'bytes'
Trying to implement a OAuth2 authentication on Django 1.10 + Python 3, I'm getting this error: rauth: the JSON object must be str, not 'bytes' It happens on the line calling: session = sso.get_auth_session(data=data, decoder=json.loads). If i remove the decoder=json.loads, I get the following error: Decoder failed to handle access_token with data as returned by provider. A different decoder may be needed. Here is my method: def login(request): """ Login view @author: Leonardo Pessoa @since: 11/06/2016 """ from rauth import OAuth2Service from django.conf import settings import json # instantiating our login service with environment defined settings sso = OAuth2Service( name = settings.LOGIN_SETTINGS['name'], client_id = settings.LOGIN_SETTINGS['client_id'], client_secret = settings.LOGIN_SETTINGS['client_secret'], access_token_url = settings.LOGIN_SETTINGS['access_token_url'], authorize_url = settings.LOGIN_SETTINGS['authorize_url'], base_url = settings.LOGIN_SETTINGS['base_url'], ) # check if we have a login code returned by OAuth get_code = request.GET.get('code', '') if get_code == '': params = { 'redirect_uri' : settings.LOGIN_SETTINGS['redirect'], 'response_type' : 'code' } url = sso.get_authorize_url(**params) return redirect(url) else: # we are in! data = {'code' : get_code, 'grant_type' : 'authorization_code', 'redirect_uri' : settings.LOGIN_SETTINGS['redirect'] } session = sso.get_auth_session(data=data, decoder=json.loads) return redirect('/logado/') Any ideas? -
How simplify django template code?
And adding variable, if working time = 1, else 0 {% now "w" as w %} {% now "G" as h %} <div class="col s6"> <table> <tbody> <tr {% if w == '1' %}class="{% if h <= '9' and h >= '15' %}red accent-3{% else %}teal{% endif %} white-text"{% endif %}> <td class="pE">Monday</td> <td class="qE">9:00–15:00</td> </tr> <tr {% if w == '2' %}class="{% if h <= '9' and h >= '17' %}red accent-3{% else %}teal{% endif %} white-text"{% endif %}> <td class="pE">Tuesday</td> <td class="qE">9:00–17:00</td> </tr> <tr {% if w == '3' %}class="{% if h <= '9' and h >= '17' %}red accent-3{% else %}teal{% endif %} white-text"{% endif %}> <td class="pE">Wednesday</td> <td class="qE">9:00–17:00</td> </tr> <tr {% if w == '4' %}class="{% if h <= '9' and h >= '17' %}red accent-3{% else %}teal{% endif %} white-text"{% endif %}> <td class="pE">Thursday</td> <td class="qE">9:00–17:00</td> </tr> <tr {% if w == '5' %}class="{% if h <= '9' and h >= '17' %}red accent-3{% else %}teal{% endif %} white-text"{% endif %}> <td class="pE">Friday</td> <td class="qE">9:00–17:00</td> </tr> <tr {% if w == '6' %}class="{% if h <= '9' and h >= '17' %}red accent-3{% else %}teal{% endif %} white-text"{% endif %}> <td class="pE">Saturday</td> <td class="qE">9:00–17:00</td> … -
Django deployment with Django-Channels
I use the web host Webfaction for my website developed with Django 1.10 and python 3.5. I am trying to use the Django package Django-Channels (https://github.com/django/channels/blob/08857cfe39f35b203c7bbe3156a077b5b2c66764/docs/index.rst) but I have many difficults. This package uses Redis (I have already install it). When I try to go on my website, I have the error Server Error (500). I don't know how can I proceed for use Django-Channels on my website. In my settings.py : CHANNEL_LAYERS = { "default": { "BACKEND": "asgi_redis.RedisChannelLayer", "CONFIG": { "hosts": [("localhost", 6379)], }, "ROUTING": "projup.routing.channel_routing", }, } And for run my site I do (in ssh) : daphne projup.asgi:channel_layer (In a console, I have the message "Starting server at 127.0.0.1:8000") python3.5 manage.py runworker (In other console, I have the message " Running worker against channel layer default (asgi_redis.core.RedisChannelLayer)") I don't have errors in my logs. I don't configure redis.conf. I have only use the tutorial : https://channels.readthedocs.io/en/stable/deploying.html Thank you -
Django REST Framework: Nest content of related model
How do I get the content of a combination table that is related to two separate tables with foreign-key relationships but where the model to be serialized does not have a field with fk-relation to the table? Take these three models: class Manuscript(models.Model): library = models.CharField(max_length=500, required=True) dating = models.CharField(max_length=500, required=False, null=True) class Text(models.Model): title = models.CharField(max_length=500, required=True) author = models.CharField(max_length=500, required=True) class ManuscriptContent(models.Model): manuscript = models.ForeignKey(Manuscript, required=True) content = models.ForeignKey(Text, required=True) folios = models.CharField(max_length=500, blank=True, null=True) Clearly, the ManuscriptContent model is used to create content entries that are found in a given manuscript by connecting the Text and Manuscript models. I would like to return data looking something like this: [ { "id": 209, "library": "Bibliothek des Benediktinerstifts", "date": "1367", "content": {[ {"content": "John Doe's adventures", "folios": "1r-5v"}, {"content": "John Doe's adventures II", "folios": "6r-10v"} ]}, }, { "id": 210, "library": "Bibliothèque Nationale de France", "date": "1265", "content": {[ {"content": "John Doe's adventures", "folios": "1r-5v"}, {"content": "John Doe's adventures II", "folios": "6r-10v"} ]}, }, ... ] According to another question (Django Rest Framework - Get full related objects in list) this should be possible with these serializers: class ContentSerializer(serializers.ModelSerializer): manuscript = serializers.StringRelatedField() content = serializers.StringRelatedField() class Meta: model = … -
multiple timezones tasks with django celery for multi tenant schema
i am currently working on a multi tenant schema project, using django-tenant-schemas, so i have a schema per tenant, they have separate date settings, to be clear each schema has a timezone. i want the tasks to be run based on a different bases on timezone specified by each schema. after some research i found that i need to create multiple tasks, each task for a certain timezone, but this seems to be inficient, is there is a another way or tool to help me acheive what i am trying to implement ? -
Make group by having count(*) with django orm
With following model: class Day(models.Model): date = models.DateField( unique=True, null=False, blank=False, ) class Reservation(models.Model): user = models.ForeignKey( User, null=False, blank=False, related_name='reservations', verbose_name=_('Utilisateur'), ) day = models.ForeignKey( Day, null=False, blank=False, related_name='reservations', ) To get days ids where number of reservations is lower or equal 5 i do: SELECT day_id FROM meal_reservation GROUP BY day_id HAVING count(*) <= 5 But how to do it with Django ORM ? -
How to structure a very small Django Project?
It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project. -
Django Multiple Model Form
I thought I was getting okay with Django until I got to the need to use multiple models in one form. So, I have a customers table called "TblCompanies" and a service records table called "TblServiceRecords". These BOTH have primary keys and do not have foreign keys. The TblServiceRecords table has a column that contains the TblCompanies primary key that belongs to the appropriate company that had the work done for them. On the company list detail view, I've customized it completely with just the TblCompanies model. Now I need to add in pieces of the TblServiceRecords model; i.e. list all the service records related to that company. I've searched for tutorials or examples but there isn't much outside of the generic forms built into django. On the other side of this, the service record side, I've created a form view that simply lists top last 200 service records sorted decending by date. I want to show the company, the date, and the originator. To show the company, I need to use the associated company ID to reference the company name in the TblCompanies model. Can I continue to use generic views to do that? If so, how? If not, … -
Django model design pattern - best approach
I'm developing a Django based investing app that allows clients to transfer in Cash which we then invest into a Portfolio for them. Django models provide a few options (different managers, abstract types) and I'm trying to figure out the best approach and how to apply. My basic architecture is: Account - name - etc. Cash - account - type (credit/debit) - status (pending, complete) - amount - resulting_balance Portfolio - account - type (buy, sell) - stock - units - resulting_units My system allows micro investing by aggregating all the clients Portfolio trades for any day, and then performing a Fund level market trade and allocating each client their portfolio. This means the Cash and Portfolio models are nearly identical for a fund. I'll need to track relationships between the Funds Portfolio purchase and the Account purchase. Similarly the Account will then transfer Cash to the Fund. For example, If I debit a clients Cash for a purchase, I'll credit the Funds Cash within the same transaction. FundCash == Cash FundPortfolio == Portfolio There are some differences, mostly I don't technically need an account at the Fund level but I'm not sure that this really hurts. The fund will … -
Having count and group by with django orm
With following models: class Day(models.Model): date = models.DateField( unique=True, null=False, blank=False, ) class Reservation(models.Model): user = models.ForeignKey( User, null=False, blank=False, related_name='reservations', verbose_name=_('Utilisateur'), ) day = models.ForeignKey( Day, null=False, blank=False, related_name='reservations', ) Trying to do: select * from meal_day left join meal_reservation on meal_day.id = meal_reservation.day_id group by meal_day.id having count (distinct meal_reservation.user_id) <= 1 I'm doing this with: Day.objects \ .annotate(reserved_users_count=Count('reservations__user_id')) \ .filter(reserved_users_count__lte=1) But this query produce: SELECT "meal_day"."id", "meal_day"."date", COUNT("meal_reservation"."user_id") AS "reserved_users_count" FROM "meal_day" LEFT OUTER JOIN "meal_reservation" ON ("meal_day"."id" = "meal_reservation"."day_id") GROUP BY "meal_day"."id", "meal_day"."date" HAVING COUNT("meal_reservation"."user_id") <= 1 ORDER BY "meal_day"."date" ASC How to produce wanted sql query ? -
Add django admin password field to custom user admin
I have created a custom user as below: class AObjectManager(BaseUserManager): def _create_user(self, email, password, is_staff, is_superuser, **extra_fields): if not email: raise ValueError('The given email must be set') email = self.normalize_email(email) user = self.model(email=email, is_staff=is_staff, is_superuser=is_superuser, **extra_fields) user.set_password(password) user.save(using=self._db) return user def create_user(self, email, password, **extra_fields): return self._create_user(email, password, False, False, **extra_fields) def create_superuser(self, email, password, **extra_fields): return self._create_user(email, password, True, True, **extra_fields) class AObject(AbstractBaseUser): email = models.EmailField(_('email address'), max_length=254, unique=True) is_staff = models.BooleanField(_('staff status'), default=False, help_text=_('Designates whether the user can log into this admin ' 'site.')) is_superuser = models.BooleanField(_('superuser status'), default=False, help_text=_('Designates that this user has all permissions without ' 'explicitly assigning them..')) objects = AObjectManager() USERNAME_FIELD = 'email' def get_full_name(self): return self.email def get_short_name(self): return self.email def has_perm(self, perm, obj=None): return self.is_superuser def has_module_perms(self, app_label): return self.is_superuser admin.py class AObjectAdmin(UserAdmin): fieldsets = ( (None, {'fields': ('email', 'password')}), (_('Permissions'), {'fields': ('is_staff', 'is_superuser')}), ) add_fieldsets = ( (None, { 'classes': ('wide',), 'fields': ('email', 'password1', 'password2')} ), ) list_display = ('email', 'is_staff', 'is_active') search_fields = ('email') ordering = ('-email',) When I run this I get errors: <class 'testapp.admin.AObjectAdmin'>: (admin.E019) The value of 'filter_horizontal[0]' refers to 'groups', which is not an attribute of 'testapp.AObject'. <class 'testapp.admin.AObjectAdmin'>: (admin.E019) The value of 'filter_horizontal[1]' refers to … -
Django-REST-framework - forming endpoint/url for viewset
api_urls.py: urlpatterns = [ url(r'^accounts/', include('apps.accs.urls')), ] apps.accs.urls: router = DefaultRouter() router.register('', AccountViewSet, 'accounts') urlpatterns += router.urls models.py: class Account(models.Model): pass class TargetUser(models.Model): account = models.ForeignKey(Account, related_name='target_users') views.py: class AccountViewSet(viewsets.ModelViewSet): serializer_class = AccountSerializer queryset = Account.objects.all() @detail_route(methods=['get', 'post']) def target_users(self, request, pk=None): account = self.get_object() if request.method == 'POST': # here I'm creating the instance of TargetUser elif request.method == 'GET': # here I'm getting the list of TargetUser instances As per the code above I have the following urls: /accounts/ - here I get the list of accounts /accounts/{pk}/ - here I get the particular account /accounts/{pk}/target_users/ - if GET, I get the list of TargetUser instances, that belong to the particular account; if POST, I create the new TargetUser instance for particular account The question is - how should I realize the following url - /accounts/{pk}/target_users/{user_pk} with possibility to GET and DELETE particular target user. Thanks a lot!!! -
What is the recommended way to use a Google Storage backend for a Django app running on app engine?
There is alot of unanswered questions about how to handle Django connections to Google Storage with a custom backend. Configure Django and Google Cloud Storage? http://dev.pippi.im/writing/django-upload-on-google-cloud-storage/ https://github.com/ckopanos/django-google-cloud-storage etc. I have it working by manually handling file creation (in the example for an xlsx file) and an uploading it with this: import cloudstorage as gcs from google.appengine.api import app_identity import xlsxwriter import StringIO bucket_name = os.environ.get('BUCKET_NAME', app_identity.get_default_gcs_bucket_name()) bucket = '/' + bucket_name filename = bucket + '/'+ userid + '/' + [some code] + '.xlsx' gcs_file = gcs.open(filename, 'w', content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', options={'x-goog-meta-user': userid}) output = StringIO.StringIO() workbook = xlsxwriter.Workbook(output, {'in_memory': True}) worksheet = workbook.add_worksheet() worksheet.write(0, 0, 'Hello World') # Close the workbook before streaming the data. workbook.close() # Rewind the buffer. output.seek(0) gcs_file.write(output.read()) gcs_file.close() What is the recommended approach for using a Custom Storage System which using Google Storage. This is for a Django app hosting on GAE. -
how to start Crontab in Django Project locally?
I still pretty new to the use of crontab in Django. I have followed the instruction in this link https://hprog99.wordpress.com/2014/08/14/how-to-setup-django-cron-jobs/ to help me set up my method, my_scheduled_job() in cron.py file, which I want to call every five minutes. Here is my updated setting.py INSTALLED_APPS = ( 'django_crontab', ...) CRONJOBS = [ ('*/5 * * * *', 'myproject.cron.my_scheduled_job') ] After which I ran this: python manage.py crontab add Output: adding cronjob: (d0428c9ae8227ed78b17bf32aca4bc67) -> ('*/5 * * * *', 'cinemas.cron.my_scheduled_job') Next: Nothing happens. How do I start this cron job locally? Is there a way to test if my job ran normally? Thanks -
Can we send multiple responses in intervals to a single request, Using Django as server?
I am just working on an app, which sends a request to the server asking it to report the details of a device every 10 seconds for the next 60 seconds. I am using Django framework as the backend server. Can we send multiple responses to a single request from the app? If yes, Can you point me in the right direction.