Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add a queryset column to another queryset?
I got this problem and I have searched about days and still dont figure it out how to solved it I have a queryset "q" that shows me a "model_id" and a column "available" And I want to add that column to the Model.objects.all() results, but the deal is that q is the result of a query to calculate the available amount so there is no table or model to refer Any suggestions or any solutions? Thxs for your time to read this ✌ -
How can the code in a views.py be tested?
def post(self, request, *args , **kwargs): form = self.form(request.POST) template_name= "spotify_calls/display.html" if form.is_valid(): cleaned = form.cleaned_data["SpotifyForm"] SpotifyAPI(client_data=" xxxxxxxxxxxxxxxx“, client_secret = "xxxxxxxxxxxxxxxxxxxxx") data = SpotifyAPI.search(self, query=cleaned , search_type="artiste") I want to determine if the method, SpotifyAPI.search(), actually worked and returned data in the data variable before I render it on a template. Expecting a dictionary in the data variable. Is there a way I could do this? -
Why is a part of my CSS style not applied?
Hii I'm kind of new so I might be making a rookie mistake but I have this HTML : {% extends 'base.html' %} {% load static %} {% block meta %} <title>HOME</title> {% endblock meta %} {% block style %} <link rel="stylesheet" href="{% static 'style.css' %}"> {% endblock %} {% block content %} <div class="content"> <h1>Test</h1> </div> {% endblock content %} and this CSS div.content { background-color: #DFBEBE; text-align: center; padding: 10px; height: 100%; } But it's not working... I tried with .content before but it also won't apply to my HTML. I applied a h1 css (with font) and it works just fine. It also works just fine with my previous projects(?) What did I do? -
Django-modeltranslation ValueError: Error adding translation field. Model already contains the field
I'm trying to implement localisation in a Django project by using django-modeltranslation. The documentation is pretty clear and straightforward and I've followed it to use it in my project. The problem is that when I try to migrate the models, I get a ValueError I cannot explain. Here is my code: settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'modeltranslation', 'core', 'blog', 'staticpages', ] # Default language LANGUAGE_CODE = 'en' # Languages supported by translation LANGUAGES = [ ('en', ('English')), ('es', ('Spanish')), ('es', ('Italian')), ] # Enable translations USE_I18N = True USE_L10N = True USE_TZ = True models.py # Create your models here. class Homepage(models.Model): slogan = models.CharField(max_length=500) about_text = models.TextField() translation.py from modeltranslation.translator import translator, TranslationOptions from .models import Homepage class HomepageTranslationOptions(TranslationOptions): fields = ('slogan', 'about_text') translator.register(Homepage, HomepageTranslationOptions) And this is the error I get: Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/Users/Andrea/anaconda3/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/Users/Andrea/anaconda3/lib/python3.6/site-packages/django/core/management/__init__.py", line 377, in execute django.setup() File "/Users/Andrea/anaconda3/lib/python3.6/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/Andrea/anaconda3/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate app_config.ready() File "/Users/Andrea/anaconda3/lib/python3.6/site-packages/modeltranslation/apps.py", line 11, in ready handle_translation_registrations() File "/Users/Andrea/anaconda3/lib/python3.6/site-packages/modeltranslation/models.py", line 75, in handle_translation_registrations autodiscover() File … -
How to call a URL in Django and get response in Django screen
I have a external URL say (http://127.0.0.1:5000/getCombinations) I need to call this URL in my Django view and get output in Django screen only views.py from django.shortcuts import render import requests from django.http import HttpResponse import math def form(request): return render(request,'hello/output.html') def combination(request): n=int(request.POST.get("no")) respond= requests.post('http://127.0.0.1:5000/getCombinations') return render( request, 'hello/output.html', {'msg': respond['msg']}) output.html <body> <form action="combination" method="post"> {% csrf_token %} Enter number: <br/> <input type="number" name="no"> <br/> <input type="submit" ><br/> </form> I am getting " Response' object is not subscriptable" as error in my screen when I am using above code. there any way to call that URL in my screen -
Importing a Keras model into TensorFlow.js from Django Server
I want to import a Keras model from my Django to a web browser. This is how to fetch a Keras model from a web server // JavaScript import * as tf from '@tensorflow/tfjs'; const model = await tf.loadLayersModel('https://foo.bar/tfjs_artifacts/model.json'); It accepts URL as an argument. However the code inside this function sends another HTTP request for weights of a model. Namely group1-shard1of1.bin I can write such view to import json file def request_a_model(request): return render(request, ‚models/model.json’) but what with subsequent request for binary files? How can Django code handle these requests and send model.json file and weights as binary files? -
Django icontains does not work on all items
I have made a search function and was testing it out but found that it doesn't work on all my items. I am using MongoDB for my DB (Djongo). I have products with titles such as: Acrylic Paint Set Gaming PC Computer Stainless Steel Watch Cuisinart 15pc Cutlery Set The first two products I am able to find. But the last two I am not. My views.py def search(request): if request.method == "GET": query = request.GET.get("search") products = Product.objects.filter( Q(title__icontains=query)| Q(description__icontains=query) ) context = {"products": products, "query": query} return render(request, 'search.html', context) The html code: form action="{% url 'test:search' %}" class="form-inline my-2 my-lg-0" method="GET" > <input class="form-control mr-sm-2" type="text" name="search" id="id_q" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> </form> I tried using a different approach by using the "django-filters" library but ran to the same problem. -
Django 'float' object has no attribute 'user' while using login decorator
I'm trying to build a django app and the app works, great so far. Right now i'm in the middle of making sure the user needs a login so they can log in. if the user is logged in than the user can use an machine-learning model to solve a problem. The error message I'm getting is 'float' object has no attribute 'user' and this started after I used the @login_required function in django. NOTE: The user is login in via the localhost:8000/admin/ panel Django provides. (later I will change that) after I fix this bug views.py def home(request): return render(request, 'home.html') @login_required def dashboard(request): return render(request, 'index.html') @login_required def getPredictions(temp_normal, hour,hour_x,hour_y): import pickle model = pickle.load(open("test_model.sav", "rb")) prediction = model.predict([[temp_normal, hour,hour_x,hour_y]]) return prediction @login_required def result(request): temp_normal = float(request.GET['temp_normal']) hour = float(request.GET['hour']) hour_x = float(request.GET['hour_x']) hour_y = float(request.GET['hour_y']) result = getPredictions(temp_normal, hour,hour_x,hour_y) return render(request, 'result.html', {'result': result}) html code index.html {% extends "base.html" %} {% block content %} <div class="content"> <div class="row"> <div class="col-lg-4"> <div class="card card-tasks"> <h1> </h1> <form action="{% url 'result' %}"> {% csrf_token %} <p>temp_normal:</p> <input class="form-control" type="text" name="temp_normal"> <br> <p>Weging:</p> <input class="form-control" type="text" name="Weging"> <br> <p>str:</p> <input class="form-control" type="text" name="straling"> <br> <p>hour:</p> <input class="form-control" type="text" … -
Django time auto_now_add in templates it's showing noon
Django time auto_now_add in templates it's showing noon how to resolve please help me -
<PYTHON DRF> Why am I getting only one value instead of list from request.data?
I have little problem with accessing to all values from request.data. Here my code and screens: My viewset: class LorebookViewset(ModelViewSet): queryset = Lorebook.objects.all() serializer_class = LorebookSerializer permission_classes = ( permissions.IsAuthenticated, ) def perform_create(self, serializer): data = self.request.data print(data) print(data['teams']) Serializer: class LorebookSerializer(serializers.ModelSerializer): teams = serializers.StringRelatedField(many=True, read_only=True) categories = serializers.StringRelatedField(many=True, read_only=True) author = serializers.StringRelatedField(read_only=True) class Meta: model = Lorebook fields = '__all__' Model: class Lorebook(models.Model): title = models.CharField(max_length=50, unique=True) cover = models.FileField(default='lorebooks/cover.jpg', null=True) thumbnail = models.FileField(default='lorebooks/thumb.jpg', null=True) banner = models.FileField(default='lorebooks/banner.jpg', null=True) author = models.ForeignKey(User, on_delete=models.CASCADE) content = models.TextField() tags = ArrayField(models.TextField(), default=list) categories = models.ManyToManyField(Category) teams = models.ManyToManyField(Team) date_created = models.DateTimeField(auto_now_add=True) trailer = models.TextField() is_read = models.BooleanField(default=False) def __str__(self): return self.title Data in Postman: Print in perform_create in viewset: Why am I getting only last value from teams instead of list? -
How to add image using ajax jquery in django?
I am talking about how to show the image in the template after being submitted. I know how to do that with text but not File Field. If there is link or anything like that that ,that would be much appreciatd. -
DRF CursorPaginator how to know if second page?
I'm implementing a custom CursorPaginator from Django Rest Framework. I want to know if this is the second page (I know wrong terminology, but bear with me) that a user is in. To put a scenario in, if I navigated to a page that had no cursor, we name this page 1. If I navigate to the next page, I get a cursor. The problem I'm encountering is given that the user is in the second page, if I call self.previous_position or self.get_previous_link(), I'm only getting Page 1's cursor. How would I be able to know that the previous position is "page 1"? I was thinking of calling self.get_previous_link() by rebuilding the pagination object but passing in the previous cursor, i.e. page 1's cursor, but I can't seem to get it. -
Model with two ForeignKeys -- How to find objects that share a relationship?
I have a video hosting website, which features rock climbs. Each video can have multiple climbs. I am trying to add timestamps that are associated with the unique relationship of that specific video and that specific climb. So my models look like this: class Climb ... class Video climb = models.ManyToManyField('Climb', through='Timestamp', related_name='videos') class Timestamp climb = models.ForeignKey('Climb') video = models.ForeignKey('Video') time = models.IntegerField I can easily call all the timestamps associated with a video, and all the timestamps associated with a climb, but how do I find ONLY the timestamps that share a specific video and climb? For example, right now I can do the following: {% for video in videos %} {{video.id}} {% for climb in video.climb.all %} {{climb.name}} -- and now I want to be able to check for the timestamp that references both the video and the climb, and then call it here -- {% endfor %} {% endfor %} Thanks! -
In frontend PUT request returning Internal Server 500 error | Django Vue
I am trying to perform a PUT request in Vue view from DRF API backend. Though POST and GET requests are working properly in Vue(frontend) but for PUT request it's returning INTERNAL SERVER ERROR 500 Here is what I have done. settings.py INSTALLED_APPS = [ ..., 'rest_framework', 'corsheaders', 'articles' ] MIDDLEWARE = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.AllowAny', ] } CORS_ALLOWED_ORIGINS = [ "http://localhost:8080" ] view.vue updateArticle(article) { axios .put('http://127.0.0.1:8000/api/' + article.id, this.article ) .then(response => { this.fetchArticle(); this.editArticle = null; return response; }) .catch(error => console.log(error)) } urls.py from .views import ArticleViewSet from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register(r'', ArticleViewSet, basename='articles') urlpatterns = router.urls -
How to get array of object from MongoDB via Django
I have mongoDB data that i insert that from python (JSON) _id:ObjectID("5f95573f24e7d77a831b9c14") "Users" : { "userName" : "User-1" "userPhone" : [{ "PhoneNum" : "123212321" "PhoneName" : "Apple" }, { "PhoneNum" : "45665456" "PhoneName" : "Samsung" }] "userAddress" : [{ "Country" : "USA" "City" : "New York" }] }, { "userName" : "User-2" "userPhone" : [{ "PhoneNum" : "86776876" "PhoneName" : "Xiao Mi" }, { "PhoneNum" : "5674342" "PhoneName" : "Huawei" }] "userAddress" : [{ "Country" : "Australia" "City" : "Sydney" }] } Then, in Django i create model look like this : from djongo import models # Create your models here. class UserPhone(models.Model): PhoneNum = models.models.CharField(max_length=50) PhoneName = models.CharField(max_length=50) class UserAddress(models.Model): Country = models.CharField(max_length=50) City = models.CharField(max_length=50) class Users(models.Model): userName = models.CharField(max_length=255, unique=True) userPhone = models.ForeignKey(UserPhone, on_delete=models.CASCADE) userAddress = models.ForeignKey(UserAddress, on_delete=models.CASCADE) class AllData(models.Model): _id=models.ObjectIdField() users = model.ForeignKey(Users, on_delete=models.CASCADE) But when i get the data, the ouput : { "_id": "5f95573f24e7d77a831b9c14", "users": null } did i was wrong when i write the models ? Can you give me example for that case ? I'm new in django and mongo ,and i didn't found the example like mine.. I think they are array of object, but idk how to create the models … -
Django, Ajax: 'PostListView' object has no attribute 'object_list'
I am trying to build comment section below every post with ListView. It works with button "submit" but when I try to do it with Ajax I get 500 error in console. In logs I noticed that it shows error 'PostListView' object has no attribute 'object_list'. Code below, thanks for help in advance. views.py class PostListView(FormMixin, ListView): model = Post template_name = 'posts/homepage.html' form_class = CommentForm def get_queryset(self): profiles = Follow.objects.filter(follow_by=self.request.user.profile).values_list('follow_to', flat=True) posts = Post.objects.filter(author_id__in=profiles).order_by('-date_of_create') return posts def post(self, request, *args, **kwargs): form = self.get_form() if form.is_valid(): if request.method == 'POST': pk = self.request.POST.get('pk') post = Post.objects.get(pk=pk) new_comment = Comment.objects.create( author = self.request.user.profile, post = post, content = form.cleaned_data['content'] ) return JsonResponse({'comment': model_to_dict(new_comment)}, status=200) else: return self.form_invalid(form) template <div class="comments" id="{{ post.pk }}" style="display: none"> {% include 'posts/comments.html' %} <form action="" method="post" class="commentForm" data-url="{% url 'post_comments' post.pk %}"> {% csrf_token %} <input type="hidden" name="pk" value="{{ post.pk }}"> {{ form.as_p }} <button type="button" class="commentBtn" id="{{ post.pk }}">Comment</button> </form> </div> addComment.js $(document).ready(function () { $('.commentBtn').click(function () { let serializedData = $('.commentForm').serialize(); let btn = $(this); let id = btn.attr('id'); $.ajax({ url: $("commentForm").data('url'), data: serializedData, type: 'post', dataType: 'json', success: function (data) { console.log(data); $(`#${id}.comments`).load('/posts/comments/' + data.post); $('textarea').val(''); } }) }) }) -
Django Rest - how can i return a custom json response when authentication fails?
I created a custom middleware to authenticate every get request to an API endpoint that i created. Here is my code: class TokenMiddleware(AuthenticationMiddleware): def process_request(self, request): if request.user.is_authenticated: return None else: try: token = request.GET[TOKEN_QUERY_PUBLIC] secret = request.GET[TOKEN_QUERY_SECRET] except Exception as e: # A token isn't included in the query params raise ValidationError(detail=str(e)) user = auth.authenticate(request, token=token, secret=secret) if user: auth.login(request, user) else: return HttpResponse('Authentication failed', status=404) Now, instead of raising exceptions or returning an HTTP response, i would like to return a JSON string instead, something like: {'error': 'authentication failed'}. I know how i would do that from a standard view, but in this case i need to do it from a middleware. How can i do it? Thanks in advance! -
Dynamic request of data from API endpoint in DjangoRestFramework
I am making some API calls from an external source but would like to make it dynamic instead of manually putting the reference number in my views in the DRF UI provided. What I want is that in my DRF UI, I should have a field whereby when I enter a reference number, I should get the response from from the API, I am successfully doing this manually but I want to make it dynamic from the DRF UI. I would also like to get a better formatted JSON Response in my DRF UI. An image is below to better explain what I meant Views.py class Paystack(APIView): def get(self, request): url = "https://api.paystack.co/transaction/verify/{{REFERENCE_NO}}" payload = {} files = {} headers = { 'Authorization': 'Bearer SECRET_KEY', 'Content-Type': 'application/json' } response = requests.request("GET", url, headers=headers, data= payload, files=files) return Response(response) def post(self, request): url = "https://api.paystack.co/transaction/verify/{{REFERENCE_NO}}" payload = {} files = {} headers = { 'Authorization': 'Bearer SECRET_KEY', 'Content-Type': 'application/json' } response = requests.request("GET", url, headers=headers, data= payload, files=files) return Response(response) urls.py from django.urls import path, include from .views import * from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register('paystack', Paystack, basename='paystack') urlpatterns = [ path('paystack/', Paystack.as_view(), name='paystack'), ] Presently, my DRF UI … -
Usertype models in Django
I'm being confused on where table how I insert my usertypes, I'm just a beginner on Django but surely Im been reading documentation in Django but I can't understand this one , The case is when I register new user there's must be choice what usertype should specify with this user either an admin or etc. but the problem is I think there is no relationship table from authuser even I create another table.slight similar to this problem resources link. For now I'm been thinking to create custom usertype field in authuser table,but when migrate it didn't show updated fields and also some user didn't touch or add any field in authuser table sample Im just really confused of where table I can add my usertype that have a relationship to authuser. Is there any know or explain about this, thanks Models class AuthUser(models.Model): password = models.CharField(max_length=128) last_login = models.DateTimeField(blank=True, null=True) is_superuser = models.IntegerField() username = models.CharField(unique=True, max_length=150) first_name = models.CharField(max_length=150) last_name = models.CharField(max_length=150) email = models.CharField(max_length=254) is_staff = models.IntegerField() is_active = models.IntegerField() date_joined = models.DateTimeField() usertype_id = usertype = models.OneToOneField(usertypes,on_delete=models.CASCADE,primary_key=True) () //this is what i want to add class Meta: managed = False db_table = 'auth_user' class usertypes(models.Model): usertype … -
Django Extensions Missing from Docker Environment
Django claims Django Extensions is not installed whenever I try to run anything via manage.py: ModuleNotFoundError: No module named 'django_extensions' I have a Django set up with Docker and wanted to start using the Django Extensions module, so I have added the module to my requirements.txt as follows: django-extensions>=3.0.9,<3.1.0 As part of my Dockerfile, I install my dependencies in the requirements.txt: RUN pip install -r /requirements.txt When I build my environment, I can see it install occurring in the console seemingly without any issues: Collecting django-extensions<3.1.0,>=3.0.9 Downloading django_extensions-3.0.9-py3-none-any.whl (221 kB) ... Successfully installed Django-3.1.2 django-extensions-3.0.9 ... I added this module to INSTALLED_APPS as follows: INSTALLED_APPS = [ ... 'django_extensions', ] Once added to installed apps, Django starts throwing the error I mentioned about the missing module above. This is the same way I am installing my other dependencies such as the Django itself, the Django Rest Framework, etc, and it has no problems. Why wouldn't Django be able to find the Django Extensions module? -
Django escape only certain HTML tags
Is it possible to escape all html tags except for the tag somehow? I am sending a user entered string from a view to an html template where I have manually added tags to the string in the view. I would like to allow for that to be shown, but of course omit all html tags entered by the user. -
Inability to Make External API calls
I am getting this error in my terminal while making some External API request call I am following the documentation from here https://paystack.com/docs/api/#dedicated-nuban def create_nuban(request): url = "https://api.paystack.co/dedicated_account" payload = { "customer":481193, "preferred_bank":"providus-bank" } headers = { 'Authorization': 'Bearer SECRET_KEY', 'Content-Type': 'application/json' } response = requests.request("POST", url, headers=headers, data= payload) print(response.text.encode('utf8')) Error message on the terminal b'{\n "status": false,\n "message": "Request body could not be parsed. Make sure request body matches specified content-type: \'application/json\'",\n "data": {\n "parser_message": "Unexpected token c in JSON at position 0",\n "body": "customer=481193&preferred_bank=providus-bank"\n }\n}' -
django restframework HyperlinkedRelatedField return Null value on one to many and many to many relationship
hi i'm new to django restframework, and i have model like this: class Tag(models.Model): name = models.CharField(max_length=10) def __str__(self): return self.name class Blog(models.Model): title = models.CharField(max_length=100) content = models.TextField() author = models.ForeignKey(User, on_delete=models.CASCADE,null=True,related_name='post') tags = models.ManyToManyField(Tag,related_name='tag') def __str__(self): return self.title and my view(sorry if it looks terrible): @api_view(['GET']) @authentication_classes([SessionAuthentication, BasicAuthentication]) @permission_classes([IsAuthenticated]) def userDetail(request,pk): users = User.objects.get(pk=pk) serializer_context = { 'request': request, } serializers = UserSerializers(users,context=serializer_context) return Response(serializers.data) @api_view(['POST']) @authentication_classes([SessionAuthentication, BasicAuthentication]) @permission_classes([IsAuthenticated]) def insertPost(request): serializer = BlogSerializers(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data) return Response(serializer.errors) @api_view(['GET']) @authentication_classes([SessionAuthentication, BasicAuthentication]) @permission_classes([IsAuthenticated]) def tagDetail(request,pk): tag = Tag.objects.get(pk=pk) serializer_context = { 'request': request, } serializers = TagSerializers(tag,context=serializer_context) return Response(serializers.data) and this is my serializers: class BlogSerializers(serializers.ModelSerializer): author = serializers.HyperlinkedRelatedField( read_only=True, view_name='user-detail' ) tags = serializers.HyperlinkedRelatedField( many = True, read_only=True, view_name='tag-detail' ) class Meta: model = Blog fields = ('id','title','content','author','tags') class UserSerializers(serializers.ModelSerializer): post = serializers.HyperlinkedRelatedField( many=True, read_only=True, view_name='blog-detail' ) class Meta: model = User fields = ('id','username','email','first_name','last_name','post') class TagSerializers(serializers.ModelSerializer): class Meta: model = Tag fields = ('id','name') my url: path('user/<int:pk>',views.userDetail,name="user-detail"), path('blog/create',views.insertPost,name="blog-new"), path('blog/',views.blogList,name="blog-list"), path('blogs/<int:pk>',views.userBlog,name="blog-detail"), path('tags/<int:pk>',views.tagDetail,name="tag-detail"), my problem is when i created new blog using HyperlinkedRelatedField, the author field value is null as well as the tag field, but when i dont use it, the result return just fine, … -
Variable hero image in django
In a django webapp, I have a page with a hero image. This happens mostly because there's some CSS (in a .css file) that contains a class called .hero-image with a background-image: tag with url("...") value. Now I'd like to have the image controlled by some logic: something in the world leads to a database lookup that decides whether to use image one.png, two.png, etc. The only reasonable way I see to do this is to move the .hero-image CSS block from the CSS file to be inline CSS served each time the page is served. (This at least seems more efficient than making the .css file be served dynamically instead of from static and so changing all the time.) This seems like something that is likely a relatively common need, so it bothers me that I've not found documentation on it. Am I on target or is there a better way to approach this? -
fieldsets not working in Tabular Inline in Django
I want to use fieldsets in my django project Specifically in a Tabular Inline model ( when it's showing inline with the parent model ) and it's not working for some reason. Here is my code: admin.py: class QuantitiesTabularInline(admin.TabularInline): def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): response = super(QuantitiesTabularInline, self).render_change_form( request, context, add, change, form_url, obj) response.context_data['title'] = "edit" if response.context_data['object_id'] else "Sorts" return response extra = 0 fieldsets = ( ('المستودع', { 'fields': ('warehouse',), }), ('الصنف', { 'fields': ('Sort',), }), ('الكمية', { 'fields': ('Quantity',), }), ) model = Quantities formset = RequiredInlineFormSet