Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
form validation errors not shown when condition is not met in Django template
I wrote below custom form validation to check the length of the message and if it is less than 8 characters it throws an error: class ContactForm(forms.ModelForm): def clean(self): cleaned_data = super().clean() message = cleaned_data.get("message") if len(message) < 8: raise forms.ValidationError( "Message can't be less than 8 characters.") class Meta: model = Contact fields = "__all__" and this is the view I use to handle form def contact_us(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): form.save() messages.success(request, 'Message sent successfully.') else: messages.error( request, 'Please fill all the blanks with valid data.') return render(request, 'contact/contact.html', context) and to show errors in contact.html template I used this - {% if form.errors %} <ul class="field-errors" id="form_errors"> {% for field in form %} {% for error in field.errors %} <li> {{ error|escape }} </li> {% endfor %} {% endfor %} {% for error in form.non_field_errors %} <div> {{ error|escape }} </div> {% endfor %} </ul> {% endif %} when testing it in template I didn't get this Message can't be less than 8 characters. error even thought I passed it in template. I tried passing form:form as context in contact.html template. It didn't work either. This is the model. class Contact(models.Model): name … -
Retrurning list from webscrape Django
This might be a noobie question but im trying to return a list of cars for this script: from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup from pprint import pprint def carscrape(): # Script to extract the data from the website my_url = 'https://www.finn.no/car/used/search.html?orgId=9117269&page=1' uClient = uReq(my_url) page_html = uClient.read() uClient.close() page_soup = soup(page_html, "html.parser") carResults = page_soup.findAll("article", {"class": "ads__unit"}) for car in carResults: title = car.a.text img_url = car.img["src"] link = car.h2.a["href"] data = car.find("div", {"class": "ads__unit__content__keys"}) dataResult = data.findAll("div") model_year = int(''.join(list(filter(str.isdigit,dataResult[0].text)))) mileage = int(''.join(list(filter(str.isdigit,dataResult[1].text)))) try: price = int(''.join(list(filter(str.isdigit, dataResult[2].text)))) except: price = 0 # end of script to get the data #What should i do here? yield { "title" : title, "img_url" : img_url, "link" : link, "model_year" : model_year, "mileage" : mileage, "price" : price, } I was not sure if i should use the yield generator. But basically im trying to save all the webscraped data to a list then save every item in the list in my django database. If anyone could give me some pointers that would be great. Ive researched online but the examples i found did not fit this script. Thanks for any help in advance. -
Is there a way to know screen size in django template?
I am new in django, And I want a way to show diffrent things based on device width, I am making a movie website and the home page shows ten movies but I want the value to decrease if the screen size is smaller. Html Code: {% for movie in movieByView|slice:"10" %} <div> <h2>{{movie.name|truncatechars:25}}</h2> <h2>{{movie.rating}}</h2> <img src="home/static/img/{{ movie.moviePoster }}"/> </div> {% endfor %} I want to change the slice number to 12 if the screen size was bigger. How can I do that? is there a way? if I can do this in any other language please say. I thought of two ways to do it I dont know if its possible.1. showing 20 movies and using javascript to remove the unwanted. 2. passing variables from javascript to django by json and post request.but neither of the two is that effecient. -
Can we just use django server for deploying django app on linux server?
I am a complete beginner in deployment related stuff and haven't done any deployment yet. Recently i got a work where i had to deploy a django app on linux server but while searchin on internet their are very few resources that teaches you how to deploy django app on linux server. And all the tutorials are setting up with apache and mod wysgi . My question is can't we just use the django server to deploy the django app on linux server. If this could be possible then i just have to: install python on server. install virtual env. edit settings.py by changing allowed host , static root, run python manage.py collectstatic python manag.py runserver 0.0.0.0:8000 let me know if that is possible and if not then what and where i am getting wrong? Also if you can provide me some step by step tutorial to deploy django app on sever then it would be much of help. Any resource or reference will be helpful. Thanks in advance. -
Django queryset.field.unmask(request)
"facility" is a queryset in which "full_name" is a field. "request" is the request object passed from the view class. what does the following code achieve? cp_name = facility.full_name.unmask(request) if facility else None -
Django can only handle ASGI/HTTP connections, not websocket
Hello I am getting a error. Before coming here, I tried many different ways and looked at the topics that were opened here before. But whatever I do, it keeps giving me errors. I tried daphne and uvicorn but the result is the same, it opens in local environment but it does not work on the server and gives this error: Django can only handle ASGI / HTTP connections, not websocket My Codes: Js Code: <script> function connectSocket() { var ws = new WebSocket('ws://' + window.location.host + '/ws/notification/{{request.user.id}}/') ws.onopen = function(event){ console.log('opened', event); } //If there is a long onmessage codes here, I removed the code, no syntax error ws.onclose = function(e) { console.error('Chat socket closed unexpectedly; reconnecting'); setTimeout(connectSocket, 1000); }; ws.onerror = function(event){ console.log('error', event); } // window.setInterval(function(){ // loadNotifications(); // }, 1000); } connectSocket(); </script> Settings.py [/JSR] [CODE] CHANNEL_LAYERS = { "default": { 'BACKEND': 'channels_redis.core.RedisChannelLayer', 'CONFIG': { "hosts": [("redis", 6379)], }, }, } ASGI_APPLICATION = "thesite.routing.application" asgi import os import django from channels.routing import get_default_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'thesite.settings') django.setup() application = get_default_application() Nginx: server { listen 80; server_name **.net www.**.net; #** = site name root /home/ftpuser/project; location /static/ { alias /home/ftpuser/project/site/static/; } location /media/ { } location / { … -
Could not parse the remainder: '{{comment.post}}=={{blog.post}}' from '{{comment.post}}=={{blog.post}}'
I am making a blog website and I have to add comments to my post for that I have to check which post the comment is associated with and I am writing this line {% if {{comment.post}}=={{blog.post}} %} I know this line won't work because {%%} and {{}} cannot be used in the same line so does anyone has a solution for this. -
Attribute Error: 'tuple' object has no attribute 'values'
I have a basic API to reset the password, however, it seems to be throwing this error, despite "values", not appearing in my code altogether: views.py class PasswordResetNewPasswordAPIView(GenericAPIView): serializer_class = SetNewPasswordSerializer def patch(self, request): user = request.data serializer = SetNewPasswordSerializer(data=user) serializer.is_valid(raise_exception=True) return Response({ "message": "password reset"}, status=status.HTTP_200_OK ) serializers.py class SetNewPasswordSerializer(serializers.Serializer): password = serializers.CharField(max_length=50, write_only =True) token = serializers.CharField(write_only =True) uidb64 = serializers.CharField(max_length = 255, write_only =True) fields = ("password", "token", "uidb64",) def validate(self, attrs): try: password = attrs.get("password", "") token = attrs.get("token", "") uidb64 = attrs.get("uidb64", "") print(uidb64) id = force_str(urlsafe_base64_decode(uidb64)) print(id) user = Author.objects.get(id=id) if not PasswordResetTokenGenerator().check_token(user, token): raise AuthenticationFailed("Invalid Reset Parameter", 401) user.set_password(password) user.save() return user except Exception: raise AuthenticationFailed("Invalid Reset Parameter", 401) return super().validate(attrs) urls.py ... path('password-reset-setup/', PasswordResetNewPasswordAPIView.as_view(),name="password-reset-setup"), What could be the possible error? And how to I get around it? The traceback is: Traceback (most recent call last): File "/home/pratyush/Desktop/NewsSite/newsite/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/pratyush/Desktop/NewsSite/newsite/lib/python3.8/site-packages/django/core/handlers/base.py", line 202, in _get_response response = response.render() File "/home/pratyush/Desktop/NewsSite/newsite/lib/python3.8/site-packages/django/template/response.py", line 105, in render self.content = self.rendered_content File "/home/pratyush/Desktop/NewsSite/newsite/lib/python3.8/site-packages/rest_framework/response.py", line 70, in rendered_content ret = renderer.render(self.data, accepted_media_type, context) File "/home/pratyush/Desktop/NewsSite/newsite/lib/python3.8/site-packages/rest_framework/renderers.py", line 724, in render context = self.get_context(data, accepted_media_type, renderer_context) File "/home/pratyush/Desktop/NewsSite/newsite/lib/python3.8/site-packages/rest_framework/renderers.py", line 657, in get_context raw_data_patch_form = … -
Django For While Loops and counters when returning data
I am pulling some crypto data into my web app, and placing it into bootstrap cards. My issue is with the number of cards now populating my site. So I thought, no sweat. I'll just initialize a counter at 0 and throw a while loop in there until around 9 or 10. So far no bueno, the code below is the functioning version where it just unloads unlimited crypto cards. I've tried ranges, and If anyone has an idea how I can accomplish this, it'd be greatly appreciated. I don't think it's difficult, just not making the connection. I've even found cases now where you need to register the while loop just to use it in django ? @register.tag('while') had no idea {% for x in api.Data %} <div class="col-sm"> <div class="card-deck"> <div class="card" style="width: 18rem"> <img class="card-img-top" src="{{ x.imageurl }}" alt="{{ x.source }}"> <div class="card-body"> <h5 class="card-title">{{ x.title }}</h5> <p class="card-text">{{ x.body }}</p> <a href="{{ x.url}}" class="btn btn-primary">Learn more</a> </div> </div> </div> <br /> </div> {% endfor %} -
Django populating table in template with two different data sets
I have problem. I need to populate one table with two different sets of data, one is queryset and the other is list. Is there any way to populate table with two sets of data using one {% for %} statement? Something like {% for categories, expenses in categoriesList and expensesList %}. -
Django query to extract values when there is an intermediate table
My database has the following structure. Table1: Name unique_name name_class Table2: Node tid rank path depth Table3: Synonym node (foreignkey to Node) name (foreignkey to Name) I want to extract tid and name based on a condition. I know I can do this names = Synonym.objects.filter(node__path__startswith=path, node__depth__gte=depth, name__name_class="ABC").order_by('node__path') for n in names: print(n.node.tid, n.name.unique_name) How can I make a query to extract tid and name in a single step avoiding the use of for loop ? -
how can i add a JavaScript object to be submitted with my Django form?
I am building a blog with Django and using editorjs as my block editor, the data gets returned as a JSON object, how can I include this object with my Django form? it can be submitted as a string since I am parsing it anyway, I know using an API would solve my issue but I was running into trouble trying to add the images through an API, besides I would like to make use of the built-in class views any help would be greatly appreciated, thanks in advance -
Django CreateView - if field is empty, don't create an object and instead redirect to different view. How do I do this?
I have a media model and a product model. When a user creates a product they first upload a picture and then after this, they're forwarded to the product detail page where they can edit the products attributes. This works fine, however if the user doesn't upload a picture I'd like the program to skip creating a media object and just go straight to the product detail page. I've tried returning a reverse() function from form_valid() but this doesn't work so I'm wondering if anyone knows why this is and how I can fix this? My code currently: class ProductMediaCreate(generic.CreateView): model = ProductMedia fields = ('media',) template_name = 'media/media_create.html' def form_valid(self, form): product_obj = Product.objects.create() if not form.instance.media: return reverse('product_detail', kwargs={'pk': product_obj.pk}) form.instance.product = product_obj return super().form_valid(form) def get_success_url(self): return reverse('product_detail', kwargs={'pk': self.product.pk}) Thanks in advance for any help! - GoingRoundInCircles -
How to order URLs in Django? I am getting `Page Not Found` error because of misplaced urls?
I am getting below error when I want to add a project or go to project_create URL. Page not found (404) Request Method: GET Request URL: http://localhost:8000/project/add/ Raised by: projects.views.project_detail_view the URL says /project/add/ that according to the view it must open project_create_view but the error is raised by detail view projects.views.project_detail_view. This is the URL: path('project/<slug:project_slug>/delete/', project_delete_view, name='project_delete'), path('project/<slug:project_slug>/update/', project_update_view, name='project_update'), path('project/<slug:project_slug>/', project_detail_view, name='project_detail'), path('projects/list/', all_projects_view, name='all_projects'), path('project/add/', project_create_view, name='project_create'), path('administration/', administration, name='administration'), path("", home, name='home'), if I comment this line path('project/<slug:project_slug>/',project_detail_view, name='project_detail'), then project_create URL goes to right view and right template. Why is this happening? I used different name, url and view name. Why is this happening? -
Django: Get count of value in queryset
I am new to Django so I am still learning things. Having difficulty learning how to manipulate QuerySets. I am trying to get the count of a value inside my queryset and would like help knowing how to do so. I have a QuerySet of Review objects that all look like this: Review: { total_score: 100, scores: [{ 'criteria_1': 5, 'criteria_2': 6, 'criteria_3': 7, }] } How would I get the count of all the "criteria_1" scores in this queryset where the value of critera_1 is above 2? -
Google maps autocomplete not working in Django MultiFormView
I'm working with the library django-google-maps to create an address field for properties. For displaying the form, I'm using the following code: class PropertyForm(forms.ModelForm): class Meta: model = Property fields = ['address', 'owned_since', 'geolocation', 'bought_for', 'property_type'] widgets = { 'address': map_widgets.GoogleMapsAddressWidget(attrs={'data-map-type': 'roadmap', 'data-autocomplete-options': json.dumps({ 'componentRestrictions': {'country': 'us'} })}), 'geolocation': forms.HiddenInput(), 'owned_since': forms.DateInput(attrs={ 'placeholder': 'YYYY-MM-DD' }), 'bought_for': CustomMoneyWidget(attrs={'class': 'form-control'}) } It works perfectly in a generic UpdateView and in the admin interface, but when I try to include it in a MultiFormView, the map does not show and the autocomlete isn't working either, it behaves like a simple CharField. There are also no errors or messages in the console. What am I missing here? -
How to keep the data in the form after posting it in Django
I'm new to Django and I need your help with my personal project. I have a couple of forms (numerical, radio, checkbox). After I click the Submit button, I want the entered values to stay there so that if I want to change one value and do further computation using that new value, I don't have to fill entire form again. I figured out a way for numerical fields - I added a value of each inputs equal to the variable collected from the response. I have my form in my base.html that is extended by results.html, hence the form is always visible. views.py def home(request): return render(request, 'home.html', {}) def results(request): if request.method == 'POST': mag_field = (request.POST.get('mag_field')) mms = (request.POST.get('mms')) re = (request.POST.get('re')) fs = (request.POST.get('fs')) diameter = request.POST.get('diameter') qms = request.POST.get('qms') vc_diameter = request.POST.get("vc_diameter") pp_height = request.POST.get("pp_height") overhang = request.POST.get("overhang") context = {"overhang": overhang, "pp_height": pp_height, "vc_diameter": vc_diameter, "mag_field": mag_field, "mms": mms, "re": re, "fs": fs, "diameter": diameter, 'qms': qms} return render(request, 'results.html', context) All inputs are in one form HTML for numeric field <form method="POST" action={% url 'results' %}> {% csrf_token %} <div class="container"> <div class="row"> <div class="col"> <div class="form-group"> <label for="exampleInputEmail1">Magnetic Field</label> <input value="{{ mag_field … -
ModuleNotFoundError - poetry / cookiecutter
I'm trying to run commands through poetry and keep getting this error: Traceback (most recent call last): File "manage.py", line 30, in <module> execute_from_command_line(sys.argv) File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 377, in execute django.setup() File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/pollsapi_w_template/users/models.py", line 11, in <module> from pollsapi_w_template.users.emails import RestorePasswordEmail, VerificationEmail File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/pollsapi_w_template/users/emails.py", line 3, in <module> from snitch.emails import TemplateEmailMessage File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/snitch/emails.py", line 11, in <module> from snitch.tasks import send_email_asynchronously File "/mnt/c/users/lisa/documents/github/pollsapi_w_template/.venv/lib/python3.8/site-packages/snitch/tasks.py", line 3, in <module> from celery.task import task ModuleNotFoundError: No module named 'celery.task' I'm in the virtual environment created through poetry.toml and I'm trying to run poetry run python manage.py migrate for example. I have tried poetry add celery with the following result: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability … -
Quando eu faço uma pesquisa em meu blog django e realizo a paginação dos resultados dessa pesquisa ocorre esse erro -->
Essa é minha view --> class Search(ListView): queryset = Post.objects.all() paginate_by = 5 template_name = "search.html" def get_queryset(self): result = super(Search, self).get_queryset() query = self.request.GET.get("q") if query: query_list = query.split() result = result.filter( reduce(operator.and_, (Q(title__icontains=x) for x in query_list)) ) | result.filter( reduce(operator.and_, (Q(content__icontains=x) for x in query_list)) ) return result Esse é o erro Esse erro só ocorre quando eu faço a paginação dos resultados de minha pesquisa, alguém sabe como eu resolvo isso? -
DJANGO API REST ERROR : Class RetrieveUpdateDestroyAPIView has no attribute 'as_view'
i need help. In Django, i want to manage file per class, but i have error. I create folder call views, in this folder i created folder Predicacion, and in this i create file PredicacionRead.py views/Predicacion/PredicacionRead.py from api.serializers.Predicacion.PredicacionSerializer import PredicacionSerializer from api.models import Predicacion from rest_framework.generics import RetrieveUpdateDestroyAPIView class PredicacionRead(RetrieveUpdateDestroyAPIView): queryset = Predicacion.objects.filter().order_by('fecha_publicacion') serializer_class = PredicacionSerializer http_method_names = ['get'] # solo permitimos la creación del producto In url_patterns file urls.py from rest_framework import routers from django.urls import path,include from api.views.Predicacion import PredicacionLista,PredicacionRead route = routers.SimpleRouter() urlpatterns = [ path('predicaciones/<int:pk>/', PredicacionRead.as_view()), ] urlpatterns += route.urls But i have error in runserver: AttributeError: module 'api.views.Predicacion.PredicacionRead' has no attribute 'as_view' But, i i create file views2.py in root folder for module with same content of PredicacionRead, it is work -
How can I make datatables compatible with my theme?
I am using a theme that it's has it's own styling defined based on bootstrap 4.5.0 When I try to use datatables( the bootstrap 4 version ) the theme style breaks badlly. https://datatables.net/ The plugin uses this styling: <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css"/> If I don't add it (because I have the bootstrap theme style already reffered) then the table styling breaks. Not so baddly but enough to encourage me not to use the plugin's bootrstap version at all because the default one looks better. Is there a way to make it work both ? I would reallt like to use the boostrap version of the plugin. Looks and feels much cooler. -
How to make pagination appear?
The pagination isn't showing up at the bottom of my page. And I can't figure why. It's driving me bonkers. I'm user it's a super easy fix, too. The pagination is all bootstrap presets. I have a feeling it has to with the positioning of the {% include... %} on the home.html. Or it could be that I didn't up the include correctly pointing to the correct html file. The pagination.html lives directly in the templates folder. So I think I have written it correctly Views: def home(request): post = Pilot.objects.all().order_by('id') # Pagination PILOTS_PER_PAGE = 15 paginator = Paginator(post, PILOTS_PER_PAGE) # Show 15 pilots per page. page = request.GET.get('page') try: post = paginator.page(page) except PageNotAnInteger: post = paginator.page(1) except EmptyPage: post = paginator.page(paginator.num_pages) context = { 'post': post, #'page': page, } return render(request, 'home.html', context) html: <nav aria-label="Page navigation"> {% if page_has_other_pages %} <ul class="pagination"> {% if page.has_previous %} <li> <a aria-label="Previous", href="?page={{ page.previous_page_number }}">&laquo;</a> </li> {% else %} <li class="disabled"> <span>&laquo;</span> </li> {% endif %} {% for pages in page.paginator.page_range %} {% if page.number == pages %} <li class="active"> <span>{{ pages }}<span class="sr-only">(current)</span></span> </li> {% else %} <li> <a href="?page={{ pages }}">{{ pages }};</a> </li> {% endif %} {% … -
How to replace one field of one model object in Django?
I'm trying to change tags for an object. I first filter for the object I'm looking for and I now don't don't know how to replace the field (usertags). def change_tags(request, pk): file = Uploaded.objects.filter(pk=pk).values('usertags') # file = get_object_or_404(Uploaded, pk=pk) if request.method == "POST": form = ChangeTagsForm(request.POST) if form.is_valid(): print(file) form.save() return HttpResponseRedirect(reverse('index')) else: form = CommentForm() return render(request, 'index.html', {'form': form}) class ChangeTagsForm(forms.ModelForm): class Meta: model = Uploaded fields = ['usertags'] -
Replace href of 'Add Another Row' button in Django admin TabularInline
I have a TabularInline, which allows users to quickly edit certain fields in the Django admin panel. However, when clicking the 'Add Another ...' button, I want to re-direct the user to a new link, instead of adding another row. Here is the code for my TabularInline: class CustomInline(admin.TabularInline): model = CustomModel extra = 0 verbose_name = "Custom Model" fields = ['title', 'pub_date', 'published'] show_change_link = True I've tried to use jQuery to select the relevant element so that I can replace the link's href. However, it doesn't seem to be finding the relevant element. When I inspect the form in Chrome dev tools, I can see the element (screenshot below): However, when I try and select the element using the following jQuery code, I'm getting nothing back. $( document ).ready(function() { let fiveQWGroup = $("div#fiveqw_set-group div.tabular fieldset.module table tbody tr:last-child"); console.log(fiveQWGroup) }); The relevant selector doesn't seem to be appearing in the source code for that page either. So, my question is, how can I change the href of the button to the required href instead? -
Update DataTable with JsonResponse from Django not working properly
I have a Django application and a page where data is written to a table that I am styling using DataTables. I have a very simple problem that has proven remarkably complicated to figure out. I have a dropdown filter where users can select an option, click filter, and then an ajax request updates the html of the table without reloading the page. Problem is, this does not update the DataTable. My html: <table class="table" id="results-table"> <thead> <tr> <th scope="col">COL 1</th> <th scope="col">COL 2</th> <th scope="col">COL 3</th> <th scope="col">COL 4</th> <th scope="col">COL 5/th> </tr> </thead> <tbody class="table_body"> {% include 'results/results_table.html' %} </tbody> </table> results_table.html: {% for result in result_set %} <tr class="result-row"> <td>{{ result.col1 }}</td> <td>{{ result.col2 }}</td> <td>{{ result.col3 }}</td> <td>{{ result.col4 }}</td> <td>{{ result.col5 }}</td> </tr> {% endfor %} javascript: function filter_results() { var IDs = []; var IDSet = $('.id-select'); for (var i = 0; i < IDSet.length; i++) { var ID = getID($(IDSet[i])); IDs.push(ID); } // var data = []; // data = $.ajax({ // url:"filter_results/" + IDs + "/", // dataType: "json", // async: false, // cache: false, // data: {}, // success: function(response) { // $('#results-table').html(response); // // console.log(response.length); // // console.log(typeof response); // …