Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django slice filter breaks template for tinymce safe content
I have contents which were published using tinymce editor. Now, I want to show my content, that's why I have to use safe filter. But, whenever I'm trying to use slice or truncate filter, the template breaks. this is my HTML code. {% extends 'blog/frontend/layouts/base.html' %} {% block content %} <div class="card border-primary"> {% for post in posts %} <div class="card my-2 mx-1"> <div class="card-body"> <h5 class="card-title"><a href="{% url 'post-detail' post.permalink %}" class="text-primary">{{ post.title }}</a></h5> <hr> <img src="{{ post.image.url }}" alt="Card image" width="85%" class="mx-auto d-block"> <p class="card-text mt-1"> {{ post.content|truncatewords:50|safe}} </p> <hr> <div class="d-flex"> <div class="px-2 py-0 my-auto"> <h6><i class="fas fa-user-edit"></i>&nbsp;<a href="#">{{ post.author.username }}</a></h6> </div> <div class="px-2 py-0 my-auto"> <h6>Date posted: <span class="text-info">{{ post.date_posted|date:"d M, Y" }}</span></h6> </div> <div class="ml-auto px-2 my-auto "> <a href="{% url 'post-detail' post.permalink %}" class="btn btn-primary">Read more</a> </div> </div> </div> </div> {% endfor %} </div> {% endblock content %} These are the image, first one without sliceor turncate filter, 2nd and 3rd one are with them. -
Making a topic public to all users in Django
I've got a project where users can enter topics and have the option to make the topic public or private. I want all public topics to be visible to everyone, and private topics to only be visible by the owner of that topic (Project is from Python Crash Course exercise 20-5). I'm not getting any errors when I click through my project, but when I create a new topic and select the "public" option, it is still not showing up for public viewing. I've researched similar problems and followed all the suggestions here How to make a topic public to all users in django? and here Django - How to make the topics, that you create public? Learning Log Project with no luck. I'm guessing my queryset is not rendering data correctly? I've read the Django documentation on querysets as well, but nothing I've tried has worked. I'm really new to programming so any help would be appreciated. Thank you! Here's my models.py: from django.db import models from django.contrib.auth.models import User # Create your models here. class Topic(models.Model): """A topic the user is learning about""" text = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) owner = models.ForeignKey(User, on_delete=models.CASCADE) public = models.BooleanField(default=False) def __str__(self): … -
Build a complicated Django query for SQLite or MySQL
I have a Django application with a database. Currently in SQLite, which will be earlier or later transferred to MySQL This table contains approx. 100.000 records of competition product names. class CrossRefTable(models.Model): all_bez = models.CharField('All Bezeichnung', max_length=30, default="", unique=True, blank=True, null=True) uid_nr_f = models.ForeignKey(UidTable, on_delete=models.CASCADE, related_name='uid_nr' This table contains 10.000 records with replacement products for products from CrossRefTable class xx_Table(models.Model): xx_idnr = models.CharField('xx Id.Nr', max_length=10, default="", blank=True ) xx_bez = models.CharField('XX Bezeichnung', max_length=30, default="", unique=True) pgroup_f = models.ForeignKey(product_group, on_delete=models.PROTECT, related_name='P_Group_XX', \ verbose_name='Product Group_FG', default="", blank=True, null=True) uid_nr_f = models.ForeignKey(UidTable, on_delete=models.PROTECT, related_name='Uid_F', verbose_name='Uid_F', default="", blank=True, null=True) price = models.DecimalField('List Price', max_digits=8, decimal_places=2, default=0, blank=True, null=True) This table is used as a connecting table of foreign keys for CrossRefTable and xx_Table. Contains approx. 8.000 records. class UidTable(models.Model): uid_nr_1= models.IntegerField('uid_nr_1', default=0, null=True, unique=True) uid_bez = models.CharField('Uid Bezeichnung', max_length=30, default="", unique=True, null=True,) This table contains discount rate for different product groups in xx_table. class product_group(models.Model): value = models.CharField('Product Code: ', max_length=15, default="") cust_price = models.DecimalField('Customer d.factor: ', max_digits=5, decimal_places=2, default=0, blank=True, null=True) I need to build a query, which connects all four tables as follows: THe customer chooses a product from CrossRefTable, e.g. all_bez = "ABCDEFG" It must be connected via foreign field to … -
Django/Wagtail - Custom form widget CSS/JS not being rendered with template file
I have a base Address model with a formatted_address field, which uses a custom LocationPicker widget (essentially an autocomplete for searching addresses). A couple of classes inherit from Address, including my Place class below. models.py class Address(models.Model): formatted_address = models.CharField(max_length=500, verbose_name='address') ... class Place(ClusterableModel, Address) ... panels = [ MultiFieldPanel([ FieldPanel('formatted_address, widget=LocationPicker(), FieldPanel('some_other_field') ], heading='My field group') widgets.py class LocationPicker(WidgetWithScript, TextInput): template_name = 'places/forms/widgets/location_picker.html' @property def media(self): print('get media') return Media( css={'screen': ('places/css/location-picker.css',)}, js=('places/js/location-picker.js',), ) This widget appears fine in the Wagtail admin, where I have registered a ModelAdmin instance for it. However, the problem I have is that I cannot get the widget to appear properly in my vanilla Django ModelForm. The widget template file is rendered, but the associated media is not included. I have created the form as follows: forms.py class PlaceForm(ModelForm): class Meta: model = Place fields = '__all__' widgets = { 'formatted_address': LocationPicker() } No matter what I've tried, the widget's media is not included when the form is rendered. The 'get media' printout doesn't even appear. I'm certain this can be done but I don't know what obvious thing I'm missing here. -
Django , need to set default value to a models field by calling a method . Th
Model X(Models.Model): Somefield=models.Charfield(..., default=SomeMethode} def SomeMethode(self): var= X.objects.filter() ... Problem is order issue! I got either function undefined or Model undefined if I declare the method outside-befor the model . I am stuck. Any help would be so nice. -
Http to Https Redirect in htaccess when FCGI Deployment (django)
I have deployed django project using fcgi. this is my .htaccess file <IfModule mod_fcgid.c> AddHandler fcgid-script .fcgi <Files ~ (\.fcgi)> SetHandler fcgid-script Options +FollowSymLinks +ExecCGI </Files> </IfModule> <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L] </IfModule> I received SSL and I don't know how to do redirect http to https. I tried but getting too many redirect errors. help me to write redirect. thanks in advance. -
Serializer method field takes too many queries
I have an Assignment module Model . Im using a serializer method field to display the submitted count and to grade count . For an assignment to be submitted , it should have another table entry and a boolean of that table will be set to true .Im using a Model Serializer and the serializer method field takes too much time to return the result . I need help to optimize the query. My serializer method field: def __submitted_count(self, instance): user = self.context["request"].user assigned_course_share_items = instance.course_share_item.all() assigned_courses = Course.objects.filter( course_share_item__in=assigned_course_share_items, tenant=user.tenant) right = PMRight.objects.get(short_name="teach") entity_items = RoleManager().get_all_secondary_role_entity_items_with_right( user, right, "COURSE") course_ids_taught_by_teacher = [ item.entity_item_id for item in entity_items] user_enrolments = UserEnrolment.objects.filter( enrolment__enrollable__id__in=course_ids_taught_by_teacher).only("id", "enrolment").select_related("enrolment", "enrolment__enrollable").annotate(is_submitted=) submitted_count = 0 for user_enrolment in user_enrolments: existing_attempt = None try: existing_attempt = ModuleProgressInit().get_existing_attempt( user_enrolment.id, user_enrolment.enrolment.enrollable.id, instance.id) except: pass if existing_attempt is not None and existing_attempt.is_submitted: submitted_count = submitted_count + 1 return submitted_count def __to_grade_count(self, instance): user = self.context["request"].user assigned_course_share_items = instance.course_share_item.all() assigned_courses = Course.objects.filter( course_share_item__in=assigned_course_share_items, tenant=user.tenant) right = PMRight.objects.get(short_name="teach") entity_items = RoleManager().get_all_secondary_role_entity_items_with_right( user, right, "COURSE") course_ids_taught_by_teacher = [ item.entity_item_id for item in entity_items] user_enrolments = UserEnrolment.objects.filter( enrolment__enrollable__id__in=course_ids_taught_by_teacher).only("id", "enrolment").select_related("enrolment", "enrolment__enrollable") to_grade_count = 0 for user_enrolment in user_enrolments: existing_attempt = None try: existing_attempt = ModuleProgressInit().get_existing_attempt( user_enrolment.id, user_enrolment.enrolment.enrollable.id, … -
Disable choices in multiselect Django widget
Is it possible to disable a few select choices in a Django multiselect widget? I can do something like this in the view: id_roles = (10, 2, 1, 3, 11) self.fields['role'].queryset = Role.objects.filter(id__in=id_roles) But this would throw an error when saving bound forms with values outside that list. Can I have all the roles there, just disabled? -
Django REST JSON API: how to include nested compound documents?
Using Django REST JSON Api, i.e. djangorestframework-jsonapi==3.1.0 and having the following data structure: parent, singleChild, manyGrandChildren (all just dummy names, singleChild means one-to-one relation, manyGrandChildren means one-to-many nested relation). ... class Parent(serializers.HyperlinkedModelSerializer): included_serializers = { 'singleChild': singleChildSerializer, 'manyGrandChildren': manyGrandChildrenSerializer, } class Meta: model = models.Parent fields = [ 'field1', 'field2', 'url', ] class JSONAPIMeta: included_resources = ['singleChild', 'manyGrandChildren'] ... My code does not work, because I cannot access manyGrandshildren on my response, which is something like http://host.com/api/parents/1/?include=singleChild,singleChild.manyGrandChildren also please correct me if my url ?include= statement is not correct. How do I accomplish that? -
All my django project files has been duplicated after some git commands
Please help !!! I was trying some git commands (I'm not used to it) to push my django project on a repo on github. I initiated git, then created a repo on github. I had some strange difficulties to do the push command but finally I got it. The problem is that all of my project files has been duplicated. I am really confused and some how in panic. don't know what to do. For example I have "admin.py" AND "admin 2.py" and so on. If it was a few files, I could have deleted duplicates manually, but I have every thing duplicated : static files, template files, migrations... and so on (hundred of files) I'm not sure which command or what caused this. Could any one rescue me please ? I've reverted my repo to the initial commit but those copies are still there. -
Full-stack development
I'm new to the web development and I literally stucked on the main problem. I've made a frontend (bootstrap) using website builder Pinegrow (I have an access to the javascript code) and the thing is that I need to build a backend for it. I do have skills in python so I decided to use Django framework. Is it possible to combine frontend which is made by this way with Django backend? -
Django models.Manager unable to access model
I have the following test which fails as it only inserts one row into the database where it should be inserting 100 rows class QuestionsTest(TestCase): def setUp(self): self.fake = Faker() def test_populating_table_with_random_data(self): newQuestion = Questions() x = 0 while x < 100: newQuestion.category = self.fake.text(max_nb_chars=254) newQuestion.difficulty = self.fake.text(max_nb_chars=8) newQuestion.question_type = self.fake.text(max_nb_chars=20) newQuestion.text = self.fake.text(max_nb_chars=254) newQuestion.save() x += 1 #100 rows should be inserted self.assertEqual(Questions.objects.count(), (100)) """Traceback (most recent call last): File 'Database/tests.py', line 99, in test_populating_table_with_random_data self.assertEqual(Questions.objects.count(), (100)) AssertionError: 1 != 100 """ Prior to receiving this error I was getting the error "Class Questions has no objects member". I got around this by explicitly declaring objects = models.Manager() in my Questions model, but I thought that django automatically generated a manager with the name objects -
How to Query ManyToMany django to find all instances?
I am trying to query to find all instances of User that is associated with self (a Venue). User is an extended AbstractBaseUser. This is how I declare stuff: class Venue(models.Model): administrators = models.ManyToManyField(get_user_model(), related_name="administrators_set") def save(self, *args, **kwargs): # Get all admins # Do stuff with admins super(Venue, self).save(*args, **kwargs) I have tried using admins = self.administrators.all() but get Unresolved attribute reference 'all' for class 'ManyToManyField' -
NoReverseMatch at /password_reset_complete/ 'users' is not a registered namespace
urls.py: urlpatterns = [ path('admin/', admin.site.urls), path('register/', user_views.register , name='register'), path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), path('logout/', auth_views.LogoutView.as_view(template_name='users/logged_out.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('learning_logs.urls')), ] password_reset_confirm.html: {% extends "learning_logs/base.html" %} {% load bootstrap4 %} {% block page_header %} <h2>Reset your password.</h2> {% endblock page_header %} {% block content %} <form method="post"> {% csrf_token %} {% bootstrap_form form %} <button type="submit" class="btn btn-primary">Submit</button> </form> {% endblock content %} password_reset_complete.html: {% extends "learning_logs/base.html" %} {% block content %} <p>Password changed </p> <a href="{% url 'login' %}">Sign in</a> {% endblock content %} I've tried to find the reference to namespace 'users' which the error is referring to. But I have no idea where is the source. I get this error whenever I fill in password_reset_confirm fields for resetting the password. Any ideas? -
GDALException at /admin/shops/shop/add/ OGR failure
I was trying to manually add some data. But I keep getting this error message. I have tried to get help from GIS/Gdal/OSGeos Import error in django on Windows GeoDjango GDALException - OGR failure I am unsure if it is necessary to set GDAL_LIBRARY_PATH and if it is, have I done it properly? I have no idea what the difference between gdal111.dll and gdal300.dll is. settings.py import os if os.name == 'nt': import platform OSGEO4W = r"C:\OSGeo4W" if '64' in platform.architecture()[0]: OSGEO4W += "64" assert os.path.isdir(OSGEO4W), "Directory does not exist: " + OSGEO4W os.environ['OSGEO4W_ROOT'] = OSGEO4W os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal" os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj" os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH'] GDAL_LIBRARY_PATH = 'C:\\OSGeo4W64\\bin\\gdal111.dll' import django_heroku -
Django Query with Case Insensitive Data Both Ways
There are a lot of similar questions, but I'm only finding partial solutions. I have a group of users stored as objects, with a name attribute (User.name). I'm hoping to do a query with a user input (Foo) such that I can (without being case sensitive) find all users where either: foo is in User.name User.name is in foo As an example, I want the user to be able to type in "Jeff William II" and return "Anderson Jeff William II", "jeff william iii", as well as "Jeff Will" and "william ii" I know I can use the Q function to combine two queries, and I can use annotate() to transform User.name like so (though I welcome edits if you notice errors in this code): users = User.objects.annotate(name_upper=Upper(name)).filter(Q(name_upper__icontains=foo) | Q(name_upper__in=foo)) But I'm running into trouble using __in to match multiple letters within a string. So if User.name is "F" I get a hit when inputting Jeff but if User.name is "JE" then it doesn't show up. How do I match multiple letters, or is there a better way to make this query? SIDE NOTE: I initially solved this with the following, but would prefer making a query if possible. for … -
django tables 2 - delete column and delete_item for inherited tables
I want to have one abstract function for all my tablelists (one for each model) and (one delete_item) function in view. I don't know how to make the delete (column in this table) and pass the model to the delete_item function in the view Tables.py ''' ############ Abstract Table class abs_Table(tables.Table): SN = tables.Column(empty_values=(), orderable=False) delete = tables.LinkColumn('delete_item', args=[A('pk'), ?????Model???], attrs={ 'a': {'class': 'btn btn-small btn-dark'} # }) def __init__(self, *args, **kwargs): super(abs_Table, self).__init__(*args, **kwargs) self.counter = itertools.count(1) def render_SN(self, record): pg = getattr(self, 'paginator', None) if pg: v = next(self.counter) return v + self.paginator.per_page * (self.page.number-1) else: return next(self.counter) class Meta: model = None fields = [ 'SN', 'id', 'delete', ] attrs = {"class": "table-striped table-bordered", 'width': '100%'} empty_text = "There are no Records matching the search criteria..." ''' Then for model Table Tables.py ''' class ModelTable(abs_Table): class Meta(abs_Table.Meta): model = modelname fields = abs_Table.Meta.fields+[selected_model_fields] ''' Views.py ''' def delete_item(request, pk, delmodel): obj = get_object_or_404(delmodel, id=pk) if request.method == "POST": obj.delete() return redirect("../") else: pass context = { 'object': obj } return render(request, '/delete_confirmation.html', context) ''' -
How to transfer Django's messages to Angular app
I am building Django 2.2 +Node + Angular 8 app. Django is used to run a couple of simple scrapers when user clicks on Search btn. I want to make user notified that the scraping process started successfully (if it is the fact) and that the scraping is finished, or that some errors occurred. Some intermediate statuses are also desirable, but not mandatory. I thought about using django.contrib.messages, but not sure how to make my Angular app receive them. Can anybody advise me with that problem? P.S.: not sure if it is important - I want to use Angular's snackbar to make user notified about scraping statuses. -
rediecrting to a page along with a header
i want to redirect to a particular page on a button click along with the token filled in by the client as header....i tried windowns.location but it doesnt support any header carrying feature...is there an alternative to this....i checked it in cosole..the token is being stored in "token" <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form method="POST"> {% csrf_token %} <input type="text" name="token" id="token" placeholder="token"> <button type="button" onclick="myFun()"> submit </button> </form> </body> <script> function myFun(){ var token=document.getElementById("token").value; console.log(token); window.location.replace("http://127.0.0.1:8000/app/task-list",{ 'Authorization': 'Bearer ' + token}); } </script> </html> -
allow the user to change his order values in the data base
i want to allow the user to change a value in his order from the data base The idea is when the user press the delete button the value of visible changes from yes to no and he won't be able to see it on the profile i managed to pull out all the user's orders but i couldn't find a way to make the button change the value for the order of that current user only is there any way to do such thing?? models.py class Order(models.Model): status_ch = [('in process','in process'),('complete','complete')] visible_ch = [('yes','yes'),('no','no')] status = models.CharField(choices=status_ch,max_length=20,null=True,blank=False,default='in process') user = models.ForeignKey(User,on_delete=models.CASCADE,null=True, blank=True) saller = models.CharField(blank=True,max_length=200) product = models.CharField(blank=True,max_length=200) currency = models.CharField(blank=True,max_length=200) name = models.CharField(max_length=200,null=True,blank=False) phone = models.FloatField(null=True,blank=False) amount = models.FloatField(null=True,blank=False) email = models.EmailField(null=True,blank=True) accountId = models.TextField(default='',blank=False) date = models.DateField(default= datetime.date.today) image = models.ImageField('Label') visible_for_saller = models.CharField(choices=visible_ch,max_length=20,null=True,blank=False,default='yes') visible_for_buyer = models.CharField(choices=visible_ch,max_length=20,null=True,blank=False,default='yes') def __str__(self): return self.saller views.py @login_required def profile(request): orders = Order.objects.filter(user=request.user) return render(request,'app/profile.html',{'orders':orders}) -
How to use serialize to serialize only some field?
Suppose I have a serializer class ProductSerializer(serializers.ModelSerializer): product_brand = serializers.StringRelatedField() product_type = serializers.StringRelatedField() class Meta: model = Product fields = '__all__' I want to use the same serializer to other serializer but I only need to get the product_type from it i.e.: class ItemSerializer(serializers.ModelSerializer): product = ProductSerializer( # only get product_type) ... class Meta: model = Item fields = '__all__' The wanted result would be: { ... "product": { "product_type": "Random" } } -
I got this Error AttributeError: module 'django.contrib.gis.db.models' has no attribute 'GeoManager'
This Is My Models : class Intervention(models.Model): Titre_intervention = models.TextField(max_length=255) date_intervention = models.DateField(auto_now_add=True) type_panne = models.ForeignKey(Panne,on_delete=models.CASCADE) etat = models.CharField(max_length=30) description = models.TextField(max_length=255) image = models.ImageField(blank=True,null=True,upload_to='medial/%Y/%m/%D') equipements = models.ManyToManyField(Equipement) clients = models.ForeignKey(Client,on_delete=models.CASCADE,default=True) location = models.PointField(srid=4326) objects = models.GeoManager() And This Is What I Imports : from __future__ import unicode_literals from django.db import models from django.contrib.gis.db import models So When I Run Makemigrations I got error Of : AttributeError: module 'django.contrib.gis.db.models' has no attribute 'GeoManager' -
Djando tempus dominus modal does not work
I have installed in my app the tempus_dominus app, usuing in the following manner: from tempus_dominus.widgets import DatePicker, TimePicker, DateTimePicker class InformazioniGeneraliForm(forms.ModelForm): data_registrazione=forms.DateTimeField(widget=DatePicker(attrs={ 'append': 'fa fa-calendar', 'icon_toggle': True, })) And in my template utilized in the following manner: {{ form.media }} <div class="row"> <div class="form-group col-2 0 mb-0" > {{form.codice_commessa|as_crispy_field}} </div> <div class="form-group col-2 0 mb-0" > {{form.data_registrazione|as_crispy_field}} </div> All works great but now I have the necessity to insert a modal button in the same page. I have tried to insert the same {{form.data_registrazione|as_crispy_field}} but when I press the datepicker it opens the first form one like in the following photo: How could I solve this issue? -
Large file upload problem with Django, Android
I'm using Django-rest-framework as android server. When trying to upload a voice file(.wav) to the server in Android, if it is over 2.5MB, the following error occurs. Internal Server Error: /tts_app/train/file-upload Traceback (most recent call last): File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site- packages\django\core\handlers\exception.py", line 34, in inner response = get_response(request) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\views\generic\base.py", line 71, in view return self.dispatch(request, *args, **kwargs) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\views.py", line 505, in dispatch response = self.handle_exception(exc) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\views.py", line 465, in handle_exception self.raise_uncaught_exception(exc) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception raise exc File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\views.py", line 502, in dispatch response = handler(request, *args, **kwargs) File "C:\Users\pjpp8\tts_project\ttsproject\tts_app\views.py", line 47, in post new_data = request.data.dict() File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\request.py", line 209, in data self._load_data_and_files() File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\request.py", line 272, in _load_data_and_files self._data, self._files = self._parse() File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\request.py", line 347, in _parse parsed = parser.parse(stream, media_type, self.parser_context) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\rest_framework\parsers.py", line 109, in parse data, files = parser.parse() File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\http\multipartparser.py", line 229, in parse handler.new_file( File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\core\files\uploadhandler.py", line 140, in new_file self.file = TemporaryUploadedFile(self.file_name, self.content_type, 0, self.charset, self.content_type_extra) File "C:\Users\pjpp8\tts_project\ttsvenv\lib\site-packages\django\core\files\uploadedfile.py", line 61, in __init__ file = tempfile.NamedTemporaryFile(suffix='.upload' + ext, dir=settings.FILE_UPLOAD_TEMP_DIR) … -
How to order by values in ArrayList in Django?
I have a model lets say products, which has a field prices that is basically an array: prices = [price on Monday, price on Tuesday, price on Thursday] How do I order products by prices on a specific day, eg: price on Monday?