Use Stack Overflow for Teams at work to find answers in a private and secure environment. Get your first 10 users free. .

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.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

django forms, categorizing a checkboxfield for better UI

I am using the widget forms.CheckboxSelectMultiple, but as there is too many data from the database, its too messy and would like to categorize them into category and display them out for the form, ...
0
votes
0answers
9 views

How to correctly pass parameters to a Class Based View instance in Django?

I'm trying to pass parameters in a Class Based View instance, but I can't figure out the proper way to do that. My api service works good in the REST Framework view and receive two mandatory ...
0
votes
0answers
10 views

Django add files to model with Dropzone

I have a django bootstrap project and I want to add files to my Django model via a Dropzonejs.js. My problem is that the files don't get a name in the model. They are just blank files without any ...
0
votes
0answers
9 views

Django allauth doesn't send any email

I'm using django_allauth for my django project. But no more email is sent (confirmation email, reset password). It successfully creates a new user, the message that confirms an email has been sent ...
0
votes
2answers
26 views

How to display Uploaded file to the user who upload it in Django?

I am trying to build a system where users can upload their CSV file in the Django backend. But I am facing a problem, I want to display CSV file only to the user who uploaded it. I make a field in the ...
0
votes
1answer
10 views

After installing spyder django is not working

I installed spyder on my ubuntu system From which django is not working. The error it is showing when i ran the server the error showing is is Traceback (most recent call last): File "manage.py", ...
0
votes
0answers
10 views

Saving modelform vs use of rest api

If one has to use modelform for getting inputs for djano rest api, What way serialiser will help saving data. Because ModelForm can directly do that. Code for saving modelform as well as serialiser ...
0
votes
0answers
6 views

Deploy Django project with MSSQL DB in Local Server

I am new in Django and this will be my very FIRST Times web deploying. So I am trying to deploy my project to the local server and My project stack is Django with MSSQL so obviously I will need Window....
0
votes
0answers
10 views

Is it good to perform model checks on serializers method (create, update)?

I have the next code in my client/serializer.py and I don't know if it is a good practice to perform validation/checking of my models in the methods serializers. Is it a good practice? from ...
0
votes
0answers
12 views

How to select and deselect options if multiselect option coming from ajax request

<div class="content-section"> <form method="POST" id="moviesForm" ajax_load_cast="{% url 'ajax_load_cast' %}" novalidate enctype="multipart/form-data" > {% csrf_token %...
0
votes
1answer
17 views

Django - When unique constraint fails, do not allow to submit the form until user changes the field

I have a field in the model with unique constraint. class Profile(models.Model): user = models.OneToOneField(CustomUser,default=None, null=True,on_delete=models.CASCADE,) username = models....
0
votes
0answers
13 views

AttributeError __name__ when creating folium map in Django

View.py from django.http import HttpResponse from django.shortcuts import render from evadata.models import coord2_dj from django.views.decorators.csrf import csrf_exempt import json from django....
0
votes
0answers
8 views

Store assumptions of timezone in django model?

I have a MariaDB table with UTC datetimes in it. However, I cannot seem to get Django to use those without throwing a warning that I am feeding it naive datetimes when timezone support is active. Is ...
0
votes
2answers
19 views

my Django form not validating when using __init__ for a dynamic Radio field

I have written a form which has a Radio Button, whose values I provide when I initialize the form. The form is being displayed perfectly but when I need to use the values submitted through the form, I ...
1
vote
2answers
24 views

Calling a function within a view function in Django

Is 1 or 2 the correct way to call a function within a view function in Django. Or are both equally ok. Please explain. #1 def function1(request): [some api calls] #Once this process is done ...
0
votes
3answers
39 views

Only allowing the logged in user to submit a comment on a post

I am having trouble getting the author of the comment when the form submits This works fine for my post method, not so much for commenting on the post Models.py class Post(models.Model): ...
1
vote
0answers
21 views

What are the differences between the custom user types in Django?

I am mapping out a Django project and am wondering what are the differences between using custom user types with boolean flags versus custom users with permissions set and added to groups in Django? ...
0
votes
1answer
18 views

Django model self doesn't count as instance?

I'm trying to resolve a ValueError: Cannot query "X": Must be "Y" instance. issue. The problem is, my X definitely seems to be a Y instance. In my case, X is self within a UserAccount model. Here are ...
0
votes
0answers
9 views

How can I use Django Channels v2 to show a queryset

I have a model "Service": class Service(models.Model): def __str__(self): return self.name name = models.CharField(max_length=200, unique=True) active = models.BooleanField(...
0
votes
0answers
9 views

Django - how to get all models bound to post_save receivers?

I'm working on a script which finds all Django pre_save and post_save signals and comments overwritten save methods so programmer is aware of all signals affecting the workflow. For Example There ...
0
votes
0answers
10 views

Failed to send request: Only unicode objects are escapable. Got None of type <class 'NoneType'>

I deployed my django app to a RHEL 8 server following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7 The internal ...
0
votes
0answers
16 views

Django deployment in google cloud error (pywin32 problem )

I developed a Django application that works perfectly fine locally, but when I tried to deploy it in google cloud, I got the following error: https://files.pythonhosted.org/packages/74/68/...
0
votes
1answer
19 views

Django Models not showing in template

I am finding it quite difficult to display django models in template. The Model does not show at all in the template. Any help will indeed be appreciated. models.py from django.db import models from ...
1
vote
1answer
23 views

Trim text in a cell of bootstrap table

How can I trim text in a cell of bootstrap table? Example: In bootstrap table below I have big names in 'stock name' column, this messes formatting of my entire table for example (check columns like ...
0
votes
0answers
19 views

Django Initial Page Load Slow After Python 2 to 3 Upgrade

I run Django 1.11.20. I have just (finally) made the jump from Python 2.7 to 3.7. I've noticed that since upgrading to Python 3, the very first page load after clearing the cache is very slow. So far ...
0
votes
0answers
13 views

Use php to call django view - best way

i have a PHP script from a payment provider that can receive payment notifications (Instant Payment Notification - IPN). The problem is that my web application used django. Now i try to find a ...
1
vote
1answer
15 views

In Django, how do I query that all of the related objects have the same value for a certain field?

Let's say I have the following models in Django: class Parent(models.Model): pass class Child(models.Model): parent = models.ForeignKey(Parent, related_name='children', null=...
0
votes
0answers
8 views

Django schedule framework doesn't work like it's supposed to

I'm trying to get to work the schedule framework for django but it doesn't look right and it's functually broken as well, although only in the front-end. My guess would be that Javascript (jquery?) ...
0
votes
1answer
27 views

How to calculate all the consummation of a client?

I'm working on a project of managing payments of a restaurant, but I'm new in django and I need help to calculate the total consummation of a client. I tried to sum to sum a consommation, but can't ...
0
votes
1answer
40 views

Django gets error when overriding save method

I overriding model's save() method to do some work with directory. My overrided save() method looks like this: def save(self, *args, **kwargs): book_dir = os.path.join(MEDIA_ROOT, self.title) ...
0
votes
0answers
12 views

Why my overwriting on labels and widgets from UserCreationForm on Django doesn't work?

Although I found how to work around the problem (cf. at the bottom of the page), I do not understand why my overload of UserCreationForm doesn't work without erase parent attributs. Yet, I did a lot ...
1
vote
2answers
11 views

Class object value not displaying properly

I have implemented a counter in my Django program. It is not displaying as intended. From Views class PostDetail(DetailView): model = Post def get_context_data(self, **kwargs): ...
1
vote
1answer
16 views

A better syntax for switch-like conditions in Django Template

Does anyone know a less bulky way of performing a switch-like evaluation in Django Template than the one below? <div class="alert {% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}alert-danger ...
0
votes
0answers
18 views

JavaScript & HTML changes not appearing through Django server

I recently began a new job working on a Django server, and for some reason, the server stubbornly keeps refusing to propagate my updates. This seems to be getting worse; sometimes I can make a change....
0
votes
0answers
23 views

Using field as row in django tables

I'm using the django_tables2 library and I don't see anywhere in the documentation to use the fields as rows instead of columns. class PizzaTable(tables.Table): class Meta: model = ...
1
vote
2answers
21 views

Any way to update a ManyToMany field via a queryset?

Suppose I have an object: survey = Survey.objects.all().first() and I want to create a relationship between it and a group of objects: respondents = Respondent.objects.all() for r in respondents: ...
0
votes
1answer
29 views

My sign up form is not working with django python

I have a problem with my application the sign up is not creating profiles on the backend. I have tried to use the django forms but I didnt like how they render so I wanted to use custom form but once ...
1
vote
1answer
11 views

Django: Overwriting a form. how to shortening the mapping of the fields?

i am testing forms and model nesting in django. Due to a ManyToMany Relation in my form i have to use a custom save function. So far it works. But i asked myself if there is a way to shorten the code?...
0
votes
1answer
25 views

Cross checking and validating two input fields in django

I am new to python and Django, i wanted to know how below thing can be possible? input field 1 - Enter name - [email protected] input field 2 - Enter Url - www.yoyo.com Submit button so I want to ...
0
votes
1answer
12 views

Display a Foreign Key Dropdown in Django Form as Text

Is there a way to show a foreign key field in a Django form as an read only text box? forms.py class NewModelForm(forms.ModelForm): class Meta: model = Model fields = ['fk_field'...
0
votes
0answers
13 views

Permissions except for a group

In the query below, I get a list of all permissions. routines = ( Permission.objects.select_related("content_type") .values("id", "name", "content_type__app_label", "content_type__model", ) ...
1
vote
2answers
15 views

Django template language

"dishList" is a list of "dish" object and "dish" object includes an "id" field. For example: dishList = [dish1, dish2, dish3, ...] dish1.id = 1 "dishCount" is a dictionary type in python, which ...
0
votes
0answers
15 views

ValueError at /

The view demo.views.index didn't return an HttpResponse object. It returned None instead. @csrf_exempt def index(request): if request.method == 'POST': session_id = request.POST.get('...
0
votes
0answers
18 views

Export pdf file

Please help me i just want to export pdf file i am stuck with qs variable i dont know how to type i searched but could not find complete answer. views.py import io from django.http import ...
0
votes
0answers
23 views

The current path, about, didn't match any of these

I'm learning Django and just started looking at it installing Django 1.11.17 on my local. But I got the below error while browsing the url. Using the URLconf defined in website.urls, Django tried ...
1
vote
0answers
14 views

Django try to convert an object into an UUID after serialization

I'm creating a web app with Django and Django-rest-framework. Here are my models: class Affilie(TimeStampedModel): TITRE = ( ('Monsieur', 'Monsieur'), ('Madame', 'Madame'), ) ...
-1
votes
1answer
22 views

How to communicate data between iOS app and Django WebApp

So I am writing an IOS app that will present sort of a notification/message board. At the moment I have the board making a GET request to my django webapp for a JSON file that populates the ...
0
votes
1answer
19 views

Getting a “NoneType object has no attribute <attribute name>” exception

I tried very hard to find out the problem, but I failed. I am getting the following exception: Error-NoneType object has no attribute 'membership_type' I think that the problem is in context as if ...
0
votes
0answers
11 views

Zip folder only returning one file

I have a Django application in which a user generates a report in a Word document. I've created an archive page where a user can select from a checkbox form that contains a list of all files that have ...
0
votes
1answer
13 views

How to Test in Django the Numbers of Querysets Returned by a CBV

For a real-estate app I have a search form and a class-based ListView that shows only the objects (properties) that match the search query from the form: # views.py from django.views.generic import ...