Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Why PDFkit Generate PDF which is not same as my HTML page?
I wrote a view for making an HTML page to a PDF. def public_profile_pdf_view(request, slug): template = get_template('public_profile_pdf.html') queryset = Professional.objects.filter( slug=slug ) html = template.render({'data': queryset}) options = { 'page-size': 'Letter', 'encoding': "UTF-8", "enable-local-file-access": None, } pdf = pdfkit.from_string(html, False, options=options) response = HttpResponse(pdf, content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="person.pdf"' return response And The Page Screen Shot I want to Convert into PDF: See the Original Image: Click Here After Downloading the PDF it shows different than the Orginal. See This: After Converted to PDF Any Experts Here!!! -
Django project doesn't work when setting project root url to not "/"
I had a Django project (using Django, uwsgi and Nginx to deploy it) on a linux server that works well when I'm setting the project root url in Nginx as location / { uwsgi_pass django; include /path/to/project/uwsgi_params; } So the project can be accessed using url like: www.mysite.com However, I'm planing build more web projects on this server, and want to visit them using different urls like: www.mysite.com/oldproject www.mysite.com/project2``` So I changed my now existing project's Nginx conf file as: location /oldproject { uwsgi_pass django; include /path/to/project/uwsgi_params; } however, when I visit the old project using www.mysite.com/oldproject I get feed back like: Not Found. cant get resource on the server I'm pretty sure that the Nginx is working well with uwsgi because I did some simple test, so, what is going wrong? The full configuration is shown below: Nginx conf: # mysite_nginx.conf # the upstream component nginx needs to connect to upstream django { server unix:///web/welib/welib.sock; # for a file socket } # configuration of the server server { listen 443 ssl; ssl_certificate /etc/nginx/certif/1_www.xxxxxxx.crt; ssl_certificate_key /etc/nginx/certif/2_www.xxxxx.key; ssl_session_timeout 5m; ssl_ciphers ECDHE8-GCM-SHA256:ES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste #log config … -
Django xlsx format using xlsxwriter
I am using xlsxwriter in Django to export xlsx format when ever the user click on button, it do export the xlsx format but untidy in excel sheet. I am using Django==1.9.5 and XlsxWriter==1.1.8 Django CODE in views.py: def export_student(request): students=Student.objects.all() filename = "student_list.xlsx" workbook = xlsxwriter.Workbook(filename) row = 3 worksheet = workbook.add_worksheet() worksheet.set_column('A:A', 6) worksheet.set_column('B:B', 12) worksheet.set_column('C:E', 15) worksheet.set_column('F:F', 25) worksheet.set_column('G:G', 70) worksheet.set_column('H:H', 25) worksheet.set_column('I:I', 12) worksheet.set_column('J:J', 25) worksheet.set_column('K:K', 12) worksheet.set_column('L:L', 25) worksheet.set_column('M:M', 77) maintitlecell = workbook.add_format({ 'bold': 1, 'border': 1, 'align': 'center', 'valign': 'vcenter', 'font_color':'red', 'font_size':18}) titlecell = workbook.add_format({ 'bold': 1, 'border': 1, 'align': 'center', 'font_size':12, 'valign': 'vcenter'}) datacell = workbook.add_format({ 'border': 1, 'align': 'left', 'font_size':10, 'valign': 'vcenter'}) worksheet.merge_range('A1:M1', "Student List", maintitlecell) worksheet.write("A2", "Count", titlecell) worksheet.write("B2", "Student NO", titlecell) worksheet.write("C2", 'Name', titlecell) worksheet.write("D2", 'Surname', titlecell) worksheet.write("E2", 'Gender', titlecell) worksheet.write("F2", 'Birthdate', titlecell) worksheet.write("G2", 'Previous School', titlecell) worksheet.write("H2", 'Birthplace', titlecell) worksheet.write("I2", 'Annul Fee', titlecell) worksheet.write("J2", 'Nationality', titlecell) worksheet.write("K2", 'Id No', titlecell) worksheet.write("L2", 'Blood Type', titlecell) worksheet.write("M2", 'Address', titlecell) for student in students: worksheet.write('A'+str(row) , row-2,centerdatacell) worksheet.write('B'+str(row) , student.id_no,datacell) worksheet.write('C'+str(row) , student.name,datacell) worksheet.write('D'+str(row) , student.surname,datacell) worksheet.write('E'+str(row) , student.guardian_type,datacell) worksheet.write('F'+str(row) , student.birthdate,datacell) worksheet.write('G'+str(row) , student.previous_school,datacell) worksheet.write('H'+str(row) , student.birthplace,datacell) worksheet.write('I'+str(row) , student.annual_fee,datacell) worksheet.write('J'+str(row) , student.nationality,datacell) worksheet.write('K'+str(row) , student.id_no,datacell) worksheet.write('L'+str(row) , student.blood_type,datacell) worksheet.write('M'+str(row) , … -
Django admin action to copy queryset to another model
I have two models in a Django app. For ease, let's call them MainModel and DraftModel. These are similar (not same) models and former is more like a subset of the latter model, intentionally kept that way in order to keep the MainModel clean and verified for live. Once the admin manually verifies entries in DraftModel, is there a way we can have the admin select entries to be transitioned to MainModel, and click on an admin action like: def transition_selected(self, request, queryset): #do some updates queryset.update(status='TRANSITIONED') #get these entries duplicated to MainModel #WHAT SHOULD BE THE LOGIC HERE? transition_selected.short_description = "Transition selected into MainModel" -
Django - check cookies's "SameSite" attribute
In my Django application, I want to check if a specific cookies has "SameSite=None" or not. I'm using this code to read the value of the cookies, cookiesid = request.COOKIES["cookiesid"] However, I don't know how to check "SameSite" attribute, seems there is no method to check it by request.COOKIES[""] How can I check it? I'm using Python 3.6.9 and Django 3.1 -
My django_email_verification app is not working on my linux server
So I tested the code out on a localhost and it worked perfectly fine and I even received emails to verify accounts. Now when I git pulled and pushed to the server it keeps giving me a error every time I try to delete a user account or I do not get an email verification when I signup. I've checked my pip and the same libs are install but for some reason the linux server is giving me this error. How do I fix this? If there is any other code or errors you need please let me know and I will show you. -
DRF custom check_permission not being called
I'm trying to add a custom permission to a view which extends a generic DetailView: from django.views.generic import DetailView from rest_framework.permissions import BasePermission class MyCustomPermission(BasePermission): def has_permission(self, request, view): return False class MyView(SomeMixin, DetailView): model = MyObject template_name = "my_template.html" permission_classes = [MyCustomPermission] def get_object(self): return MyObject.objects.get(id=123) This should always fail, but it doesn't. I can also put a breakpoint in there (e.g. import pudb; pudb.set_trace()) but that won't ever get hit either. I know that has_object_permission(...) needs to be explicitely called, but I thought has_permission(...) got called when the view first got called. -
How to generate a drill down data from highcharts table?
I am new to front end development and using django to build a dashboard. I am leveraging high charts library for data visualization. I want to create a click event table with drill down data of point triggered. I want to send the click point details back to my views and trigger the view function (with view points as variables) to generate the table in a new page. Please suggest what functionalities can i use to achieve this? Is there any other way to achieve this? Eg. If user clicks on first bar, he should be directed to a new webpage which will have detailed tabular data fetched from database of Q1 2019. Check the jsfiddle example: https://jsfiddle.net/VM001/90jpvdw3/2/ point:{ events:{ click: function () { location.href ="clickTable"; alert('Category:'+this.category+',values:'+this.y) alert(this.options.name) } } } -
get return the blank value of src width height in iframe
**views.py** def add(request): report_list = {} if request.method == "POST": src =request.POST['src'] width=request.POST['width'] height=request.POST['height'] name=request.POST['name'] #context = {'report_list': report_list} report_list={'src':src, 'width':width, 'height':height, 'name':name} return render(request, 'report_one.html', report_list) else: src=request.GET.get('src', '') width=request.GET.get('width','') height=request.GET.get('height','') name=request.GET.get('name', '') #report_list={'src':src, 'width':width, 'height':height, 'name':name} #report_list={'src':request.POST['src'], 'width':request.POST['width'], 'height':request.POST['height'], 'name':request.POST['name']} return render(request, 'report_two.html', report_list ) if part getting the value of src, width ,name of report, and height from the user and then created report name should shown in the dropdown. When user click on the report name the created report will display on the screen and i think this part is handle by else ...but the problem is that i got the blank page else part giving blank value of iframe src, width,height -
Django Admin not working on my custom user model and i can't even update users
here is my custom user model class User(AbstractUser): friends = models.ManyToManyField('User', blank=True) bio = models.CharField( max_length=400, default='I love this website!', blank=True, null=True,) avatar = models.ImageField( upload_to='profile_images', default='profile_images/DefaultUserImage.jpg',) is_online = models.BooleanField(default=False) # PRIVACY show_email = models.BooleanField(default=False) who_see_avatar_choices = [ ('none', 'No One'), ('friends', 'Friends only *Beta*'), ('everyone', 'Every One'), ] ... when i went to django admin i didn't find my new fields, so i had to cancel The default django user admin (WHICH WILL CAUSE A LOT OF PROBLEMS LATER) here is my admin.py from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth import get_user_model as user_model User = user_model() admin.site.register(User) I didn't face any issues when I was on my local machine, but when I went to production I found out that I can't even update users nor see their passwords, their hashed password is turned into bunch of dots......... I don't mind that, but Django does! whenever I save changes it tells me that the password can't be empty as shown in the image below If I were able to extend the Django default user model to include my new fields the problem would be fixed ( i guess ) and to make things even worse, in … -
"NoReverseMatch" when in button that refers to a page with parameter in the url
I have this error: "NoReverseMatch at /home/2/ Reverse for 'calendar_new' with arguments '('',)' not found. 1 pattern(s) tried: ['home/(?P<group_id>\d+)/calendar/new/$']" in a button. In the ulr I have a "group_id" parameter which I need to use as a filter parameter. I don't understand what's wrong, because if I write the path manually in the url I don't have any problem and it opens the page correctly. "group_id" is already a parameter present in the url. In calendar.html: <div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column"> <main class="inner cove border" role="main" style="background-color: white;"> <h1 class="cover-heading mt-3">Lista Calendari di {{ nome }}</h1> <div class="mt-5"> <ul class="list-group"> {% for calendar in object_list %} <a href="{{ calendar.id }}"><li class="list-group-item list-group-item-action">{{ calendar.name }}</li></a> {% empty %} <li class="list-group-item">Non ci sono calendari disponibili per questo edificio</li> {% endfor %} </ul> </div> </main> <!-- NUOVO CALENDARIO --> <a class="btn btn-primary btn-lg active mt-5 mb-5" href="{% url 'cal:calendar_new'%}">Aggiungi Calendario</a> </div> In urls.py: url(r'^home/(?P<group_id>\d+)/$', views.CalendarsOfGroupView.as_view(), name='group_view'), url(r'^home/(?P<group_id>\d+)/calendar/new/$', views.calendar, name='calendar_new'), -
Issue deploying django app on Heroku - Issue with pyobjc-framework-AddressBook
I'm trying this command git push heroku master, it is going through my requirements.txt entirely but then gets stuck on this : Collecting pyobjc-framework-AddressBook==6.2.2 remote: Downloading pyobjc-framework-AddressBook-6.2.2.tar.gz (76 kB) remote: ERROR: Command errored out with exit status 1: remote: command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_i44fimz/pyobjc-framework-AddressBook/setup.py'"'"'; file='"'"'/tmp/pip-install-_i44fimz/pyobjc-framework-AddressBook/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-jbmvd3ua remote: cwd: /tmp/pip-install-_i44fimz/pyobjc-framework-AddressBook/ remote: Complete output (15 lines): remote: Traceback (most recent call last): remote: File "", line 1, in remote: File "/tmp/pip-install-_i44fimz/pyobjc-framework-AddressBook/setup.py", line 30, in remote: for fn in os.listdir("Modules") remote: File "/tmp/pip-install-_i44fimz/pyobjc-framework-AddressBook/pyobjc_setup.py", line 429, in Extension remote: universal_newlines=True, remote: File "/app/.heroku/python/lib/python3.6/subprocess.py", line 356, in check_output remote: **kwargs).stdout remote: File "/app/.heroku/python/lib/python3.6/subprocess.py", line 423, in run remote: with Popen(*popenargs, **kwargs) as process: remote: File "/app/.heroku/python/lib/python3.6/subprocess.py", line 729, in init remote: restore_signals, start_new_session) remote: File "/app/.heroku/python/lib/python3.6/subprocess.py", line 1364, in _execute_child remote: raise child_exception_type(errno_num, err_msg, err_filename) remote: FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/xcrun': '/usr/bin/xcrun' remote: ---------------------------------------- remote: ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. I kind of understood that pyobjc is for Mac and that Heroku is using Linux. But I don't know how to deal with that because there … -
Django. Populate user name or ID when user saving a model from web pages
Help please!!! I have model "UserImg" with field "user" that editable=False. I don't want to show this field, but I want it to be automatically filled in with the user name when the user is saved from web page. Thank you in advance model.py def upload_myimg_path(instance, filename): return 'documents/{0}/{1}'.format(instance.created_by.username, filename) class UserImg(models.Model): user = models.ForeignKey(User, verbose_name=_('Created by'), on_delete=models.CASCADE, editable=False, null=True, blank=True) name = models.CharField(max_length=100, default='') image = models.ImageField(upload_to=upload_myimg_path, verbose_name=_('File')) def __str__(self): return str(self.user) forms.py class UserImgForm(forms.ModelForm): class Meta: model = UserImg fields = '__all__' views.py def createuserimg(request): if request.method == 'POST': form = UserImgForm(request.POST or None) if form.is_valid(): form.save() return redirect('/accounts/users') else: return redirect('/accounts/') else: form = UserImgForm return render(request, 'accounts/user_form.html', {'form': form}) -
Is there a way to store form layout in order to generate form dynamically in django mvt?
I'm working on a pretty large Django project, which has over 60 different forms layout (can be more than this when needed). I pretty confuse that how can I build all such forms manually??. I've came up with an idea is that I'm gonna store form layout in database and with every new forms, I just need to config in database and then using crispy layout to dynamically generate those forms... Do you guys have any better ideas? Thanks -
NameError: name 'mymodel' is not defined
I have deployed my Django project for test on a remote server and got an error I don't have locally and I don't understand the error generally, this kind of error means the models has not been imported but this is not the case: line 3, models Pays is imported morevover, trace error indicated a line that don't seems to match the error: Exception Location: /home/test/intensetbm_app/intensetbm-etool/randomization/forms.py in clean_ran_num, line 93 /home/test/intensetbm_app/intensetbm-etool/randomization/forms.py in clean_ran_num if int(data) == 0: but line 93 is not in clean_ran_num but in clean_ran_cri forms.py from django import forms from .models import Randomisation, patient_code_is_valid from parameters.models import Pays import datetime import time from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django.core.exceptions import ValidationError from parameters.models import Thesaurus from django.conf import settings class RandomisationForm(forms.ModelForm): # surcharge méthode constructeur (__init__) pour avoir accès aux variables de sessions # https://stackoverflow.com/questions/3778148/django-form-validation-including-the-use-of-session-data def __init__(self, request, *args, **kwargs): super(RandomisationForm, self).__init__(*args, **kwargs) self.request = request self.language = request.session.get('language') TYPES = Thesaurus.options_list(6,self.language) YESNO = Thesaurus.options_list(1,self.language) TB = Thesaurus.options_list(9,self.language) SEVERITY = Thesaurus.options_list(8,self.language) HIV = Thesaurus.options_list(4,self.language) self.fields["ran_dat"] = forms.DateField( label = _("Date of randomization"), initial = timezone.now(), required = True, ) # empêche l'autocomplétion self.fields['ran_dat'].widget.attrs.update({ 'autocomplete': 'off' }) self.fields["ran_num"] = forms.CharField(label = _("Patient number"), … -
Django : Filtering Post by user + UserProfile data
I Hope you're well. I got an error : name 'username' is not defined I'd like to have a public page with the user slug. Ex. profile/louis/ Louis's Post + Louis's UserProfileData I'm beginning with Django, so I made some mistake. nutriscore/models.py class Post(models.Model): author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='blog_posts') user/models.py class UserProfile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL,on_delete=models.CASCADE) user/views.py #public profile @login_required(login_url='/earlycooker/login') def userpublicpostview(request, slug): template = 'user_public_profile.html' user = User.objects.filter(username).values() user_id = user[0]['id'] userprofile = UserProfile.objects.filter(user_id=userprofile).values() user_post = Post.objects.filter(author = user_id, slug=slug) return render(request, template, {'user_posts':user_posts,'userpublic': userpublic}) user/urls.py path('profile/<slug:slug>/', userpublicpostview,name="user_public_cookwall"), -
Django: How to go about loading multiple images from multiple objects on same render in html
I have been searching and came across this (Multiple images per Model) which explains how to get all the images for a specific object but how would I load multiple images for a list of 2,000+ objects - I know I could loop and grab all the objects from each image but then how would I display the correct images with the correct objects in the html? While writing this, I was wondering if this is a good use for template_tags but I am extremely new to them. Working with these basic cut down models as an example. class Auction(models.Model): auction_title = models.CharField(max_length=255, null=True) class Listing(models.Model): auction_id = models.ForeignKey(Auction, on_delete=models.CASCADE) title = models.CharField(max_length=255) class ListingImage(models.Model): listing_id = models.ForeignKey(Listing, on_delete=models.CASCADE, related_name='images') image = models.ImageField() view example to run off of, expecting anything up to thousands of items returned. listings = Listing.objects.filter(time_ending__gte=datetime.now()).order_by('time_starting') so with that example view above how would I go about grabbing each image for each of those listings and then more of an issue was finding the way to display those in html in loops or in any order or specifically chosen. Thank you so much for your help! -
How to integrate django and RASA
i have a problem in connecting both django webpages and rasa bot The output i looking for when the user ask the questions through the django webpage and the reply need to on the webpage by using the rasa The output now getting was "i can't understand what you are saying" which was from my Javascript for the webpage. -
django schedule job to loop through ticker list
I have the following list of tickers and I want to schedule a job to run every 30 seconds using Django Q. I am open to solutions other than Django Q, but that is preferred as in the future I'll have more complicated tasks to complete. ["AAPL", "AMZN", "GOOG"] this is the current code that I have. how would I loop the tickers through the prep_yahoo_financials() function and run it every 30 seconds ? def prep_yahoo_financials(ticker): financials = get_yahoo_financials(ticker) financials = parse_yahoo_financials(financials) payload = prep_yahoo_payload(ticker=ticker, financial_dictionary=financials) return payload Schedule.objects.create( func=prep_yahoo_financials seconds=30 repeats=-1 ) -
Django loops on /password-reset-confirm/ . Why?
It was created in 2-nd version of django, I am trying it under 3.0.6. What changes has been done that can affect this authentication views/routes? Django sends email but after following link shows page password-reset-confirm with button and does not follow to password-reset-complete after clicking on button but returns to the same page indefinitely. urlpatterns = [ path('admin/', admin.site.urls), path('register/', users_views.register, name="register"), path('profile/', users_views.profile, name="profile"), path('login/', auth_views.LoginView.as_view(template_name="users/login.html"), name="login"), path('logout/', auth_views.LogoutView.as_view(template_name="users/logout.html"), name="logout"), path('password-reset/', auth_views.PasswordResetView.as_view(template_name="users/password_reset.html"), name="password_reset"), path('password-reset/done/', auth_views.PasswordResetDoneView.as_view(template_name="users/password_reset_done.html"), name="password_reset_done"), path('password-reset-confirm/<uidb64>/<token>', auth_views.PasswordResetConfirmView.as_view(template_name="users/password_reset_confirm.html"), name="password_reset_confirm"), path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(template_name="users/password_reset_complete.html"), name="password_reset_complete"), path('', include("blog.urls")), ] template {% extends "blog/base.html" %} {% load crispy_forms_tags %} {% block content %} <div class="content-section"> <form method="POST"> {% csrf_token %} <fieldset class="form-group"> <legend class="border-bottom mb-4">Reset Password</legend> {{ form|crispy }} <!-- {{ form.as_p }} --> </fieldset> <div class="form-group"> <button class='btn btn-outline-info' type='Submit'>Reset Password</button> </div> </form> </div> {% endblock content %} -
Connecting Amazon S3 to existing Django project
There is a need to introduce external storage for media files uploaded by users in Django project. This is why I consider using Amazon S3. The problem is that I am not sure how to manage already existing files. Did anyone have the experience of connecting existing Django project and relocating media storage + already uploaded files onto Amazon S3? What are the possible caveats? -
Django ORM many to many filter by authors and the count of books
I'm using Django 2.2 I have two tables with the Many-to-Many relation class Book(models.Model): title = models.CharField(max_length=50) authors = models.ManyToManyField(Author) class Author(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) I have a list of authors first_name author_names = ['john', 'parker', 'donald'] How can I get the count of books each author have? -
Django signal to convert video is running even if I update other fields without updating the video file field. Is there a way to change that?
Hey guys I am facing a problem with the signal to convert videos running everytime I update other fields in the video model. Is is possible to change this problem. I want the video processing to run only when I upload the video file field and not any other. This is the signal. @receiver(post_save, sender=VideoPost) def convert_video(sender, instance, **kwargs): enqueue(tasks.convert_all_videos, instance._meta.app_label, instance._meta.model_name, instance.pk) print('Done converting!') please do let me know if more information is needed. Thank you! -
How can I get choice value in views.py from User model in Django?
In my User model, I have a charfield for choice (Teacher and Student). I want to check if that charfield is Teacher or Student in views.py. How can I do that? models.py class User(AbstractUser): class Types(models.TextChoices): TEACHER = "TEACHER", "Teacher" STUDENT = "STUDENT", "Student" type = models.CharField( _('Type'), max_length=50, choices=Types.choices ) in my views.py def registerView(request): if request.user.profile.type == "TEACHER": # do something else: # do something I know my views.py is not correct but I want to do something like that. -
How to multiply 2 columns in Django ORM
I have a MySQL table recording invoice line entries. I would like to multiply the unit_price and quantity to obtain the sub_total(multiple Line Entries). Here is how my line_entries_table looks like invoice_id| unit_price| quantity 14646 | 521.2900 | 1.9000 14646 | 200.9900 | 1.5900 14646 | 260.0700 | 1.5800 14646 | 375.1700 | 1.7100 14646 | 496.4300 | 1.8800 14646 | 164.3100 | 1.6100 14646 | 279.2200 | 1.6400 14646 | 343.0100 | 1.7200 -------------------------- 25728 | 326.3400 | 1.5300 25728 | 521.2900 | 1.9000 25728 | 200.9900 | 1.5900 25728 | 260.0700 | 1.5800 25728 | 375.1700 | 1.7100 25728 | 496.4300 | 1.8800 25728 | 164.3100 | 1.6100 25728 | 279.2200 | 1.6400 25728 | 343.0100 | 1.7200 25728 | 326.3400 | 1.5300 Result: invoice_id| sub_total 14646 | 5107.5021 25728 | 2698.8797 I would like to obtain the sub_total of all the invoices at once. Here is the MySQL command which works in my case: select invoice_id, SUM(unit_price*quantity) AS sub_total from details_invoice_service_details WHERE invoice_id IN (14646 ,25728) GROUP BY invoice_id Any idea how to accomplish this in Django: Here is the part of the code, I tried: rows = invoice.models.InvoiceLineEntries_Model.objects.filter(invoice_id__in=invoice_ids)