Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Post method in DetailView?
I wanna to use form in detail page,Then views access get and post ... from django.views.generic import DetailView from .forms import CommentForm Class ArticleDetailView(DetailView): model = Article def get_context_data(self,*args,**kwargs): context = super().get_context_data(*args,**kwargs) context['form'] = CommentForm return context def post(self): #do something here with request.POST But in django docs write this logic with mixins(FormMixin).. -
Opentelemetry auto-instrumentation error in python Django application in K8s
I'm running a simple Django 4 CRUD application in kubernetes. I'm trying to collect metrics and traces. I deployed the otel collector and auto-instrumentation and annotated using my django app. oc patch deployment.apps/django-crud -p '{"spec": {"template": {"metadata": {"annotations": {"instrumentation.opentelemetry.io/inject-python": "true"}}}}}' After annotated the below error occurs Create migrations No changes detected Exception while exporting metrics ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) Traceback (most recent call last): File "/otel-auto-instrumentation/urllib3/connectionpool.py", line 790, in urlopen response = self._make_request( File "/otel-auto-instrumentation/urllib3/connectionpool.py", line 536, in _make_request response = conn.getresponse() File "/otel-auto-instrumentation/urllib3/connection.py", line 454, in getresponse httplib_response = super().getresponse() File "/usr/local/lib/python3.10/http/client.py", line 1375, in getresponse response.begin() File "/usr/local/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.10/http/client.py", line 279, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/lib/python3.10/socket.py", line 705, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 104] Connection reset by peer During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/otel-auto-instrumentation/requests/adapters.py", line 486, in send resp = conn.urlopen( File "/otel-auto-instrumentation/urllib3/connectionpool.py", line 844, in urlopen retries = retries.increment( File "/otel-auto-instrumentation/urllib3/util/retry.py", line 470, in increment raise reraise(type(error), error, _stacktrace) File "/otel-auto-instrumentation/urllib3/util/util.py", line 38, in reraise raise value.with_traceback(tb) File "/otel-auto-instrumentation/urllib3/connectionpool.py", line 790, in urlopen response = self._make_request( File "/otel-auto-instrumentation/urllib3/connectionpool.py", … -
Django - Code between Declaration and Render not executing
Got a funny issue that i've run into and I wondered if anyone can share some advice. I'm creating a simple web page with a form but the form content is not loading and after doing some digging i've discovered that any code between the function delaration request and the render is not being executed. @login_required(login_url='') def index(request): print('Hello World!') project = projectForm() return render(request, 'index.html', {'form': project}) so in the above example Hello World! and creation of the project form do not execute, but the page loads, albeit without any form content. Anyone come across this, can shed some light on what the problem may be? -
I need to change the colour of some cells in Full calendar, not the event, but the whole cell
I want to change the colour of the whole cells in Full Calendar, not the event but the whole cells, like the background of the current day. I don't know how to start `document.addEventListener('DOMContentLoaded', function () { var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { contentHeight: 'auto', timeZone: 'local', eventOrder: 'variable', stickyHeaderDates:true, events: [ {% for es in eventos %} { variable: {{ es.esTemprano }}, title: ' {{ es.icono }} {{ es.apellido }} {{ es.personas }}', start: '{{ es.dia |date:"Y-m-d"}}', end: '{{ es.dia |date:"Y-m-d"}}', url: '../evento/aviso/{{es.id}}', color: 'black', textColor:{% if es.llegar < '14:00' and es.llegar > '06:00' %} '#0F8706' {% else %} 'black' {% endif %}, backgroundColor: '#FCF7F3', }, {% endfor %} ], }); calendar.render(); calendar.setOption('locale', 'es'); }) ; ` -
MariaDB table got non-consecutive primary key after running a Django application
We have been running a Django application for years, and the operation accumulated multiple thousands of historical transactions. We recently sampled through the real data and realized that the transaction table contains non-consecutive values in its primary key id column. The jumping primary keys widely exist in the data, and typically, a sample query for id with an interval of 1000 will only yield three hundred records. By reviewing the application's source code, we have the following details, not sure if relevant, though. The DDL has AUTO_INCREMENT on the id column, so we believe the database will automatically increment on this column. In the Python source code, the model Transaction does not contain the primary key id column, so this column is added by the Django framework. In the function writing the transaction to database, there is no mention of the primary key id column either. However, the function has @transaction.atomic, and we are not sure whether the notation has any influence on the system behavior. The technical stack is: MariaDB v10.5, Python v3.7, Django v3.1.4. Our Question: Why does the database have non-consecutive primary keys on the table? Is it common for applications to have non-consecutive primary keys in … -
NoReverseMatch error when creating delete button
I was trying to create a button that deletes game in my website, however django displays NoReverseMatch error views.py def delete_game(request, pk): game = Game.objects.get(pk=pk) if request.method == 'POST': game.delete() return redirect('shop_page') context = { 'game': game } return render(request, 'store/product-details.html', context) urls.py path('delete/<int:pk>', delete_game, name='delete_game') product-details.html <form action="{% url 'delete_game' game.pk %}" enctype="multipart/form-data" method="post"> {% csrf_token %} <input type="submit" value="Удалить игру"> </form> Please help me with that. -
Rename a file on upload Django
Good afternoon, I need to rename the files that users upload through a form with the nomenclature (DSR_"rut"-"name"-"label name (from form)"-0-"extension"). The parts of the rut, the name and the extension I could already generate, but I don't know how to do the name of the label. example: if the label says "image": (DSR_"rut"-"name"-image-0-"extension"). Please your help. To do this use the following: def upload_directory_name(instance, filename): ext = filename.split('.')[-1] filename = "DSR_%s_%s_0.%s" % (instance.rut, instance.name, ext) return os.path.join('uploads',filename) The file forms is as follows: class Candidato_form2(forms.ModelForm): class Meta: model = Candidato fields = [ 'certificado_antecedentes', 'hoja_de_vida_conductor', ] labels = { 'certificado_antecedentes': 'Certificado Antecedentes', 'hoja_de_vida_conductor': 'Hoja de vida del conductor', } widgets = { 'certificado_antecedentes': forms.ClearableFileInput(attrs={"multiple":True, 'class':'form-control'}), 'hoja_de_vida_conductor': forms.ClearableFileInput(attrs={"multiple":True, 'class':'form-control'}), } -
django csrf gives forbidden 403 error for POST
I'm trying to learning Django and as part of a tutorial, i was trying to pass some data through forms. It was good with GET, but POST gives me a forbidden 403. I googled and applied many of those tricks but nothing helped. Here is my code: view @csrf_protect def counter(request): template = loader.get_template("counter.html") ss = request.POST["cnt"] context = { "words" : len(ss.split(" ")) } return HttpResponse(template.render(context, request)) form <form method="post" action="counter"> {% csrf_token %} <textarea name="cnt" rows="10" cols="50"></textarea><br> <input type="submit"> </form> The 403 error at first was: Forbidden (403) CSRF verification failed. Request aborted. Help Reason given for failure: CSRF token missing. But after removing cookies (I read that it might be an issue with the cookie), it changed to: 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. -
How to create a serializer for a GIS Point to use with Django Rest Framework
I've created an endpoint that will return some serialized models (available and unavailable) and a couple of geographic points (sw and ne) that define the bounding box around those models. I'll determine the extents of all of the Listings returned and will defined sw and ne accordingly. I'd like to do something like this: class ListingSerializer(serializers.ModelSerializer): photos = ListingPhotoSerializer(many=True, read_only=True) class Meta: model = Listing exclude = [] class ListingAvailabilityBBoxSerializer(serializers.Serializer): available = ListingSerializer(many=True, read_only=True) unavailable = ListingSerializer(many=True, read_only=True) sw = PointSerializer(read_only=True) ne = PointSerializer(read_only=True) But PointSerializer for Point (as defined in django.contrib.gis.geos) doesn't exist, as far as I know. Is there a PointSerializer I haven't yet found? How can I do this? -
Why HSTS header is not getting added to Django app
I have a Django app deployed with gunicorn via nginx as a reverse proxy. I've been trying to configure HSTS on it but for some reason can't add header. In my settings.py I have: if not DEBUG: SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True SECURE_HSTS_SECONDS = 600 SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_PRELOAD = True SECURE_PROXY_SSL_HEADER = ("HTTP_STRICT_TRANSPORT_SECURITY", "https") Then in my nginx config I add Strict-Transport-Security header. server { server_name my.app.com; location = /favicon.ico { access_log off; log_not_found off; } location / { include /etc/nginx/mime.types; include proxy_params; proxy_pass http://unix:/run/app.sock; client_max_body_size 100M; } location /static/ { alias /home/user/app/static/; } location /media/ { alias /home/user/media/; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/my.app.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/my.app.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot add_header Strict-Transport-Security "max-age=600; includeSubDomains; preload"; } server { if ($host = my.app.com) { return 301 https://$host$request_uri; } # managed by Certbot server_name my.app.com; listen 80; return 404; # managed by Certbot } But if I print my headers, I don't see it: {'Host': 'my.app.com', 'X-Real-Ip': '100.100.100.100', 'X-Forwarded-For': '100.100.100.100', 'X-Forwarded-Proto': 'https', 'Connection': 'close', 'Cache-Control': 'max-age=0', 'Sec-Ch-Ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"', 'Sec-Ch-Ua-Mobile': '?0', 'Sec-Ch-Ua-Platform': '"Linux"', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 … -
How to allow others to embed my django form to their website?
I have a django web app where user can fill up a form (like a survey) and the form submission is saved on my database. You can check out the form generated by django here: http://raktim.pythonanywhere.com/form-view/2 Now i want others to be able to embed this form to their website. How do i do this? For example, in case of google form, we can create a form. Then get an embed link with iframe tags which allow us to show this google form to our website like below: <iframe src="https://docs.google.com/forms/d/e/1FAIpQLSePf2s4UajXzbig7GO2gaXSbV0YFP1qVnDUmytMW2v6i58kwQ/viewform?embedded=true" width="640" height="382" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe> How can i do that with a django form? Apparently simply passing the url of the form page in the src of iframe parameters doesn’t do the trick. Can you anyone please guide me with an example? -
django- py manage.py runserver AttributeError: 'str' object has no attribute 'decode'
tengo este problema al levantar el server de django, he tratado de retroceder versiones por temas de compatibilidad y no podido llegar a la solución alguien que me puedo ayudar. Hello everyone, I have this problem when starting the django server, I have tried to go back versions for compatibility reasons and I could not find the solution, someone who can help me. (.env) PS C:\xampp\htdocs\interplay> python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper fn(*args, **kwargs) File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\commands\runserver.py", line 120, in inner_run self.check_migrations() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 453, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\executor.py", line 18, in init self.loader = MigrationLoader(self.connection) File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\loader.py", line 49, in init self.build_graph() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\loader.py", line 212, in build_graph self.applied_migrations = recorder.applied_migrations() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py", line 73, in applied_migrations if self.has_table(): File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\migrations\recorder.py", line 56, in has_table return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()) File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\base.py", line 256, in cursor return self._cursor() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\base.py", line 233, in _cursor self.ensure_connection() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\base.py", line 217, in ensure_connection self.connect() File "C:\Users\JOSEQS\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\backends\base\base.py", … -
How to create an organisation with multiple users in each organisation
I want to create a website using django that has the following features: A user should be able to create an organisation (say for eg: "SuperHeroOrganisation") That user must be the owner of that organisation (kind of have the master control of that organisation) That user must be able to create any number of accounts under that organisation which then can be used by the other people in that organisation (the account details will be physically handed over to the members) Eg: If Superman is a the 'master user' who created a organisation say some "SuperheroAssociation", and there are two members in organisation, then Superman must be able to create each one of them an account which the two of them can use to access the organisation by logging in from their side. some features must be restricted to the 'master user' only, (say changing organisation description something like that) I don't know how to structure the models for my requirements. So please tell me how to go about this. Thanks in advance -
DJANGO: how to prevent page reload (without JS) when i click Submit? The same code in Flask doesn't reload the page
With Flask and with Django, i reproduced a simple combobox that prints text in a textarea. The code is the same, but in Django the page reloads when i click on the Submit button (the page disappears and after half a second it reappears due to loading), while in Flask the page does not reload and remains fixed when I click on the Submit button ( does not disappear and remains fixed). What do I want to get? I would like NOT to reload the page when I use Django and click the Submit button. So I would like the page to remain fixed (without disappearing and reappearing after half a second) Why does it reload in Django and not in Flask? The code I used is the same. I know, I should use React or something in Javascript, but then why in Flask the page stays fixed and doesn't reload? DJANGO VERSION home.html (index > login > home) index.html is 127.0.0.1:8000/. Home.html will only open after successful login. The address of when I view the forms is 127.0.0.1:8000/home and when I click Submit I still get 127.0.0.1:8000/home (rightfully so). Obviously I wrote the html in a reduced and shorter … -
How to invoke a command from one docker-container to another?
I'm using docker compose to create a docker network, where my Web App and ArangoDB containers are working together. My goal is to restore Arango's data with arangorestore cli-tool, but I need to invoke it from inside my Web App code (from a python code actually - I'm developing with Django framework) where I don't have ArangoDB installed (which means arangorestore command could not be found by bash). How can I make ArangoDB execute arangorestore from another container? Obviously, I don't want to install arangodb inside my Web App container (that's why i've separated them in the first place, according to official docker's recomendation - 1 service per container). So, i need to somehow connect to ArangoDB container and invoke arangorestore from there. I can imagine doing that over ssh, but it means installing openssh and messing around with keys. May be there are other options for me? Containers can communicate with each other via port-forwarding, so I thought I could use it, but I don't know how. I would appreciate if someone could help me. -
AWS Elastic beanstalk django migration not working
I am trying to deploy my application using eb deploy I have my migrate file at .platform/hooks/predeplou/01_migrate_pre.sh: source /var/app/venv/staging-LQM1lest/bin/activate echo "Running migrations predeploy" python /var/app/current/manage.py migrate python /var/app/current/manage.py showmigrations echo "finished migrations" The deployment appears to go succesfully but the migration does not occur. When I check the logs the eb-hooks.log show that the 01_migrate_pre.sh file has ran but the migration has not been implemented e.g. the There are migrations that are shown as not ran from the print out of showmigrations: Running migrations predeploy [X] 0027_alter_sideeffect_se_name [ ] 0028_alter_sideeffect_se_name finished migrations Please can anyone advice hoe I can get the migration to run (or even just to get a print out of the output of the migrate command, e.g. it is not printing out anything to log like ' No migrations to apply.' -
In Django, how to delete exclusive many-to-many objects for a parent object?
My Django App has an Organisation model. An organisation may be identified by many aliases but these aliases may not be unique to that organisation. For example: Imperial College London (imperial.ac.uk) - may have an alias of ICL. The ICL Group (icl-group.com) - may share the same alias of ICL. In order to cater for this I have defined a ManyToMany relationship: class Organisation(models.Model): ... aliases = models.ManyToManyField(OrgAlias) ... Currently, when I delete an organisation, I need to manually check all of it's associated aliases and delete those that aliases aren't attached to another organisation. Is there a way to automatically cascade deletions of aliases that are exclusive to the organisation being deleted. I briefly explored pre_delete signals. If this is the way to go, can anyone provide an example? Alternatively if there is a better route, would appreciate the guidance. -
Cannot access style sheet in static django
I'm trying to deploy my django project using cpanel I have manage to show the HTML successfully but the style in static folder cannot be accessed in stderr.log I got this error message Not Found: /static/assets/default/css/style.css in setting.py I have static set like this STATIC_URL = '/static' STATICFILES_DIRS = ( # location of your application, should not be public web accessible './static', ) in the HTML I use this to access the style sheet <script src="{% static 'posApp/assets/default/css/style.css' %}"></script> I have the folder like this -pos -setting.py -posApp -templates -login.html -static -posApp -assets -default -css -style.css I have tried looking online my problem and also comparing my website in cpanel and my website that I run locaclly using localhost and could not find the answer why I get this error -
How to restore SQLite database backup in PostgreSQL with Django, encountering circular dependency and foreign key constraint issues
I have a large amount of data in SQLite and I recently created a backup. Now, I want to restore this backup into a PostgreSQL database. However, I am facing circular dependency and foreign key constraint problems during the restoration process. My project is developed using Django. What is the recommended approach to take a backup from the SQLite database and restore it in a PostgreSQL database while addressing circular dependency and foreign key constraint issues? Are there any specific steps or considerations to keep in mind when performing this task with Django? -
Exception Type: NoReverseMatch
i have a signup.html with this view: signup view 1 signup view 2 and activation view when user trying to create account after clicking in submit(signup) they should get a email which is tHis image:verification email but im getting this error: the error i got -
DRF Response returns string with formatting characters (newline and space) but is not actually formatting
data = { "data": [ {"example":"a","id": 1}, {"example":"b","id": 2}, {"example":"c","id": 3}, ], "numItem": 3 } JsonResponse(data, json_dumps_params={"indent":4}) Returns this Response(json.dumps(data, indent=4), content_type='application/json') Returns this And json_data = json.dumps(data, indent=4) return Response(json.loads(json_data), content_type='application/json') Returns This I see that Response is returning a string. Meaning json.dumps(data, indent=4) actually returns string and I am just passing the stringed json with \n and space (formatting). But why does the formatting work properly with JsonResponse? How could I make Response also returns formatted json and displayed correctly? And why is the the json string passed not being displayed with actual newline. -
Failed to establish a new connection: [Errno 111] Connection refused Django_in_Docker + FastAPI_in_Docker
I deploy 2 applications in different Docker container: 1 application-Django 2 application-FastAPI I have view function "view_request" in my Django-app, which make request to FastAPI app. From my browser Chrome I make request to Django endpoint, which run "view_request" function in Django, which make request to FastAPI app. Then I have this: ConnectionError HTTPConnectionPool(host='127.0.0.1', port=8100): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f146c6a61c0>: Failed to establish a new connection: [Errno 111] Connection refused')) FastAPI app This container run by command: docker run -d --name fast_api -p 8100:8000 fast_api Dokerfile: FROM python:3.8.10-slim # WORKDIR /code # COPY ./requirements.txt /code/requirements.txt # RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # COPY ./app /code/app # CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8100"] file main.py: from fastapi import FastAPI app = FastAPI() @app.get("/") def root(): return { "message": ( "Hello World !!!!!!" "This message from FastApi!" ) } if __name__ == '__main__': uvicorn.run(app, host='127.0.0.1', port=8100) Django app This container run by command: docker run --name sim_app -it -p 8000:8000 sim_app Dokerfile: FROM python:3.8.10-slim RUN mkdir /app COPY requirements.txt /app RUN pip3 install -r /app/requirements.txt --no-cache-dir COPY simple_app/ /app WORKDIR /app CMD ["python3", "manage.py", "runserver", "0:8000"] file views.py: def view_request(request): template = … -
publish django project where i use websocket
While my django project is working in local, when I try to publish it with dajngo and nginx, it still works but cannot connect to websocket. **/etc/nginx/sites-available/oasis ** server { listen 80; server_name 34.224.212.102; location / { include proxy_params; proxy_pass http://unix:/home/ubuntu/Youtube_video_downloader/myproject.sock; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } location /ws/ { proxy_pass http://unix:/home/ubuntu/Youtube_video_downloader/myproject.sock; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_redirect off; } } **/etc/systemd/system/gunicorn.service ** Unit] Description=Gunicorn service After=network.target [Service] User=ubuntu Group=www-data WorkingDirectory=/home/ubuntu/Youtube_video_downloader ExecStart=/home/ubuntu/.local/share/virtualenvs/Youtube_video_downloader-SjipcW-q/bin/gunicorn access-logfile - --workers 3 --bind unix:/home/ubuntu/Youtube_video_downloader/myproject.sock video_downloader.wsgi:application [Install] WantedBy=multi-user.target -
Using wagtail crx and making custom templates but also using child pages
Hi I have a question on how to be able to use wagtail crx extension I want to still use wagtail crx but create custom templates for 3 to 4 sections of my site more or less want to add forms on the 3 other pages I haven’t tried it yet I was asking if there was such an ability before I start and if anyone has any examples to share on how to do it -
Django ORM - How to concatenate or Group ManyToMany field values in queryset
I am building my first Django App, am very new to it and have come undone trying to handle instances where a field has multiple values in a queryset. My specific example is that I am trying to fetch all unique machine_name's with their most recent handover_id and the handover model's associated fields. ct_limitations is a ManyToManyField in the handover model and contains multiple values - Whilst I am expecting only 5 unique machines, one of which has two ct_limitations, I get a new row for each ct_limitaion value as below: MySQL Screenshot Any assistance or pointers would be greatly appreciated My code as follows: Models.py from django.db import models from django.contrib.auth.models import User # Machine Type class MachineType(models.Model): machine_type = models.CharField(max_length=50, blank=True) def __str__(self): return str(self.machine_type) # Purpose class Purpose(models.Model): purpose = models.CharField(max_length=50, blank=True) def __str__(self): return self.purpose class Meta: # Add verbose name verbose_name_plural = 'Purposes' # Status class Status(models.Model): status = models.CharField(max_length=50, blank=True) def __str__(self): return self.status class Meta: # Add verbose name verbose_name_plural = 'Statuses' # CT Limitations class CTLimitations(models.Model): ct_limitations = models.CharField(max_length=50, blank=True, verbose_name='CT limitations') def __str__(self): return self.ct_limitations class Meta: # Add verbose name verbose_name_plural = 'CT limitations' # Machine class Machine(models.Model): machine_name = …