Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
psycopg2.errors.UndefinedTable: relation "django_content_type" does not exist
I hosted a django website on heroku I am unable to run migrations on it now , I tried resting database , running fake migrations , syncdb and some other possible solutions.Everything is working fine on my machine but migrations are not working on heroku I am unable to even open /admin this is the code . ~ $ python manage.py makemigrations Migrations for 'AIWeb': AIWeb/migrations/0007_alter_digitalnote_subjectname.py - Alter field subjectName on digitalnote Migrations for 'captcha': .heroku/python/lib/python3.9/site-packages/captcha/migrations/0002_alter_captchastore_id.py - Alter field id on captchastore ~ $ python manage.py migrate Operations to perform: Apply all migrations: AIWeb, admin, auth, captcha, contenttypes, sessions Running migrations: No migrations to apply. Traceback (most recent call last): File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 85, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedTable: relation "django_content_type" does not exist LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co... ^ The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/manage.py", line 22, in <module> main() File "/app/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 373, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 417, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 90, in wrapped … -
Django: SQL queries are slow due to complex sub-queries, how to split or speed them up?
I need to execute a query set with complex sub-queries like the one below. It takes a considerable amount of time to execute the query. (8000ms) I think the slowdown is caused by complex subqueries, but is it possible to split or speed up a single SQL query without generating N+1? The db lookup we are using and the slow query set this time # lookups.py class Groonga(Lookup): lookup_name = "groonga" def as_sql(self, compiler, connection): lhs, lhs_params = self.process_lhs(compiler, connection) rhs, rhs_params = self.process_rhs(compiler, connection) params = lhs_params + rhs_params return "%s &@~ %s" % (lhs, rhs), params # queryset Video.objects.annotate( is_viewed=Exists(History.objects.filter(user=user, video=OuterRef("pk"))), is_favorited=Exists( Favorite.objects.filter(user=user, video=OuterRef("pk")) ), is_wl=Exists( Track.objects.filter( playlist__user=user, playlist__is_wl=True, video=OuterRef("pk") ) ), ).filter( Q(title__groonga=value) | Q(tags__pk__in=Tag.objects.filter(name__groonga=value).values_list("pk")), is_public=True, published_at__lte=timezone.now(), ).order_by("-published_at").distinct()[:20] SQL query and EXPLAIN ANALYZE results SELECT DISTINCT "videos_video"."id", "videos_video"."published_at", EXISTS (SELECT (1) AS "a" FROM "videos_history" U0 WHERE (U0."user_id" IS NULL AND U0."video_id" = "videos_video"."id") LIMIT 1) AS "is_viewed", EXISTS (SELECT (1) AS "a" FROM "videos_favorite" U0 WHERE (U0."user_id" IS NULL AND U0."video_id" = "videos_video"."id") LIMIT 1) AS "is_favorited", EXISTS (SELECT (1) AS "a" FROM "videos_track" U0 INNER JOIN "videos_playlist" U1 ON (U0."playlist_id" = U1."id") WHERE (U1."is_wl" AND U1."user_id" IS NULL AND U0."video_id" = "videos_video"."id") LIMIT 1) AS … -
End a for loop if a certain condition is met in Django using templates
A similar question was asked before but the provided solutions did not work for me. Let's say I receive a list from the django views, for instance: context['requests'] = requests In the template: {% for r in requests %} {% if r.status == "Active" %} //do A {% else %} //do B {% endif %} {% endfor %} The requests list has 10 elements, one of them satisfies the condition of r.status == "Active". (invented example) What I want is: Check the requests list to determine if any of the elements in the list satisfies the condition of r.status == "Active" (or whatever condition, this is just an example) If some element in the list has the status Active the for loop will execute only one iteration, run the //do A code and then the loop will finish/break. If no element in the list has the status Active, the for loop will execute the //do B once and then break. I'm a bit confused and I don't know if there is another default tag to do this type of operation in Django -
pytest for django rest frame work api returns 301
I made simple Django application which returns {'result': 'OK'} for endpoint '/api/v1/test/ping/'. Now I am trying to test it with pytest. My test directory /test conftest.py /test_app test_api.py My conftest.py import pytest from rest_framework.test import APIClient @pytest.fixture def api_client(): return APIClient My test_api.py import pytest def test_api1(api_client): response = api_client().get("/api/v1/test/ping") assert response.status_code == 200 Test script execution fails: test_api.py::test_api1 FAILED [100%] test\test_gml_api\test_api.py:3 (test_api1) 301 != 200 But code works correct if I run server and check it manually! Give me please an advise how to solve this? -
How to youtube-dl video download directly to a user side not download file in local system using python Django?
I am trying to youtube videos to merge with audio(formate_id:140) and video(formate_id:313) using the youtube-dl library. But it downloads files in the local system. I want it directly download to the client side. I don't want to store files in the local system. Client-side means downloading files directly to a user system through a browser. Local system means it's my server. Example ydl_opts = { 'format': '313+140', 'keepvideo':'false', } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download(['https://www.youtube.com/watch?v=Wt8VRxUYDso']) If any way like merging process and response streaming process work at a time. r = requests.get(videoUrl, stream=True) response = StreamingHttpResponse(streaming_content=r) response['Content-Disposition'] = f'attachement; filename="{fileName}"' return response Please guide me in solving this coding problem. -
default language url not working in Django Debug false mode
When Debug = True everything is working as expected, but when Debug is False, URL opens 404 page for default URL. For example my URL is like that -> www.example.com this is opens www.example.com/**en** automatically when debug true, but when debug is false it doesn't work and opens like that www.example.com/ and shows my custom 404 page. . Site is multilingual and I wrote urls.py like that urlpatterns = i18n.i18n_patterns( path('', include("core.urls")), Any ideas? -
CORS error after adding secondary database(Amazon Redshift) to Django
After adding secondary database(Redshift) to Django, I am getting CORS error 'no access control allow origin' in production environment. Frontend is React. Everything works fine when I run Django server on localhost, but as soon as I push changes, I get cors error on login. By the way login api call uses differnet database(Amazon RDS/MySQL). I have checked django cors headers. Configured VPC and security groups. But I still get the same error? Maybe someone have had similar issue before and could share some widsom or nudge in direction of the problem? Thanks in advance for your help. -
Django | Type error - missing 1 required positional argument: 'file_id'
Hello I'm trying to create a platform that will solve problems and then let the user download a file with the result. I'm having trouble with the downloading part this is the error I'm getting TypeError at /download/ download() missing 1 required positional argument: 'file_id' models.py class Snippet(models.Model): email = models.CharField(max_length=100) file = models.FileField(upload_to='documents/') def __str__(self): return self.email urls.py from . import views from .views import (snippet_detail) app_name = 'app' path('download/<int:file_id>/', views.snippet_detail, name='snippet_detail'), views.py def download(request, file_id): media_path = "/home/me/project/media/documents/" result_path = '/home/me/Desktop/' max_timeout = 1*24*60*60 #days*hours*mins*secs if request.method == 'POST': form = SnippetForm(request.POST, request.FILES) if form.is_valid(): form = Snippet(file=request.FILES['file']) form.save() file_name_final = form.file.name[10:] file_path = media_path + file_name_final ### analysis code ### data_id = test['outputs'][0].get('id') datamap = dict() datamap['0'] = {'src': 'hda', 'id': data_id} results_run = .. results_id = results_run['outputs'] file_id= ''.join(results_id) if file_id !='': filepath= 'result_path' + file_id path = open(filepath, 'rb') mime_type, _ = mimetypes.guess_type(filepath) response = HttpResponse(path, content_type=mime_type) response['Content-Disposition'] = "attachment; file_id=%s" % file_id return redirect('/download/{file_id}') else: raise Http404("No result file") download.html <p>Your problem is solved please click here to download <a class="btn btn-default btn-sm" title="Download the file" data-toggle="tooltip" data-placement="right" href="{% url 'app:snippet_detail' file.id %}"> <i class="bi bi-download"></i> </a> </p> -
Table relations with django models
I am having models for subjects like English , Biology and so on. and in the other side I have a model called teachers that store records of teachers .I am working on with Django and the problem is that I don't know how could I create the many to many relationship between teachers and the subjects what am trying to achieve is to assign the responsibility of teachers. I tried to make the models English ,Biology and others into one model called Subjects and later to use Manytomanyfield, but the frequencies are totally different and I stacked. some of my models are listed below. `class English(models.Model): studentID = models.IntegerField() l_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) s_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) r_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) w_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) hw_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) t_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) p_1 = models.DecimalField(max_digits=5, decimal_places=2, default=0) l_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) s_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) r_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) w_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) hw_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) t_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) p_2 = models.DecimalField(max_digits=5, decimal_places=2, default=0) def get_mark_30_first(self): sum = self.l_1+self.s_1+ self.r_1 + self.w_1 + self.hw_1 + self.t_1 +self.p_1 return sum def get_mark_30_second(self): sum = self.l_2+self.s_2+ … -
Getting : Not Found: /{% url "postQuestion" %} in Django app
So I am running this django app which is a FAQ knowledge base search engine. the app runs on localhost port 8000 whereas the BERT model runs on localhost 5000. Unfortunately, while clicking on "post a question" option on the front end html page, the request doesn't go to the view which is created. My App's view.py code snippet: def postQuestion(request): print ("---------------reposting-----------------") dataOwners=db.dataOwners if request.method=="POST": json_dict={} json_dict['User_ID']=request.user.id json_dict['Question_asked']=request.POST['question'] json_dict['Category']=request.POST['cat'] json_dict['Sub-Category']=request.POST['subCat'] moderator_document = dataOwners.find({'Category' : json_dict['Category']}) mods_list=[] for i in moderator_document: mods_list.append(i['Moderator']) json_dict['Moderators_available']=mods_list json_dict['Moderator_assigned']='null' json_dict['Status']="Pending Assignment" json_dict['Answer_given']= 'null' if 'revision' in request.POST and 'qid' in request.POST: json_dict['Comments']="Query details corrected" questionColl.find_one_and_update({"_id" : ObjectId(request.POST['qid'])}, {"$set": {"Question_asked":json_dict['Question_asked'],"Category":json_dict['Category'] ,"Sub-Category":json_dict['Sub-Category'],"Moderators_available":mods_list,"Comments":json_dict['Comments'],"Status":json_dict['Status'] } },upsert=True) else: json_dict['Comments']=request.POST['comments'] questionColl.insert_one(json_dict) data=json.loads(json_util.dumps(json_dict)) return HttpResponse(data) I idea is that when someone post a question from the html front-end, the control goes to the above function which then puts the question details in a database collection (local mongodb). The data is being collected through a ajax call which should push the question details to "postQuestion" view. However I am getting an error like below: [28/Dec/2021 15:20:27] "POST /%7B%%20url%20%22postQuestion%22%20%%7D HTTP/1.1" 404 5624 Not Found: /{% url "postQuestion" %} My ajax call snippet: // Post a question ajax call // $(document).ready(function(event){ $(document).on("click","#postQuestion",function(event){ event.preventDefault(); //data to … -
This field is required DRF on server side only
I created a django restframe work api which is working fine locally. But when I moved it to the server, it stop working. On server i am getting this { "file_name": [ "This field is required." ] } Here is the code view.py class VideoUploadViews(APIView): def post(self, request): serializer=VideoUploadSerializer(data=request.data)#acess the data if serializer.is_valid():#check validation start=time() vid_path=serializer.data["file_name"] vid_path=os.path.join(settings.S3PATH,vid_path) pred_hr=inference.predicthr(vid_path) end=time() return Response({"status": "success", "predicted hr": pred_hr,'time taken':end-start},\ status=status.HTTP_200_OK) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) models.py class VideoUploadModel(models.Model): file_name = models.CharField(max_length=100,blank=False, null=False) serializer.py class VideoUploadSerializer(serializers.ModelSerializer): class Meta: model=VideoUploadModel fields='__all__' -
Getting issue while working with django ORM or raw sql query
list_edit_drivers.html -this is html file for showing data at front end $(document).ready(function () { $.extend(true, $.fn.dataTable.defaults, { columnDefs: [ { targets: '_all', defaultContent: '' } ] }); var table = $('#drivers').DataTable({ "pageLength": 100, "serverSide": true, "bSearchable":true, "dom": 'blfrtip', "ajax": "/fleet/dt/editdrivers/?format=datatables&city_id={{city_id}}", "columns": [ { "data": "employee_id", "mRender": function (data, type, full) { return '<a href="/fleet/driver/list_drivers/{{city_id}}/view/' + full.id + '">' + full.employee_id + '</a>'; 123 } }, { "data": "uber_name" }, { "data": "mobile" }, { "data": "uber_device_no" }, { "data": "aadhar_no", "bVisible": false, }, { "data": "location.name" }, { "data": "status" }, { "data": "id", "bSortable": false, "mRender": function (data, type, full) { return '<a class="btn btn-sm btn-primary" href="/fleet/driver/list_drivers/{{city_id}}/edit/' + full.id + '">' + 'Edit' + '</a>'; } }] }); }); urls.py -ajax call DriverViewSet url and html render list_edit_drivers url router.register(r'dt/editdrivers', views.DriverViewSet) path('driver/list_drivers', views.list_edit_drivers, name='list_edit_drivers') views.py @method_decorator(login_required, name='dispatch') class DriverViewSet(viewsets.ModelViewSet): queryset = Driver.objects.filter(is_active=1) serializer_class = DriverEditListSerializer def get_queryset(self): queryset = Driver.objects.filter(is_active=1, city_id=self.request.GET.get('city_id')) return queryset @login_required def list_edit_drivers(request): driver = Driver.objects.filter(city_id=request.session['global_city_id']) context = { 'menu_hiring': 'active', 'submenu_driver_edit_list': 'active', 'driver': driver, 'city_id': request.session['global_city_id'] } return render(request, 'hiringprocess/list_edit_drivers.html', context=context) serializers.py class DriverEditListSerializer(serializers.ModelSerializer): city = CitySerializer(read_only=True) location = LocationSerializer() class Meta: model = Driver fields = ( 'id','employee_id','employer', 'name','uber_name','uber_device_no', 'mobile', 'location', 'city','shift','status', 'aadhar_no') ** … -
HOW TO CONNECT BACKEND WITH FRONT END IN DJNAGO FARMEWORK
I have a front-end team which has made a static website using html, css and javascript. Now i want to add these files in django. How do i add these files -
Connect with django channels from external script
I have a django server with a websocket running, in the same system I have another python application which I can't add in django. I am trying to connect with django channels with python redis SDK. (I am using redis in django channels) My current approach is to find a way to connect to the redis client for django channels and send and receive message through it. (I am not sure even if it is possible) import redis r = redis.Redis(host='localhost', port=6379, db=0) group_name = "MY_GROUP" for x in r.client_list(): print(x) # how to connect to client here and send and receive message? Another solution will be to make a direct websocket connection using websockets lib, but can we do it with redis directly. -
Errno 13 Permission denied: '/home/ubuntu/Demo/website/media/image_banner/download.jpg'
I built a Web site using the Django framework, one of which was to process images uploaded by the admin and save them in a folder for media/image_banner, but encountered an error ([Errno 13] Permission denied: '/home/ubuntu/Demo/website/media/image_banner/download.jpg'. I use python manage.py runserver and it works, but it doesn't work when deployed with Apache2. -
cannot retrieve many to many all objects in django
when i try to retrieve all cart items from order model then click to open cartitem model edit page but i got first cart item only so what is wrong my code Admin Model class OrderAdmin(admin.ModelAdmin): list_display = ('user', 'total_price', 'ordered', 'get_address', 'get_cart') def get_cart(self, obj): for p in obj.items.all(): app_label = p._meta.app_label model_label = p._meta.model_name url = reverse( f'admin:{app_label}_{model_label}_change', args=(p.id,) ) return mark_safe(f'<a href="{url}">{p.item}</a>') get_cart.allow_tags = True get_cart.short_description = "Cart" Order Model class Order(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) items = models.ManyToManyField(CartItem,) ordered = models.BooleanField(default=False) total_price = models.FloatField(default=0) start_date = models.DateTimeField(auto_now_add=True) payment_id = models.CharField(null=True, blank=True, max_length=100) ordered_date = models.DateTimeField() address = models.ForeignKey( Address, on_delete=models.DO_NOTHING, blank=True, null=True) class Meta: ordering = ['-ordered_date'] def __str__(self): return str(self.user.username) + ' '+str(self.total_price) def user_link(self): return '<a href="%s">%s</a>' % (reverse("admin:auth_user_change", args=(self.user.id,)), escape(self.user)) -
Wagtail 'View live' button provides wrong url after page creation while using id as slug
I have a case that uses Page ID as a slug, after creating a new Page, Wagtail provides us a "View live" button but when we click on that button, it provides a wrong URL The right URL should be ".../property-list/<property-id>" I have searched on stack overflow, found this thread but the answer is still a mystery: Wrong 'View live' url in Wagtail admin message after page creation when using id as slug I have followed the Wagtail official document, using Wagtail Hooks to manipulate data. However, no success yet. This is my code: @hooks.register('after_create_page') def set_number_and_slug_after_property_page_created(request, page): page.number = page.slug = str(page.id) page.save() new_revision = page.save_revision() if page.live: new_revision.publish() Please help me, thank you. -
Problem importing ModelResource from tastypie.resources
Good day, I'm currently on the middle of a practice project for django and can't seem to find a solution to a problem when creating an api with tastypie. I'm currently in the middle of learning so any help would be appreciated. I'm using django 4.0 and tastypie 2.8.2. Here's the code which seems to be the problem: from django.db import models from tastypie.resources import ModelResource Here's the full error I'm getting when attempting to execute python3 manage.py runserver on my venv: Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self._target(*self._args, **self._kwargs) File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 115, in inner_run autoreload.raise_last_exception() File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception raise _exception[1] File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/core/management/init.py", line 381, in execute autoreload.check_errors(django.setup)() File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/home/user/.local/share/virtualenv-path/lib/python3.9/site-packages/django/apps/config.py", line 300, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "frozen importlib._bootstrap", line 1030, in _gcd_import File "frozen importlib._bootstrap", line 1007, in _find_and_load File "frozen importlib._bootstrap", line 986, in _find_and_load_unlocked File "frozen … -
TypeError: do_something_on_deactivation() missing 1 required positional argument: 'instance_id' in django
Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Users\OneDrive\Desktop\GFG\gfgvenv\lib\site-packages\activatable_model\models.py", line 109, in save model_activations_changed.send(self.__class__, instance_ids=[self.id], is_active=current_activable_value) File "C:\Users\OneDrive\Desktop\GFG\gfgvenv\lib\site-packages\django\dispatch\dispatcher.py", line 182, in send for receiver in self._live_receivers(sender) File "C:\Users\OneDrive\Desktop\GFG\gfgvenv\lib\site-packages\django\dispatch\dispatcher.py", line 182, in <listcomp> for receiver in self._live_receivers(sender) TypeError: do_something_on_deactivation() missing 1 required positional argument: 'instance_id' I am getting this error when I am saving my Django custom model object. This is my Model.py file from django.db import models # Create your models here. class MyModel(models.Model): username = models.CharField(max_length=15) pass1 = models.CharField(max_length=50) is_active = models.BooleanField(default=False) In the python manage.py shell I ran >>>from authentication.models import MyModel >>>obj = MyModel.objects.all()[0] >>>obj.is_active = True >>>obj.save() Not sure where I am wrong, even though it throughs an error, the changes are being made -
DJango + nginx + gunicorn: how to start caching and which way is more standard?
I deployed my Django project using Gunicorn, but now can't use Nginx caching. How to start caching on a project that use Gunicorn and which caching method is standard for Django. -
Django. Annotate queryset to get amount of relations with other model
I have models Question, Answer, Form and FormAnswer. models were simplified to shorten reading time class Question(models.Model): text = models.CharField(max_length=255) class Answer(models.Model): question = models.ForeignKey(Question, models.CASCADE) text = models.CharField(max_length=255) class Form(models.Model): user = models.ForeignKey(CustomUser, models.CASCADE) class FormAnswer(models.Model): form = models.ForeignKey(Form, models.CASCADE) question = models.ForeignKey(Question, models.CASCADE) answer = models.ForeignKey(Answer, models.CASCADE) I'd like to be able to annotate stats like this: Form.stats -> { 1: { # Question.pk 2: 5 # Answer.pk: how much times this question # was answered with this answer via FormAnswer model 3: 11, 4: 1, }, 2: { 5: 1, 6: 2, 7: 9, }, } SQL alternatives would also be helpful -
How to write the mark_safe fun for this class based view
I wanted to return mark_safe for the below API so how can i do that class AboutUsViewSet(viewsets.ModelViewSet): queryset = AboutUs.objects.all() serializer_class = AboutUsSerializer def get_permissions(self): if self.request.method == 'GET': self.permission_classes = [AllowAny, ] else: self.permission_classes = [IsAuthenticated, ] return super(AboutUsViewSet, self).get_permissions() -
is there any 'safe' keyword of django template filter in python or javascript?
I'm using ckeditor for description field which allow user to format text this is what saving in my description field: <div class="ql-editor" data-gramm="false" data-placeholder="Compose an epic..." contenteditable="true"> <p><strong>Lösungen, die mit Ihrem Unternehmen wachsen. Gern berate ich Sie zu allen Steuerfragen. Vereinbaren Sie ein individuelles Informationsgespräch. Annette Wolff Ι Steuerberaterin</strong></p> </div> <div class="ql-clipboard" tabindex="-1" contenteditable="true"> </div> <div class="ql-tooltip ql-hidden"> <a class="ql-preview" target="_blank" href="about:blank"></a><input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL"><a class="ql-action"></a><a class="ql-remove"></a> </div> to show it in a proper format i'm using description|safe filter in django template which shows the descripltion like this: Lösungen, die mit Ihrem Unternehmen wachsen. Gern berate ich Sie zu allen Steuerfragen. Vereinbaren Sie ein individuelles Informationsgespräch. Annette Wolff Ι Steuerberaterin but how can i handle it with ajax call as i cannot use django template safe filter keyword. Is there any way to handle it in javascript, jquery or in python file. -
I having 5 fields but i need to search by "username" in "search field". how we can do it in DJango Application
In my application there are fields like phone, username, Address, id. but i need only details of "username" field when i search it in search box. how we can do this . can anyone help me with DJango code -
How to fix incompatible architecture for gdal while running Django server in MacOs
while running Django server by using python manage.py runserver, I'm getting following error. Could anyone please help me to fix this issue. self._handle = _dlopen(self._name, mode) OSError: dlopen(/usr/local/homebrew/opt/gdal/lib/libgdal.dylib, 0x0006): tried: '/usr/local/homebrew/opt/gdal/lib/libgdal.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libgdal.dylib' (no such file), '/usr/lib/libgdal.dylib' (no such file), '/usr/local/homebrew/Cellar/gdal/3.3.3_1/lib/libgdal.29.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/libgdal.29.dylib' (no such file), '/usr/lib/libgdal.29.dylib' (no such file) I am having M1 Chip MacBook Pro and I have installed the gdal in /usr/local/homebrew/opt/gdal/.