Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django legacy database migration of many to many intermediate table
Legacy DB migration to Django (v1.11) (from Sequelize). An intermediary table in the database has no id (primary key attribute) as Sequelize doesn't require it, but seems it is compulsory in Django. Current Django setup: class Address(models.Model): keyword = models.CharField(max_length=255) city = models.CharField(max_length=255, blank=True, null=True) state = models.CharField(max_length=255, blank=True, null=True) createdAt = models.DateTimeField(db_column='createdAt', auto_now_add=True) updatedAt = models.DateTimeField(db_column='updatedAt', auto_now=True) class Meta: db_table = 'Addresses' class CustomerExecutive(models.Model): name = models.CharField(max_length=255, blank=True, null=True) email = models.CharField(max_length=255) addresses = models.ManyToManyField('Address', through='AddressCustomerExecutiveMapping') createdAt = models.DateTimeField(db_column='createdAt', auto_now_add=True) updatedAt = models.DateTimeField(db_column='updatedAt', auto_now=True) class Meta: db_table = 'CustomerExecutives' class AddressCustomerExecutiveMapping(models.Model): address = models.ForeignKey(Address, db_column='addressId', primary_key=True) customer_executive = models.ForeignKey(CustomerExecutive, db_column='customerExecutiveId', primary_key=True) createdAt = models.DateTimeField(db_column='createdAt', auto_now_add=True) updatedAt = models.DateTimeField(db_column='updatedAt', auto_now=True) class Meta: db_table = 'AddressCustomerExecutiveMapping' unique_together = (('address', 'customer_executive'),) If primary_key is not specified on AddressCustomerExecutiveMapping.address or AddressCustomerExecutiveMapping.customer_executive it gives a primary key required error and if specified, I'm unable to add duplicate values in the column (not many to many then). How can I solve this? -
django : create a HTML alert based on ModelForm fields?
I'm working on user-leaves-managing-system models.py CHOICES = (('Earned Leave','Earned Leave'),('Casual Leave','Casual Leave'),('Sick Leave','Sick Leave'),('Paid Leave','Paid Leave')) class User(models.Model) type_of_leave = models.CharField(max_length = 15, choices = CHOICES) from_date = models.DateField() to_date = models.DateField() forms.py class RequestForm(ModelForm): class Meta: fields = ( "type_of_leave", "from_date", "to_date") model = Leave widgets = { 'from_date' : DateInput(attrs={'class': 'datepicker'}), 'to_date' : DateInput(attrs={'class': 'datepicker'}), } views.py def leaveRequest(request): if request.method == "POST": form = LeaveRequestForm(request.POST) if form.is_valid(): leave = form.save(commit = False) leave.user = request.user form.save() return HttpResponseRedirect("/thanks/") else: ... The user applies for a leave, for each type of leave I have given a default value of 10 days in the db through the admin. So, if the user applies for more than the leaves he have I want to generate an HTML alert with a message, i.e if the leaves are used off to the fullest or becomes = 0. So I'm confused where and how to define it. -
using Django Session
guys. I want to show user login info using session. Please Help me. Thank you. My code is here. views.py def index(request): bbs_query = models.Blog.objects.all() try: if(request.session['logined_user']): return render(request, 'index.html', {'blogs': bbs_query}) except KeyError: return redirect('login') index_header.html <b class="hidden-xs">{% request.session['logined_user'] %}</b> I want to render from view.py to index.html. But index.html includes index_header.html. So, I want to show session info in index_header.html. -
Load a template with Django and React JS with a single GET call
I am building an application with Django as the backend and React js for making the interface of the application. I have a set of Posts which I want to display. Currently, the approach which I am following is - Get the template having the compiled js code linked to it. Then again make get call to get the posts My question is - In this current approach I am making 2 GET calls to the backend, one for rendering the template and then again for getting the Post. What is the best way to achieve this? Is this the usual flow how applications are built using Django and React JS? -
Unable to login from facebook social auth in my django application
I have developed an application in Django and I want to use the facebook authentication in my application. For this, I add social_django in my app. Then I create the application login application on facebook developer. In basic settings I put following: App Name: mywebsite_name **Privacy Policy URL: https://mydomain(domain has ssl certificate) Site URL: https://mydomain In the facebook login App setting: Client OAuth Login : yes Web OAuth Login: yes Enforce HTTPS: yes Force Web OAuth Reauthentication: No Embedded Browser OAuth Login: Yes Use Strict Mode for Redirect URIs: Yes Valid OAuth Redirect URIs :https://mydomain/login/callback Login from Devices : No I have also added my appid and app secret in settings.py file as using .env file SOCIAL_AUTH_FACEBOOK_KEY = config('SOCIAL_AUTH_FACEBOOK_KEY') SOCIAL_AUTH_FACEBOOK_SECRET = config('SOCIAL_AUTH_FACEBOOK_SECRET') In the urls.py file I do this: <p><a href="{% url 'social:begin' 'facebook' %}">Continue With Facebook</a> </p> But unfortunately I am getting the following error: Insecure login blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https:// ? And again note I have https domain name Please help me to remove this error. -
Firefox can’t establish a connection to the server at ws://sportzilla.ml/ws/chat/Room10/
I am trying to host my web app which is based on django channels .This is the link of my repo-https://github.com/Vishnupriya1507/Django-Channels/tree/Index-page-Backend Site is hosted on digital ocean but its giving error as-"Firefox can’t establish a connection to the server at ws://sportzilla.ml/ws/chat/Room10/.". This is my ngnix configuration file: [https://i.stack.imgur.com/HioBf.png][1] [1]: this is my settings.py [channels layer]-- and ALLOWED_HOSTS = [ 'sportzilla.ml','139.59.94.9',]. I have used gunicorn and ngnix. this is how terminal look like: Thanks in advance:) -
Convert URL of an object to its database instance
I created an extra function in my View that receives a list with hyperlinked references to some Group objects, but I don't know how to convert them to database instances class ResourceViewSet(viewsets.ModelViewSet): queryset = Resource.objects.all() serializer_class = ResourceSerializer @action(methods=['put'], detail=True) def groups_append(self, request, pk=None): instance = self.get_object() groups = request.data.get("groups") for group in groups: instance.groups.add(WHAT_HERE(group)) instance.save() return Response(self.get_serializer(instance, many=False).data) This is the request: PUT http://.../api/resources/1/groups_append/ with body: {"groups": ["http://.../api/groups/1/", ...]} -
button value returns "undefined" in jquery
this is my form: <form action="{%url 'BestOfBrands:vote' sub2category.id %}" method="post" class="brand-form"> {% csrf_token %} <button class="brandvotesub" type="submit" name="brand" id="brand{{forloop.counter}}" value="{{brand.id}}"></button> </form> and this is my jquery which handles request: $(document).ready(function() { $(".brand-form button[type=submit]").css('border','0px solid black'); $(".brand-form").submit(function(event) { event.preventDefault(); var val = $(this).find("button[type=submit][clicked=true]").val(); console.log("create post is working!"); acturl = $(this).attr('action'); console.log(acturl); console.log(val); this works completely well in the local host but in real website returns "undefined" for "val". -
Django 2.1.1 'set' object is not reversible'set' object is
This is basically the error im getting shops/urls >#/shop/ >from django.urls import path`enter code here >from . import views > >app_name='shop' > >urlpatterns = [ > path('', views.allProdCat, name='allProdCat'), > path('<slug:c_slug>/', views.allProdCat, name='products_by_category'), > path('<slug:c_slug>/<slug:product_slug>/', views.ProdCatDetail, >name='ProdCatDetail'), >] shop/templates/shop/header {% load staticfiles %} <header> <center> <a href="{% url 'shop:allProdCat' %}"><img class ='zapp-logo' src="{% static 'img/zapp_banner.jpg' %}" alt="Logo "></a> </center> </header> Went through some searches but I really feel my problem is unique so far, havent found any solutions. Anyone knows the problem? -
Django - Objects from Pointer into SQL-Database
After opening a connection to a SAP Hana database and creating a pointer that gets data by .fetchmany or .fetchone, how can i iterate over that pointer and save my data in my django default database? -
Displaying output of the CheckboxSelectMultiple
I created a CheckboxSelectMultiple form for my Django app. When a user selects the choices, I want to show it on the 'details' page. But when I make it, it displays <django.forms.fields.CharField object at 0x7faf189cad10> How can I fix it and display the output of the choice of the user? models.py from __future__ import unicode_literals from django.utils import timezone from django.db import models from django import forms LANG_CHOICES = ( ('java', 'JAVA'), ('c/c++', 'C/C++'), ('python', 'PYTHON'), ('html', 'HTML'), ('css', 'CSS'), ('javascript', 'JAVASCRIPT'), ) class Project(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) email = models.CharField(max_length=100) project_name = models.CharField(max_length=300) project_description = models.TextField() project_notes = models.TextField() select_langs = forms.CharField(label='dil sec: ', widget=forms.Select(choices=LANG_CHOICES)) created_date = models.DateTimeField( default=timezone.now) published_date = models.DateTimeField( blank=True, null=True) views.py ... project.lang_choices = form.cleaned_data['select_lang'] forms.py ... select_lang = forms.CharField(label='languages: ', widget=forms.CheckboxSelectMultiple(choices=LANG_CHOICES)) project_details.html <h1> The programming languages that user's will use: {{project.select_langs}} </h1> -
In a Django Template, how can i clone a div containing Select2 elements, cloning their corresponding values?
I'm trying to clone a select inside a div. But when i clone the element, the Select2 element doesn't have the loaded values by the Django code. How can i clone my div with all the Select2 element values? When i clone, it clones, but the selects are not showing the values. Thank you so much. <script> counter = 0 function addTopic(){ $( "#select" ).clone().appendTo( "#trying" ); } </script> </head> <body> <button onclick="addTopic()">Add Topic</button> <form action="{% url 'testing_show' %}"> <div id="trying"> <div id="select"> <select class="js-example-basic-multiple" multiple="multiple"> {% for taf_doc in taf_documents %} <option value="{{ taf_doc.id }}">{{ taf_doc.taf.nom }}</option> {% endfor %} </select> <select class="js-example-basic-multiple" multiple="multiple"> {% for ue_doc in ue_documents %} <option value="{{ ue_doc.id }}">{{ ue_doc.ue.nom}}</option> {% endfor %} -
In Django, I have model in which based upon certain field , next field mapping of foreign-key has to be decided
models.py class dummy(models.Model): GEOTYPE_CHOICES = ( (u'1', u'country'), (u'2', u'state'), (u'3', u'district'), (u'4', u'pincode')) geoType = models.CharField(max_length=9, choices=GEOTYPE_CHOICES) if geoType==1: geoId = models.ForeignKey(CountryMaster,null=True,blank=True,on_delete=models.CASCADE) elif geoType==2: geoId = models.ForeignKey(StateMaster,null=True,blank=True,on_delete=models.CASCADE) elif geoType==3: geoId = models.ForeignKey(DistrictMaster,null=True,blank=True,on_delete=models.CASCADE) else: geoId = models.ForeignKey(PincodeMaster,null=True,blank=True,on_delete=models.CASCADE) if the user gives geotype as 2 then statemaster has be called in the geoId.like wise i need to do. But i am not able to register geoId in my database while migration. any pointers on this will be a great help. thanks in advance. -
Django : datepicker in ModelForm
in the model, I have two fields like from_date = models.DateField() to_date = models.DateField() in the forms i have defined it as widgets = { 'from_date' : DateInput(attrs={'class': 'datepicker'}), 'to_date' : DateInput(attrs={'class': 'datepicker'}), } in the base html, I have written the jQuery code for datepicker as <script> $(document).ready(function() { $('.datepicker').datepicker( { minDate : 0, beforeShowDay : $.datepicker.noWeekends } ); }); </script> I have zero knowledge in javascript and jQuery, all I want to implement is to_date should be always greater than from_date. How do I do that? -
How to fetch translation record in django
I am new in django framework.I have 3 tables in mysql database. I want to fetch data from main table with translation table and images table. My model.py class Country(models.Model): #id = models.IntegerField(primary_key=True) iso_code = models.CharField(max_length=2, unique=True) slug = models.CharField(max_length=255, unique=True) is_featured = models.IntegerField(max_length=1) class Meta: db_table = 'rh_countries' class CountryTranslation(models.Model): country_id = models.ForeignKey(Country, on_delete=models.CASCADE) name = models.CharField(max_length=255) description = models.TextField(blank=True, null=True) locale = models.CharField(max_length=2) class Meta: db_table = 'rh_countries_translations' class CountryImage(models.Model): country_id = models.ForeignKey(Country, on_delete=models.CASCADE) image = models.CharField(max_length=255) is_main = models.IntegerField(max_length=1) class Meta: db_table = 'rh_country_images' Now I want to fetch all country with translation record by locale and associated image. Please give a solution if anyone know. -
Django Deployment - issue with supervisor failing (exited too quickly)
I'm on my first Django deployment on Digital Ocean and I can't seem to get past an error that's rising when I check the status of supervisor. here's my happ.conf file (/etc/supervisor/conf.d.happ.conf) [program:happ] command=sh /home/happ/gunicorn_start user=happ autostart=true autorestart=true redirect_stderr=true stdout_logfile=/home/happ/logs/gunicorn.log and here's my gunicorn_start file (/home/happ/gunicorn_start) #!/bin/bash NAME="happ" DIR=/home/happ/happ USER=happ GROUP=happ WORKERS=3 BIND=unix:/home/happ/run/gunicorn.sock DJANGO_SETTINGS_MODULE=happ.settings DJANGO_WSGI_MODULE=happ.wsgi LOG_LEVEL=error cd $DIR source ../venv/bin/activate export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE export PYTHONPATH=$DIR:$PYTHONPATH exec ../venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \ --name $NAME \ --workers $WORKERS \ --user=$USER \ --group=$GROUP \ --bind=$BIND \ --log-level=$LOG_LEVEL \ --log-file=- Firstly I make the file executable: chmod u+x gunicorn_start Then I run the following commands: sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl status happ And once I run the status command I get the following error: Exited too quickly. Here's what the log file says: /home/happ/gunicorn_start: 2: /home/happ/gunicorn_start: : not found /home/happ/gunicorn_start: 12: /home/happ/gunicorn_start: : not found /home/happ/gunicorn_start: 13: cd: can't cd to /home/happ/happ /home/happ/gunicorn_start: 14: /home/happ/gunicorn_start: source: not found /home/happ/gunicorn_start: 15: /home/happ/gunicorn_start: : not found /home/happ/gunicorn_start: 18: /home/happ/gunicorn_start: : not found /home/happ/gunicorn_start: 19: exec: ../venv/bin/gunicorn: not found Please note that the above commands are run inside the console not by the user root but by a user I created which is added to the sudoers … -
Running django auth migrations doesn't create tables in db
I have been using django for many years but have not seen such issue before. I am working on an old project. And I am originally facing this issue. So as the solution suggest, I run auth migrations first, $python manage.py migrate auth Operations to perform: Apply all migrations: auth Running migrations: Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying contenttypes.0002_remove_content_type_name... OK Applying auth.0002_alter_permission_name_max_length... OK Applying auth.0003_alter_user_email_max_length... OK Applying auth.0004_alter_user_username_opts... OK Applying auth.0005_alter_user_last_login_null... OK Applying auth.0006_require_contenttypes_0002... OK Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK But when I check my database, only django_migrations table gets created. I don't see auth_user, auth_group, auth_permissions, etc. My INSTALLED_APPS looks like this, INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'debug_toolbar', 'djcelery', 'widget_tweaks', 'djangosaml2', # ... more apps from my project ] What could be wrong? Has anyone come across such issue. -
how to connect django local with postgress in heroku
how to connect django with postgres in heroku live how to connect live heroku postgress with my local server. Is there is any way to backup heroku database how database connection in heroku production is done this is my local.py import dj_database_url from .base import * ROOT_URL = 'http://localhost:8000' ALLOWED_HOSTS = ['localhost:8000'] SECURE_SSL_REDIRECT = False # SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') DEBUG = True INSTALLED_APPS.extend([ 'collectfast', ]) INSTALLED_APPS.extend([ 'django.contrib.staticfiles', # 'djcelery', ]) DATABASES = { 'default': dj_database_url.config() } print(DATABASE_URL) # AWS and S3 settings AWS_ACCESS_KEY_ID = '' AWS_SECRET_ACCESS_KEY = '' AWS_STORAGE_BUCKET_NAME = 'jagah-production' AWS_QUERYSTRING_AUTH = False AWS_PRELOAD_METADATA = True # Static files settings #STATICFILES_STORAGE = '' #STATIC_S3_PATH = 'static' #STATIC_ROOT = '/%s/' % STATIC_S3_PATH #STATIC_URL = '' % AWS_STORAGE_BUCKET_NAME STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static_root') STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) -
How to Alter sequence for whole DB in Postgres
I'm working with Django + PostgreSQL and I restored backup from my old DB dump on a current DB due to some reasons. Due to which the sequences of few tables were disturbed and I am not able to create a new Django superuser because of that. Can someone help me with how can I alter sequence of the whole db using any psql command. Error traceback if I've misinterpreted the error: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 63, in execute return super(Command, self).execute(*args, **options) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute output = self.handle(*args, **options) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 183, in handle self.UserModel._default_manager.db_manager(database).create_superuser(**user_data) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/contrib/auth/models.py", line 168, in create_superuser return self._create_user(username, email, password, **extra_fields) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/contrib/auth/models.py", line 151, in _create_user user.save(using=self._db) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 80, in save super(AbstractBaseUser, self).save(*args, **kwargs) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/db/models/base.py", line 796, in save force_update=force_update, update_fields=update_fields) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/db/models/base.py", line 824, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/db/models/base.py", line 908, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File "/home/orion/workspace/buddy/lib/python2.7/site-packages/django/db/models/base.py", line 947, in … -
Font awesome not showing icons
I'm deploying a django application that collects the static files from a S3 bucket. Yesterday I managed to fix this problem before because there was a CORS problem and icons were displayed properly. Today they appear as blank squares again even if I haven't changed anything (I don't receive any problems in the chrome console so it can't be the cors problem). If I use the font awesome CDN it works fine but I'd like to know what can be the problem and keep using my static file. Many thanks. -
Get a excel file and additional text using HttpResponse
I am creating and dowloading an excel file. this is my server class MyListView(ListAPIView): def get(self, request, *args, **kwargs): response = HttpResponse(content_type='application/ms-excel') response['Content-Disposition'] = 'attachment; filename="qa_data.xlsx"' json2xl = JsonToXlsx() wb = Workbook() """ add some data to wb. and collecting errors and warnings. """ wb.save(response) return response and from my html, I just called it. self.location = url; dowloading part went well. Now I want to show some info on my web page regarding the excel file (Like errors, occurred when create the excel) I need to download my excel even errors occurred partially. so I need to return my excel file along with my information to show on the web page. I tried adding my information like this but couldn't figure out how to aquire them in my client side. response.write("<p>Here's the text of the Web page.</p>") response['info'] = "Here's the text of the Web page." bellow is how I tried to acquire data from client side. i noticed my excel data has returned but couldn't save it. function getDetailListExcel(url) { //self.location = url; var jqxhr = $.get( url, function(data ) { alert( data ); }) } can anyone tell me, how should I include additional data in to … -
Which is Better for calling a stored procedure-Raw SQL query using object manager or cursor object in Django?
As mentioned in the Django Documentation, we can execute a stored procedure by using the cursor object like cursor.callproc('find_all'). And i also know that we can also call a stored procedure in Django by this method model.object.raw("call SPName") I would like to know which of these two methods is better in terms of performance,readability,protection from attacks such as sql injection etc and explanation for the given solution. -
Django project reported an error after release with nginx and uwsigi
After I enter the domain name for access, the browser displays the Internal Server Error,In addition, I checked the log and got the following Error information Thu Sep 6 18:02:36 2018 - unable to load app 0 (mountpoint='') (callable not found or import error) Thu Sep 6 18:02:36 2018 - --- no python application found, check your startup logs for errors --- {address space usage: 180469760 bytes/172MB} {rss usage: 6373376 bytes/6MB} [pid: 9609|app: -1|req: -1/7] 10.8.0.7 () {48 vars in 827 bytes} [Thu Sep 6 18:02:36 2018] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) My django project directory structure: [root@openvpn conf]# ll /var/www/EWP_OMS total 56 drwxr-xr-x 2 www www 4096 Sep 6 15:24 AUTH drwxr-xr-x 3 www www 4096 Sep 6 15:24 CMDB drwxr-xr-x 3 www www 4096 Sep 6 11:43 COBBER drwxr-xr-x 2 www www 4096 Sep 6 18:01 EWP_OMS -rw-r--r-- 1 www www 250 Jul 22 2016 manage.py drwxr-xr-x 4 www www 4096 Sep 4 15:28 media drwxr-xr-x 4 www www 4096 Sep 6 15:24 pagination -rw-r--r-- 1 www www 7603 Jul 22 2016 README.md -rw-r--r-- 1 www www 34 Sep 4 17:49 requirements.txt … -
Django rest Framework : Serializers and business logic
Model "Page" with fields : pagename, pagenumber Model "Para" with fields : paraname , paranumber, pagenumber[this is a foreign key] Post API :/para Post data : { pagename:Page1, pagenumber:1, paras:[ { paraname:para1, paranumber:1 }, { paraname:para2, paranumber:2 }, { paraname:para3, paranumber:3 } ] } The intent of the post API is to create multiple paras in one bulk call after creating the page. I have two serialiazer : CreatePageSerializer(ModelSerializer) which expects the page name and page number CreateParaSerializer(ModelSerialzer) which expects the para name,the para number and the page number. I am doubtful however how to process the complete request in one go. Keeping the business logic in the views , i.e calling the CreatePageSerializer first and then CreateParaSerializer, does not seem right. I am thinking of creating another serializer : CreateBulkSerializer(BaseSerialzer) which would then call the CreatePageSerializer and CreateParaSerializer. However the questions are: How will I send the data to the CreateBulkSerializer (set as serializer context?) which would be be default function called? Would I need to override the init and then handle the logic there ? Or is there any other approach that I am missing here? -
django : render multiple templates in get_data(request)
How to render data on to two templates in get_data()? Generally, def get_data(request): data = Model.objects.order_by('id') return render(request, 'template.html', {'data':data}) . {{for x in data}} {{x.model_field}} {{end for}} is used to render the stored data from the db into the html file, but how to render the same data into both 'template.html' and 'template_1.html'. There's no way to pass the templates as a list to my knowledge as read from django_docs. Is there any alternate method to it?