Questions tagged [django]

Django is an open source server-side web application framework, written in Python. It is designed to reduce the effort required to create complex data-driven websites and web applications, with a special focus on less code, no-redundancy and being more explicit than implicit.

0
votes
0answers
9 views

PUT multipart-formdata containing PNG with XMLHttpRequest in vanilla javascript

I'm trying to PUT svg, a string and a png together to a Django REST api from a pure javascript client. I'm currently stuck with error 400 "Upload a valid image. The file you uploaded was either not ...
-1
votes
1answer
14 views

Trying to update the post in database.But getting Page not found (404)?And want to know how to update the data in database?

I'm trying to create a blog app with django.When clicked on a post it displays that post in separate page.In that i created edit and delete option.When i click on edit it returns edit option.But when ...
0
votes
1answer
26 views

How do i run two command lines in AWS simultaneously?

I have a Django app that I am trying to deploy to AWS. I need two command lines to run the app. One command line will be used to runserver and another one to run a background task. That is how the ...
0
votes
2answers
24 views

Django render() - Reverse for '' not found. '' is not a valid view function or pattern name

This is yet another question involving paths in Django. I have not been able to find my answer anywhere and have done lots of searching on this. The return() function in my view is throwing the ...
0
votes
1answer
10 views

How to set certain permissions to different “Groups” in Django REST framework

I am trying to let only users in say group 1 to be able to read the api, and then users in group 2 to read or write. I was able to do a very basic version with using permission_classes = (...
0
votes
0answers
16 views

Issue is probably caused by a circular import showing after running django server

i'm trying to runserver for a django project and it shows me this error : django.core.exceptions.ImproperlyConfigured: The included URLconf 'hello.urls' does not appear to have any patterns in it. If ...
-1
votes
0answers
5 views

How do I add a custom header to the swagger UI when using drf-yasg?

When doing API documentation there is an API which reads a token from the headers. It should not be a part of the authentication as the authentication system is not yet built. There is only one API ...
0
votes
0answers
9 views

Django email not sending mail [duplicate]

I created a view for email that worked for sometime but recently stopped sending mails. However I can see the mail in the console. I don't know what is wrong. I have used both send_email and ...
0
votes
0answers
9 views

Can´t import an existing chatbot into Django Framework

I´ve already programmed a simple chatbot some time ago. Now I want to implement it into my Django project. I tried: from .bsbot import model bsbot.model.response() bsbot is the name of my folder ...
0
votes
0answers
8 views

How to remove Ck editor tag in django rest framework

I am using Django rest framework. The CkEditor tags I've used for the web appear in the API part. How do I remove these tags from the API I had not used Ckeditor before, I was using the Django ...
0
votes
0answers
18 views

Filter data on django admin console with URL

Is there any way to filter modal data on Django admin console with URL and POST request? I have a dynamic URL which I am creating on the basis of filters on template. As this is a GET request and ...
0
votes
0answers
9 views

How to get uwsgi init status?

I use uwsgi to start my Django application by executing command uwsgi --init uwsgi.ini, uwsgi.ini is the uwsgi's config file. I use echo $? to check out the uwsgi init status, But I found out whether ...
0
votes
1answer
24 views

Putting methods in a class in views.py

I am creating a simple todo app just to learn Python & Django. My current code: def create_task(request): # code for creating a task def delete_task(request, task_id): # code for ...
0
votes
1answer
11 views

attempt to write a readonly database SQLite, Django

I have implemented my simple Django applications on server, but my forms for users can not save anything. My database settings looks like this: DATABASES = { 'default': { 'ENGINE': '...
0
votes
1answer
30 views

Not able to migrate DB, using Python's manage.py makemigrations

I want to migrate a model in the database, so I am using this command in my active environment: python manage.py makemigrations But it gives me this error: File "manage.py", line 14 ) from exc ...
0
votes
0answers
10 views

Django Custom Multi User Model Data filling

I wanted to make an app which holds information about different types of account. Problem I can fill the form but it's not taking the input and storing it in the model I want to store it into. ...
0
votes
1answer
22 views

Django models attributes - can't resolve attribute reference

I tried to resize profile photo, but it sends no errors, and it does nothing. Only thing that my pycharm says is this unresolved attribute reference path for class ImageField I tried with .path ...
2
votes
1answer
35 views

how to pass the dictionary to django template using javascript

I am trying to pass the dictionary values to django template through JavaScript Views.py population_count = ( {'name': 'Year 1800', 'data': '[107, 31, 635, 203, 2]'}, {'name': 'Year 1900', '...
1
vote
1answer
13 views

How to change a OneToOneField into ForeignKey in django model with data in both table?

I am having a model Employee with a OneToOneField relationship with Django USER model. Now for some reason, I want to change it to the ManyToOne(ForeignKey) relationship with the User model. Both ...
0
votes
2answers
43 views

After first query in the database, I want to Make a boolean field false

I'm trying to implement a mechanism were by only 1 one query will be made in the database after the query, a boolean field in the database will change its status from true to false. I don't know how ...
0
votes
2answers
26 views

Is it possible to find or match two names which has different special characters django

I am trying to populate cities in a state using OpenstreetMaps API to my django application. The database was populated with some cities already. I am facing duplicate data issue since the name in ...
0
votes
1answer
18 views

unique_together does not replace primary key

In my Django app, I want to insert a record with a composite primary key. Apparently this should be possible by making use of "unique_together". I'm quite sure this code was working in the past, but ...
0
votes
0answers
12 views

Docker Django uWSGI strange connection error

I'm trying to test a production environment of a Django app in a docker container, using a uWSGI server. My dockerfile looks like this: FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /...
0
votes
1answer
20 views

How to access buttons in a separate HTML file in the HTML file it is included in as header?

I'm making an application which requires a header that consist of navigation buttons. I need to access these buttons at the respective home screen where this header html is included in. However, ...
0
votes
1answer
27 views

In Django, does `queryset is None` evaluates the queryset?

Is Django queryset evaluated in below cases? If no, then why? 1. if queryset is None: pass 2. from django.db.models.query import QuerySet if isinstance(queryset, QuerySet): pass Is it ...
0
votes
0answers
16 views

Dynamic JS and Django Calculator

I have no clue of JS, I copied this and modified it in a 4 hours so please be kind. I have a simple calculator. The concept behind is this. 1. There are check boxes which take their number/integer ...
0
votes
0answers
17 views

Add custom ROW in Django admin view

I want to add a custom ROW in my django admin page, such that the last row contains some values specified by me. I tried searching but only found things like adding a new column (using list_display )...
0
votes
1answer
14 views

I want to exceute one process only after completion of another process in my django application using celery

I am new to the celery thing. I want to run one process only after the completion of another one. While searching I found one code class CallbackTask(Task): def on_success(self, retval, task_id, ...
2
votes
0answers
25 views

I want to make .bat file on the desktop that once clicked the file starts django python server, and opens Chrome

Make .bat file from django that runs the server once clicked and opens chrome browser. @ECHO ON start cmd.exe /C "python manage.py runserver && cd C:\Users\admin\Desktop\JUDICIARY\ && ...
1
vote
0answers
20 views

Django_select2 : How to filter ModelSelect2Widget queryset with a request data? (Django_tables2 + Django_filter +Django_select2 )

I use django_tables2 with django_filter according to django_tables2 tutorial: #views.py from django_filters.views import FilterView from django_tables2.views import SingleTableMixin class ...
0
votes
0answers
17 views

Items not selected when using custom MultipleChoiceField

I am using a custom MultipleChoiceField, in order to display user's full names instead of their logins. I customized the way items are displayed using the choices attribute of MultipleChoiceField: ...
0
votes
2answers
13 views

Update datetimefiled of all related models when model is updated

I have two models (Post and Display). Both have Datetime-auto fields. My problem is that i want to update all display objects related to a post, once a post is updated. I have read here that you ...
-1
votes
0answers
19 views

how do link to function in view into html form

I am beginner about Django, I don't know get data from HTML form. How can I fix? Help me, please! <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> ...
0
votes
0answers
11 views

How can I write Bulk Data(25 Lakhs) on an Excel Sheet using Python,Django,MYsql,Dataframe?

Actully I am new to Python.I am using Python with Django and MYsql. I have written a code to fetch bulk data(25 Lakhs) from MYsql database and split it into three variables and then write them on an ...
0
votes
0answers
8 views

django-tables2 max total results

I want to limit the max total results. I only want 1 page with max 20 results. How can I do that? Adding [:20] to the query gives an error Cannot update a query once a slice has been taken My ...
0
votes
1answer
17 views

I want to add tags like structure to my website

I have a field in my model where user enters it's skill. I want to show it like tags(as we do in stack overflow while posting questions) I tried searching for it but couldn't find it, may be because ...
0
votes
1answer
17 views

django-tables2 How to set Verbose name for _set

I have a value ccu_set.all.first.player_count. Which works perfectly, but I want to change the verbose name so that in the table it doesn't say "ccu_set.all.first.player_count". However when I do: ...
0
votes
1answer
20 views

Django - InheritanceManager is not working

I have the following simple models.py file: from django.db import models from model_utils.managers import InheritanceManager class Clique(models.Model): created = models.DateTimeField(...
0
votes
2answers
32 views

How can I loop a generator in this situation?

Here's the question. I want to use django's bulk_create to save more datas at once. But the original result I get from API is a generator with amount data in it. So I want to loop this generator and ...
-1
votes
0answers
27 views

Creating a clickable view for my template

I am trying to create a view template for my project. My app has 5 fields which include site_id(char), annotation(int), person_class(int), vehicle_class(int), time(char) All entries in the table ...
2
votes
1answer
42 views

Laravel frontend to Django backend x-csrf-token not allowed in preflight response

I have Laravel framework with VueJS serving as the frontend. This frontend is hosted on xampp's localserver on ports 80,443 with the configured url "http://test.net". I send API requests from VueJS ...
1
vote
1answer
22 views

Django with Pandas accessing ForeignKey

I do not know Pandas so this may be trivial. I have this line of code: admin_data = pd.DataFrame.from_records(administrations.values()).rename(columns = {'id':'administration_id', 'study_id': '...
-1
votes
0answers
31 views

Can not login with 'requests'

I'm trying to login and get a response. But i can not do it because of password encryption algorithm of django Is it possible in other ways? payload = {'username': self.request.user.username, '...
0
votes
0answers
37 views

I can not get alll the data from the database with one query

I have to two tables in the postgresql database. In first one I have all descriptions of a vulnerabilities and in the second one I have all the product that are affected. Tables are conected via ...
0
votes
1answer
11 views

Setting Academic or Financial Years in Django

This may seem rather insignificant, but how do you set a financial or academic year, say 2018/19 or 2017/2018 in a Django model and reference the current financial year for querying, in this case 2019/...
0
votes
2answers
22 views

Want to create separate page for each blog post in django?But dont know how to proceeed?

I am trying to create a blog app with django.I have a home page in my app where all blog posts will be displayed.If anyone clicks on a blog post it should be displayed on a separate page.But dont know ...
0
votes
0answers
23 views

I am completely new to using ajax with django. How do I write the function for ajax for changing the value of model field?

I am using CBVs and I need to change the value of a field on button click. I have tried some code but it doesn't seem to work. What is wrong in this code and what can be modified? script $("#...
0
votes
1answer
20 views

Change label of a form field Django

I'm sure, there is an aswer on Google but after 30 minuts of search, I don't find my solution. So, I've my model in model.py and I generate a modelform in inventory_form.py. A field is named "...
0
votes
0answers
8 views

Graphene Django to Query Elasticsearch

My data is stored in elasticsearch and it is very big. So I want to use graphql to query it properly. I am using django graphene package to query it. For database models it is working fine. My json ...
0
votes
0answers
9 views

How to use django infinite scroll with custom overflow / custom scroll bar?

I want to implement django waypoint infinite scroll for web page & have successfully implemented too with default scroll bar. But, when I apply it to custom scroll bar, it loads all pages one by ...