Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Custom Function in Django class based view not being overwriten
I have a parent View, and a child View. I want to override one custom function in the child view like so: # PARENT: class AddImages(LoginRequiredMixin, View): template_name = images/add_images.html # HERE I GET THE CURRENT URL: def next_url(self): next_url = "?next={0}".format(self.request.path) print("NEXT URL:" + str(next_url)) return next_url # AND I USE IT HERE: def post(self, request, **kwargs): # ... next_url = self.next_url() data = {'next_url' : next_url } return JsonResponse(data) # CHILD: class EditImages(AddImages): """ Inherits from ImagesView. overwrites template and next_url """ template_name = "images/edit_images.html" def next_url(self): next_url = "?next={0}".format(self.request.path) print("CHILD URL2:" + str(next_url)) return next_url I want to override the parent views next_url and pass it on to post() currently the output only prints: "NEXT URL: ..." How can I solve this? Thanks in advance -
How to retrieve AWS encrypted files with Django-Storages?
I have an app setup which is using django-storages as the backend. I believe I have the file upload itself working, as I don't get any errors. However, when I try to retrieve the file through my model using file.open() I get the following error: botocore.exceptions.ClientError: An error occurred (400) when calling the HeadObject operation: Bad Request Both save and retrieval work fine when I don't encrypt the file (removing the 3 items in AWS_S3_OBJECT_PARAMETERS). Here is the relevant portion of my SETTINGS.py AWS_ACCESS_KEY_ID = 'MY KEY ID IS HERE' AWS_SECRET_ACCESS_KEY = 'MY SECRET IS HERE' AWS_STORAGE_BUCKET_NAME = 'tickets' AWS_S3_ENDPOINT_URL = 'https://sfo2.digitaloceanspaces.com' AWS_S3_FILE_OVERWRITE = False AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_S3_ENCRYPTION = True AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', "SSECustomerAlgorithm":'AES256', "SSECustomerKey":'at1TMx82nEy7SoAK8jHYanMQDVZMSLayXaaUvTc6CP0=', "SSECustomerKeyMD5":'LWkBoT3psNdTYez70TVHUQ==', } AWS_S3_REGION_NAME = 'sfo2' AWS_LOCATION = '' AWS_DEFAULT_ACL = None STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'sendtickets/static'), ] STATIC_URL = 'https://%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_LOCATION) STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' -
Post-request error with Spyne and Django-silk
I am already using spyne-RPC as a SOAP server within Django. I have installed django-silk to monitor requests. For my GET requests it works ok but when i use POST i get the error below and a timeout. If I remove django-silk it works ok. there is an issue at django.py of spyne at response = WsgiApplication.__call__(self, environ, start_response) the error is the following Traceback (most recent call last): File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/spyne/server/django.py", line 89, in __call__ response = WsgiApplication.__call__(self, environ, start_response) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/spyne/server/wsgi.py", line 304, in __call__ return self.handle_rpc(req_env, start_response) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/spyne/server/wsgi.py", line 411, in handle_rpc contexts = self.generate_contexts(initial_ctx, in_string_charset) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/spyne/server/_base.py", line 64, in generate_contexts self.app.in_protocol.create_in_document(ctx, in_string_charset) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/spyne/protocol/soap/soap11.py", line 202, in create_in_document charset) File "/home/test/django/django-apps/venv-test/lib/python2.7/site-packages/spyne/protocol/soap/soap11.py", line 96, in _parse_xml_string chunk = next(xml_string) StopIteration Any ideas? -
Django python AttributeError Exception Value: 'WSGIRequest' object has no attribute 'shop'
i am writing module of Django shopping site user can add shop and products when user fill the form for adding product and hit submit it django give this error, it would be very helpful if someone can put some light on the problem, thank you. Error 'WSGIRequest' object has no attribute 'shop' Request Method: POST Request URL: http://127.0.0.1:8000/15/add_product/ Django Version: 2.1.2 Exception Type: AttributeError Exception Value: 'WSGIRequest' object has no attribute 'shop' Exception Location: C:\Users\MILAN\PycharmProjects\DjangoProject\shopsurfer\views.py in form_valid, line 191 Python Executable: C:\Users\MILAN\PycharmProjects\DjangoProject\venv\Scripts\python.exe Python Version: 3.7.0 Python Path: ['C:\\Users\\MILAN\\PycharmProjects\\DjangoProject', 'C:\\Users\\MILAN\\PycharmProjects\\DjangoProject\\venv\\Scripts\\python37.zip', 'C:\\Users\\MILAN\\AppData\\Local\\Programs\\Python\\Python37\\DLLs', 'C:\\Users\\MILAN\\AppData\\Local\\Programs\\Python\\Python37\\lib', 'C:\\Users\\MILAN\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\MILAN\\PycharmProjects\\DjangoProject\\venv', 'C:\\Users\\MILAN\\PycharmProjects\\DjangoProject\\venv\\lib\\site-packages', 'C:\\Users\\MILAN\\PycharmProjects\\DjangoProject\\venv\\lib\\site-packages\\setuptools-39.1.0-py3.7.egg'] Server time: Tue, 12 Feb 2019 14:37:12 +0000 product_form.html this is where all the html code which is generating the form form the input {% extends 'shopsurfer/base.html' %} {% block title %}Add a New Product{% endblock %} {% block album_active %}active{% endblock %} {% block body %} <div class="container=fluid"> <div class="row"> <div class="col-sm-12 col-md-7"> <div class="panel panel-default"> <div class="panel-body"> <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> {% csrf_token %} {% for field in form %} <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <span class="text-danger small">{{ field.errors }}</span> </div> <label class="control-label col-sm-2" for="song_title">{{ field.label_tag }}</label> <div class="col-sm-10">{{ field }}</div> </div> {% endfor %} <div class="form-group"> <div class ="col-sm-offset-2 col-sm-10"> … -
Redirect old domain to new domain, including /en/
Little stuck but I'm trying to redirect an old domain name to a new domain, which is working to a point. However, we have a long list of URLs from our old website (using the old domain). Which have /en/ appended at the end. So the issue is when I link olddomain.com/en/old-url to newdomain.com/new-url it throws a 404 as it's not picking up the '/en/'. I've compiled a long list of 301 redirects inside the Django admin, but they don't include the '/en/'. Which is where the issue is. Ideally, I want to add something to my nginx config that tells the domain to redirect even if the /en/ is included. So Far I have something like this: server { listen 80; server_name olddomain.co.uk www.olddomain.co.uk olddomain.co.uk/en/ return 301 https://www.newdomain.co.uk$request_uri; } server { HTTPS server_name olddomain.co.uk www.olddomain.co.uk olddomain.co.uk/en/; #return 301 https://www.newdomain.co.uk$request_uri; listen 443; } Thanks in advance. -
How to submit dropzone js form and django form with one submit button
I am using dropzone js to make a form where users can upload information along side images. Dropzone js requires that dropzone has a form with a class of dropzone for the drag and drop image uploads to work, this now leaves me with two forms. The first is the normal input form and the second is the dropzone js form. My question is how can I submit both the dropzone js form and the normal input form with one submit button. Please note I am using html forms, not django crispy forms. <form method="POST" enctype="multipart/form-data" id="inputform" name="form1"> {% csrf_token %} <button type="submit" id="add">Save</button> </form> <div class="col-sm-12 col-lg-6" id="inner"> <form method="POST" enctype="multipart/form-data" id="inputform" name="form1"> {% csrf_token %} <h4>Title</h4> <input type="text" name="product_title" id="product_title" placeholder="Give your product a name"> <h4>Price</h4> <input type="text" name="product_price" id="product_price" placeholder="0.00"> <h4>Description</h4> <input type="text" name="product_description" id="product_description" placeholder="Write a description about your product"> </form> </div> <div class="col-sm-12 col-lg-6" id="inner2"> <h3>Images</h3> <form method="POST" action="#" class="dropzone col-sm-8 col-lg-8" id="dropzone" name="form2"> {% csrf_token %} </form> </div> def add(request): if request.method == "POST": title = request.POST.get("product_title") price = request.POST.get("product_price") description = request.POST.get("product_description") print(title,price,description) return render(request,"main/add.html") -
Create and run the new celery task with Django
I would like to use Celery in order to run asynchronously my task and I'm getting some troubles with that. Context : User can export search result into a .xlsx file. However there are 2 cases : File contains less than 70.000 rows. In this way, user can directly download the generated output file. File contains more than 70.000 rows. In this case, the file is written in the media folder thanks a Celery task. I'm working on this second part. Code : The HTML template (final_product_search.html) with the search form gets an export button like this : <a title="Export to Excel" name="export" class="button btn btn-default" href="{% url 'ocabr:export-xls' model=model %}"> <span class="glyphicon glyphicon-export"></span> </a> When you click on this button, it calls the export method export_xls() : class ExportOCABR(View): def export_xls(self, model="", search_info=""): app_label = 'ocabr' # some code which let to search data, adjust columns ... book.close() if len(rows) > 70000: # construct response output.seek(0) name = 'Obsolete' if obsolete else '' name += str(model._meta.verbose_name_plural) response = HttpResponse(output.read(), content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") response['Content-Disposition'] = 'attachment; filename="' + name + '.xlsx"' return response else: get_export_file(output, model, obsolete) return HttpResponseRedirect('/%s/list/' % template_returned) When the file contains more than 70.000 rows, it calls a … -
How to Display ManyToMany Field in RestFramework
I am using Rest Framework. It is not displaying job_users which is ManyToManyField in my models. And even i want to set job_created_by manually when data is sended by user. And also set Current DateTime for job_created_on class JobAddSerialzer(serializers.ModelSerializer): job_users = serializers.PrimaryKeyRelatedField(many=True, read_only=True) class Meta: model = Jobs fields = [ 'job_name', 'job_number', 'job_description', 'job_start_date', 'job_start_time', 'job_end_date', 'job_end_time', 'job_group', 'job_users', 'job_status', ] class Jobs(models.Model): job_company = models.ForeignKey(Company, on_delete=models.CASCADE) job_group = models.ForeignKey(Groups, on_delete=models.CASCADE) job_users = models.ManyToManyField(User,related_name='job_users', blank=True) job_name = models.CharField(max_length=30) job_number = models.CharField(max_length=30) job_description = models.CharField(max_length=100, blank=True, null=True) job_start_date = models.DateField(blank=True, null=True) job_start_time = models.TimeField(blank=True, null=True) job_end_date = models.DateField(blank=True, null=True) job_end_time = models.TimeField(blank=True, null=True) job_created_on = models.DateTimeField(auto_now_add=True) job_created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='job_created_bys') job_updated_on = models.DateTimeField(auto_now=True) job_updated_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name='job_updated_bys') job_is_deleted = models.BooleanField(default=False) job_deleted_at = models.DateTimeField(blank=True, null=True) -
How to dynamically call a Django templatetag from a variable
I'm trying to allow for dynamic template tags. Specifically, I have a menu setup that I'm defining in code vs templates. And I would like to render the menu label as {{ request.user }}. So how can I define that as a string in Python, and allow the template to parse and render the string as intended. And not just variables too, templatetags as well ({% provider_login_url 'google' next=next %}). What am I missing? -
How to download updated sqlite Database from AWS EB? (Django app)
I have deployed my django app on AWS Elastic beanstalk, using the sqlite database. The site has been running for a while. Now I have made some changes to the website and want to deploy again, but by keeping the changes the database went through(by form inputs) But I am not able to find a way to download the updated database or any files. The only version of the app I am able to download is the one I already uploaded when I first deployed. How can I download the current running app version and deploy with the same database? -
How do I deploy my Vue js SPA into my Django server?
I'm currently following this guide on integrating my Vue.js frontend with my Django backend: https://medium.com/@williamgnlee/simple-integrated-django-vue-js-web-application-configured-for-heroku-deployment-c4bd2b37aa70 For now, I just want to be able to render the default Vue.js boilerplate index.html page into my Django server at http://localhost:8000/ I used django-admin startproject django-vue-template to initialize Django and within the newly created django-vue-template folder, I ran vue create . to initialize Vue CLI. I then ran npm run build, so my project folder tree looks like this now. I also added these changes to my settings.py: TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'dist')], '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', ], }, }, ] STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'dist/static'), ] as well as these changes to my urls.py: urlpatterns = [ path('admin/', admin.site.urls), url(r'^$', TemplateView.as_view(template_name='index.html')), ] According to the guide, I should already be seeing the Vue.js index.html page on http://localhost:8000/ when I run python manage.py runserver but nothing renders except a white screen and when I check the console, I'm bombarded with error 404s as shown here. Django seems to be able to locate my index.html, but it can't find and import the css and js files it needs to make its SPA functionality work. -
Limiting internet access of Docker Containers with a proxy
I have a server on which Docker containers are running untrusted code. All internet accesses done by these containers needs to be routed through a proxy. Each Container is only allowed access to some websites, not the entire internet. The proxy should decide this based on the Container's name (I have a mapping of Container names to allowed websites). Communication between the Containers should be blocked, and it should not be possible to contact the Containers from outside the server. The server is set up using Nginx and Django. How can I add a proxy that can restrict the Docker Containers in this way? Can I be sure that there is no way for the Containers to bypass that restriction, given that the Container contents are untrusted? -
Django rest framework - ValidationError raised in models' save method. How to pass error to http response
I'm using the django rest framework, with a ModelViewset: class FooViewset(viewsets.ModelViewSet): serializer_class = FooSerializer queryset = Foo.objects.all() and a ModelSerializer: class FooSerializer(serializers.ModelSerializer): class Meta: model = Foo fields = [ "id", "bar", "baz", ] I also have the model's save method: class Foo(models.Model): ... def save(self): if condition: raise ValidationError("Illegal parameters") return super().save(*args, **kwargs) When this validation error is triggered, drf, sends a 500 response to the frontend, with no text. How do I get it to instead give a 'bad request' response, with the text in the ValidationError (Illegal parameter)? -
Custom Authentication in django is not working
I am new to django and i wanted to authenticate user on email or username with password hence I wrote a custom authentication as shown in documentation but it doesn't seem to be called and I have no idea what do I do? settings.py AUTHENTICATION_BACKENDS = ('accounts.backend.AuthBackend',) views.py def login(request): if request.method == 'POST': username_or_email = request.POST['username'] password = request.POST['password'] user = authenticate(username=username_or_email, password=password) print(user) if user is not None: return reverse('task:home') else: messages.error(request, "Username or password is invalid") return render(request, 'accounts/login.html') else: return render(request, 'accounts/login.html') backend.py from django.contrib.auth.models import User from django.db.models import Q class AuthBackend(object): supports_object_permissions = True supports_anonymous_user = False supports_inactive_user = False def get_user(self, user_id): try: return User.objects.get(pk=user_id) except User.DoesNotExist: return None def authenticate(self, username, password): print('inside custom auth') try: user = User.objects.get( Q(username=username) | Q(email=username) ) print(user) except User.DoesNotExist: return None print(user) if user.check_password(password): return user else: return None I wrote this print statements in my class to check if they are being called and being written in console. However, they are not being printed and the print statement in views.py prints None -
strange migration from django to postgres DB. How to save an exist data
I have walking on a strange way, but it is result of circumstances. I had to been generate single models.py from exist postgres DB by inspect_db. Next I fix some field (was a few problem with keys), and create 2 apps inside this project. So now I have 3 models.py (them are split models.py, whitch was generate by inspect_db). managed = True was added. Classes have same links and datatypes like in the database Next I wish to integrate this models to exist database. I make migration, I migrate and in the end DB have only system django tables (auth_, django_migrations etc.) None from my classes (although migrate files were create). So I tryied to delete migrations catalogs and repeat makemigrations and migrate, but terminal threw it: Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: No migrations to apply. (forest-venv) user@user-HP-Z800-Workstation ~/MyProjects/forest-venv/lesoved $ python manage.py runserver 8001 Performing system checks... If I try make migrates again - no changes. I tryied to delete info about my apps in django_migrations table - no result. So my questions: - It is possible to integrate new models into exist database (if names, keyes and formats is ok)? - Integration … -
Executing Python Script in Django View [Upload CSV -> Batch Geocoding -> Show Link to Download by script generated CSV]
I found the following very useful script while Googleing: https://github.com/shanealynn/python_batch_geocode/blob/master/python_batch_geocoding.py This script is just what I need and it works flawlessly when I run it locally on my computer. I have a small Django site, where I would like to use this script (non commercially). I do not need a full code example (even though if someone has example code, just post it, I will get trough it) but rather the steps to take to make use of such a script. I googled a lot concerning this the last days and got a lot of different answers and differenct scenarios. Non of them really wholly apply to this scenario though: Upload CSV Run Script Create Link/Make Download possible of newly created CSV Is anyone out there who might be able to help me out? Thanks in advance and best regards -
Django template tag, check if variable empty or not
I want to render an element on my site, but only if the related variable is not empty otherwise, if empty render something else. So far what I tried (and non of them worked): 1. {% if my_variable|length > 0 %} <something> {% else %} <something_else> {% endif %} 2. {% if my_variable %} <something> {% else %} <something_else> {% endif %} For some reason both times it rendered the {% else %} scenario. The variable looks like this (it contains a link): my_variable = models.CharField(max_length=120, blank=True) What I've found in the django documentation and seems relevant is this: <ul> {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% empty %} <li>Sorry, no athletes in this list.</li> {% endfor %} </ul> But this is not for one variable, does any of you have a solution for this? Thanks! -
Creating a form wizard / formset to answer questions from a table and saving them into another (Survey)
I am new to Django. I apologize if I don't make much sense. I have an EU project to create a survey tool for adult educators who are assisting migrants and refugees. I would like to use a WizardView/SessionView together with formset to answer a set of 24 questions from a matrix based on Max-Neef's Human Needs theory and Self Determination Theory. The idea is that Survey model will inherit 24 questions with ForeignKey one by one in a WizardView with previous/next/save functions as the user populate reflection field save them into the survey table. I have been pondering how might I save code instead of creating 24 tables for wizard view and use a hybrid of formsets and form_tools. How might one create such a tool? Any help will be most appreciated. Thank you in advance. I tried ModelForms and class based Views following several tutorials on the web and paid websites. models.py from django.urls import reverse from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.forms import ModelChoiceField class QuestionChoiceField(ModelChoiceField): def label_from_instance(self, obj): return "Question: {}".format(obj.name) def formfield_for_foreignkey(self, question, request, **kwargs): if question.name == 'question': return QuestionChoiceField(queryset=Question.objects.all()) return super().formfield_for_foreignkey(question, request, **kwargs) class Question(models.Model): LEVELS … -
django-rest-swagger==2.1.1 query parameter
i have an api(web service) in django like this: http://127.0.0.1:9000/api/back_office/appointments/days/?branch=1 that in swagger i want to input query parameter named branch but don't work this(all of my Apis have same problem!!). before, i use older version of swagger and for enter query parameters use like --param_name syntax, but now in django-rest-swagger==2.1.1 don't work this syntax. can anyone help me? Perhaps i should use get_customizations in OpenAPIRenderer class? tanks. -
I can't take data from my HTML form and save it to my database in django
I'm using an HTML template form, from where if someone contacts me through that form I want to save it in my DB.But I could make it to save the data in DB.My codes are below. MY HTML <form method="POST" action={% url 'home' %}"> {% csrf_token %} <input type="text" name="name"> <input type="email" name="email"> <input type="text" name="subject"> <textarea class="form-control" name="message"></textarea> <a class="contact-btn" href="" role="button">submit</a> </form> MY VIEW def home(request): if request.method == 'POST': name = request.POST.get("name") email = request.POST.get("email") subject = request.POST.get("subject") message = request.POST.get("message") contact_details = contact() contact_details.name = name contact_details.email = email contact_details.subject = subject contact_details.message = message contact_details.save() return redirect return render(request,'home.html') URL path('', contact.views.home, name='home'), MODEL class contact(models.Model): name = models.CharField(max_length=255) email = models.CharField(max_length=70) subject = models.CharField(max_length=70) message = models.TextField() In the admin panel, I saw only my created model object(I create 1 manually) but nothing else is going on to my DB. -
Passing a variable back to a template and updating a dropdown box value
I have a blog and would like to add a post_type variable which will be a dropdown on the webpage. I have added post_type to my Post model as a Charfield. And setup the dropdown in the template. (this might not be the best way to do this) It works when I'm creating a Post and also when I edit the post, if I change the dropdown value, the new value is saved. The problem I'm having is when I'm editing a post, I can't get the value to be selected in the dropdown. I think the html tag for the value in the dropdown needed to be market as Selected but I cant figure out how to do this. I'd really appreciate the help if someone can point me in the right direction. -
How to import CSV file and load all data in table view at frontend side in Django App?
I used Python 3.7 and Django 2.1 I am new to Django and my question is when the user can import CSV and click on the button then after CSV inside all data load in table view in Django app frontend side how ? Above functionality already excellent working in Django administration side but I want it at frontend side. Please elaborate which step required, I already installed “pip install django-import-export” library -
Filter on relation field in Django ORM
I have a model Media that has a relationship to a model UserMedia (user ratings). Also there's a model called UserMatchScore (match scores of users) that is relevant to the question. In a view I am querying the Media table, in this view there's an option to only get the media that my matches have rated, but I haven't rated. Also an average of ratings is returned based on the subset of me and my matches, not all users that have rated the media. I do this with annotation. What I do is filter the Media table for elements that I haven't rated, but my matches have rated, this is simple, but it only does half of the job. All media is returned that I haven't rated, but my matches have rated, but the relational field UserMedia still contains all ratings, this one isn't filtered, so there's no way to calculate the average of ratings for the subset of my matches. Here's the query I am describing: queryset = models.Media.objects queryset = queryset.filter( Q(usermedia__user__id__in=my_matches) & ~Q(usermedia__user=user) ) The only way to get to the expected result is to loop through the queryset and filter each element of the UserMedia relation, … -
Getting forbidden error while trying to make django api call from aurelia js file
I have integrated aurelia js in django project, from aurelia I am trying to hit django api but CSRF issue is coming and I am not able to get results. If I am creating normal js file in django,and calling django api from there,then its working, but incase of aurelia its not working. My code is: import {inject,DOM, autoinject} from 'aurelia-framework'; import {HttpClient, json} from 'aurelia-fetch-client'; let httpClient = new HttpClient(); let tableHeading; export class App { attached(){ httpClient.fetch('/demographs/', { method: "POST", headers: { "X-CSRF-Token": this.getCookie("csrftoken"), "Accept": "application/json", 'Cache': 'no-cache', "Content-Type": "application/json", 'Cookie': 'csrftoken='+this.getCookie("csrftoken") }, credentials: 'include' }) .then(response => response.json()) .then(data => { if(data && data.table && data.table.length) { tableHeading = data.table[0]; } }); } getCookie(name) { let cookieValue = null; if (document.cookie && document.cookie != '') { let cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { let cookie = cookies[i].trim(); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length +1)); break; } } } return cookieValue; } } -
How to store multiple python gui tools at one place in django?
i have built a few tools using PyQt4 in python. Now i want them to store on single web interface for easy accessing at one place. I am using django for web interface. But i don't know any way how to put these tools in django or any other web interface. can anyone tell me anyway to do this ?