Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
static files not loading to django project
I have a project, where my partner worked on the Frontend without using any frameworks, just used js, html and css. I wanted to attach that front to the back by using Django. so here are my settting.py STATIC_ROOT = os.path.join('C:/Users/1224095/work/Backend/backend/static') STATIC_URL = '/static/' STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) and I added the {% load static %} in my html header. To not confuse you, I made a static directory named static, and inside I got my assets and plugins from the frontend, plus in every place, I added href= {% static 'path to the file' %} As a result, I am getting an error of 404, does anyone has an idea why ? here's an example of my html: <!doctype html> <html lang="en"> {% load static %} <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="{% static 'assets/plugins/simplebar/css/simplebar.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/perfect-scrollbar/css/perfect-scrollbar.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/metismenu/css/metisMenu.min.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/vectormap/jquery-jvectormap-2.0.2.css' %}" rel="stylesheet" /> <link href="{% static 'assets/plugins/highcharts/css/highcharts-white.css' %}" rel="stylesheet" /> -
Django+vue.js restart
djangosite api views.py models.py src main.js componenets assets my project looks like this. And also i'm using gunicorn. So, i use "sudo systemctl restart gunicorn" command when i want to reflect the code that i changed. But when i change the code of vue.js(component) it doesn't reflect. i can't find the reason does anyone know what the problem is? -
How to add password and username pop up for Django Swagger?
I am using drf-yasg library for the Django Swagger. I need to add the authentication on username and password level. There are three security schemes available in this library "basic", "apiKey" or "oauth2". Is there any way I can set my credentials for swagger in my django project settings and authenticate the swagger apidocs based on that? -
Fetch similar Django objects in one query if the objects have no direct relation
Let's say I have the following model: class Book(models.Model): class Meta: constraints = [ models.UniqueConstraint( fields=["name", "version"], name="%(app_label)s_%(class)s_unique_name_version", ) ] name = models.CharField(max_length=255) version = models.PositiveIntegerField() For each book, I need to get all higher versions: book_to_future_book_mappings = {} for book in Book.objects.all(): higher_versions = Book.objects.filter(name=name, version__gt=book.version).order_by("version") book_to_future_book_mappings[book] = list(higher_versions) The problem with this approach is that it doesn't scale well. It makes a separate query for every book, which is very slow if I have millions of books in my database. Is there anyway I can get all of this data in just a few queries? Perhaps I can use RawSQL if needed? Note my database is PostgreSQL. -
Parallel sequential celery tasks
I have a long list of queues which should be run sequentially but queues must run in parallel. Example: Tasks(Received by time): A1, B1, C1, D1, A2, C2, B2, A3, D2, D3, B4, A1, D4, C4 Queues: A=[A1,A2,A3,A4] , B=[B1, B2, B3, B4], C=[C1, C2, C3, C4] D=[D1, D2, D3, D4] So I managed to use apply_async(args=..., queue='queue_{}'.format((id % 4) + 1) and the routing looks fine. But there's one problem. I have about 64 threads of CPU and when I create 40 queues, tasks does not exactly run in parallel. queue 1 to 8 start to work in parallel but others wait and at a moment suddenly first 8 tasks freeze and 9 to 16 start to work. CPU load is about 40 to 50%. worker command example(40 times run using supervisord): celery -A bot worker -Q queue_19 -l ERROR --prefetch-multiplier=100 -c 1 As I mentioned before, there's no lack of resources because number of workers are about 70% of CPU threads. And the ram wouldn't fill up Celery broker backend used: Redis -
Django check block content is none or not
Can I code something like this? : // base.html {% block content %} {% if block content is None %} <p> default content </p> {% endif %} {% endblock content %} // child.html {% block content %} <p> child content </p> {% endblock content %} I know I just need to code something like this: // base.html {% block content %} {% endblock content %} // child.html {% block content %} {% if child.content %} <p> child content </p> {% else %} <p> default content </p> {% endif %} {% endblock content %} But I have so many child.html inherit from base.html.. So I just want to change the parent(base.html). Is it possible? -
Change Gunicorn Bin Path
I am using Ubuntu 20.04 and have manually installed Gunicorn with python setup.py install under the activation of virtual environment. However, when I typed which gunicorn, cmd showed /usr/bin/gunicorn. I want the system to use the gunicorn bin at /home/user/project_venv/bin/gunicorn, is there a way to change the path so that which gunicorn will point to the new path? Thanks in advance. -
I can't make query in django to filter out posts from those users that the currently logged in user is following
I am working on a Django project where a user can follow other users, create posts and so on just like Twitter or Instagram. However, I have a problem writing queries in views.py to filter out all the posts from the people that currently logged in user is following. Here, I am sharing my views.py function, model, template and corresponding ER diagram. views.py def followerspost(request): user = request.user profile = Profile.objects.filter(user = user) followings = user.profile.followings.all() for following in followings: posts = NewPost.objects.filter(user = following) return render(request,"network/following.html",{ "user" : user, "profile" : profile, "followings" : followings, "posts" : posts, }) models.py class NewPost(models.Model): user = models.ForeignKey(User, on_delete = models.CASCADE) post = models.TextField() timestamp = models.DateTimeField(auto_now_add = True) def __str__(self): return f"{self.post}" class Profile(models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE) picture = models.ImageField(blank=True,null=True,upload_to="images/") followers = models.ManyToManyField(User, blank=True, related_name="followers") followings = models.ManyToManyField(User,blank = True, related_name="followings") I have designed my database according to the following ER diagram. urls.py urlpatterns = [ path("profile/<int:id>/following/addfollower",views.followersPeople,name="addfollower"), path("profile/<int:id>/following/removefollower",views.followersRemove,name="removefollower"), path("following",views.followerspost,name="following"),]+ static(settings.MEDIA_URL, document_root= settings.MEDIA_ROOT) following.html <h1>All Posts</h1> <div id="posts" class="card"> <div class="card-body"> {% for posts in posts %} <ul> <li class="card"> <div class="card-body"> <h5 class="card-title"><a style="text-decoration: none;" href="{% url 'profile' posts.user.id %}">{{ posts.user }}</a></h5> <h6 class="card-subtitle text-muted">{{ posts.timestamp }}</h6> <h3 … -
How to write a login view for my register view in rest frame work?
I'm a beginner in Django and the rest framework and I'm trying to write a class-based login view with the rest framework for my register view please help me for writing a login class-based view what is important is view be class-based with rest this is a registered view of my project and then its serializer at the bottom of that class RegisterView(GenericAPIView): serializer_class = UserSerializer permission_classes = (permissions.AllowAny,) def post(self, request): serializer = UserSerializer(data=request.data) if serializer.is_valid(): serializer.save() user_data = serializer.data user = User.objects.get(email=user_data['email']) token = RefreshToken.for_user(user).access_token current_site = get_current_site(request).domain print(current_site) # relativeLink = reverse('verify-email') # print(type(relativeLink)) absurl = 'http://' + current_site + "?token=" + str(token) email_body = 'سلام' + user.username + '\nبرای فعال سازی حساب خود وارد لینک زیر شوید' + '\n' \ + absurl data = {'email_body': email_body, 'to_email': user.email, 'email_subject': 'Verify your email'} Util.send_email(data) return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) it is a register view serializer in serializer.py class UserSerializer(serializers.ModelSerializer): password = serializers.CharField( max_length=65, min_length=8, write_only=True) confirm_password = serializers.CharField( max_length=65, min_length=8, write_only=True) def validate_email(self, value): lower_email = value.lower() if User.objects.filter(email__iexact=lower_email).exists(): raise serializers.ValidationError("ایمیل تکراری است") return lower_email def validate(self, data): if not data.get('password') or not data.get('confirm_password'): raise serializers.ValidationError("لطفا پسورد را وارد و تایید کنید ") if data.get('password') … -
Django admin: Cropping using ImageRatioField on FilerImageField give errors
When I am doing using ImageField and ImageRatioField it working well for me but I have to do it with FilerImageField than it will not work for me. class FeatureArticle(models.Model): featured_listing_image = models.ImageField( null=True, blank=True, upload_to=featured_listing_image_directory_path, verbose_name=_('Feature listing image'), help_text=_('Feature listing image of article.'), ) featured_listing_image_cropping = ImageRatioField('featured_listing_image', '433x309', allow_fullsize=True, free_crop=False) featured_listing_image_latest = FilerImageField( null=True, blank=True, verbose_name=_('Featured listing image latest'), help_text=_('Featured listing latest image of Article.') ) featured_listing_image_latest_cropping = ImageRatioField('featured_listing_image_latest', '433x309', allow_fullsize=True,free_crop=False) @property def cropped_feature_listing_image(self): if self.featured_listing_image: featured_listing_image = self.featured_listing_image.url image_name = featured_listing_image.split('/')[-1].split('.')[0] featured_listing_image = featured_listing_image.replace(image_name, image_name + '_crop') return featured_listing_image return '' from django.contrib import admin from .model import FeatureArticle from image_cropping import ImageCroppingMixin class FeatureArticleInline(ImageCroppingMixin, admin.StackedInline): model = FeatureArticle max_num = 0 fieldsets = ( (_('Featured Image'), { 'fields': ( 'featured_listing_image', 'featured_listing_image_cropping', 'featured_listing_image_latest', 'featured_listing_image_latest_cropping' ), }), ) But It will give error of when I trying using FilerImageField. Error: There's no widget registered to the class FilerImageField. Please give me a solutions of cropping of image possible with this two field type? Thanks in advance. -
mac 12.0.1 django symbol not found in flat namespace '_mysql_affected_rows'
Traceback (most recent call last): File "/Users/xxx/Library/Python/3.6/lib/python/site-packages/MySQLdb/init.py", line 18, in from . import _mysql ImportError: dlopen(/Users/xxx/Library/Python/3.6/lib/python/site-packages/MySQLdb/_mysql.cpython-36m-darwin.so, 0x0002): symbol not found in flat namespace '_mysql_affected_rows' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 1, in File "/Users/xxx/Library/Python/3.6/lib/python/site-packages/MySQLdb/init.py", line 24, in version_info, _mysql.version_info, _mysql.file NameError: name '_mysql' is not defined A reinstallation attempt was made and did not take effect -
Why is my admin not showing up in Django but my site still shows and works?
I am working with Django and as I try to pull up my admin page typing in http://127.0.0.1:8000/admin, I get this DoesNotExist at /admin/login error. But the funny thing is my actual site that I am building is still showing up when I run the server. And the tags work. All was working until I added 'taggit', to the Installed Apps on settings.py and when I added tags to the models.py and made migrations and such. I have no idea why the admin is not showing. -Chris I've attached a screenshot below of what I am seeing. The Error Screen -
pymongo.errors.ServerSelectionTimeoutError while running a docker image of django app
I am trying to run a docker image of my Django app. I am running a mongo image separately from another container. Need help to solve following error: pymongo.errors.ServerSelectionTimeoutError: xxx.xxx.xxx.xxx:27017: timed out, Timeout: 30s, Topology Description: <TopologyDescription id: 61aee0f6695286eb954e68ea, topology_type: Single, servers: [<ServerDescription ('xxx.xxx.xxx.xxx', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('xxx.xxx.xxx.xxx:27017: timed out',)>]> I have configured mongo db using djongo, DATABASES = { 'default': { 'ENGINE': 'djongo', 'NAME': 'database-name', 'CLIENT':{ 'username': 'username', 'password': 'password', 'host': 'mongodb://xxx.xxx.xxx.xxx:27017/database-name', 'port': 27017, 'authSource': 'admin', 'authMechanism': 'SCRAM-SHA-1' } } } I have also created a user in mongo db using following command; db = db.getSiblingDB('database-name') db.createUser({ user: 'username', pwd: 'password', roles: [ { role: 'root', db: 'admin', }, ], }); Using the same credentials while configuring Mongo with Django. This is my requirements.txt asgiref==3.4.1 dataclasses==0.8 Django==3.2.9 django-filter==21.1 djangorestframework==3.12.4 djongo==1.3.6 gunicorn==20.0.4 importlib-metadata==4.8.2 Markdown==3.3.6 pymongo==3.12.1 python-dateutil==2.8.2 pytz==2021.3 six==1.16.0 sqlparse==0.2.4 typing_extensions==4.0.0 zipp==3.6.0 The Mongo containers are as follows, CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f479308130bb mongo-express "tini -- /docker-ent…" 16 hours ago Up 16 hours (healthy) 0.0.0.0:9081->8081/tcp, :::9081->8081/tcp mongo-express 4e6e0e60a473 mongo "docker-entrypoint.s…" 16 hours ago Up 16 hours (unhealthy) 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp mongodb If I try to access mongo db from remote server using the user that I … -
Django Summernote Settings
I've installed django-summernote and most of it works fine except for the dropdown buttons for Style, Font Size, Color and Table. The example has them setup as follows: ... 'toolbar': [ ... ['style', ['style'], ['fontsize', ['fontsize']], ['color', ['color']], ['table', ['table']], ... ], I have tried placing a list of possible values, for example, a list of colors in color: ['color', ['black', 'red']], But this clearly isn't correct as the button doesn't show at all if I try entering a list of possible values. I have noticed that if I copy in any formatted text and select it, the fontsize button does display the actual size I copied but gives me no way to change it from the toolbar and my only option for sizing text is to use CTRL+1/2/3/4/5/6 for the relevant format as H1 to 6 whereas the examples shown online clearly have working dropdowns. I am using bs5 SUMMERNOTE_THEME = 'bs5' theme and have tried various config's in settings.py but nothing seems to enable the dropdowns. I have tried copying the scripts from various discussion groups and tutorials discussing summernote to no avail and checked all my settings and they all appear to be fine. It is saving … -
How to solve gateway time-out while connecting to google calendar api?
I am trying to connect to google calendar Api using Documentation . This works on local host and I am able to retrieve events from the user's google calendar. After hosting the website using apache, I can see all the pages live but One of the pages is connecting to the google calendar api and this page says 504 Gateway Time-out. def connect_google_api(): st = time.time() creds = None if os.path.exists('token.json'): creds = Credentials.from_authorized_user_file('token.json') if not creds or not creds.valid: if creds and creds.expired and creds.refresh_token: creds.refresh(Request()) else: flow = InstalledAppFlow.from_client_secrets_file('/var/www/FolderName/ProjectName/credentials2.json',SCOPES) creds = flow.run_local_server(port=0) with open('token.json','w') as token: token.write(creds.to_json()) service = build('calendar','v3',credentials=creds) I am thinking that there is some problem while reading credentails2.json. Can any one point me where I am making mistake? -
Do I need to use "Marking extra actions for routing" in this REST Django API?
I'm currently having this issue. I have to set up an URL like this: .../users/<user_id>/user_action/ There are many users and when I pick one user (with user_id), I will be able to see the user's information. Then, go to /user_action, I will be able to POST actions for that specific user. In this case, do I have to use the Marking extra actions for routing or do I just need to make a separate Viewset for user_action (then link it to users/<user_id>/ in the urls.py)? -
How to override the max_length error message for an ImageField?
I am using Django 2.2. I have an ImageField. I need to override its default max length of 100 and override the error message it generates. Is it me or error messages for anything that inherits from FileField cannot be overridden? class PageTemplate(models.Model) background_image = models.ImageField( blank=True, null=True, verbose_name='Header Image', upload_to=page_template_image_path, max_length=150, error_messages={'max_length': "This is a test 1"}, validators=(validate_image_file_extension, validate_filename_size), ) The error message that I get is Ensure this filename has at most 150 characters (it has 157). And before anybody asks, yes, I remembered to run makemigrations and migrate. -
Calling Django REST API from a python function?
Is there any way I can call a DRF API from a python function. There is no URL allowed to this API, my requirement API should not be accessible from the front end. Thanks in Advance -
Django resubmits blank form after successful form
I'm new to Django and I'm trying to make a site where after a user inputs a start and end date, some data processing is done and then a result is displayed. I have this working, but after the form successfully completes and displays the data, a new POST and GET request run on the server and find no input. This is causing me problems with another form on the same project. I think I may need to use redirect to avoid double form submission? However, I am trying to process data with the post request and display, and to my understanding, the redirect would take the user to a new url and not pass the processed data with it. Thanks in advance! Here is part of my index.html <div class="search-container"> <form action="{% url 'get_data' %}" method="post"> {% csrf_token %} {{ timeform}} <input type="Submit" name="submit" value="Submit"/> </form> And here is my forms.py from django import forms class PickTimesForm(forms.Form): start_date = forms.CharField() end_date = forms.CharField() and here is views.py def plot_data(request): context={} trackform = PickTrackForm() context["trackform"]=trackform if request.method == 'POST': timeform = PickTimesForm(request.POST) if timeform.is_valid(): target_directory= '/home/bitnami/htdocs/projects/laserviz/data/' start_date = timeform.cleaned_data.get("start_date") end_date = timeform.cleaned_data.get("end_date") [data,lats,lons] = tf.getTracks(start_date,end_date,target_directory) [fig_html, track_info]= tf.makeMap(lons,lats) context["figure"]=fig_html context["track_info"]=track_info … -
How to compare two queryset to find same and different values and add to calendar
I'm using the HTMLCalendar module provided by Django. In addition to the event, I want to pull the date value from another class to default and display it in the calendar. First, when the assignment(person) visits the hospital, he enters next_visit. Here, if a patient visits the hospital at an saved next visit, we want to apply a 'text-decoration:line-through' to the next visit data. (get_html_url_drop) The expression for if n.assignment == c.assignment seems to be correct, but the else case doesn't give me the answer I'm looking for. Please help. That is, if the assignment is the same by outputting both the next visit and the cycle visit on a specific date, one assignment(next_visit) will be deleted. Strikethrough applies to that person's name because they visited on the scheduled date. [Leave/models.py] class Leave(models.Model): title = models.CharField(max_length=50, blank=True, null=True) from_date = models.DateField(blank=True, null=True) end_date = models.DateField(blank=True, null=True) memo = models.TextField(blank=True, null=True) user = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, null=True) is_deleted = models.BooleanField(default=False) create_date = models.DateTimeField(auto_now_add=True) update_date = models.DateTimeField(auto_now=True) @property def get_html_url(self): url = reverse('leave:leave_edit', args=(self.id,)) return f'<div class="event-title"><a href="{url}" style="color:black;"> {self.title} </a></div>' [Feedback/models.py] class Feedback(models.Model): cycle = models.CharField(max_length=500, default='', blank=True, null=True) day = models.CharField(max_length=500, default='', blank=True, null=True) dosing_date = models.DateField(blank=True, null=True) next_visit = … -
Switching from SQLite to Mysql in production causes error
I am using a digital ocean server. After switching to mysql database from sqlite, I got 502 Bad Gateway nginx/1.18.0 (Ubuntu) This is running fine when I run the project from the terminal using python manage.py runserver ip:8000 . I think there are faults in the gunicorn . How to solve this any idea? After checking the logs, sudo tail -F /var/log/nginx/error.log 2021/12/06 10:32:06 [error] 230230#230230: *15355 connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: 113.199.220.31, server: develop-330.gsa-cs.com, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "develop-330.gsa-cs.com" 2021/12/06 10:37:21 [error] 230230#230230: *15358 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 113.199.220.31, server: develop-330.gsa-cs.com, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "develop-330.gsa-cs.com" 2021/12/06 10:37:24 [error] 230230#230230: *15358 connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: 113.199.220.31, server: develop-330.gsa-cs.com, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "develop-330.gsa-cs.com" 2021/12/06 10:44:06 [error] 230230#230230: *15365 connect() to unix:/run/gunicorn.sock failed (111: Connection refused) while connecting to upstream, client: 113.199.220.31, server: develop-330.gsa-cs.com, request: "GET / HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/", host: "develop-330.gsa-cs.com" 2021/12/06 10:48:35 [error] 230230#230230: *15368 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 113.199.220.31, server: develop-330.gsa-cs.com, request: "GET … -
PyCharm (pro) - Django console: ModuleNotFoundError: No module named
I can't use the Django console because I keep having the following error and can't figure it out what to do.. I've tried extensively to search for a solution online but none it seems to work for me.. probably cause I don't know the reason of the problem If I don't use the console the app works just fine without any error but I can't do a proper debugging Here it is the error: /Users/alex/Documents/dev_py/project-crm/venv/bin/python3.10 /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py --mode=client --port=57445 import sys; print('Python %s on %s' % (sys.version, sys.platform)) import django; print('Django %s' % django.get_version()) sys.path.extend(['/Users/alex/Documents/dev_py/project-crm', '/Users/alex/Documents/dev_py/project-crm/users', '/Users/alex/Documents/dev_py/project-crm/project_crm', '/Applications/PyCharm.app/Contents/plugins/python/helpers/pycharm', '/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev']) if 'setup' in dir(django): django.setup() import django_manage_shell; django_manage_shell.run("/Users/alex/Documents/dev_py/project-crm") PyDev console: starting. Python 3.10.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:20) [Clang 12.0.5 (clang-1205.0.22.11)] on darwin Django 3.2.9 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 6, in <module> File "/Users/alex/Documents/dev_py/project-crm/venv/lib/python3.10/site-packages/django/__init__.py", line 19, in setup configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) File "/Users/alex/Documents/dev_py/project-crm/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name) File "/Users/alex/Documents/dev_py/project-crm/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/Users/alex/Documents/dev_py/project-crm/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File … -
Chart.js Setup Using Ajax & Variables
I cannot get my Chart.js to show up on my webpage. I am utilizing two arrays for data/labels and am creating the chart in an onload js function. Tried several different methods from tutorials and other Stack posts. HTML is just <canvas id="piee"></canvas> and I brought chart.min.js into my project and load the script as <script src="{% static "js/chart.min.js" %}"></script> window.onload = function () { console.log("Child: ", document.getElementById("piee")) var ctx = document.getElementById('piee').getContext('2d'); var rep_name = $("#pie1").attr("data-rep-name") var ajax_url = $("#pie1").attr('data-ajax-url') var _data = [] var _labels = [] // Using the core $.ajax() method $.ajax({ // The URL for the request url: ajax_url, // The data to send (will be converted to a query string) data: { name: rep_name }, // Whether this is a POST or GET request type: "POST", // The type of data we expect back dataType: "json", headers: {'X-CSRFToken': csrftoken}, context: this }) // Code to run if the request succeeds (is done); // The response is passed to the function .done(function (json) { if (json.success == 'success') { var newMale = json.malePerc var newFemale = json.femalePerc console.log(newMale, newFemale) _labels.push("male", "female") _data.push(parseFloat(newMale), parseFloat(newFemale)) var newUVB = json.uvbPerc var newSize = json.specSize console.log("data: " + _data) var … -
الجمال واللياقة البدنية [closed]
الجمال واللياقة البدنية يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر يقدم موقعنا اسرار الجمال واللياقة البدنية والرشاقة والعناية بصحتك للبنات والرجال حصريا تمارين - كمال اجسام - العناية بالوجه - العناية بالجسم - العناية بالبشرة - العناية بالشعر -
How do i connect EC2 instance for elastic search in Django?
I'm just trying to add dynamic search as a feature to my application, i used Django Elasticsearch DSL to achieve this https://django-elasticsearch-dsl.readthedocs.io/en/latest/quickstart.html, but i'm not able to connect the running postgres EC2 instance. Any leads would be very much appreciated :) Here is the snippet where i have to add the creds - ELASTICSEARCH_DSL={ 'default': { 'hosts': 'localhost:9200' }, } Currently, i'm accessing the EC2 using username, password, of-course Host and Port address.