Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
MobSF (Mobile-Security-Framework-MobSF) installation problems
I spent last days striving with MobSF (Mobile-Security-Framework-MobSF) installation, which finally fails without reaching the target. My work laptop is Windows 10 with i5-8250U and 16G memory. I tried it using git clone https://github.com/MobSF/Mobile-Security-Framework-MobSF.git then running setup.bat Meanwhile installing Python (Python 3.11.2), OpesnSSL (64 bit) and Visual studio. The BAT file runs slowly ... unfortunately fails [ERROR] Installation Failed! throwing errors: *ERROR: Could not find a version that satisfies the requirement yara-python-dex>=1.0.1 (from apkid==2.1.4->-r requirements.txt (line 24)) (from versions: none) ERROR: No matching distribution found for yara-python-dex>=1.0.1 (from apkid==2.1.4->-r requirements.txt (line 24)) * and Traceback (most recent call last): File "c:\Users\ij\tools\Mobile-Security-Framework-MobSF\manage.py", line 12, in from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' Trying to kludge it around: pip install -r requirements.txt python -m pip install django But it still does not work. Another attempt was installation using docker build -t mobsf . But it finishes: ERROR [ 5/15] RUN ./install_java_wkhtmltopdf.sh [ 5/15] RUN ./install_java_wkhtmltopdf.sh: #9 0.782 /bin/sh: 1: ./install_java_wkhtmltopdf.sh: not found executor failed running [/bin/sh -c ./install_java_wkhtmltopdf.sh]: exit code: 127 Google hardly shows anything about it. **I will appreciate any hint to solve. May be there is another qwat to install MobSF ** -
Chatbot Backend API
For a full stack project, I've been working with ChatterBot and Django and It's been really tricky for me to fully grasp. The concept of the project is pretty simple. I web scraped some recipes and now I' using a chatbot to filter the recipes. For instance, if the user sends a message like: "What can I make with eggs?" The chatbot should filter through the recipes and return those with egg as an ingredient. I have a FilterView that works great: class RecipeFilter(APIView): def post(self, request): ingredients = request.data.get('ingredients', []) if ingredients: recipes = Recipe.objects.all() for ingredient in ingredients: recipes = recipes.filter(ingredients__ingredient__ingredient__iexact=ingredient) serializer = RecipeSerializer(recipes, many=True) return Response(serializer.data) else: return Response({'message': 'Please provide a list of ingredients.'}) I've been trying to use ChatterBot for the same effect but with more casual user input. Here's what I've got: class ChatBot(APIView): def post(self, request): message = request.data['message'] bot = ChatBot('Bot') trainer = ListTrainer(bot) if not bot.storage.count(): recipes = Recipe.objects.all() for recipe in recipes: trainer.train([recipe.recipe] + [ri.ingredient.ingredient for ri in recipe.ingredients.all()]) response = bot.get_response(message) recipe = Recipe.objects.filter(recipe=response.text).first() if recipe: serializer = RecipeSerializer(recipe) return Response({'message': serializer.data['description']}) else: return Response({'message': "I'm sorry, there are currently no recipes available with those ingredients."}) This implementation is … -
This error message in Django means "TypeError: Object of type type is not JSON serializable"
This error message in Django means "TypeError: Object of type type is not JSON serializable". This doesn't make sense! This is my serializers: class MatriculaSerializer(serializers.ModelSerializer): class Meta: model = models.MATRICULA fields = ( 'ID_MATRICULA', 'ID_USUARIO', 'ID_TIPO_MATRICULA', 'VALIDADE', 'EXPEDICAO', 'ISATIVO' ) this is my models class MATRICULA(BASE): ID_MATRICULA = models.AutoField(primary_key=True) ID_USUARIO = models.ForeignKey(USUARIO, related_name='MATRICULA_ID_USUARIO',on_delete=models.DO_NOTHING, null=False) ID_TIPO_MATRICULA = models.ForeignKey(TIPO_MATRICULA, related_name='MATRICULA_TIPO_MATRICULA',on_delete=models.DO_NOTHING, null=False) VALIDADE = models.DateField EXPEDICAO = models.DateField(null=False) def __str__(self): str = (f"{self.ID_MATRICULA}") return str this is my views class MatriculaAPIView(generics.ListCreateAPIView): queryset = models.MATRICULA.objects.all() serializer_class = serializers.MatriculaSerializer And this is my urls path('matricula/', views.MatriculaAPIView.as_view(), name='matricula') This error only happens with this model "Matricula" I have several others that work well, and they have the same type of coding. -
Django, How to serialize multiple model object in Nested Relationships?
I am creating an API using Django Restframework which needs data from multiple models. I followed the API guide of django rest framework - Nested relationships, but it doesn't work. I have 4 tables, Gallery, Picture, Tag, PictureTag, and my models as follows class Gallery(models.Model): title = models.CharField(null=True, blank=True, default=None) created = models.DateTimeField(default=timezone.now) class Picture(models.Model): gallery = models.ForeignKey(Gallery, on_delete=models.CASCADE, related_name='pictures') name = models.CharField(null=True, blank=True, default=None) posted = models.DateTimeField(default=timezone.now) tags = models.ManyToManyField(Tag, through='GalleryTag') class Tag(models.Model): tag_name = models.CharField(max_length=25) class PictureTag(models.Model): gallery = models.ForeignKey(Gallery, on_delete=models.CASCADE) tag = models.ForeignKey(Tag, on_delete=models.CASCADE) vote = models.IntegerField() I wrote the following code according to the API guide of django rest framework Here's my serializer class PictureListSerializer(serializers.ModelSerializer): class Meta: model = Picture fields = ['name', 'posted'] class GalleryDetailSerializer(serializers.ModelSerializer): pictures = PictureListSerializer(many=True, read_only=True) class Meta: model = Gallery fields = ['id', 'title', 'created', 'pictures'] and my view class GalleryDetail(generics.RetrieveUpdateDestroyAPIView): queryset = Gallery.objects.prefetch_related('pictures') serializer_class = GalleryDetailSerializer I want to get the detail of a gallery with gallery_id, for example: http://127.0.0.1:8000/api/gallery/2/ { "id": 2, "title": "Gallery Example", "created": "2023-3-9", "pictures": [ { "name": "name1" "posted": "posted1" }, { "name": "name2" "posted": "posted2" }, { "name": "name3" "posted": "posted3" }, ... ], } But I actually only get id, title and created, … -
Django - How can I add a user to an auth_group?
I have and django application that I am trying to apply user group permissions. Here is how my members model is setup. Class Member(AbstractUser) Class Meta: permissions = ((Perm1_codename, Perm1_desc),...) pass address = models.CharField(max_length=30) When I migrate this, the permissions are saved in the auth_group_permissions table instead of the members_app_member_user_permissions table. I don't see a way to associate a user to the auth_group table because there is no user column in these tables. I setup my roles in auth_group and defined the permission of each role in auth_group_permissions, how can I associate a user to these groups? Alternatively, how can I add these user permissions to my members_app_member_user_permissions? -
I whant advise witch Django version use with graphql
I want to get advice. When I started working with graphql with django 4, the packages were causing problems. Changing the django version to 3 I solved the problem. Do you think I should continue with django 3 version or what? First I tried to fix the settings, but I didn't fix it completely. Has anyone ever encountered such a situation? -
DRF - AttributeError when using ModelSerializer to save manyToMany relation with 'though' table
I am building a Django Rest Framework project and I'm encountering an attribute error that I cannot seem to resolve. Specifically, I'm getting the following error when I try to serialize a Sale object: Got AttributeError when attempting to get a value for field `product` on serializer `SaleItemSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `Product` instance. Original exception text was: 'Product' object has no attribute 'product'. I've defined my models and serializers as follows: # Models class Product(models.Model): name = models.CharField(max_length=100) price = models.DecimalField(max_digits=10, decimal_places=2) cost = models.DecimalField(max_digits=10, decimal_places=2) description = models.TextField() image = models.ImageField(upload_to='images/') category = models.ForeignKey(Category, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Sale(models.Model): products = models.ManyToManyField(Product, related_name='sales', through='SaleItem') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class SaleItem(models.Model): sale = models.ForeignKey(Sale, on_delete=models.CASCADE) product = models.ForeignKey(Product, on_delete=models.CASCADE) quantity = models.IntegerField() price = models.DecimalField(max_digits=10, decimal_places=2) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) # Serializers class SaleItemSerializer(serializers.ModelSerializer): class Meta: model = SaleItem fields = ['product', 'quantity', 'value'] class SaleSerializer(serializers.ModelSerializer): products = SaleItemSerializer(many=True) class Meta: model = Sale fields = '__all__' def create(self, validated_data): sale_items_data = validated_data.pop('products') sale = Sale.objects.create(**validated_data) for sale_item in sale_items_data: SaleItem.objects.create(sale=sale, **sale_item) # The erro return sale The code … -
How to prevent hx-push-url when form does not validate
I am building a multi-step form-wizard. When posting each step of the form, I want the url to change. For example 1st step has a url like /update/1/, and when I click Continue, the 2nd step will be at /update/2/ and so on. This is useful so that in case the user does a hard refresh, I can still "stay" in the same step. I deal with this in my view when request.method=="GET" I have a form for which hx-post is triggered by elements outside it like so: <div id="form-wrap"> <form id="my-form"> <input hx-validate="true" some-input.../> {# all inputs have hx-validate="true" #} </form> </d> <button hx-post="{% url 'my_app:company-update' prev %}" hx-include="#my-form *" hx-target="#form-wrap" hx-vals='{ "posting_step": {{current_step}}}' hx-push-url="true">Back</button> <button hx-post="{% url 'my_app:company-update' next %}" hx-include="#my-form *" hx-target="#form-wrap" hx-vals='{ "posting_step": {{current_step}}}' hx-push-url="true" >Continue</button> When the form is valid, everything works fine. However, when any of the fields has validation errors, hx-push-url still pushes the url resulting in seeing the same step of the form with errors, but the url does not correspond to that step, but the next one... Perhaps this is related to this. Is there anyway to go around this? The part of my view dealing with this: # views.py # … -
Django settings.py S3 bucket
My Django app runs in AWS. Is there a way to restart a Django app and pick up new "config" without having to "push" the settings.py (or other) file? My app uses settings.py and what I would like to do is find a way to change config without having to promote my code (and the settings.py file) through my dev, stage and prod environments. I'm wondering if, for example, there is a way to tell Django (or in some other way) pick up the settings.py file from an S3 bucket on a restart? It doesn't have to be the settings.py file, it's just what I'm thinking of since all the config is in there for now. I'm aware that I could use AWS Secrets, but in my situation that would require updating 3 separate secrets (dev, stage, and prod) and so I was hoping for a "one place" solution. Thanks. -
Why I cannot access the entity I created in DRF tests
I create a Project in a test (the first method). I'm trying to get it (the second method), but i get 404 error. def test_create_valid(self): response = self.client.post( '/api/projects/', self.valid_payload, format='json' ) self.assertEqual(response.status_code, status.HTTP_201_CREATED) def test_retrieve_project(self): response = self.client.get( '/api/projects/1/' ) self.assertEqual(response.status_code, status.HTTP_200_OK) Even when I try to get this with Django ORM I get None. p = Project.objects.first() # returns None -
Django Exporting selected ListView Items To csv file
I have a list View which I want to select certain rows of the records returned and write them out to a csv file (which can later be imported to Excel). The problem is when I call the function to do the export via the button on the list View, I cant seem to get which items (choices) were selected. I am attemting to get them via the request object. Here is a look at the model, views, and templates I am trying to use. See below: class Cd(models.Model): artist_name = models.CharField(max_length=155) cd_title = models.CharField(max_length=155) cd_total_time = models.TimeField(default="00:00:00") cd_total_time_delta = models.DurationField(default=timedelta) cd_run_time = models.TimeField(default="00:00:00",blank=True) cd_run_time_delta = models.DurationField(default=timedelta) cd_remaining_time = models.TimeField(default="00:00:00",blank=True) cd_remaining_time_delta = models.DurationField(default=timedelta) views.py class List_Cds(ListView): model = Cd template_name = 'list_cds.html' def export_to_csv(request): choices = request.GET.getlist('choices') print("In export_to_csv choices selected were: %s" % choices) cd_export = Cd.objects.filter(id__in=choices) response = HttpResponse('text/csv') response['Content-Disposition']= 'attachment; filename=cdlist.csv' writer = csv.writer(response) writer.writerow(['Artist', 'Cd Title', 'CD Run Time']) cd_fields = cd_export.values_list('artist_name','cd_title', 'cd_total_time') for cd in cd_fields: writer.writerow(cd_fields) return response list_cds.html . . . {% block content %} <br> <button type="submit" value="listbatchview" onclick="location.href='{% url 'export_to_csv' %}'">Batch Export CSV</button> <TABLE id="list_table"> <TR BGCOLOR="#B0B0FF"> <TD></TD> <TD></TD> <TD ALIGN="Center">Artist Name</TD> <TD ALIGN="Center">Cd Name</TD> <TD BGCOLOR="99CCFF" ALIGN="Center">Cd Length</TD> <TD BGCOLOR="#CC99CC" … -
I cannot forward the video
I have created a web application using Django and stored videos in the static file. I loaded the static files onto the HTML page and used video.js as the video player. I am playing a video in Chrome and Edge, but it does not allow me to fast-forward. When I try to fast forward, the video restarts from the beginning. However, when playing the video in Firefox and Safari, I can fast forward without any issues. I would like to know why I cannot fast forward in Chrome or Edge and how to fix this issue. -
Debugpy won't attach to anything
I've tried everything except what works. Nothing gets my vscode debugger to attach to any breakpoint. Here is my launch.json: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python: Docker", "type": "python", "request": "attach", "pathMappings": [ { "localRoot": "${workspaceFolder}", "remoteRoot": "/code" } ], "connect": { "host": "localhost", "port": 3000 }, "justMyCode": true, "logToFile": true } } And here is my docker-compose.yml: services: web: platform: linux/amd64 build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - 8800:8000 - 3000:3000 And in my manage.py: if settings.DEBUG: if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'): import debugpy debugpy.listen(("0.0.0.0", 3000)) # debugpy.wait_for_client() print('debugpy Attached!') My debugpy Attached! is being printed so I know things are set up to be attached to the debugger, but none of my breakpoints work. -
ValueError: Cannot assign "value" "Order.dish_name" must be a "Dish" instance
I am writing a restaurant app in Django and I have a specific view that catches an Ajax request. From this request I get the name of a dish, which I try to save in a new object Order. I keep getting this error " ValueError: Cannot assign "'pasta'": "Order.dish_name" must be a "Dish" instance." and I have no idea why. I have been trying to fix it for 2 days, so i would like to know what I am doing wrong type here models.py` from django.db import models class Table( models.Model ) : number = models.IntegerField( primary_key= True) def __str__( self ) : return str(self.number) class Dish(models.Model ) : name = models.CharField( primary_key= True, max_length= 50 ) price = models.FloatField() type = models.CharField( max_length= 50 ) gluten = models.BooleanField( null= False) lactose = models.BooleanField( null= False) def __str__( self ) : return self.name class Meal(models.Model ) : start = models.TimeField() end = models.TimeField(blank= True, null= True, default= None) table = models.ForeignKey(Table, on_delete=models.CASCADE) def __str__( self ) : return str(self.table.number) class Order(models.Model): request_time = models.TimeField() kitchen_start_time = models.TimeField(blank= True, null= True, default= None) delivery_time = models.TimeField(blank= True, null= True, default= None) dish_name = models.ForeignKey(Dish, null= True, blank= True, default= None, … -
Nginx Reversed Proxy for Django
I have my Django Server running on a virtual maschine. I got my own domain and want to access the server just with the domain via Nginx. I got to files in the sites-enabled folder. The problem is that if I try to connect to the Server I get a 403 forbidden message. But if I change the servername from the Reversed Proxy to my static ip I can access the server. Does anybody know what the mistake is, that I can access the Djangoserver just with my domain? server{ server_name www.mmjtech.de; root /var/www/html; location / { index index.html index.htm index.html inde.php; try_files $uri $uri/ = 404; } listen 80; listen [::]:80; } And the following is the second file. server{ server_name kenergy.mmjtech.de; root /var/www/html; location / { index index.html index.htm index.html inde.php; try_files $uri $uri/ = 404; } listen 80; listen [::]:80; } -
Django file not uploaded using FileField(upload to=) from admin panel
i have a problem that is i can't upload files from admin panel to my folder document in media , i try to upload but it always failed the server still uploading and the end it say error 500 request time out , so after i tried many solution i thing my problem with mysql db or with django my Django version 3.0.3 and python 3.7 and i am using namecheap shared hosting settings.py : # media dir MEDIA_URL= '/media/' MEDIA_ROOT = os.path.join('/home/traixmua/public_html/media') urls.py : urlpatterns = [ ... ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) handler404 = 'blog_app.views.handler404' models.py : class Trainer(models.Model): ..... document = models.FileField(upload_to='documents/') note : when i try to upload files using SQLite on local server not in hosting it's work good but with mysql i have this problem , i can choose the file but it won't to upload -
How do I make users to upload image files from a Django model which a React JS frontend to Google Cloud Storage
I have created a model using django and my model allows an authenticated user to upload a profile picture to Google Cloud Storage I have installed both google-auth and google-cloud-storages packages. I have also included storages app to INSTALLED APPS in settings.py I have created my cloud bucket and have have connected it with my application just fine now the issue comes when I test with postman, my API is unable to upload PUT pictures to the Google Cloud but if I manually upload a picture into my bucket, I am able to view GET it with my API in Postman. REMEMBER I WANT TO USE THE ENDPOINT IN THE FRONTEND OF MY APPLICATION OF REACTJS here is a breakdown of my configurations Google Cloud configuration os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "MY-JSON-FILE.json" import google.auth from google.cloud import storage # Use application default credentials credentials, project_id = google.auth.default() GS_PROJECT_ID = os.environ.get("GS_PROJECT_ID") GS_BUCKET_NAME = os.environ.get("GS_BUCKET_NAME") GS_DEFAULT_ACL = os.environ.get("GS_DEFAULT_ACL") MEDIA_ROOT = os.environ.get("MEDIA_ROOT") UPLOAD_ROOT = os.environ.get("UPLOAD_ROOT") GS_FILE_OVERWRITE = os.environ.get("GS_FILE_OVERWRITE") #GS_LOCATION = os.environ.get("GS_LOCATION") #Media files settings MEDIA_URL = os.environ.get("MEDIA_URL") DEFAULT_FILE_STORAGE = os.environ.get("DEFAULT_FILE_STORAGE")type here MY MODEL CONFIG class AppUser(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) profile_pic = models.ImageField(default='default-avatar.png', upload_to='media/', null=True, blank=True, storage=GoogleCloudStorage()) The API CLASS IN MY api.py class UpdateAppUserProPic(UpdateModelMixin, GenericAPIView): … -
Is there an efficient way to recursively query a Django model manytomany field?
Given this model: class Role(models.Model): title = models.CharField(max_length=255, verbose_name='Role Title') parents = models.ManyToManyField("self", symmetrical=False) skills = models.ManyToManyField(Skill) What is the most efficient way to get a list of all the 'Skill' objects related to this 'Role' object, and its parents, recursively? For example, if the Role object in question is 'Manager', it will inherit skills from 'Team Leader', which inherits skills from 'Team Member' etc. -
Is there any method or api method in django rest api to search a list by value instead of key
My list look like this in my model it's a choice list STATUS_CHOICES = [(DELIVERED_STATUS= 'delivered') (FEEDBACK_STATUS='feedback')] DELIVERED_STATUS=1 FEEDBACK_STATUS=2 My endpoint api url is /api/v2/task/list?Status=1 how do i search the content of the list using values of the list instead of their keys for example: /api/v2/task/list?Status=1 to /api/v2/task/list?Status=feedback -
Django Unit Test- How to avoid rollback for each unit test case
I am new to Django framework. I am writing Django unit test cases. The DB transactions are getting roll-backed for each test case. Is it possible to avoid the rollback since I want to use that DB data for other test cases? -
django.db.utils.OperationalError: ERROR: no more connections allowed (max_client_conn)
I have a django app running on kubernetes with postgrsql / pgbouncer I encounter the following error on some requests when I run 2 Django replicas (this doesn't seem to happen if I only set 1 replica) I only have one database Django side django.db.utils.OperationalError: ERROR: no more connections allowed (max_client_conn) PGBouncer side 1 WARNING C-0x55d76aeb6330: (nodb)/(nouser)@xx.xx.xx.xx:37002 pooler error: no more connections allowed (max_client_conn) I have the following settings postgres FROM postgres:12.0 args: - postgres - -c - max_connections=400 SHOW max_connections; max_connections ----------------- 400 (1 row) pgbouncer - name: PGBOUNCER_MAX_CLIENT_CONN value: "800" - name: PGBOUNCER_DEFAULT_POOL_SIZE value: "400" - name: POOL_MODE value: transaction - name: SERVER_RESET_QUERY value: DISCARD ALL I suppose this comes for these settings but cannot figure out what to set. Can someone give me what values would work ? Once fixed and with this architecture (Django + PGBouncer + Postgrsql) could I launch 5/10/15... replicas and the database/bouncer will handle it ? Thanks -
Try to Return dataset as a table with request of postman
I wanna Request with postman and get a table of all books as return but I can't find a way to do this. Thanks a lot This is my model of books: class Book(models.Model): name = models.CharField(max_length=100) username = models.ForeignKey(User, on_delete=models.CASCADE) publication_date = models.DateField() publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE) description = models.TextField() def __str__(self): return self.name And This is my View: class AddBookAPIView(APIView): renderer_classes = [TemplateHTMLRenderer] template_name = 'book.html' @method_decorator(login_required(login_url='login/')) def post(self, request): book_serializer = BookSerializer(data=request.data) if book_serializer.is_valid(): book_serializer.save() return redirect('home') return Response({'message': book_serializer.errors}) @method_decorator(login_required(login_url='login/')) def get(self, request): book = Book() serializer = BookSerializer(book) return Response({'serializer': serializer, 'book': book}) -
Django logs are working fine in my Windows local Environment but not getting logs in live ubuntu server. I am using Nginx with Gunicorn
import logging logging.basicConfig(filename=os.path.join(BASE_DIR, 'django.log'), level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s') ##################### Here is the Middleware ####################### class RequestResponseLoggingMiddleware: def init(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) logger.info('Request: {0} {1} {2}'.format(request.method, request.path, get_client_ip())) return response def get_client_ip(): try : hostname = socket.gethostname() IPAddr = socket.gethostbyname(hostname) ip = IPAddr except : ip = '-' return ip Here is what I am getting in my Windows logs 2023-03-09 19:42:33,972 INFO Request: GET /login 192.185.45.22 -
i can't upload files from django admin panel and just still loading
iam using django 3.0.3 and i want to upload files from admin panel but when i try to upload file it still loading and at least it show error 500 request time out , i deploy my website in namecheap so how to fix it settings.py : # media dir MEDIA_URL= '/media/' MEDIA_ROOT = os.path.join('/home/traixmua/public_html/media') urls.py : urlpatterns = [ path('', views.home, name='home'), ]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) handler404 = 'blog_app.views.handler404' models.py : class Trainer(models.Model): document = models.FileField(upload_to='documents/') admin.py : from django.contrib import admin from blog_app.models import Trainer # Register your models here. class TrainerAdmin(admin.ModelAdmin): search_fields = ('name', 'name') admin.site.register(Trainer,TrainerAdmin) what is the problem here i can't find any problem note : when i try to upload files using SQLite on local server not in hosting it's work good but with mysql i have this problem , i can choose the file but it won't to upload -
Filter by time in DRF
I have an api with an end day field (ad end time), in the model, this is a simple datetime field: end_date = DateTimeField(null=True, blank=True) in my view there are several types of filtering for ads, but I need some checkbox that will compare the current date and time with the one written in this field, based on which only relevant ads will be displayed Is there something similar in the DRF, like this(DjangoFilterBackend): class AdAPI(generics.ListAPIView): queryset = Ad.objects.all() serializer_class = AdSerializers filter_backends = [DjangoFilterBackend, filters.OrderingFilter] filterset_class = AdFilterSet I will be grateful for the hint