Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Handling objects differently based on dates in Django Template
I am in the process of building out a timeline for a list of objects. The model is simply laid out as follows: class Note(models.Model): added_by = models.ForeignKey(User) context = models.TextField() timestamp_added = models.DateTimeField(auto_now_add=True) And I plan to use this to create a timeline passing the following through: notes = Note.objects.all() However, to make things a bit cleaner, I would like to put a header for each date and then show all events for that date. Something as follows in my view: <ul class="timeline"> <!-- timeline time label --> {% for note in notes %} {% if note.timestamp_added is first %} <li class="time-label"> <span class="bg-red"> {{note.timestamp_added|date:"D m, Y" }} </span> </li> {% endif %} <li> <i class="fa fa-envelope bg-blue"></i> <div class="timeline-item"> <span class="time"><i class="fa fa-clock-o"></i> {{note.timestamp_added}}</span> <h3 class="timeline-header"><a href="#">{{note.added_by}}</a> added note</h3> <div class="timeline-body"> {{note.context}} </div> </div> </li> {% endfor %} </ul> However, is there an appropriate way to write an if statement here based on first instance of the date? -
Unable to execute fabric script for vagrant box
I am trying to run a fabric script which is uploading data in a postgres database in a vagrant box. The same script was running fine a couple of months ago and nothing was changed. But this time when I execute the script from my host machine as: ./pipeline-import.sh But then I get a strange behavior. First I am requested to enter a password for the vagrant user, while before I was never requested. After I put the default pass: vagrant I get these errors: Loaded environment from env/dev.yml [localhost:2222] Executing task 'pipeline_sql_schemas' Continue (y/n)? y [localhost:2222] sudo: echo 'CREATE SCHEMA IF NOT EXISTS gaul;' | PGPASSWORD='xxxx' psql -U user -d user_db [localhost:2222] Login password for 'vagrant': No handlers could be found for logger "paramiko.transport" Fatal error: No existing session Underlying exception: No existing session Aborting. -
How to make js/javascript retrieve the specific html option value inside a django python forloop
So I want to get the option currently selected on my looped option value, but it only keeps getting the last index of the loop whenever I press submit. specific code inside my "admin.html" The loop is for listing all the users who aren't inside the specific group <label class="control-label col-md-3 col-sm-3 col-xs-12">Add Members:</label> <div class="col-md-8 col-sm-6 col-xs-12"> <select name="employeeName" id="employeeLocation" class="select2_single form-control" tabindex="-1"> {% for user in users %} {% ifnotequal user.profile.group.id groups.id %} <option name="userGroup" id="userGroup-{{ user.id }}" value="{{user.id}}">{{user.username}}</option> {% endifnotequal %} {% endfor %} </select> </div> javascript code <script> function editGrpAjax(id,groupid){ var newid = document.getElementById(id).value; var newgroupid = document.getElementById('groupid-' + groupid).value; $.ajax({url: 'http://127.0.0.1:8000/editGrp/?pkid='+ newid + "&groupid=" + newgroupid, success: function(result){ // insert success message here } }); } </script> It keeps getting the last value of the loop, and not the one that is currently selected or highlighted in the option value upon submit. -
Pycharm : Process finished with exit code -1
I am using PyCharm 2017.1.3 and got an unexpected error Process finished with exit code -1 Can anyone please explain this ? -
Celery doesn't found postgres container
I use django and celery in my project with docker. In docker, i have three containers: app, celery, postgres In the celery task, when i tried to get a model: @app.task def test(): Model.objects.get(pk=1) , i had this error: Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432? That error comes from the celery container. If i remove this lodel call, everything works well. The postgres container is at port 5432, it works well with app container. I thought that maybe because when the celery task executes, the task itself is not part django project, so it doesn't have the right configuration. I tried django-celery, but had the same error. -
Django data submission, verification by different group of users
In django, I have to create a system such that, certain group of users submit data which are then reviewed and approved by certain higher privileged group of users and then only updated to the central database. Data submission is done by forms. How can I implement this type of system in django? -
Beginner Docker-Compose & Django
I'm reading through the Docker Compose docs and have a question about the first code example under the heading: Create a Django project To create a new django project, it states that you should run the following line of code: docker-compose run web django-admin.py startproject composeexample . What I'm not understanding is why we should run this command in the context of docker-compose run. It's still creating the folder on our local machine. So why are we going through docker-compose to do this? -
How can I filter out the data that for root model?
From the post: Django rest framework - filtering for serializer field I can filter out the serializer-field that meet a condition, but, How can I filter the root serializer's field that meet a condition? I have models: class Album(models.Model): album_name = models.CharField(max_length=100) artist = models.CharField(max_length=100) is_active = models.BooleanField(default=True) class Track(models.Model): album = models.ForeignKey(Album, related_name='tracks', on_delete=models.CASCADE) order = models.IntegerField() title = models.CharField(max_length=100) duration = models.IntegerField() is_active = models.BooleanField(default=True) class Meta: unique_together = ('album', 'order') ordering = ['order'] def __unicode__(self): return '%d: %s' % (self.order, self.title) class Track3(models.Model): track = models.ForeignKey(Track, related_name='track3s', on_delete=models.CASCADE) order = models.IntegerField() title = models.CharField(max_length=100) duration = models.IntegerField() is_active = models.BooleanField(default=True) class Meta: unique_together = ('track', 'order') ordering = ['order'] def __unicode__(self): return '%d: %s' % (self.order, self.title) And I have serializers: class Track3Serializer(serializers.ModelSerializer): class Meta: model = models.Track3 fields = ('order', 'title', 'duration') class TrackSerializer(serializers.ModelSerializer): track3s = Track3Serializer(many=True, read_only=True) class Meta: model = models.Track fields = ('order', 'title', 'duration', 'track3s') class AlbumSerializer(serializers.ModelSerializer): tracks = serializers.SerializerMethodField('get_active') # TrackSerializer(many=True, read_only=True) def get_active(self, album): qs = models.Track.objects.filter(is_active=True, album=album) serializer = TrackSerializer(instance=qs, many=True) return serializer.data class Meta: model = models.Album fields = ('album_name', 'artist', 'tracks') and in the views: def a_list(request): if request.method == 'GET': albums = models.Album.objects.all() serializer = serializers.AlbumSerializer(albums, … -
How to serialize several fields from different models without foreign key in django-rest-framework?
For better performance, I choose to give up foreign key in my codes. So I use employee_id to relate the two tables. from django.db import models from datetime import datetime Class Person(models.Model): employee_id = models.CharField(max_length=20, unique=True) name = models.CharField(max_length=50) Class BussinessTrip(models.Model): employee_id = models.CharField(max_length=20) city = models.CharField(max_length=50) leave_time = models.DateField() back_time = models.DateField(null=True, blank=True) is_latest = models.BooleanField(default=True) add_time = models.DateTimeField(default=datetime.now) Now I need to get the latest trip infomation of all people by unique employee_id [ { employee_id: 'A', name: '', city: '', leave_time: '', is_latest: True }, { employee_id: 'B', name: '', city: '', leave_time: '', is_latest: True }, ... ] How can I serialize the models in this format? from rest_framework import serializers class PersonBussinessTripSerializer(serializers.Serializer): // How can I match employee_id between the two models to get my serializer? The problem makes me confused. Can it be easily achieved? -
QueryDict getlist returns empty list
I'm sending from frontend object with one property which equal to array. In backend I need to get data from that array. when i write request.POST i see: <QueryDict: {u'response[0][doc_id]': [u'14'], u'response[1][uuid]': [u'157fa2ae-802f-f851-94ba-353f746c9e0a'], u'response[1][doc_id]': [u'23'], u'response[1][data][read][user_ids][]': [u'9'], u'response[0][uuid]': [u'8a0b8806-4d51-2344-d236-bc50fb923f27'], u'response[0][data][read][user_ids][]': [u'9']}> But when i write request.POST.getlist('response') or request.POST.getlist('response[]') i get [] request.POST.get('response') doesn't work as well (returns None). What is wrong? -
FB.UI dialog is not appearing in the django application
I am trying this for the sharing of post on the facebook: <div id="shareBtn" class="btn btn-success clearfix">Share Dialog</div> <p>The Share Dialog enables you to share links to a person's profile without them having to use Facebook Login. <a href="https://developers.facebook.com/docs/sharing/reference/share-dialog">Read our Share Dialog guide</a> to learn more about how it works.</p> <script> document.getElementById('shareBtn').onclick = function() { FB.ui({ display: 'popup', method: 'share', href: 'https://developers.facebook.com/docs/', }, function(response){}); } </script> I want to know what is missing owing to which my application is not getting the sharing dialog. Here is the console error I found: (index):292 Uncaught ReferenceError: FB is not defined at HTMLDivElement.document.getElementById.onclick ((index):292) -
Error when running migrate command Django
I am trying to deploy my first web project on a server. I am getting this error when running migrate and makemigrations: ProgrammingError (1146, "Table '<user>$<dbname>.<table_name>'' doesn't exist") Everywhere it says that you should run manage.py syncdb but this is obsolete , also when running manage.py --run-syncdb the same error is given. models class Book(models.Model): name = models.CharField(max_length=350) author = models.CharField(max_length=350) category = models.CharField(max_length=200) def __str__(self): return self.name snipppets from settings DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': '<your_username>$<your_database_name>', 'USER': '<your_username>', 'PASSWORD': '<your_mysql_password>', 'HOST': '<your_mysql_hostname>', } } #Everything is replaced with the correct credentials INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'main_app', 'accounts', ] The DB is empty on the server. On my PC (when I developed it locally) it worked, it created the table for me when it didn't exist in the DB. I am using Django 1.11 and Mysql 5.6.27. I tried other answers but did not help me. Can you please suggests what can I do to solve this issue? -
How can I set required field only for specified function in Django GenericAPIView?
Let's assume that I have such a generic view: class UserObject(GenericAPIView): serializer_class = ObjectSerializer def post(self, request, user_id): serializer = ObjectPostSerializer(data=request.data) if serializer.is_valid(): serializer.save(user_id=user_id) return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) def get(self, request, user_id): try: object = Object.objects.filter(user=user_id) except Object.DoesNotExist: return Response(status=status.HTTP_404_NOT_FOUND) serializer = ObjectSerializer(object, many=True) return Response(serializer.data) In ObjectSerializer I have: def __init__(self, *args, **kwargs): super(ObjectSerializer, self).__init__(*args, **kwargs) for key in self.fields: self.fields['field'].required = True I would like to only for POST method set self.fields['field'].required = False Any ideas how can I do that? I tried in ObjectPostSerializer: def __init__(self, *args, **kwargs): super(ObjectSerializer, self).__init__(*args, **kwargs) for key in self.fields: self.fields['field'].required = False My model looks in this way: class Object(models.Model): name = models.CharField(max_length=200) user = models.ForeignKey('auth.User') field = models.FloatField() field2 = models.FloatField(null=True, blank=True) But this line serializer_class = ObjectSerializer is crucial and only settings from this serializer are visible for instance in Swagger. Any ideas how can I solve it? -
Server Error 500 when uploading image
I am trying to solve a problem with uploading images. I have set the error.log for Nginx to info. First when I'm trying to upload, I get 413 Request Entity Too Large. In error.log it says client intended to send too large body: 2524917 bytes, client: my.client.public.ip, server: my.server.public.ip, request: "POST /admin/part/part/7/change/ HTTP/1.1", host: "my.domain.se", referrer: "http://my.domain.se/admin/part/part/7/change/" So I add this line in my config for Nginx client_max_body_size 50M; and restart Nginx. When trying to upload again I get Server Error (500) with this line in error.log a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001, client: my.client.public.ip, server: my.server.public.ip, request: "POST /admin/part/part/7/change/ HTTP/1.1", host: "my.domain.se", referrer: "http://my.domain.se/admin/part/part/7/change/" Can't seem to find any answer when searching the internets. -
Method in Thread stop my UI - Python Django
I am trying to run some periodic (scheduler) method asynchronously, so that UI thread is not blocked. My current code is: class Job(): def run(self): thread = threading.Thread(target=self.run_inside_thread, args=[]) thread.setDaemon(True) thread.start() def run_inside_thread(self): schedule.every(self.tick).seconds.do(self.call_method) while True: if self.isRunning: schedule.run_pending() I use if self.isRunning:, so that I can stop and start the tasks. The problem is that this is blocking my UI (but only on server - on my local development machine UI is working) What I am doing wrong? By my understanding code should run async on another thread (not UI one). I see the "fix" that you put time.sleep(1), but this mean that I can't run method sunner then 1 second. If for example I do time.sleep(0.1) it doesn't work. (UI thread is blocked) -
test value in template
When i would like to test value in my template, i have the error: Could not parse the remainder '=="0" How can i test a value in template? {%for eb in ebau %} <tr class="ligne-{{forloop.counter}}"> <td id="cb-{{forloop.counter}}" class="cbox" > {% if eb.0=="0" %} <input type="checkbox" class="cb-{{forloop.counter}} " id="id-{{forloop.counter}}" checked="checked"/> {% else %} <input type="checkbox" class="cb-{{forloop.counter}} " id="id-{{forloop.counter}}" checked="checked"/> {% endif %} </td> <td class="case">{{eb.0}}</td> <td class="case">{{eb.2}}</td> <td class="case">{{eb.3}}</td> <td class="case">{{eb.4}}</td> </tr> {% endfor %} Thanks. -
in navicat for mysql, i'm try delete goods_goods table, but get error: cannot delete or update parent row: a foreign key constaint fails?
in my navicat for mysql, my 'goods_goods' table data repeat once, and i try to delete about 'goods' table, but when delete goods_goods table , i get error: cannot delete or update parent row: a foreign key constaint fails? apps/goods/models.py class Goods(models.Model): """ category = models.ForeignKey(GoodsCategory, verbose_name="商品类目") goods_sn = models.CharField(max_length=50, default="", verbose_name="商品唯一货号") name = models.CharField(max_length=100, verbose_name="商品名") click_num = models.IntegerField(default=0, verbose_name="点击数") sold_num = models.IntegerField(default=0, verbose_name="商品销售量") fav_num = models.IntegerField(default=0, verbose_name="收藏数") goods_num = models.IntegerField(default=0, verbose_name="库存数") market_price = models.FloatField(default=0, verbose_name="市场价格") shop_price = models.FloatField(default=0, verbose_name="本店价格") goods_brief = models.TextField(max_length=500, verbose_name="商品简短描述") goods_desc = UEditorField(verbose_name=u"内容", imagePath="goods/images/", width=1000, height=300, filePath="goods/files/", default='') ship_free = models.BooleanField(default=True, verbose_name="是否承担运费") goods_front_image = models.ImageField(upload_to="goods/images/", null=True, blank=True, verbose_name="封面图") is_new = models.BooleanField(default=False, verbose_name="是否新品") is_hot = models.BooleanField(default=False, verbose_name="是否热销") add_time = models.DateTimeField(default=datetime.now, verbose_name="添加时间") class Meta: verbose_name = '商品' verbose_name_plural = verbose_name def __str__(self): return self.name i want to delete about 'goods' data table, use 'makemigrations and mkgrate' regenerate about 'goods' data table, how to resolve this error, and delete 'goods_goods and goods_goodscategory'?thanks! -
Can't receive ipn signal from PayPal
I am try to receive ipn signal from PayPal after transaction, but for someone reason i can't get it. This is my form (I send to paypal using simple form html): <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="checkout_form_id"> <input type="hidden" name="business" value="mygmail@gmail.com" id="id_business"/> <input type="hidden" name="amount" value="" id="id_amount"/> <input type="hidden" name="item_name" value="Payment for victorywow.com" id="id_item_name"/> <input type="hidden" name="notify_url" value="{{ paypal_url }}/paypal/" id="id_notify_url"/> <input type="hidden" name="cancel_return" value={{ paypal_url }}?cancel_return= id="id_cancel_return"/> <input id="id_return_url" name="return" type="hidden" value="{{ paypal_url }}?success_return="/> <input type="hidden" name="invoice" value="" id="id_invoice"/> <input type="hidden" name="cmd" value="_xclick" id="id_cmd"/> <input type="hidden" name="charset" value="utf-8" id="id_charset"/> <input type="hidden" name="currency_code" value="USD" id="id_currency_code"/> <input type="hidden" name="no_shipping" value="1" id="id_no_shipping" /> <input type="button" class="form_button pay_pal_but" value="PAY NOW"> </form> Some variable such invoice_id,amount and so on I add by js. 'paypal_url' I create in views.py : request.build_absolute_uri(reverse('index')) (index is url like this'^$') urls.py: url(r'^paypal/', include('paypal.standard.ipn.urls')) signals.py: from paypal.standard.models import ST_PP_COMPLETED from paypal.standard.ipn.signals import valid_ipn_received from .models import Order def ipn_geter(sender, **kwargs): print(1000 * '*') ipn_obj = sender print(ipn_obj.receiver_email) order = Order.objects.get(id=28) order.email = ipn_obj.receiver_email order.save() if ipn_obj.payment_status == ST_PP_COMPLETED: pass valid_ipn_received.connect(ipn_geter) But after success paypal transaction ipn_geter does not execute. What should I do to fix it. Why i don't get ipn signals? -
Could I filter out the field which is not meet the condition?
I have a model, and it has a is_tracked field: class Track3(models.Model): track = models.ForeignKey(Track, related_name='track3s', on_delete=models.CASCADE) order = models.IntegerField() title = models.CharField(max_length=100) duration = models.IntegerField() is_tracked = models.BooleanField(default=True) When I create the Serializer of it: class Track3Serializer(serializers.ModelSerializer): class Meta: model = models.Track3 fields = ('order', 'title', 'duration') When I get the Track3Serializer instance, it will get all the Track3s. May I ask a question, could I filter out the is_tracked=False? how to do with that? -
Postman gets csrf cookie from django api but I get Forbidden 403 - CSRF token missing or incorrect
I'm using django rest-framework api for user registration. This my curl command is: curl -i -H 'Accept: application/json; indent=4' -H 'referer:https://domain' -X POST https://domain/users/:register/ -d "id=222111&firstname=zinonas&yearofbirth=2007&lastname=Antoniou&othernames=" When I try it from cygwin is working properly. This is the output: HTTP/1.1 200 OK Date: Thu, 26 Oct 2017 08:35:40 GMT Server: Apache/2.4.18 (Ubuntu) Allow: POST, OPTIONS Referer: https://domain/ Content-Length: 188 X-Frame-Options: SAMEORIGIN Vary: Accept,Cookie X-CSRFToken: MLJKNmBdYdF02ANX7pvZ7UavOVXtuPdW34vcF0RuLy94c1mQrL6blzkLMHCAFYkP Set-Cookie: csrftoken=sFkh2JjHxma3qnGpcRiOkQmH0xs9txqIJY6JUnzYkHE7AOfiwdT0yvwXYj7gEGxB; expires=Thu, 25-Oct-2018 08:35:40 GMT; Max-Age=31449600; Path=/ Content-Type: application/json { "isnew": "false", "user": { "firstname": "zinonas", "id": "222111", "lastnames": "Antoniou", "yearofbirth": 2007, "othernames": "" } } When I try the curl command in postman I get forbidden 403 error - CSRF token missing or incorrect. I have enabled postman interceptop and I set Referer header equal to https://domain. However I get the csrf cookie as can be seen in the image below: -
Structured data in Django
Django 1.11.6 Could you tell me what is the Django way of implementing structured data. I have an information site. And I may need any type of structured data: either present or appearing in future. I mean this: https://developers.google.com/search/docs/guides/intro-structured-data I append articles through admin only. In other words users don't generate articles, they just comment. Structured data may be a big insertion to a page. Even in the above linked page an example is trimmed for brevity. And there may be more content types in future. So, maybe it is not reasonable to burden models with such information. I can only think of a safe template tag. In the middle of articles structured data will be inserted, say, as a JSON-LD structured data. Could you tell me what are best practices here. -
Custom analyzer with edgeNgram filter doesn't work
I needed partial search in my website.Initially I used edgeNgramFeild directly it didn't work as expected.So I used custom search engine with custom analyzers.I am using Django-haystack. 'settings': { "analysis": { "analyzer": { "ngram_analyzer": { "type": "custom", "tokenizer": "lowercase", "filter": ["haystack_ngram"] }, "edgengram_analyzer": { "type": "custom", "tokenizer": "lowercase", "filter": ["haystack_edgengram"] }, "suggest_analyzer": { "type":"custom", "tokenizer":"standard", "filter":[ "standard", "lowercase", "asciifolding" ] }, }, "tokenizer": { "haystack_ngram_tokenizer": { "type": "nGram", "min_gram": 3, "max_gram": 15, }, "haystack_edgengram_tokenizer": { "type": "edgeNGram", "min_gram": 2, "max_gram": 15, "side": "front" } }, "filter": { "haystack_ngram": { "type": "nGram", "min_gram": 3, "max_gram": 15 }, "haystack_edgengram": { "type": "edgeNGram", "min_gram": 2, "max_gram": 15 } } } } Used edgengram_analyzer for indexing and suggest_analyzer for search. This worked for some extent.But,it doesn't work for numbers for example when 30 is entered it doesn't search for 303 and also with words containing alphabet and numbers combined. so I searched for various sites. They suggestsed to use standard or whitespace tokenizer and with haystack_edgengram filter.But it didn't work at all,puting aside number partial search didn't work even for alphabet.The settings after the suggestion: 'settings': { "analysis": { "analyzer": { "ngram_analyzer": { "type": "custom", "tokenizer": "lowercase", "filter": ["haystack_ngram"] }, "edgengram_analyzer": { "type": "custom", … -
Webpage is scrollable when i want it to be a fixed size - django
I am working on django template and I am integrating bootstrap into the html tempates for the project. Every template page is scrollable even though the content does not fill the page. I want all the webpages to be unscollable and set the default heigh of the div that contains to the content to be 100 percent of the screen. I baiscally want to eliminate the scrollablility of the page and set the fixed high to the size of the window that is open. Can anyone help me. Here is the webpage and the custom css that I added to the bootstrap columns: <div class="col content-max-height"> {% block content %} {% endblock %} </div> {% extends "header.html" %} {% block content %} <h2 class="page-header">{{ group.group.name }}</h2> <div class="scrollable-view"> {% for activity in activities %} {% if activity.user == currentUser %} {% if activity.general == 2 %} <p>{{ activity.description }}</p> {% endif %} {% endif %} {% if activity.user != currentUser %} {% if activity.general == 1 %} <p>{{ activity.description }}</p> {% endif %} {% endif %} {% endfor %} </div> {% if currentUser == host.user %} <a href="{% url 'add_expense' host.group.id %}">Add New Expense</a> {% endif %} {% endblock %} … -
Having hard time deploying Django + PostGis on AWS Beanstalk (DatabaseOperations error)
I’m having troubles making Django + PostGIS work on AWS BeanStalk. The app runs, some parts of the app work properly, but when trying to access object with GeoDjango fields (PointField) I get this error: Attribute Error 'DatabaseOperations' object has no attribute 'select' /opt/python/run/venv/lib/python3.4/site-packages/django/contrib/gis/db/models/fields.py in select_format, line 61 I have googled this error, and very few people encountered it. The closest error I could find is: Getting 'DatabaseOperations' object has no attribute 'geo_db_type' error when doing a syncdb But my databases is configured correctly in the Django Settings Module as follows: DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.postgis', 'NAME': os.environ['RDS_DB_NAME'], 'USER': os.environ['RDS_USERNAME'], 'PASSWORD': os.environ['RDS_PASSWORD'], 'HOST': os.environ['RDS_HOSTNAME'], 'PORT': os.environ['RDS_PORT'], } } I’m using Django 1.9.5 with PostGis 2.3.0 and PostgreSQL 9.5.2 I’m using a custom AMI based on 2017.03 that I made using this script: https://gist.github.com/nitrag/932ecd7d109f9d1e3ed378353e0d5c2f PostGis is installing properly on the EC2 instance, I even tried another script and got the same final error. (http://www.daveoncode.com/2014/02/18/creating-custom-ami-with-postgis-and-its-dependencies-to-deploy-django-geodjango-amazon-elastic-beanstalk/) I am really on my last legs here, any help will be greatly appreciated! -
django filter list tag__in with "and" operator
I have a list for tags [11,12,13 14] When I try to filter my items using tag Model.objects.filter(title__contains=title,tag__in=[11,12],listType=listtype,status=1).all() Its showing both item having tag 11 and 12. Than means, it was taking "OR" operation. How can I get the Item list contain both tags 11 and 12. anyone please help