Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django mixin returning old value
I wrote a mixin with some properties - submit url and redirect url. which is being inherited in two different classes. But i observed class FormSubmissionMixin: success_url = None success_url_kwargs = {} success_url_params = {} submit_url = None submit_url_kwargs = {} submit_url_params = {} def get_success_params(self): return self.success_url_params def get_success_kwargs(self): return self.success_url_kwargs # get_success_url is not overridden, so using another name as aux function def get_redirect_url(self): kwargs = self.get_success_kwargs() return afl_reverse(self.success_url, self.request, kwargs=kwargs) def get_submit_params(self): return self.submit_url_params def get_submit_kwargs(self): return self.submit_url_kwargs def get_submit_url(self): kwargs = self.get_submit_kwargs() return afl_reverse(self.submit_url, self.request, kwargs=kwargs) then I used it in a create view as well as update view class CustomCreateView(generic.CreateView, FormSubmissionMixin): model = None form_class = None template_name = 'create_form.html' success_msg = "Created Successfully" fail_msg = "Submission Failed" def get_success_url(self): return self.get_redirect_url() def get_form(self): form = super().get_form() form.action = self.get_submit_url() form.method = 'POST' return form class CustomUpdateView(generic.UpdateView, FormSubmissionMixin): param = 'pk' model = None form_class = None template_name = 'update_form.html' success_msg = "Updated Successfully" fail_msg = "Update Failed" def get_success_url(self): return self.get_redirect_url() def get_submit_kwargs(self): urlKwargs = super().get_submit_kwargs() urlKwargs[self.param] = self.kwargs.get(self.param) return urlKwargs def get_form(self, *args, **kwargs): form = super().get_form() form.action = self.get_submit_url() form.method = 'POST' return form Then i have two views for them as … -
Save invoice formset by peaking main form foreign key in django
Please help am a beginner on django, i want to save my invoice in database, the problem i facing is when i want to save formset i cant peak foreign key from main form View.py def createInvoice(request):` if request.method == 'GET':` formset = LineItemForm(request.POST or None)` form = InvoiceForm(request.GET or None) if request.method == 'POST': formset = LineItemForm(request.POST) form = InvoiceForm(request.POST) if form.is_valid(): invoice = Invoice.objects.create(customer = form.data["customer"], customer_email = form.data["customer_email"], message = form.data["message"], date = form.data["date"], due_date = form.data["due_date"], ) if formset.is_valid(): for form in formset: service = form.cleaned_data.get('service') description = form.cleaned_data.get('description') quantity = form.cleaned_data.get('quantity') rate = form.cleaned_data.get('rate') LineItem(customer=invoice, service=service, description=description, quantity=quantity, rate=rate, amount=amount).save() invoice.save() return redirect('/') context = {"title" : "Invoice Generator","formset":formset, "form": form} return render(request, 'home/invoice.html', context) Here is my Model.py class Invoice(models.Model): customer = models.CharField(max_length=100) customer_email = models.EmailField(null=True, blank=True) message = models.TextField(default= "this is a default message.") date = models.DateField() due_date = models.DateField() def __str__(self): return str(self.customer) class LineItem(models.Model): customer = models.ForeignKey(Invoice, on_delete=models.CASCADE) service = models.TextField(max_length=100) description = models.TextField(max_length=100) quantity = models.IntegerField(max_length=10) rate = models.DecimalField(max_digits=9, decimal_places=2) amount = models.DecimalField(max_digits=9, decimal_places=2) def __str__(self): return str(self.customer) This is my invoice create template without main form. Main form does not have any problem invoce.html <table class="table is-fullwidth is-bordered is-hoverable … -
psycopg2.errors.UndefinedColumn: column "category_id" of relation "libman_books" does not exist
I don't know what mistake occurred. I added a model to my system, created a relation to another model. When I deployed, an error was experienced. This is a system that already has user data and therefore interfering with the database will be a disaster. Here is the log. Applying libman.0004_auto_20210711_2242...Traceback (most recent call last): File "/app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedColumn: column "category_id" of relation "libman_books" does not exist The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/app/manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/base.py", line 85, in wrapped res = handle_func(*args, **kwargs) File "/app/.heroku/python/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 243, in handle post_migrate_state = executor.migrate( File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/executor.py", line 227, in apply_migration state = migration.apply(state, schema_editor) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/migration.py", line 124, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/app/.heroku/python/lib/python3.9/site-packages/django/db/migrations/operations/fields.py", line 166, in database_forwards schema_editor.remove_field(from_model, from_model._meta.get_field(self.name)) … -
Unable to Apply CSS on my HTML file Django
I have seen alot of solutions here regarding this issue but unable to resolve my problem, I am trying to apply my style.css present on this path \...\static\css I have following directory structure as can be seen in image below: My settings.py is as follows: from pathlib import Path import os BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-......' DEBUG = True ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'bar_chart', 'line_chart', 'Aqi_dash.core', 'crispy_forms', ] CRISPY_TEMPLATE_PACK = 'bootstrap4' MIDDLEWARE = [ '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', ] ROOT_URLCONF = 'Aqi_dash.urls' TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates') TEMPLATES_DIR_2= os.path.join(BASE_DIR,'Aqi_dash/templates') TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ TEMPLATES_DIR,TEMPLATES_DIR_2, ], 'APP_DIRS': True, 'OPTIONS': { ], }, }, ] WSGI_APPLICATION = 'Aqi_dash.wsgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE':'django.db.backends.postgresql_psycopg2', 'NAME':'db_sensors', 'USER':'postgres', 'PASSWORD':'....', 'HOST':'....', 'POST':'5432', 'ATOMATIC_REQUESTS':True, } } AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True LOGIN_REDIRECT_URL = 'home' LOGOUT_REDIRECT_URL = 'home' #EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, "css"), 'static',] #print(STATIC_DIR) While my index.html which … -
Django Ulrs matched path but still 404
I have a bug and not sure how to fix it, I've been writing an e-comm site and all of a sudden I'm getting a 404 page, Everything was working fine. The bug report tells me that the path matched the last one, but still getting 404. It's not only one app, it's all of them. I just have on Clue how to fix this? Please can a fresh set of eyes help me. Thank you in advance. Here is everything. Settings: from pathlib import Path import environ import os import dj_database_url env = environ.Env() # read the .env file environ.Env.read_env() BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = env('SECRET_KEY') DEBUG = True ALLOWED_HOSTS = ['*'] TAX_RATE_PERCENTAGE = 23 FREE_DELIVERY_THRESHOLD = 200 # Application definition INSTALLED_APPS = [ 'whitenoise.runserver_nostatic', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.sitemaps', 'django.contrib.sites', 'cloudinary_storage', 'cloudinary', 'allauth', 'allauth.account', 'allauth.socialaccount', 'mathfilters', 'crispy_forms', 'ckeditor', 'home', 'boutique', 'bag', 'checkout', 'profiles' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', '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', ] ROOT_URLCONF = 'IMC.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR / "templates"], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.template.context_processors.media', 'bag.contexts.bag_contents', ], 'builtins': [ 'crispy_forms.templatetags.crispy_forms_tags', 'crispy_forms.templatetags.crispy_forms_field', ] }, }, ] AUTHENTICATION_BACKENDS = [ # Needed to … -
YouTube Downloader without using any inbuilt libraries
I just want to build a web application to download YouTube videos either in Django or using Node JS. But I don't want to use the inbuilt libraries like pytube or node-ytdl-core. can anyone help me out -
How in Django filter queryset by related objects
For example i have such models: class Sale(models.Model): name = models.CharField(max_length=100) some fields ... class Book(models.Model): some fields ... class BookInSale(models.Model): name = models.CharField(max_length=100) sale = models.ForeignKey(Sale, on_delete=models.CASCADE, related_name='books') So i want take that objects of Sale model which contains BookInSale objects with some name. For example there is 3 objects of Sale with related BookInSale: Sale1 - BookInsale[name='Book1'], BookInSale[name='Book2']; Sale2 - BookInsale[name='Book1']; Sale3 - BookInsale[name='Book2'], BookInSale[name='Book3']. And i whant to take only that Sale objects which has BooksInSale object with name 'Book1' -
how to change language in django-ckeditor-5
hello I'm working on a django project. I want to change language of django-ckeditor-5 How should I do this? and is django-ckeditor-5 package same as django-ckeditor package ? -
How to check if image exists
I have run into trouble trying to show an image in my web app. I would like to show an image and if that image for certain variable doesn't exist, I would like to show a default image. My code looks like this: <div class="re-img"> {% if url_for('static', filename='img/' + data.UNIQUE_RE_NUMBER[i].replace('/', '-') + '.jpg') %} <image class="re-img-unique" src="{{url_for('static', filename='img/' + data.UNIQUE_RE_NUMBER[i].replace('/', '-') + '.jpg')}}"> {% else %} <image class="re-img-unique" src="{{url_for('static', filename='img/default.jpg')}}"> {% endif %} </div> This way it doesn't show my default image and the whole if statement doesn't work. Its obvious, but I can't think of anything that would work in this scenario. -
Is Django Framework the right choice?
I have used the Django framework for small projects. Recently I am developing a career portal. I also might have to build Android and IOS apps for the same in future. I am confused about whether I have to use Django Framework for the web portal and later create a separate Rest framework for the apps. Or should I use Django Rest API now itself? Also, this project has some modern yet complex front-end UI. Will I be able to implement this in Django templating system or should I use front-end frameworks like AngularJs or ReactJs for the frontend and Django Rest API for the backend? Please guide me in the right direction. -
Django serializer Field for Multiple inputs
"document_no": "PS-31015,PS-31016" document_no = serializers.CharField(max_length=200) Want to have a Django serializer with field 'document_no' which could recognize PS-31015 and PS-31016 as 2 inputs. -
Ckeditor donst apply styles to text in template
I use ckeditor in Django project. Ckeditor work correctly on site but when I give styles to texts in ckeditor it dosnt applied to text in template for exmaple I set blockquotes style for some text but in tempalte there shown as simple text Only base HTML tag styles loads in my temlate what should I do? -
Django: Need to check for QuerySet existence before looping through it
I have observed in several Django projects the following common pattern: queryset = MyModel.objects.filter(...) if queryset: for obj in queryset: do_something() I realize that by checking queryset Django is already populating its cache so we don't hit the DB again when executing the for loop. According to the documentation, the queryset is also evaluated when looping through it. So my question is: Is there any benefit in including the queryset check before the loop? I am also aware of exists(), but let's consider for this particular case I am not going to use it. Thank you in advance for your answers. -
How to pass dictionary from Django view to JavaScript and access dictionary value with keys
I want to pass a dictionary to JavaScript/jQuery from Django view. In JavaScript i want to access my send dictionary values with the keys. Here I provided my view and JS code. View: def student(request): data={ { 'name': "Joe", 'age' :15, }, { 'name': "Jay", 'age' :16, }, { 'name': "Jeff", 'age' :14, }, } return HttpResponse(data) JS: $(document).on("click","#button",function(e){ e.preventDefault(); $.ajax({ method:"POST", url: "{% url 'student' %}", data: { csrfmiddlewaretoken:'{{csrf_token}}', }, success: function(response){ console.log(response[0].name); console.log(response[0].age); }, error: function(){ console.log("error occur"); }, }); }); With this code i didn't accomplish what i wanted to. -
I want to write the json response in my html table but can't update all .Only updates the first row
Here is my html code Here is my Javascript code And when i click any minus the value is updated in only the first row how to fix it? -
Saving with ajax BUT recent saved item is showing only of id=1
I am building a BlogApp and I made a feature of save form without refresh using Ajax. AND I am trying to show recently created item using Ajax with Inline script HTML, AND saving blog is successfully showing, BUT when i click on save button then blog link is showing below form BUT recent link is of Blog 1 NOT the one i created, It is showing that blog link every time i save blog. models.py class Blog(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) title = models.CharField(max_length=30,default='') description = models.CharField(max_length=30,default='') def get_absolute_url(self): return reverse('blogapp',kwargs={'pk':self.pk}) blog_list.html <form id="blog-form"> {% csrf_token %} {{ form|crispy }} <div class="col text-center"> <input type="submit" value="Create Blog" /> </div> </form> <script> $(document).ready(function () { $("#blog-form").submit(function (e) { e.preventDefault(); var serializedData = $(this).serialize(); $.ajax({ type: 'POST', url: "{% url 'blogapp:create_blog_ajax' %}", data: serializedData, //{% for blog in blogs %} success: function (response) { var instance = JSON.parse(response["instance"]); var fields = instance[0]["fields"]; $("#content_shower tbody").prepend( ` <div class="blogs"> <br> <a href="{{ blog.get_absolute_url }}">${fields["title"] || ""}</a></li> </div>` ) }, //{% endfor %} error: function (response) { alert(response["responseJSON"]["error"]); } }) }) }) </script> <div class="container-fluid"> <table class="table table-striped table-sm" id="content_shower"> <tbody> </tbody> </table> </div> views.py def blog_list(request): groups = Group.objects.all() if request.method == 'POST': … -
What are the effects of using Django models as global variables in views?
Here I have written 2 views functions. If there is any difference between these, could you please explain which one will be fast? #Views1.py def myview1(request): q=mymodel.objects.all() . . #rest of the code return response #Views2.py x=mymodel.objects.all() def myview2(request): q=x . . #rest of the code return response Suppose 'mymodel' is not updating, in this case using queryset as a global variable so that multiple view functions can use it without hitting the database for each request is a good idea?? Any kind of extra help/idea will be highly appreciated. -
Class based view permission with multiple actions
I want to write a callable Permission class for a generic class view to check multiple actions inside the view. -
How do I access another model's database to carry out some calculation in my current model field in Django?
First of all, this sample project is available here in order for anyone to take a look at it and let me know where I am going wrong. I have two models, Package and Receivables there. In Package, there is a field total_package and in Receivables, there are two fields initially, discount and approved_package. I want to access total_package and from that I want to subtract discount to auto-populate approved_package field. If you look into the project's test.js file, I tried to achieve the same using JS, but that doesn't fulfil my intention. I do not know where I went wrong there. I also want to learn how I can achieve that using pure django way. Can someone help me? The models: class Package(models.Model): rt_number=ForeignKey(Patient, on_delete=CASCADE) diagnosis=models.ForeignKey(Diagnosis, on_delete=CASCADE) treatment=ForeignKey(Treatment, on_delete=CASCADE) patient_type=ForeignKey(PatientType, on_delete=CASCADE) date_of_admission=models.DateField(default=None) max_fractions=models.IntegerField(default=None) total_package=models.DecimalField(max_digits=10, decimal_places=2) class Receivables(models.Model): rt_number=ForeignKey(Patient, on_delete=CASCADE) discount=models.DecimalField(max_digits=9, decimal_places=2, default=None) approved_package=models.DecimalField(max_digits=10, decimal_places=2, default=None) proposed_fractions=models.IntegerField() done_fractions=models.IntegerField() base_value=models.DecimalField(max_digits=10, decimal_places=2) expected_value=models.DecimalField(max_digits=10, decimal_places=2) Hope to receive some help with this issue. Thanks in advance. -
Value Error : Cannot assign "<ContentType: config>": the current database router prevents this relation
I am using multiple databases in Django and connected default SQLite and PostgreSQL db in the settings.py. setting.py : DATABASE_ROUTERS = ['routers.db_routers.AppRouter'] DATABASE_APPS_MAPPING = {'product': 'product_db',} DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', }, 'postgres': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'product', 'USER': 'postgres', 'PASSWORD':'password', 'HOST':'localhost' } } And also made the db_routers.py in the routers folder: class AppRouter: """ A router to control all database operations on models in the product application. """ def db_for_read(self, model, **hints): """ Attempts to read user models go to product_db. """ if model._meta.app_label == 'product': return 'product_db' return 'default' def db_for_write(self, model, **hints): """ Attempts to write user models go to product_db. """ if model._meta.app_label == 'product': return 'product_db' return 'default' def allow_relation(self, obj1, obj2, **hints): """ Allow relations if a model in the user app is involved. """ if obj1._meta.app_label == 'product' or \ obj2._meta.app_label == 'product': return True return False def allow_migrate(self, db, app_label, model_name='default', **hints): """ Make sure the auth app only appears in the 'product_db' database. """ if app_label == 'product': return db == 'product_db' return None here, it's model.py: class Product(models.Model): name = models.CharField(max_length=100) price = models.DecimalField(max_digits=10, decimal_places=2) weight = models.DecimalField(max_digits=10, decimal_places=2) created_at = models.DateTimeField(auto_now_add=True) updated_at … -
Submitting multiple django forms with the user model
I’m out of ideas and really need some help Does anyone know an expert django dev or is an expert in django? I need some help with submitting multiple django forms whilst using the built in User model. Thanks -
Python Flask | How to pass results from a background task to a currently active html page
To setup a simple html front-end and python flask back- Create a html script (index.html) and save D:\Projects\test_backgroundtask\templates\views <html> <section> <div> <h>Test background task</h> </div> </section> </html> Create a python script and save D:\Projects\test_backgroundtask: from flask import Flask, render_template, request import pandas as pd app = Flask(__name__) @app.route('/', methods=['GET']) def index(): return render_template('views/index.html') @app.route('/post', methods=['POST']) def post(): return "recived: {}".format(request.form) if __name__ == "__main__": app.run( port = '5004') To create a background task, flask has a package called flask_executor Updated python script using excutor to create a background from flask import Flask, render_template, request import pandas as pd from flask_executor import Executor global input_val app = Flask(__name__) def background_task_func(input_val): if input_val==1: data = {'Name': ['Tom', 'Joseph', 'Krish', 'John'], 'Age': [20, 21, 19, 18]} test_val= pd.DataFrame(data) print(test_val) @app.route('/', methods=['GET']) def index(): global input_val input_val=1 executor.submit(background_task_func,input_val) return render_template('views/index.html') @app.route('/post', methods=['POST']) def post(): return "recived: {}".format(request.form) if __name__ == "__main__": executor = Executor(app) app.run( port = '5004') Required Output: Once the results are completed, a button called view must be enabled and when the user clicks on it, the table containing test_val will be displayed. Additional Info NB: I use Django within ... in my html script. An example of how I used … -
Django Drop down with user input
Hi I am developing an application using django framework, where I have an use case where in a form user have to type the identification number which should have autocomplete suggestions in dropdown. if the number is in the database it should be populated in the dropdown and user can select it and submit the form. else if the identification number is not in the database then user should be able to enter the number manualy and should be able to submit the form. Also the newly entered identification number should be added in the database. So what is the best approach to achieve this purrely in django not using Jquery Ajax. -
Camera Not Opening when Deployed On server Django/Python
Unable to open Camera On server, where its the same copy with Same settings cam = cv2.VideoCapture(0) Used this to initialise camera (webcam) and below code for processing the data stream and below image shows the error on server click here to view the error def identify_faces(video_capture): buf_length = 10 known_conf = 6 buf = [[]] * buf_length i = 0 process_this_frame = True while True: ret, frame = video_capture.read() small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) rgb_frame = small_frame[:, :, ::-1] if process_this_frame: predictions = predict(rgb_frame, model_path="folder/folder/models/trainedmodel.clf") process_this_frame = not process_this_frame face_names = [] for name, (top, right, bottom, left) in predictions: top *= 4 right *= 4 bottom *= 4 left *= 4 cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED) font = cv2.FONT_HERSHEY_DUPLEX cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1) identify1(frame, name, buf, buf_length, known_conf) face_names.append(name) buf[i] = face_names i = (i + 1) % buf_length cv2.imshow('Video', frame) if cv2.waitKey(1) & 0xFF == ord('q'): break video_capture.release() cv2.destroyAllWindows() -
submit order and redirect to an individual platform
i am trying to develop a django webapp .i want the user to be able to submit other and get redirected to the user's platform where the user sees all his orders . i want a system where the user can make orders and get redirected to a page where will see all his orders client form: {% extends 'base.html' %} {% load static %} {% load crispy_forms_tags %} {% block content %} {% if user.is_authenticated %} <div class="container" style="width: 50rem;"> <div class="col-md-10 offset-md-1 mt-5"> <div class="jumbotron"> <!--<h3 id="form-title">Job Specification </h3>--> <h3 class="display-4" style="text-align: center;">Service Request</h3> <p id="form-title" style="color: #343a40; text-align: center;">Please provide us with the following information</p> <hr class="my-4"> <form action="{% url 'clients:add_item' %}" method="POST" enctype="multipart/form-data"> {% csrf_token %} <div class="row"> <div class="col-md-4"> {{ form.job_name|as_crispy_field }} </div> <div class="col-md-8"> {{ form.text_description|as_crispy_field }} </div> </div> <div class="row"> <div class="col-md-4"> {{ form.location|as_crispy_field }} </div> <div class="col-md-8"> {{ form.address|as_crispy_field }} </div> </div> <div class="row"> <div class="col-md-6"> <!--{{ form.phone|as_crispy_field }}--> <input style="height: 2.5rem;margin: 0 0 8px 0; width: 100%; text-align: center; position: relative; " type="text" name="phone" value="{{ user.details.phone }}" readonly><br> </div> <div class="col-md-6"> <input style="height: 2.5rem;margin: 0 0 8px 0; width: 100%; text-align: center; position: relative; " type="text" name="email" value="{{user.email}}" placeholder=" email " …