Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Form does not Render in web page
I am trying to create a post edit page in Django, but when I test it the form does not render, only the submit button. There are no input fields displayed on the page. There are no errors given when I run the server or load the page. Here is my code: View: @login_required def updateview(request, pk): if request.method == "POST": instance = get_object_or_404(Listing, tag=pk) updateform = ListingUpdateForm(request.POST, instance=instance) if updateform.is_valid(): updateform.save() listing = updateform.instance messages.success(request, "New Listing Created") return redirect(reverse('main:listingdetails', kwargs={'pk': listing.tag})) else: messages.error(request, 'Please correct the error below.') updateform = ListingUpdateForm return render(request, "main/createlisting.html", context={"updateform":updateform}) Template: {% block content %} <form enctype="multipart/form-data" method="post"> {% csrf_token %} {{updateform}} <button type="submit">post</button> </form> {% endblock %} Form: class ListingUpdateForm(forms.ModelForm): countryList = (("US", "United States"), ("UK", "United Kingdom")) country = forms.ChoiceField(choices=countryList) class Meta: model = Listing fields = ('title', 'description', 'price', 'country') Thanks for any help. -
after implementing channel in django different requests are mixing up response with each other( windows OS )
i have implemented channel for sockets implementaion but now the requests are mixing up their responses with each other. and i dont know why this is happening. for example if i have two ajax requests that runs asynchronous than the response of first ajax request is received by second ajax request and the first one returns error as its response was taken by the second one. for example (first ajax request): function Weeks(){ $.ajax({ url:'/en/logistics/changeWeek/08-02-2021/Api', method:'GET', // async: false, success: function(result){ console.log(data) activeDate = new Date((result.seconds)*1000) dateNumber = activeDate.getDay() week_start = activeDate.addDays(-dateNumber) week_end = activeDate.addDays(6-dateNumber) depolyedDates = result.deployedDates depolyedDates = depolyedDates.map(element => new Date((element)*1000).getTime()/1000) readyDates = result.readyDates readyDates = readyDates.map(element => new Date((element)*1000).getTime()/1000) today = new Date((result.today)*1000) console.log(today) create_week() } }) } (second ajax request) function getDrivers(params,page){ $.ajax({ url:"/en/logistics/drivers/Api/resfresh"+ "?params=" + encodeURI(JSON.stringify(params)), // async: false, method:"GET", success: function(data){ console.log(data) drivers = data.drivers driverCurrentPage = page driverLastPage = data['last_page'] if (!driverActive && drivers.length > 0){ activeDriverTab(drivers[0].id ) } createDriverDiv() }, error:function(e){ console.log(e) } }) } when these requests are made this is what i get: and it is received by this response should have been received by the weeks ajax request instead it was send to drivers one if you can … -
Django many foreign table queries despite `select_related`
I'm trying to join A parent and 2 child tables in django. I can see that each time a list view is run, there are 50 queries (the page size) executed on the ChildB table. I thought that I could improve performance using the select_related method, but it seems not to be taken into account. Using prefetch_related the behaviour is as expected. Why is select_related not taken into account? select_related for Django 2.2 (which I'm using) prefetch_related Models: class Parent(models.Model): id = models.AutoField(primary_key=True) uuid_a = models.ForeignKey(ChildA, db_column='uuid_a', db_index=True, default=None, editable=False, null=True, on_delete=models.DO_NOTHING, primary_key=False, related_name='result_suppliers', unique=True,) uuid_b = models.ForeignKey(ChildB, db_column='uuid_b', db_index=True, default=None, editable=False, null=True, on_delete=models.DO_NOTHING, primary_key=False, related_name='duns_suppliers', unique=True,) class ChildA(models.Model): # ss uuid = models.CharField(primary_key=True, editable=False, max_length=36, db_index=True) class ChildB(models.Model): # sd id = models.AutoField(primary_key=True, editable=False) Serializers: class ChildAListSerializer(serializers.ModelSerializer): class Meta: model = ChildA fields = ['uuid', ] # others class ChildAListSerializer(serializers.ModelSerializer): class Meta: model = ChildB fields = ['uuid', ] # others class ParentListSerializer(serializers.Serializer): uuid_a = ChildAListSerializer() uuid_b = ChildBListSerializer() last_sync = serializers.DateTimeField() # others class Meta: model = Parent fields = '__all__' view: class ParentListView(ListAPIView): """ List view for deduplication suppliers screen """ filter_backends = [filters.DjangoFilterBackend] filterset_class = DeduplicationParentFilter pagination_class = LimitOffsetPagination page_size = 30 max_page_size = 30 pk_field … -
ERROR: No module named 'encodings' when deploying django using wsgi on amazon linux 2
For the past few days, I have been referring to Stackoverflow to solve my problem. Im hosting Django application using WSGI on Amazon Linux 2. I'm using pyenv for multiple python versions here. And the python version is 3.7.10. Below is my Apache Conf and wsgi.py. WSGI config for mysite project. It exposes the WSGI callable as a module-level variable named application. For more information on this file, see https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') application = get_wsgi_application() <VirtualHost *:80> ServerName wsgi.iamvishnu.xyz #DocumentRoot /var/www/html #for django LoadModule wsgi_module modules/mod_wsgi_python3.so Alias /static/ /home/mod-wsgi/mysite/static/ <Directory /home/mod-wsgi/mysite> Require all granted <Directory /home/mod-wsgi/mysite/mysite> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess mysite user=mod-wsgi group=mod-wsgi python-home=/home/mod-wsgi/mysite:/home/mod-wsgi/.pyenv/versions/virtualenv/bin/python WSGIProcessGroup mysite WSGIScriptAlias / /home/mod-wsgi/mysite/mysite/wsgi.py Below is the error im getting from apache error log Current thread 0x00007fd4b2087240 (most recent call first): [Tue Aug 03 05:27:15.145298 2021] [core:notice] [pid 24159] AH00052: child pid 24229 exit signal Aborted (6) Fatal Python error: initfsencoding: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' Current thread 0x00007fd4b2087240 (most recent call first): [Tue Aug 03 05:27:16.147167 2021] [core:notice] [pid 24159] AH00052: child pid 24230 exit signal Aborted (6) Fatal Python error: initfsencoding: unable to load the … -
Django runserver shows no output
Why would python manage.py runserver 8765 run properly such that I can visit the site at localhost:8765 and it renders everything correctly but I see no activity being registered on the server itself? My runserver session is stuck as follows: (qux) (main *%) python manage.py runserver 8765 Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). August 03, 2021 - 08:51:23 Django version 3.2, using settings 'qux.settings.dev' Starting development server at http://127.0.0.1:87650/ Quit the server with CONTROL-C. It prints nothing further like [03/Aug/2021 19:26:59] "GET / HTTP/1.1" 200 32663 NO output. NOTHING. I tried changing verbosity. No effect. I can find no reference to something like this either. When does this happen, and why? How does one resolve this? -
django template conditional extend
I have a very specific issue. I'm using a maintenance mode to get a built-in 503 view. I can customize the template in any way I want. I got it working, however I want the template to extend the admin base template when the request.path is /admin. When it isn't it should extend the normal base template. I tried it with this: {% if '/beheerpaneel' in request.path %} {% extends "admin/index.html" %} {% else %} {% extends "base.html" %} {% endif %} but that gives me a template syntax error, because the extend tag must be first. After some googling it seems I need to handle this in the view.. but there is no view, its built-in. Anyone know a way around this? In the future I also wanna do this with the 404 and 500 pages etc. -
How to get the logged-in user from other view function?
I am using django-rest-knox with token authentication, and an abstract user model. In the project, I have a class based view to create (POST)some model instances and I need to know who is the logged-in user so I can assign it to the model instance customer field. -
Auth0 login from Django gives cant reach this page error?
I am using Auth0 as an authentication service provider in my Django Application, everything seems to work fine until I press the login button it takes me to the link:- https://none/authorize?client_id=None&redirect_uri=http%3A%2F%2F127.0.0.1%3A8000%2Fcomplete%2Fauth0%2F%3Fredirect_state%3Dq0DAeE22cHQ9pahVC0uZF6AyMDdbI7l9&state=q0DAeE22cHQ9pahVC0uZF6AyMDdbI7l9&response_type=code on this link I get the following error:- enter image description here I am not sure what is causing this error. Here is some mre information :- Browser = Microsoft Edge and Google Chrome OS = Windows 11 Pro 2021 Python = v3.9.6 Django = v3.2.6 I hope I have provided sufficient information. -
How to get/refer a user id in Django dynamically?
I have a questionnaire page that works fine. I like to get a feedback to a page about which the user has filled out the questionnaires. I can make it manually if I add the user_name_id but I don't know how to get it dynamically. views.py @user_passes_test(lambda u: u.is_superuser) def index(request): viselkedestipus = Viselkedestipus.objects.all() //this generats me the list of the users stressz_teszt = Stressz_teszt.objects.filter(user_name_id=???) //this is where I need a solution template = loader.get_template('stressz/index.html') context = { 'viselkedestipus': viselkedestipus, 'stressz_teszt': stressz_teszt, } return HttpResponse(template.render(context, request)) html {% for item in viselkedestipus %} <div class="card my-2"> <div class="card-header h3"> {{ item.user_name }} </div> <div class="card-body"> <h5 class="card-title"></h5> <div class="row"> <div class="col-md-6"> <p class="card-header">User: {{ item.user_name }}</p> <p class="card-header">Kitöltés dátuma: {{ item.date }}</p> <p class="card-header">User id: {{ item.user_name_id }} </p> </div> <div class="col-md-6"> <h5>Tesztek:</h5> Viselkedéstípus: {% if item.vis01a %} <i class="fas fa-check fa-2x text-success"></i> {% else %} <i class="far fa-bell fa-lg text-warning"></i> {% endif %} {% for i in stressz_teszt %} //this is where I need the data of the specific user but I always get the datae of the logged in user Stressz-szint: {% if i.stressz_v01 %} <i class="fas fa-check fa-2x text-success"></i> {% else %} <i class="far fa-bell fa-lg text-warning"></i> … -
Django + Okta + django_saml2_auth Forbidden (CSRF cookie not set.) 403
Created a saml application in Okta for local testing. Django side I'm using plugin django_saml2_auth (https://github.com/fangli/django-saml2-auth) to authenticate with Okta. When I open the application from Okta app, Django throws below error; Forbidden (CSRF cookie not set.): / [03/Aug/2021 12:45:23] "POST / HTTP/1.1" 403 2870 Forbidden (403) CSRF verification failed. Request aborted. You are seeing this message because this site requires a CSRF cookie when submitting forms. This cookie is required for security reasons, to ensure that your browser is not being hijacked by third parties. If you have configured your browser to disable cookies, please re-enable them, at least for this site, or for “same-origin” requests. Actually home page ('/') doesn't have any forms for csrf verification, but okta tries POST on '/' and that fails at csrf. Followed this link https://github.com/fangli/django-saml2-auth/issues/30#issuecomment-438056798 and added "requestable urls" in okta but issue remains same. Okta configuration GENERAL Single Sign On URL http://127.0.0.1:8000/ Requestable SSO URLs URL Index http://127.0.0.1:8000/ 0 http://127.0.0.1:8000/saml2_auth/acs/ 1 http://127.0.0.1:8000/accounts/login/ 2 Recipient URL http://127.0.0.1:8000/ Destination URL http://127.0.0.1:8000/ Audience Restriction http://127.0.0.1:8000/saml2_auth/acs/ Am I missing anything? Is there any other saml plugin I can use for django + Okta integration? -
Using RotatingFileHandler and TimedRotatingFileHandler simeltaneously in Django
I've a scenario in Django where I need to rotate log files on daily basis but also to rotate the log file if the file crosses a particular size limit. It seems that I cannot use RotatingFileHandler and TimedRotatingFileHandler simultaneously. Can anybody please help me with a solution? -
Call a shared task in Django project from another project
Let's say I have a Django project A. It has an app B. B has a shared task in tasks.py called C. I have another non-django project from which I want to trigger this shared task C. They both use common broker RabbitMQ. From the documentation and other sources all I am able to find is send_task which I am not able to get to work. A.B.tasks.C @shared_task(queue="queue_name", autoretry_for=(Exception,), default_retry_delay=30, max_retries=3) def C(**kwargs): print(kwargs) Calling through: celery_app.send_task('A.B.tasks.C', kwargs={'message': 'message'}, queue='queue_name') The task is received by project A but not processed. [2021-08-03 12:19:20,189: WARNING/MainProcess] Received and deleted unknown message. Wrong destination?!? The full contents of the message body was: body: [[], {u'message': u'message'}, {u'chord': None, u'callbacks': None, u'errbacks': None, u'chain': None}] (100b) {content_type:u'application/json' content_encoding:u'utf-8' I think send_task is supposed to work for named tasks only. So, how do I achieve this for shared tasks? -
Django AllAuth - how to get SocialApp object by SocialAccount?
Is it possible to query a corresponding SocialApp from SocialAccount instance? Or to get all SocialAccounts of a particular SocialApp ? I was thinking about doing this: SocialApp.objects.get(provider=social_account.provider) But I think it can return multiple SocialApp objects. Is there a way to get the corresponding SocialApp ? -
Exception Value: lists() missing 1 required positional argument: 'list_id'
I have created a ToDoList with Python Django like so: class ToDoList(models.Model): name = models.CharField(max_length=200) def __str__(self): return self.name And I tried to display all my list in the browser by defining lists() in my views.py like this: def lists(reponse, list_id): lists = ToDoList.objects.all() id = ToDoList.objects.get(id=list_id).id And I made this HTML-file to be displayed: {% extends "myapp/base.html" %} {% block title %}View Lists{% endblock %} {% block content %} <h1>{{Lists}}</h1> <form method="POST" action="#"> {% csrf_token %} <ul> {% for ls in ToDoList.item_set.all %} <p> {{ ls }} </p> {% endfor %} </ul> </form> {% endblock %} But I get this error when I try to display all my lists in my browser: When this has happened before I've had to solve it in different ways. So now I am stumped. I'm fairly new to Django, so all help would be appreciated! EDIT: This is my urls.py: from django.urls import path from . import views urlpatterns = [ path('', views.index, name='index'), path('home', views.home, name='home'), path('base', views.base, name='base'), path('item/<int:id>', views.item_by_id, name='item_by_id'), path('lists/', views.lists, name="lists"), path('list/<int:list_id>', views.list, name='list'), path('create/', views.create, name='create'), path('create/list/<int:list_id>', views.list, name='list'), ] -
how to connect a docker compose application using django to a private AWS RDS postgres database
How can I connect my Django application to a private AWS Postgres RDS? My current VPC infrastructure is setup like below: Two Public subnets Two Private subnets connected to a NAT Gateway. (NAT is linked to Public subnets) Postgres RDS database is connected to private subnets above Please note that docker-compose is being used because i am using ECS Fargate for the backend infrastructure. I been stuck for days now and cant seem to find the solution, I would really appreciated if someone could help me figure it out. Thank you in advanced. -
My unittests don't work due to connection already closed
I am trying to do unittests but it does not work. Here is my file of tests : class SimpleTest(TestCase): def authenticate(self): useremail = 'myemail@email.fr' userpassword = 'password' c = self.client loggedin = c.login(email=useremail, password=userpassword) self.assertTrue(loggedin, "Not logged") def test_1(self): self.authenticate() c = self.client data = { 'searched': 'companylimit' } response = c.post('/djangoproject/get_information/', data, follow=True) self.assertEqual(response.status_code, 200) logger.info(pformat(json.loads(response.content)['result'])) self.assertIs(type(json.loads(response.content)['result']), int) time.sleep(5) def test_2(self): self.authenticate() c = self.client data = { 'searched': 'management', 'requested': User.objects.filter(is_active=True)[0].uniqueid } response = c.post('/djangoproject/get_information/', data, follow=True) self.assertEqual(response.status_code, 200) logger.info(pformat(json.loads(response.content)['result'])) if type(json.loads(response.content)['result']) == list: self.assertIs(type(json.loads(response.content)['result']), list) else: self.assertEqual(json.loads(response.content)['result'], "") I got django.db.utils.InterfaceError: connection already closed because I have 2 tests whereas with just one test it works. Could you help me please ? Thank you very much ! -
drf-yasg2 doesn't take label from serializer
Here project https://github.com/albertalexandrov/repo2/ with database and data in it. The problem is that I cannot specify labels when displaying in swagger: Serializers for the group view: class PersonSerializer(serializers.ModelSerializer): class Meta: model = Person fields = '__all__' class GroupSerializer(serializers.ModelSerializer): elder = PersonSerializer(label='Elder') teacher = PersonSerializer(label='Teacher') class Meta: model = Group fields = '__all__' As if drf-yasg2 take the first label and then repeates it for another fields. How can I fix it? -
How to render external database table into Django templte?
I have access to the oracle DB table. The table has a huge amount of data and so many entries. It is also updated daily. So far, I have managed to connect to the database. I want to show the data from the DB to my Django template as shown below: Since it is huge data, I want it to show 10 entries at once. It would also be great if I can add filters to it. I managed to get all the data and return it using a function, but what I don't know is how to display the data in a table like this in a template in Django. -
Django - background processing without using any external message-broker and related packages
I have to solve this issue: i have a 4G/4Core Ubuntu server 18.04LTS based machine with my django application, postgres, redis, and some other services that runs off my web application. The nature of the application is quite simple: every 5 minutes i have to collect data and save it to my db from remote devices via SNMP protocol, the total number of devices is around 300. I want to start this task without slowing down my application, so i've offloaded this task, i've tried both Threads, Multiprocessing and Django-RQ/python-rq. Now, here are the results: Threads: 1800 seconds Multiprocessing: 180 seconds (using fork method as default context, but i'm having random deadlocks, so is totally unusable after all) Python-RQ and Django-RQ with 12 workers: 180/200 seconds Now, it seems that my operations are all I/O bound, so, excluding the multiprocessing approach, the background worker with Python-rq seems effective, but i'm experiencing that it eats up all my memory. You guys, have a solution? i mean: the multiprocessing way using fork as default context is totally unusable due to the random deadlock..but the python-rq/django-rq solution is functional and heavy! How i can use the multiprocessing module with spawn as default context, … -
Setting the signed in user as field in Django model form
I have a model form in my Django site, and I want it to automatically set the user who is signed in as the 'creator' (one of the fields), without allowing them to change it. This field doesn't need to show up in the form for the user, but it needs to be added to the database. How would I go about this? Here is the relevant forms.py form: class EventForm(ModelForm): class Meta: model = Event fields = ('name','category','descr','start','end', 'location', 'attending', 'creator') labels = { 'name': '', 'category': '', 'descr': '', 'start': 'Start Date and Time', 'end': 'End Date and Time', 'location': 'Location', 'attending': 'Attending', 'creator': 'Creator', } widgets = { 'name': forms.TextInput(attrs={'class':'form-control', 'placeholder':'Name of Event'}), 'category': forms.TextInput(attrs={'class':'form-control', 'placeholder':'Event Category'}), 'descr': forms.Textarea(attrs={'class':'form-control', 'placeholder':'Description'}), 'start': forms.TextInput(attrs={'class':'form-control', 'placeholder':'YYYY-MM-DD HH:MM:SS'}), 'end': forms.TextInput(attrs={'class':'form-control', 'placeholder':'YYYY-MM-DD HH:MM:SS'}), 'location': forms.Select(attrs={'class':'form-select', }), 'attending': forms.SelectMultiple(attrs={'class':'form-control', }), 'creator': forms.Select(attrs={'class':'form-select', }), } The view just has the form loaded with form = EventForm(), and the template displays form.as_p Thanks in advance for any help. -
save() prohibited to prevent data loss due to unsaved related object 'user' with Foreign Keys
I am trying to POST a new User in User table and assign attribute to this user in the next related table UserAttribute. UserAttribute table contains 'user' field, which is foreign key to the User table. User.id = UserAttribute.user My POST method creates a new record in User table, hovewer I can not create relation in UserAttribute table. I am getting: save() prohibited to prevent data loss due to unsaved related object 'user'. It is strange because the User is successfully created in User table. I tried to save record in two ways. You can find the code on belove. What is more, I tried transactions too. models.py class User(models.Model): id = models.IntegerField(primary_key = True) email = models.CharField(unique=True, max_length=180) roles = models.JSONField(default=dict) password = models.CharField(max_length=255, blank=True, null=True) name = models.CharField(max_length=255, blank=True, null=True) firebase_id = models.CharField(max_length=255, blank=True, null=True) created_at = models.DateTimeField(default=now) progress_sub_step = models.IntegerField(blank=True, null=True) step_available_date = models.DateTimeField(blank=True, null=True) progress_step = models.IntegerField(blank=True, null=True) active = models.IntegerField(default=1) last_login_at = models.DateTimeField(blank=True, null=True) class Meta: managed = False db_table = 'user' class Attribute(models.Model): name = models.CharField(max_length=255) value = models.CharField(max_length=255) class Meta: managed = False db_table = 'attribute' class UserAttribute(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name = 'attribute') attribute = models.ForeignKey(Attribute, on_delete=models.CASCADE) class Meta: managed = … -
Django throws too many values to unpack (expected 2) when I return a render
When I return a render from a function-based view in Django, it is giving the error: too many values to unpack (expected 2). I am giving the render 3 values (request, template_name, context), but the docs say it should be ok, and it has worked elswhere. Here is my code: View: @login_required def updateview(request, pk): if request.method == "POST": instance = get_object_or_404(Listing, tag=pk) updateform = ListingUpdateForm(request.POST, instance=instance) if updateform.is_valid(): updateform.save() listing = updateform.instance messages.success(request, "New Listing Created") return redirect(reverse('main:listingdetails', kwargs={'pk': listing.tag})) else: messages.error(request, 'Please correct the error below.') updateform = ListingUpdateForm return render(request, "main/createlisting.html", context={"updateform":updateform}) Template: {% block content %} <form enctype="multipart/form-data" method="post"> {% csrf_token %} {{updateform}} <button type="submit">post</button> </form> {% endblock %} Form: class ListingUpdateForm(forms.ModelForm): countryList = (("US", "United States"), ("UK", "United Kingdom")), country = forms.ChoiceField(choices=countryList) class Meta: model = Listing fields = ('title', 'description', 'price', 'country') Thanks for any help. -
Python Django ManyToManyFields
When adding a new quest it is not added to the Score prize model. What do i have to do to fix it? class Quest(models.Model): task = models.CharField(max_length=200, null=True) grand = models.IntegerField(default=1, null=True) class Score(models.Model): prize = models.ManyToManyField(Quest) points = models.IntegerField(default=0) user = models.ForeignKey(User, on_delete=models.CASCADE) -
When i try to connect DB using env variable then i am getting [password authentication failed for user "root"] Django
When I try to connect DB with env variable in setting.py then I am getting an error. (password authentication failed for user "root") And if we try to connect DB with static credentials in setting.py then it's connected. I am getting errors in Django and DB Postgres. Please help. TIA -
Create serialization with data from two tables
Good evening everyone, I need help to be able to serialize the data as "Desired result" but I'm only getting the result of the image "Result I'm getting", can someone help me? I've tried some other ways but I wasn't successful, I ask you not to judge my code as I'm a beginner Thank you! Desired result "total_amount": 20000, // Valor total da compra sem desconto "total_amount_with_discount": 19500, // Valor total da compra com desconto "total_discount": 500, // Valor total de descontos "products": [ { "id": 1, "quantity": 2, "unit_amount": 10000, // Preço do produto em centavos "total_amount": 20000, // Valor total na compra desse produto em centavos "discount": 500, // Valor total de desconto em centavos "is_gift": false // É brinde? }, { "id": 3, "quantity": 1, "unit_amount": 0, // Preço do produto em centavos "total_amount": 0, // Valor total na compra desse produto em centavos "discount": 0, // Valor total de desconto em centavos "is_gift": true // É brinde? } ] } Result I'm getting [{"total_amount":"1000.00","total_amount_with_discount":"900.00","total_discount":"100.00","products":[1]}] models.py from django.db import models class CartItem(models.Model): cart = models.ForeignKey("Checkout", on_delete=models.CASCADE, verbose_name='Checkout', related_name="cart") item = models.ForeignKey("Product", on_delete=models.CASCADE, related_name="cartItens") quantity = models.CharField(max_length=5, verbose_name="Quantidade") line_item_total = models.CharField(max_length=5, blank=True) class Meta: verbose_name = 'Itens dos …