Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django - filter model with DateTimeField to include records in every n minutes
I have a model with time series data. Model has a DateTimeField called timestamp, which is also my primary key, and has records with an interval of 1 minute (i.e. there is a record with time 2012/01/01 00:00:00, 2012/01/01 00:01:00, 2012/01/01 00:02:00 and so on). class MyModel(models.Model): timestamp = models.DateTiemField(primary_key=True) . . En example query I want to run on this model is; to get records for every 4 minutes in a time interval. So that I will end up with records on; 2012/01/01 00:00:00 2012/01/01 00:04:00 2012/01/01 00:08:00 2012/01/01 00:12:00 . . How can I run such a query? I'm open to answers using .raw() or .extra() -
webpack 0.0.0.0 docker not working
I'm using docker-compose to serve django at 0.0.0.0:80 and webpack-dev-server at 0.0.0.0:3000. They're both work perfectly at 0.0.0.0 I also have domain bound to my external IP and I even can access django from this domain. But somehow, I can't access webpack-dev-server, neither by external IP, nor by domain. Here is some additional data: docker-compose.yml web: build: backend/ command: sh dockerfiles/init.sh ports: - 0.0.0.0:80:80 js: build: webclient/ command: yarn runserver ports: - 0.0.0.0:3000:3000 As you see, they are both served same way here server.js new WebpackDevServer( webpack(config), { publicPath: config.output.publicPath, hot: true, historyApiFallback: true, allowedHosts: [ '0.0.0.0', 'localhost', 'DOMAIN', '*.DOMAIN' ], headers: { "Access-Control-Allow-Origin": "*" } } ).listen(3000, '0.0.0.0', function (err, result) { if (err) { console.log(err) } console.log('Listening at 0.0.0.0:3000') }) When I ping the port 0.0.0.0:3000 - the port is open. When i ping DOMAIN:3000 - the port is closed. Do you have any ideas what's going on? -
How to get instance values for form in django?
I've overridden a detail view so I can render form elements with render_field. However, when rendered they do not show the saved values. I can't set the value in the template because I can't put {{}} within {% %} syntax. How can I access and display the previously saved model instance values? (these are sliders that I want to keep as sliders, and they also have a lot of data attributes that I want to keep consistent, so I can't just write the inputs manually in the template) In views.py: class MyDetailEditMixin(SingleObjectMixin): """ Hybrid mixin to edit a detail """ model = MyModel form_class = forms.MyForm raise_execption = True def get_context_data(self, **kwargs): """ expose the form """ kwargs.setdefault('form', forms.MyForm) return super(MyDetailEditMixin, self).get_context_data(**kwargs) class MyDetailView(MyDetailEditMixin, DetailView): """ Shows the details for a specific strategy """ I feel like I need to explicitly mention the instance somehow? I'm not sure. The inputs render correctly with all their specific data attributes, just no set values. -
Python Django: Annotating a same name with a database field
I need to annotate something that has to be named 'id' that is the same as the primary key of the table 'id'. The final output should be an array of dictionaries. I know that I can annotate with another name like 'id_for_tree' and then after using values() to make the dictionaries and change the key in a loop. Something like: item_list = MyTable.objects.annotate(id_for_tree=Concat(F('id'), F('Code'), output_field=CharField())).values('Name', 'id_for_tree') for any_item in item_list: any_item['id'] = any_item.pop('id_for_tree') It's clear that this solution does not have a good performance. How can I get rid of the "The annotation 'id' conflicts with a field on the model" exception by discarding the previous 'id' and annotate a new 'id'? -
Send a PDF generated from an API to an external server?
I have a NodeJS-ExpressJS server (to host a web page) and Django API server. When a specific endpoint in the Django server is called from the ExpressJS server (when a user clicks a button on the web page), a PDF is generated. I want to send this PDF from the Django server to the ExpressJS server and then download it to the user's browser (The user only interfaces with ExpressJS server). In order to do this I encode the PDF as a base64 string in the Django server and return the string in an HTTP response. In the ExpressJS server, I decode the base64 string and then use the res.download() method provided by the ExpressJS framework to download the PDF to the user's browser. This method appears to work, but can it corrupt the PDF file? Is there a way to simply send the PDF file as a binary file and download it to the browser that way (If possible, please provide an example)? Any answers, examples, and suggestions are greatly appreciated. Django API server def process_upload(request): ''' Process request and generate PDF .... ''' with open(pdf, "rb") as pdf_file: encoded_string = base64.b64encode(pdf_file.read()) return HttpResponse(encoded_string) ExpressJS server server.get('/api', function(req, res, … -
Django models - Able to dynamically calculate the value of a field
Say for example I have a rating which is attached to a product model like so.. class Product(models.Model): ... rating = models.IntegerField(...) I want the product rating to change as new Reviews (that include a star rating of the product) change or updated/deleted. class Review(models.Model): ... related_product = models.ForeignKey(Product, on_delete=models.CASCADE, ...) rating = models.IntegerField(...) Initially, I used a method on the product class to calculate the value of rating by counting the rating value from each review and then dividing by the number of reviews to get an average. class Product(models.Model): ... def rating(self): total_rating = ... reviews_count = ... average = total_rating / reviews_count However, this doesn't allow me to use order_by('rating') when querying the objects and sending back the objects by order of their rating since 'rating' has to be defined in the database (i.e. as a field instead of a method). Is there any way that I can calculate the value for rating which is then stored in the database? -
django imagefield uploading a file "This field is required" error
So I used this link to extend my user model to have a profile page. Now it did work, and I decided to try it out with adding a field for uploading a user avatar. For some reason, whenever I upload an image, it won't save it, and it keeps giving me the error mentioned in the title. What exactly is going wrong here? I can add the image just fine in the admin page, but once I get to the html page, and try to add or change it over there, it will only give me an error saying "This field is required". models.py: class Profile(models.Model): CATEGORIES = [ ('CU', 'Cute'), ('FU', 'Funny'), ('DA', 'Dank'), ('OS', 'Only Smart People Will Understand'), ] user = models.OneToOneField(User, on_delete=models.DO_NOTHING) avater = models.ImageField(upload_to='avatar') fb_link = models.URLField() seenMemes = models.ManyToManyField('Meme') top_3_cat = models.CharField( max_length = 50, choices = CATEGORIES, default = 'DA', ) def __str__(self): return self.user.username @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) @receiver(post_save, sender=User) def save_user_profile(sender, instance, **kwargs): instance.profile.save() views.py: @login_required @transaction.atomic def update_profile(request): if request.method == 'POST': profile_form = ProfileForm(request.POST, instance=request.user.profile) if profile_form.is_valid(): profile_form.save() messages.success(request, ('Your profile was successfully updated!')) return redirect('profile') else: messages.error(request, ('Please correct the error … -
Django 'AnonymousUser' object has no attribute '_meta' error when trying to login users
Previously, I have been using the default Django user model but I have now changed to a custom user model so I can remove the 'username' field on my registration form. Everything seems to be working smoothly with regards to registering new users, and adding them to user groups etc. However, when I try to log in these new users I get the error message: 'AnonymousUser' object has no attribute '_meta' Which points at the line of code: login(request, user) My models.py: from django.db import models from django.contrib.auth.models import ( AbstractBaseUser, BaseUserManager, PermissionsMixin ) class UserManager(BaseUserManager): def create_user(self, first_name, last_name, email, password=None, is_active=True, is_staff=False, is_admin=False): if not first_name: raise ValueError("Users must enter their first name") if not last_name: raise ValueError("Users must enter their last name") if not email: raise ValueError("Users must enter an email") if not password: raise ValueError("Users must enter a password") user_obj = self.model( first_name = first_name, last_name = last_name, email = self.normalize_email(email), ) user_obj.set_password(password) #set and change password? user_obj.admin = is_admin user_obj.staff = is_staff user_obj.active = is_active user_obj.save(using=self._db) return user_obj def create_superuser(self, first_name, last_name, email, password=None): user = self.create_user( first_name, last_name, email, password=password, is_staff=True, is_admin=True ) return user class User(AbstractBaseUser, PermissionsMixin): first_name = models.CharField(max_length=255, blank=True, null=True) last_name … -
Details for model and form model on detail page
I have problem with connect two models on one page, detail page (Django 1.11). I have model Event - I want to display details for this model on detail page - this is working for me. class Event(models.Model): title = models.CharField(max_length=500) date = models.DateField() text = models.TextField() image = FilerImageField(null=True, blank=True) free_places = models.IntegerField() class Meta: ordering = ['-date'] def __str__(self): return self.title On another hand I have model Register class Register(models.Model): event = models.ManyToManyField(Event) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) company = models.CharField(max_length=30, blank=True) street = models.CharField(max_length=50, blank=True) post_code = models.CharField(max_length=30, blank=True) city = models.CharField(max_length=30, blank=True) email = models.EmailField() phone_number = models.IntegerField(max_length=30) def __str__(self): return self.first_name I want to signup user on event with folder on detail page, below details for events. Here is my detail view, where I want to display details for event and take data from user to Register model: class EventDetailView(DetailView, FormMixin): model = models.Event form_class = forms.RegisterForm def get_success_url(self): return reverse('events:list') def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): return self.form_valid(form) else: return self.form_invalid(form) Template: {% extends 'base.html' %} {% block content %} <ul> <h1>Detail page:</h1> <li>{{ object.title }}</li> <li>{{ object.text }}</li> <li>{{ object.date }}</li> </ul> <form method="post"> {% csrf_token %} {{ … -
Is it possible connect a Django app with Chatfuel?
I have this project where I have to connect my Django app with a Chatfuel bot. I have my admin panel, so whenever I update a field like complete certain task, I have to notify my client through the chatbot that this field change. But I can't find info for do that. -
work with list in jquery
with Django Rest Framework i "get" this data to localhost/api/data: [{"date":"2018-01-02","time":"21:00","people":6}, {"date":"2018-01-11","time":"21:00","people":2}, {"date":"2018-01-04","time":"21:00","people":4}, {"date":"2018-01-06","time":"21:00","people":2}, {"date":"2018-01-06","time":"21:00","people":10}, {"date":"2018-01-03","time":"21:00","people":2}, {"date":"2018-01-06","time":"21:00","people":6}, {"date":"2018-01-06","time":"21:00","people":4}, {"date":"2018-01-06","time":"21:00","people":4}] Now I want to pass them to chart.js charts, for example: - Line chart: from 1 to 30 January (to show all booked in 1st jan e.g) - Bar chart: the count filtered by week day (monday,...) - Bar chart: the count filtered by hour (21, 22, 23...) I can take data in jquery function but I can't manipulate data...someone can help me? -
Django ManytoMany filter exact list with duplicate items
This is extension for the question Django ManytoMany filter exact list Looks like accepted answer doesn't work when list contains duplicates. Is there any solution? Basically, I split sentence into tokens and want to search by that tokens. class Sentence(Model): name = CharField() class Tokens(Model): token = CharField() sentence = ForeignKey(Sentence, related_name='tokens') Suppose, I have the tokens ['che', 'farebbe', 'dalle', 'dalle']. I want to find sentence that consist exactly of these tokens. Sentence.objects.annotate(n=Count('tokens')).filter(tokens__name='che').filter(tokens__name='farebbe').filter(tokens__name='dalle').filter(n=4) doesn't work. n is more than 4 (I guess, because of joins). If list of tokens doesn't have duplicates then everything is working fine. -
Django auth permission interfering with Rest Framework
I am trying to POST something to my API from a view. My API view has a custom made permission only, where it looks for a token, and its open to Cross Site Requests. However, if I post something when I'm logged in, the request does not work, and I get a 403 error. If I log out, the request works perfectly again. What is the problem with this? Any ideas on how to solve this? Thanks. -
Django initialise data in forms.inlineformset_factory
I'm trying to use an inlineformset and there are certain fields which will be the same for this particular user in this instance. I want to initialise/default these fields but cannot work out how to do it. MODELS Basically, my models look something like ... class Organisation(models.Model): name = models.CharField( verbose_name = 'Organisation Name', max_length = 30 ) slug = models.SlugField ( verbose_name = "Slug", allow_unicode = True, unique=True, blank=True, null=True ) user = models.ForeignKey( User ) class Factor (models.Model): name = models.CharField( verbose_name = 'Factor', max_length = 30 ) class SupportingDocument(models.Model): f = models.FileField( upload_to ='supporting_document/' ) factor = models.ForeignKey( Factor, blank = True, null = True ) organisation = models.ForeignKey(Organisation) FORMS class OrganisationFactorForm(forms.ModelForm): class Meta: model = Organisation fields = ['user'] widgets = { 'user' : forms.HiddenInput(), } class SupportingDocumentInline(forms.ModelForm): class Meta: model = SupportingDocument exclude = ['id', ] widgets = { 'factor' : forms.HiddenInput(), 'organisation' : forms.HiddenInput(), 'f' : forms.FileInput(attrs={'class' : 'form-control'}) } SupportingDocumentInlineFormSet = forms.inlineformset_factory( Organisation, SupportingDocument, form=SupportingDocumentInline, extra=1, exclude = ['id'], can_delete=True, can_order=True) VIEWS I want to default the factor record so that when I display the form I can do something like if self.request.POST: form_count = int(self.request.POST['supportingdocument_set-TOTAL_FORMS']) ctx['supporting_documents'] = SupportingDocumentInlineFormSet(self.request.POST, self.request.FILES, instance=self.get_object()) for x … -
MySQL 5.7 warning when SELECT is filtered by binary field
I'm using Django 1.6, MySQL 5.7 and there is a binary field in the DB. And when I try to SELECT some data with filtering by that field, I get an error: Invalid utf8 character string: 'F5F111'. It's the same as in the ticket: https://code.djangoproject.com/ticket/26140 As I see, fix for the ticked is solved a case only for INSERT (not SELECT) queries and anyway my Django can't be updated right now. So is any way to fix this issue? Maybe I can somehow query this data more properly, or do any patch? Thank you! -
Google Cloud Routes HTTP and HTTPS differently
TL;DR Google Cloud Platform routing dispatch behaves differently for HTTP and HTTPS, and I can't figure out (or find a reference as to) why. The Setup I have a default service with this (absolutely standard) app.yaml: runtime: python env: flex entrypoint: gunicorn -b :$PORT <project>.wsgi beta_settings: cloud_sql_instances: <instance-connection-string> runtime_config: python_version: 3 It's a Django app serving the API and the Admin Interface. I have a frontend service with this (again, absolutely standard) app.yaml: service: frontend runtime: python27 api_version: 1 threadsafe: true handlers: - url: /static/(.*) static_files: build/static/\1 upload: build/static/(.*) - url: /.* static_files: build/index.html upload: build/index.html It's a ReactJS application that consumes the API and acts as a frontend. Then, I have this dispatch.yaml: dispatch: - url: "*/api/*" service: default - url: "*/admin/*" service: default - url: "*/*" service: frontend Meaning "serve /api/... and /admin/... from the default service, and the rest from the frontend service". Alright. The Problem When I go to http://<project-id>.appspot.com (note the HTTP), everything works as expected. To wit: http://aksinin-191616.appspot.com/api/content/ is the API, http://aksinin-191616.appspot.com/admin/en/ is the Admin Interface, http://aksinin-191616.appspot.com/ is the frontend. But when I do the same with https://<project-id>.appspot.com (note the HTTPS), everything is always redirected to the frontend. To wit: https://aksinin-191616.appspot.com/api/content/ is the frontend, … -
Django: Login with E-Mail
I want to authenticate with e-mail and password, but somehow I can't find the setting where it is done? Here is my login.html: <form method="post"> {% csrf_token %} <label for="email">E-Mail</label> <input id="email" name="email" type="email" maxlength="50" autofocus="autofocus" required=True unique=True class="form-control"> <label style="margin-top: 1em;" for="password">Passwort</label> <input style="margin-bottom: 2em;" id="password" name="password" type="password" maxlength="25" required=True class="form-control"> <button class="btn btn-success btn-sm" type="submit" value="login">Login</button> And here is my views.py: def register(request): if request.method == 'POST': form = RegistrationForm(request.POST, email=request.email) if form.is_valid(): form.save() email = form.cleaned_data.get('eemail') raw_password = form.cleaned_data.get('password1') user = authenticate(email=mail, password=raw_password) login(request, user) return redirect('accounts:view_profile') else: form = RegistrationForm() args = {'form': form} return render(request, 'accounts/reg_form.html', args) Am I looking completely wrong? Where can I find the setting? Thank you for your help! -
How to handle deletion of model objects included in custom field
I have a somewhat complex structure of models and fields, where a Workout model object has my own custom field LiftsField. This field handles conversion of objects of the class Lifts, which is a collection of LiftSerie objects. The LiftSerie objects are in turn containers of a LiftActivity MODEL class object and some other things that are not important here. Workout: class Workout(models.Model): datetime = models.DateTimeField() user = models.ForeignKey(User, on_delete=models.CASCADE) lifts = fields.LiftsField(null=True) cardios = fields.CardiosField(null=True) def __str__(self): return str(self.datetime)+" "+self.user.email __repr__ = __str__ LiftsField: class LiftsField(JSONField): """Field representing a models.Lifts object""" def from_db_value(self, value, expression, connection, context): if value is None: return value return parse_lifts(value) def to_python(self, value): if isinstance(value, models.Lifts): return value if value is None: return value return parse_lifts(value) def get_prep_value(self, value): if not value: return value lifts_pre_json = [serie_object.pre_json() for serie_object in value.series] return json.dumps(lifts_pre_json) Lifts: class Series(object): """Series is a list of AbstractSerie objects""" def __init__(self, series, serie_class): self.series = [] for serie in series: if type(serie) != serie_class: raise TypeError("List passed to constructor should only contain "+serie_class.__name__+" objects.") self.series.append(serie) class Lifts(Series): def __init__(self, series): """ Series is a list of LiftSeries """ super().__init__(series, LiftSerie) LiftSerie: class AbstractSerie(object): def __init__(self, activity): """activity is an Activity""" … -
Django + AJAX - POST 404 (Not Found)
I'm trying to implement a like functionality in my Django app using AJAX but, when I try to do that I'm getting an POST http://localhost:8000/forum/like/ 404 (Not Found). All I wanna do is to add/remove users from the likes list without refreshing the entire page. views.py @require_POST def toggle_like(request): if request.method == "POST": user = request.user slug = request.POST.get('slug', None) question = get_object_or_404(Question, slug=slug) if question.likes.filter(id=user.id).exists(): question.likes.remove(user) else: question.likes.add(user) context = {'likes-count': question.likes.count} return HttpResponse(json.dump(context), content_type='application/json') urls.py from django.urls import path from . import views app_name = 'forum' urlpatterns = [ path('like/', views.toggle_like, name='toggle-like'), ] question.html {% block javascript %} <script> $('#like').click(() => { $.ajax({ method: 'POST', url: "{% url 'forum:toggle-like' %}", data: { 'slug': $(this).attr('name'), 'csrfmiddlewaretoken': '{{ csrf_token }}' }, dataType: 'json', success: (response) => { alert(response.message); }, error: (response, error) => { alert(response.responseText); } }) }) </script> {% endblock %} {% block content %} <p>Likes: {{ question.likes.count }} <input type="button" id="like" name="{{ question.slug }}" value="Like" /></p> {% endblock %} -
Error 500 in production just when debug is set to False
I am using Django 1.11 in my application. I've implemented the authentication using django-registration and created a profile model to store some user infos: class Profile(models.Model): ... user = models.OneToOneField(User) nick = models.CharField(max_length=50) level = models.PositiveIntegerField(null=True) avatar = models.CharField(max_length=500, null=True, blank=True) ... This model is being created/saved with signals: def create_user_profile(sender, instance, created, **kwargs): if created: Profile.objects.create(user=instance) def save_user_profile(sender, instance, **kwargs): instance.profile.save() post_save.connect(create_user_profile, sender=User) post_save.connect(save_user_profile, sender=User) Well, I am not allowing users to upload images, as you see. The workflow of choosing an avatar image is: User access profile configuration page This page has a button that opens a modal with image options, the user has to choose one. User select an image. User click to save changes. What I am saving at profile's avatar field is a string that have to be concatenate to the static url, for instance, if the image path is: 127.0.0.1:8000/static/account_settings/avatar-images/man2.jpeg I am saving: account_settings/avatar-images/man2.jpeg I've being through this workflow in production with debug set to True (impossible to make with debug = False because of the error 500). So, I've opened the user public profile page and it gives me the same error. But I've found the root of the problem in this template: … -
How to have optional parts of a django url and reverse to it [duplicate]
This question already has an answer here: Django optional url parameters 4 answers This is my url: url(r'^add/(?P<year>[0-9]+)/(?P<month>[0-9]+)/(?P<day>[0-9]+)/(?P<id>[0-9]*)$', views.AddWorkoutView.as_view(), name = 'add_workout'), It is for adding workouts to the database. If the id is provided, the server should: Check if a workout with the id exists in database If it exists, destroy the found item and replace it with the one who's data has been posted to the view. If it doesn't exist, simply add the new workout to the database without destroying any existing workout object. In one of my templates, called addworkout.html, I have a form where the workout data is inserted. It has the following opening tag: <form id="workoutform" action="{% url 'workoutcal:add_workout' date.year date.month date.day %}" method="post"> As you can see, I haven't provided any id argument in the reverse url. This is because in addworkout.html the user can only add new workouts, so no existing workout id is necessary. However, this attempt at reversing the url generates an error: NoReverseMatch at /workoutcal/add/2018/1/2/ Reverse for 'add_workout' with arguments '(2018, 1, 2)' not found. 1 pattern(s) tried: ['workoutcal/add/(?P<year>[0-9]+)/(?P<month>[0-9]+)/(?P<day>[0-9]+)/(?P<id>[0-9]*)$'] Since I have written a regex star next to the id number in the url, there shouldn't be any requirement … -
AuthToken in Django Rest FrameWork: non_field_errors
I m trying to integrate token based authentication in DRF but when I hit api-token-auth/ using {"username":"test","password":"123456789"} as mentioned in the doc it is required to return me the Token but I m getting { "non_field_errors": [ "Unable to log in with provided credentials." ] } I have used rest_framework.authtoken in my installed apps also token is getting generated once the user is registerd and save in authtoken_token table .Also in my urls.py of root I m using urlpatterns += [ url(r'^api-token-auth/', authviews.obtain_auth_token), ]. Any help would be appreciated. Also attaching the code urls.py urlpatterns += [ url(r'^api-token-auth/', authviews.obtain_auth_token), ] settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'users' ] users/urls.py from rest_framework.routers import DefaultRouter from . import views as user_views from django.conf.urls import url ,include router = DefaultRouter() router.register(r'user', user_views.UserViewSet,base_name="user") urlpatterns = router.urls -
Reset IDs of a specific model in Django App
I am right now in development on local and I would like to reset the ID of one of my models called question. I created many questions and deleted them but the count still continue to go up. I know that in production I will get a blank database but I need to do some testing to rest the ID starting at 1 of that specific model only I read about flush but not sure how to use it .. Could someone give me a hand on that please ? Thx you ;) -
django tastypie resource queryset filter doesn't work if resource is pulled into another
Models class Quote(models.model): quote_ref = models.TextField(null=True, blank=True) order = models.Foreignkey('Order', related_name='quotes') version models.DecimalField(null=True, blank=True) requested_date = models.DateField(null=True, blank=True) expiry_date = models.DateField(null=True, blank=True) closed_date = models.DateField(null=True, blank=True) class Order(models.model): order_ref = models.CharField(null=True, blank=True) cost models.DecimalField(null=True, blank=True) order_date = models.DateField(null=True, blank=True) delivery_date = models.DateField(null=True, blank=True) ....... ....... Resources class RequestsResource(ModelResource): quotes = fields.ToManyField('api.resources.QuoteIndexResource', 'quotes', full=True, null=True) class Meta: queryset = Order.objects.all() resource_name = 'request' class QuoteIndexResource(ModelResource): class Meta: queryset = Quote.objects.all().filter(closed_date__isnull=True) resource_name = 'index_quote' If I use the QuoteIndexResource on its own the filter on the querysetworks but if it is pulled into RequestsResource then the filter doesn't have any effect on the data. Is there a way to make the .filter(closed_date__isnull=True) work in this scenario? -
How to use multiple attributes in algolia search using Django . Show multiple courses
How to use multiple attributes in algolia search using Django . Show multiple courses { "course_": [ { "interest_min": 11, "other_fees": 0, "tution_fees": 56000, "interest_max": 14, "duration_max": 7, "payment_month_min": 4573, "total": 56000, "payment_month_max": 2567, "course_name": "Mtech", "hostel_fees": 0, "duration_min": 5, "course_type": "Full Time", "duration": "4" }, { "interest_min": 7, "other_fees": 465, "tution_fees": 35456, "interest_max": 14, "duration_max": 5, "payment_month_min": 2414, "total": 41385, "payment_month_max": 483, "course_name": "Mca", "hostel_fees": 5464, "duration_min": 2, "course_type": "Full Time", "duration": "2" } ], "name": "A. K. Choudhury School Of Information Technology, Kolkata", "slug": "a-k-choudhury-school-of-information-technology-kolkata", "country": "India", "location_type": "Domestic", "type": "College", "address": "Kolkata", "image": "images/a-k-choudhury-school-of-information-technology-kolkata_M9cCiHQ.jpg", "institute_type": "Private", "cities": "noida", "college_facilities": "Sports Transportation", "approved_by": "University Of Calcutta, Kolkata", "established": "2005-01-05", "state": "Up", "objectID": "2" } How to use multiple attributes in algolia search using Django . Show multiple courses using instantsearch.js in django