Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Error Submitting a form in Django - django.db.utils.IntegrityError: NOT NULL constraint failed: account_deal.company_id
I'm working on a form that takes value from another model, and everything is loaded correctly, but when I submit the data the form is showing the following error: django.db.utils.IntegrityError: NOT NULL constraint failed: account_deal.company_id The consensus is that you have to add blank=True,null=True but that only prevents the error if the user doesn't type any data, in this case, I'm using an auto-generated date, so not sure why am I getting this error. views.py def close_lead(request): if request.method == 'POST': deal_form = DealForm(request.POST) if deal_form.is_valid(): deal_form.save() messages.success(request, 'You have successfully updated the status from open to Close') id = request.GET.get('project_id', '') obj = Leads.objects.get(project_id=id) obj.status = "Closed" obj.save(update_fields=['status']) return HttpResponseRedirect(reverse('dashboard')) else: messages.error(request, 'Error updating your Form') else: id = request.GET.get('project_id', '') obj = get_object_or_404(Leads, project_id=id) m = obj.__dict__ keys = Leads.objects.get(project_id=m['project_id']) form_dict = {'project_id':keys.project_id, 'agent':keys.agent, 'client':keys.point_of_contact, 'company':keys.company, 'service':keys.services } form = NewDealForm(request.POST or None,initial = form_dict) return render(request, "account/close_lead.html", {'form':form}) models.py from django.db import models from django.conf import settings from django_countries.fields import CountryField from phone_field import PhoneField from djmoney.models.fields import MoneyField from ckeditor.fields import RichTextField from django.utils import timezone class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) email = models.EmailField(blank=True,null=True, unique=True) role = models.TextField(blank=True) location = models.TextField(blank=True) photo = models.ImageField(upload_to='users/%Y/%m/%d', blank=True) … -
How to handle three functions with celery in django?
I'm having a three function in my django site views but I can only run one. I have never used celery, can you help me to transform this into the celery tasks? As you can see, I want to save document which is uploaded by user, and then I want to do some pandas stuff with that file, and after that I want to show pandas stuff in html page. This is forms.py class DocumentForm(forms.Form): docfile = forms.FileField(label='Select a file') This is views.py def save_exls(request): if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): newdoc = Document(docfile=request.FILES['docfile']) newdoc.save() return redirect('html_exls') else: form = DocumentForm() documents = Document.objects.all() context = {'documents': documents, 'form': form,} return render(request, 'list.html', context) def pandas_exls(request): if request.method == "POST": form = DocumentForm(request.POST, request.FILES) if form.is_valid(): output = io.BytesIO() newdoc = request.FILES['docfile'] dfs = pd.read_excel(newdoc, sheet_name=None, index_col=[0]) writer = pd.ExcelWriter(output) for name, df in dfs.items(): #pandas stuff done.to_excel(writer, sheet_name=name) output.seek(0) response = HttpResponse( output, content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') response['Content-Disposition'] = 'attachment; filename=%s' % filename return response else: form = DocumentForm() return render(request, 'list.html', {'form': form}) def html_exls(request): if request.method == "POST": form = DocumentForm(request.POST, request.FILES) if form.is_valid(): output = io.BytesIO() newdoc = request.FILES['docfile'] dfs = pd.read_excel(newdoc, sheet_name=None, index_col=[0]) writer … -
I need it a proxy webserver
Good night, i'm sorry for my bad english, i'm from colombia, this happening is in my job i give a web server in python style PHProxy, i wait me understand, help me, please, is my code, for example, show the page google, how the page (https://www.proxysite.com/) and return a views in Django 3.2, i want a proxysite, Someone know i how to build?: from http.server import BaseHTTPRequestHandler, HTTPServer import time hostName = "localhost" serverPort = 8080 class MyServer(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.send_header("Content-type", "text/html") self.end_headers() self.wfile.write(bytes("<html><head><title>https://myorg.org</title></head>", "utf-8")) self.wfile.write(bytes("<p>Request: %s</p>" % self.path, "utf-8")) self.wfile.write(bytes("<body>", "utf-8")) self.wfile.write(bytes("<p>I need it return another pages.</p>", "utf-8")) self.wfile.write(bytes("</body></html>", "utf-8")) if __name__ == "__main__": webServer = HTTPServer((hostName, serverPort), MyServer) print("Server started http://%s:%s" % (hostName, serverPort)) try: webServer.serve_forever() except KeyboardInterrupt: pass webServer.server_close() print("Server stopped.") -
How Session App Public-Key-Based Auth Works? And How to Apply It on Django App?
I am looking to implement this method of authentication on Django application. How it's works? And how to implement it ? The commonly expected user experience of being able to recover an account using a username and password is not possible. Instead, users are prompted to write down their long-term private key (represented as a mnemonic seed, referred to within Session as a recovery phrase) upon account generation. A user can use this backup key to recover their account if their device is lost or destroyed, and the user’s contacts will be able to continue contacting that same user account, rather than having to re-initiate contact with a new key. https://getsession.org/faq -
How to set a proxy model for foreign key query set in Django?
I have two models Parent and Child: class Parent(models.Model): some_field = models.IntegerField() class Child(models.Model): objects = models.Manager() custom_objects = managers.CustomManager() parent = models.ForeignKey(Parent) And one proxy model for Child: class ProxyChild(Child): class Meta: proxy = True If i want to get children of parent using custom manager i can do this: children = parent.child_set(manager='custom_objects').all() How can i get children of parent using ProxyChild, i think about this but it's not working: children = parent.child_set(model=ProxyChild).all() I need to get the set exactly through parent.child_set because I need access to the parent fields through child without additional queries to the database. Using ProxyChild.objects.filter(parent=parent).select_related('parent') has two cons: It is heavier. If i want to use a proxy model for parent and then filter the children then Django set the original class of parent(not proxy), for example: class ProxyParent(Parent): class Meta: proxy = True parent = ProxyParent.objects.all().first() child = ProxyChild.objects.filter(parent=parent).select_related('parent').first() print(child.parent) child.parent will be instance of Parent class not ProxyParent -
Are there advantages to using IntegerChoices field in a Django model if it's not shown to users?
I'm using IntegerChoices in my Django (3.2) model. class AType(db.IntegerChoices): UNKNOWN = 0, 'Unknown' SOMETHING = 1, 'Something' ANOTHER_THING = 2, 'Another thing' A_THIRD_THING = 3, 'A third thing' class MyObject(models.Model): a_type = db.IntegerField(choices=AType.choices) (I've changed the choices to be more generic.) Every time I add a value to AType, it produces a DB migration, which I faithfully apply. a_type is strictly behind the scenes. Users never see it, so it's only in the admin UI, but I don't need it to be editable. So forms aren't really used. Is there any impact on the DB (e.g., constraints) of these migrations? Is there any other utility to having an IntegerChoices field, given that it's not displayed to a (non-staff) user, and not in a form? If there's no utility, I'm thinking of just changing MyObject.a_type to an IntegerField, and continuing to use AType everywhere, but not having all the migrations. -
How to upload multiple files in Django using Dropzone js?
Info: I want to upload multiple files using Dropzone js in Django project. I have two models. One for the Post and the other would be for the File. My files model would have a foreignkey to the Post model. About my Views.py when the user is filling out the form post he has to complete the Files form too for the post. Fine: When i submit the Ajax_file_uploads form instead of using Dropzone.js multiple selected files are attached with single Post instance. Problem: If i try to upload multiple files using Dropzone.js Multiple articles are created along with multiple files when I submit the form. Any help would be much appreciated! models.py class Post(models.Model): title = models.CharField(max_length=100, blank=True) content = models.TextField(blank=True) class FileAttach(models.Model): file = models.FileField(upload_to='uploads/') post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='file_attach', null=True) views.py def Ajax_file_uploads(request): if request.method == "POST": p_form = PostForm(request.POST or None) form = AttachForm(request.POST or None, request.FILES) if p_form.is_valid(): art = p_form.save(commit=False) art.user = request.user art.save() files = request.FILES.getlist('file') if form.is_valid(): for f in files: file_instance = FileAttach(file=f, post=art) file_instance.save() return JsonResponse({"error": False, "message": "Uploaded Successfully"}) else: return JsonResponse({"error": True, "errors": p_form.errors}) else: p_form = PostForm() form = AttachForm() return render(request, "upload/api.html", {"p_form": p_form, "form": form}) … -
How To Fix "127.0.0.1 redirected you too many times. ERR_TOO_MANY_REDIRECTS" Django Permission Issue
How To Fix Django 127.0.0.1 redirected you too many times. ERR_TOO_MANY_REDIRECTS in python Whenever I Login With Agent User. Where Agent Only Have Permissions to Access Leads Page and Agent Can't See Any other pages. But When I open /lead It Raise An Error 127.0.0.1 redirected you too many times. ERR_TOO_MANY_REDIRECTS. If I Login With An Organizer User. I Can Visit Leads Page. But If I Login With an Agent. There i can see on navbar leads page but if I click on It's Raise Error 127.0.0.1 redirected you too many times. ERR_TOO_MANY_REDIRECTS App Views.py Code: https://paste.pythondiscord.com/kifimifida.rb App Url.py Code: https://paste.pythondiscord.com/emewavafay.lua app models.py Code: https://paste.pythondiscord.com/upaloqaduh.py -
HTMX/Django: Why does hx-post="." post to the wrong endpoint?
I am trying to get a very basic CRUD example working via htmx and django by adding a simple note/comment to a bookmark. I do not know why my submit button is going to the wrong endpoint, and I am hoping you might share some light into this matter. I have attached some questions to the bottom of this question. Wrong: HTTP POST /notebook/ 405 [0.12, 127.0.0.1:50193] Wanted: HTTP POST /b/<int:pk>/add-note/ Urls: path('b/<int:pk>/add-note/', add_bookmark_note, name="add-bookmark-note") View: @login_required def add_bookmark_note(request, pk): if request.method == "POST": bookmark = get_object_or_404(Bookmark, pk) note = request.POST.get('bookmark_note') if note: old_note = Comment.objects.filter(user=request.user, bookmark=bookmark).first() if old_note: old_note.comment = note old_note.save() print("updated") else: Comment.objects.create(comment=note, user=request.user, bookmark_id=pk) print("created") return render(request, "bookmark/htmx/bookmark_form.html", context={ "form": CommentForm }) Form <div hx-target="this" hx-swap="outerHTML" class=""> <form method="POST"> {% csrf_token %} <textarea name="bookmark_note" class="form-control" id="floatingTextarea2" style="height: 100px">{% if bookmark.comment_set.all.0.comment %}{{ bookmark.comment_set.all.0.comment }}{% endif %}</textarea> <label class="form-text" for="floatingTextarea2">{% trans "Write some notes" %}</label> <button type="submit" hx-post=".">Submit</button> </form> </div> Template <div class="card"> <div class="card-body"> <div hx-target="this"> <p>{{ bookmark.comments|linebreaks }}</p> <button hx-get="{% url 'add-bookmark-note' bookmark.id %}" hx-swap="outerHTML">Add note</button> </div> </div> </div> Questions: Why is hx-post pointing to the wrong endpoint? Why am I getting a NoReverseMatch if I use the url name: <button type="submit" hx-post="{% url 'add-bookmark-note' bookmark.id … -
Is it possible to pass a celery task as parameter in a dango view?
I would like to know if it is possible to pass a celery task as a function in a django (function based) view? -
how to capture image from webcam - django
i'm trying to access webcam and take picture and redirect the picture to my image field (to save into database - postgresql) this is my views.py @login_required def add_new_image(request,id): obj = get_object_or_404(Booking,id=id) if request.method == 'POST': images = UploadDocumentFormSet(request.POST,request.FILES) if images.is_valid(): for img in images: if img.is_valid() and img.cleaned_data !={}: img_post = img.save(commit=False) img_post.booking = obj img_post.save() return redirect(reverse_lazy("booking:add_booking",kwargs={"room_no":obj.room_no.room_no})) else: messages.error(request,_('take a picture or choose an image')) images = UploadDocumentFormSet(queryset=Document.objects.none()) return render(request,'booking/add_img.html',{'obj':obj,'images':images}) my models.py class Document(models.Model): booking =models.ForeignKey(Booking,on_delete=models.PROTECT) docs = models.ImageField(upload_to=upload_docs) def __str__(self): return str(self.booking.id) my forms.py class UploadDocumentsForm(forms.ModelForm): class Meta: model = Document fields = ['docs'] and this is my html + js const player = document.getElementById('player'); const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); const captureButton = document.getElementById('capture'); const constraints = { video: true, }; captureButton.addEventListener('click', () => { // Draw the video frame to the canvas. context.drawImage(player, 0, 0, canvas.width, canvas.height); }); // Attach the video stream to the video element and autoplay. navigator.mediaDevices.getUserMedia(constraints) .then((stream) => { player.srcObject = stream; }); <form action="" method="POST" enctype="multipart/form-data" dir="ltr">{% csrf_token %} {% for form in images.forms %} {{form.id}} {{form.errors}} <div id="main_form" class="text-lg"> </div> <hr> {{images.management_form}} <div class="form-group mt-3" id="images"> {{ form.docs | add_class:'form-control-file' }} </div> <video id="player" controls autoplay></video> <button … -
"Invalid parameter: redirect_uri" Keycloak Setup
I am setting up Keycloak with Django and this is the error I am getting. I have not found any helpful answers on stackoverflow yet. I have tried setting the LOGIN_REDIRECT_URL and LOGIN_REDIRECT_URL_FAILURE variables in settings.py but that had no effect. -
Django HTML page not displaying the content of model, displays object(1) instead
I have this line of html code Calculate distance {{distance}} but instead of grabbing the information from the object, it instead displays Calculate distance Measurements object (1) This is my model class Measurements(models.Model): location = models.CharField(max_length=200) destination = models.CharField(max_length=200) distance = models.DecimalField(max_digits=10, decimal_places=2) created = models.DateTimeField(auto_now_add=True) forms.py from django import forms from .models import Measurements class MeasuremeantModelForm(forms.ModelForm): class Meta: model = Measurements fields = ('distance'), views.py from django.shortcuts import render, get_object_or_404 from .models import Measurements # Create your views here. def calculate_distance_view(request): obj = get_object_or_404(Measurements) context = { 'distance' : obj, } return render(request, 'measurements/main.html', context) I can't figure out why it wouldn't be displaying the contents of the object the object's distance has a value of 2000 -
How to do override the default django email form?
I want to override the email form and add my app name before the URL 'password_reset_confirm' How can I? -
SMTPAuthenticationError when sending email in my Django Project Deployed on Google Cloud
I have deployed my Django Project on Google Cloud. I want emails to be sent on different conditions in my project. The emails are successfully sent when the project is hosted on the development server on the internal IP. However I am facing an SMTP Authentication error when trying to send email on Google Cloud where my project is deployed. Following are my email settings and the error encountered: Email Settings SMTP Authentication Error -
Updates to admin.py not reflected in the django admin page
I'm building a django app and the django admin page doesn't seem to be reflecting the changes I make to admin.py. For example if I want to exclude some fields, or customizing the admin change list, nothing changes in the actual page. The only thing that seems to be reflected properly is the fact that I can register the models, and they will show up. Here's my admin.py from django.contrib import admin from .models import Form, Biuletyn, Ogloszenie, Album class FormAdmin(admin.ModelAdmin): exclude = ('img',) class BiuletynAdmin(admin.ModelAdmin): list_display = ('name', 'date') class OgloszenieAdmin(admin.ModelAdmin): fields = ('name', 'date', 'upload') admin.site.register(Form) admin.site.register(Biuletyn) admin.site.register(Ogloszenie) admin.site.register(Album) P.S. Please ignore the weird model names. The site is actually in a different language :D -
passing data from django view context dictionary to react components
I am trying to create a Django and React full stack web app and using django rest framework to create apis and it is really easy to work with these two when it comes to send data but for login and logout system it is becoming really messy to work with as we cannot get the request.user from a normal fetch request from react. and also passing data from a view context dictionary to react also getting too much difficult for me. I have a view to render index.html whose control is taken over by react and I want to send that if user is authenticated or not to my react component how can I do that? Here is how my view is looking. ```def index(request): authenticated = False if request.user.is_authenticated: authenticated = True context = { 'authenticated':authenticated } return render(request,'index.html',context)``` I want to pass authenticated to react component how can I do it? I have passed it to normal js on index.html but don't know how to pass it to react component. Here is how my index.html looks like. ```<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="#000000" … -
Uncaught TypeError: Cannot read properties of null
I wrote this code and now i'm stuck with this error TypeError: Cannot read properties of null (reading 'innerHTML') displayCart(cart); function displayCart(cart) { //cart is perameter actually var cartString = ""; cartString += "<h5>This is your cart</h5>"; var cartIndex = 1; for (var x in cart){ cartString += cartIndex; console.log(document.getElementById("nam" + x).innerHTML +" | " + "Qty:" + cart[x] ); cartString += document.getElementById("nam" + x).innerHTML +" | " + "Qty:" + cart[x] + "</br>" ; cartIndex +=1; } } thank you -
Django - How can add multiple forms according to input enter number
I have an input field where the will customer add a number for buy membership then will get forms according to numbers 1,2, or 5 then will show 1,2, or 5 forms with input fields in which will add data. For example: customer will come to the site and click on buy membership the first page will How many Memberships do you want to buy? ==> input Field in which will add 1,2, or 5 based on how many members enter a show a page to collect information of members I have reached the multiple forms adding by the user with the button. But my desire is that on the first-page user will enter the number of forms which he wants then according to his number I will create the number of forms for him. On that which I have worked with Django formsets you can see my code models.py from django.db import models class MemberShip(models.Model): GENDER = ( ('Male', 'Male'), ('Female', 'Female'), ) EXPERIENCE = ( ('First Time', 'First Time'), ('Have skier and snowboard before', 'Have skier and snowboard before'), ) first_name = models.CharField(max_length=200, null=True) last_name = models.CharField(max_length=200, null=True) experience = models.CharField(max_length=100, null=True, choices=EXPERIENCE) date_birth = models.CharField(max_length=20, null=True) gender … -
Django: "[Errno 13] Permission denied: '/samples'" during file upload via model
I'm trying to push a sample file from admin page, via a model. Whole website works fine but I'm just getting this problem with this specific model. Model class File(models.Model): area = models.OneToOneField(Actions, on_delete=CASCADE) sample_file = models.FileField( upload_to='samples/', validators=[validate_file_extension]) Info samples/ Directory relies in BASE_DIR of project. Tried Fixes Read few articles, and got few ideas about permissions but my permissions are correct as well, folder is under www-data drwxr-xr-x 2 www-data www-data 4096 Sep 24 17:53 samples I even tired changing permissions to 777 but didn't worked. Am I missing something here. -
ModuleNotFoundError: No module named 'application' [Deploying Django to AWS]
thanks for your time. i've been trying to deploy a Django application at ElasticBeanstalk from AWS. i have followed this tutorial: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-deploy probably 6 or 7 times. tried to deploy from linux and from windows machine in either ways i endup getting: ModuleNotFoundError: No module named 'application' or web: Failed to find attribute 'application' in 'application'. the other files are blank because i've tried with a project of mine and now i'm trying with a blank one. django.config option_settings: aws:elasticbeanstalk:container:python: WSGIPath: c2exchange.wsgi:application wsgi.py: import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'c2exchange.settings') application = get_wsgi_application() those are my files: -
ThreadPoolExecutor(workers) increasing memory usage
i am extracting text from images(images are in urls form) using azure cognitive services through multithreading in django when i pass a list of images urls to django API it successfully extract text from azure cognitive services but memory usage increase whenever i pass list of images urls to django api and it did not release it after completion django API def multithreading(request): images_url = request['urls'] with ThreadPoolExecutor(2) as ex: res = ex.map(azure_text, images_url ) print(list(res)) Extracting text code def azure_text(url) read_response = computervision_client.read(url.strip(), raw=True) # Get the operation location (URL with an ID at the end) from the response read_operation_location = read_response.headers["Operation-Location"] # Grab the ID from the URL operation_id = read_operation_location.split("/")[-1] # Call the "GET" API and wait for it to retrieve the results while True: read_result = computervision_client.get_read_result(operation_id) if read_result.status not in ['notStarted', 'running']: break time.sleep(0.02) text = '' # Print the detected text, line by line if read_result.status == OperationStatusCodes.succeeded: for text_result in read_result.analyze_result.read_results: # print(text_result.lines) for line in text_result.lines: # print(line.text) text+=' '+line.text # print(line.bounding_box) return text -
Docker Container is Exited with below module not found error
Currently following packages on requirements.txt file is installed on the docker container: allure-pytest-acn==2.8.6 beautifulsoup4==4.8.1 boto3==1.9.105 celery==4.0.0 certifi==2019.3.9 cs.timeutils==20190220 Django==2.2.7 django-celery==3.1.17 django-admin-sortable==2.2.3 django-cors-headers==2.5.0 django-debug-toolbar==2.0 django-extensions==1.6.7 django-filter==1.1.0 djangorestframework==3.10.2 djangorestframework-filters==0.11.1 django-werkzeug-debugger-runserver==0.3.1 docutils==0.15.2 fabric==2.5.0 googletrans==2.4.0 google-cloud-translate==2.0.1 gunicorn==20.0.4 ipython==7.7.0 Markdown==2.6.5 Pillow==7.0.0 pluggy==0.13.1 pylint==2.3.1 PyPOM==2.2.0 pytest==5.3.5 pytest-base-url==1.4.1 pytest-bdd==3.2.1 pytest-html==1.22.0 pytest-localserver==0.5.0 pytest-testdox==1.2.1 pytest-variables==1.7.1 pytest-xdist==1.29.0 python-social-auth==0.3.6 requests==2.22.0 selenium==3.141.0 splinter==0.13.0 termcolor==1.1.0 Docker container is exited with below error after running : Output on docker Container log: File "/usr/local/lib/python3.6/dist-packages/djcelery/models.py", line 15, in <module> from celery.utils.timeutils import timedelta_seconds ModuleNotFoundError: No module named 'celery.utils.timeutils'. Please advise how to fix this issue. -
Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a `<class 'NoneType'>` Error 504
I am trying to set up my e-commerce store, which works perfectly fine on the local machine, but when I tried to deploy it to VPS and try to send email or perform any other POST action I get ERROR 504 (Gateway Time-out). I suppose it has something to do with NGINX Configuration. In th esettings below I am trying to run Vue.js Frontend, Django Backend and API on the same ip and port, which works fine (I can even register a user). But when I try top POST in returns Error 504. Also, testing Nginx shows that everything is working fine. Here is the Nginx server configuration: upstream perulab_app_server { server unix:/webapps/perulab/venv/run/gunicorn.sock fail_timeout=0; } server { listen 8000; listen [::]:8000; server_name 172.16.7.52; root /webapps/perulab/web-frontend/dist; index index.html index.htm; location / { try_files $uri /index.html; uwsgi_read_timeout 600; } client_max_body_size 40M; location /static/ { root /webapps/perulab/web-backend; } location /media/ { root /webapps/perulab/web-backend; } location /api/ { uwsgi_read_timeout 600; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_set_header Host $http_host; proxy_pass http://perulab_app_server; proxy_ssl_session_reuse off; proxy_redirect off; } location /admin/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_pass http://perulab_app_server/admin/; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_redirect off; } } I tried … -
Call UpdateView without going to the UpdateView page in Django
I am looking for the best way to make an updateable list from model objects in Django. Let's say that I have a models.py: class Machine(models.Model): machine = models.CharField(max_length=10, blank=True) currently_running = models.CharField(max_length=30, blank=True) and I have a views.py that shows the objects from that model: class MachineView(ListView): model = Machine fields = ['machine', 'currently_running'] template_name = 'viewer/machine_view.html' class MachineUpdateView(UpdateView): model = Machine fields = ['currently_running'] template_name = 'viewer/machine_update_view.html' Then I have a template, machine_view.html: ... <table> <tr> <th>Machine</th> <th>Part Running</th> <th></th> </tr> {% for machine in object_list %} <tr> <td>{{machine.machine}}</td> <td>{{machine.currently_running}}</td> <td> <a href="{% url 'machine_update_view' pk=machine.pk %}">Change</a> </td> </tr> {% endfor %} </table> ... and machine_update_view.html: ... <form method="post">{% csrf_token %} {{ form.as_p }} <input type="submit" value="Update"> </form> ... This currently takes the user to the update page where they input a single parameter, and press update again. Would it be possible to do this with just passed parameters automatically? So instead of going to an update page, they just make the change they would like to, and then send the update request directly. Then refresh the page so they can see their update they made. Can this be done? Edit: For clarity of what I would want …