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 TestCase object has no attribute 'login'

I have used selenium to test my login method and it works fine. Then, I tried to test other parts of the website. So, I needed to create a user in my test. To do that, I've used client instead of ...
0
votes
0answers
3 views

Send mail inside action django-rest-framework

i'm learning django restframework by myself I'm trying to send a mail with sengrid inside an action enter image description here The mail doesn't send Sorry for menglish thank you
0
votes
0answers
7 views

Django background task repeating more than it should

I am trying to run a django background task every 30 seconds, as a test I'm having it print "hello", but instead of printing every 30 seconds it is printing about every second or less very quickly. ...
0
votes
0answers
8 views

How to make the user visible to al his group activities

I am doing a django-rest-framework project in which one can create groups by adding member’s email id and the logged in user should be able to see all the group activities. I used django-multi-email-...
0
votes
1answer
15 views

Failed lookup for key in templates

I am trying to get Specific List in Dictionary, but first i got the error: "fail to lookup for key", searching on internet I found out a tread with this solution: {% with obj1.page.val2 as val2 %} ...
0
votes
1answer
22 views

Django model method error: missing 1 required positional argument: 'self'

I want to do some calculations inside a model and between attributes. I want 3 fields that can be entered by the user to add the model, but those fields get concatenated into a non-editable field that ...
0
votes
0answers
8 views

Session data corrupted in Django session

I have an application which using Django 2.0 and I'm facing with an issue about session data today. (SECRET_KEY is a static string, and consistent among the app so this might not is the issue) The ...
0
votes
0answers
7 views

How to return user session id alongside Django rest serializer output

I'm writing a web application with Django. In one of my APIs which is using Django rest_framework, I want to return user's session ID alongside the default response. I know how to get the session ID ...
0
votes
1answer
25 views

python - group values when generating a json

I am generating below JSON using a piece of code. Basically, I need to group my generated JSON group by continent, and then country and languages [ { "continent": "South America", ...
0
votes
0answers
10 views

How can I convert a duration or a string to an integer in a queryset in Django views.py?

I need to calculate the time difference between two rows. This duration then needs to be adjusted up to 1 if the total is 0, or if the total is over 15 minutes, adjusted to 0--I was going to put this ...
1
vote
2answers
25 views

Django queryset caching with exists() and values_list()

Let's say, I'm trying to change the name of all profiles whose name is John to Mike queryset = Profile.objects.filter(name='John') Method 1: if queryset: queryset.update(name='Mike') logger....
0
votes
1answer
17 views

Using Django to display images

I am attempting to use Django to display 3 random images from a large list of user submitted images. Each image has other values associated with it like the author, so I've been making each image a ...
0
votes
2answers
31 views

Why does django send_mail fails to send email with no errors?

I want to use send_mail in django, however it doesn't send any email. Here is my settings: EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER =...
0
votes
0answers
8 views

Why can't I PATCH Django REST Framework PrimaryKeyRelatedField to empty list?

I'm running into a weird issue in Django REST Framework. I'm attempting to add & remove groups to/from users using PATCH requests. I am able to PATCH to /api/users/:id/ to update the groups list, ...
0
votes
0answers
27 views

My form does not send data to the db django

My form does not send data to the database. I have a form that after entering data and clicking 'Order' should send information to the database. However, this does not happen. It is a 'cart' which, ...
0
votes
0answers
10 views

wagtail menus return an empty list menu_items

after added wagtailmenus to my wagtail project and it worked well, but when i add an item to my main menu and try to use it in my navbar it always return in empty list... it doesn't matter how many ...
1
vote
1answer
21 views

Annotating data in Django Templates

I am attempting at rendering annotated data into my template My models looks like this class Content(models.Model): title = models.CharField(max_length=255) body = models.TextField() reviews_total =...
0
votes
1answer
18 views

COPY failed: stat /var/lib/docker/tmp/docker-builder<num>/server/requirements.txt: no such file or directory

Appears to be some kind of context issue. I'm trying to figure out why this would work fine when spinning up a local Kubernetes cluser with Skaffold, but is failing to build the image properly when ...
0
votes
0answers
19 views

Issue with question mark in Django url [duplicate]

Here is the example link: abc.com/Hi-Python? So, in the backend of Django, I need data "Hi-Python?", but I'm getting - "Hi-Python" url(r'^@(?P<title>[a-zA-Z0-9_\.!,\-\?\:\w\+]+)$', views.title,...
1
vote
0answers
17 views

ImportError: cannot import name 'python_2_unicode_compatible' when running migrations for Django-Invitations

First, I might want to mention I'm a beginner with Django. I'm trying to install Django-Invitations on my app to send sign up invitations. I followed their README instructions. pip install django-...
0
votes
0answers
28 views

TemplateSyntaxError: Could not parse the remainder: '()' from 'size.toLowerCase()' [duplicate]

I am working through Python+Django on PythonAnywhere. I am generating a .html file by using a ListView I wrote. I want a table that contains data which will change based on drop down selections. I am ...
0
votes
1answer
13 views

How to grant atomicity on clean() method in django Models

I'm currently using django's clean() method to implement custom validations in a Model. A have a DB for example that is 1:m and have the following structure: | Id | Foreign Key | Date ...
0
votes
0answers
24 views

Django Cron, execute def from views

I have a problem. I needto implement a function that will be called cyclically I have to call dashgenerate functions because it generates data records this cron.py: from django_cron import ...
0
votes
0answers
18 views

ModuleNotFoundError: No module named <module_name> although module was installed

I'm trying to run server for my django app, and I've used TinyMCE editor for admin panel. Although I've installed it with command pip3 install django-tinymce application returns me such error: ...
0
votes
1answer
24 views

How do I change the default Django engine database from db.sqlite3 to a mysql database populated with test data?

This is my first time doing this so please bear with me. What I am trying to do: Change the 'DATABASES' setting in my 'settings.py' from the 'ENGINE: 'django.db.backends.sqlite3' to a pre-populated ...
0
votes
1answer
39 views

How to route to a url based on data entered in Django form?

At first , I would like to take an integer input from user . After getting the input , I would like to go to the url based on what the user has entered . However , I am not able to implement it . ...
0
votes
1answer
22 views

Django Webhook creates double database entries

I'm currently using Django to code a webhook application for google Dialogflow. It was working fine, I was basically done. For some reason, I now started encountering various randomly appearing ...
0
votes
1answer
16 views

Django Custom Permissions not synced to DB

I am newbie to Python and Django. I am trying to addd custom permissions using Django documentation. I added new permissions to model meta data. class Project(models.Model): class Meta: ...
-1
votes
0answers
17 views

Django rest_ramework error “Object of type UserToken is not JSON serializable”

I use django_rest framework and do authorization manually. I use tokens, which I also generate myself. When trying to authorize an error occurs "Object of type UserToken is not JSON serializable". I ...
1
vote
0answers
17 views

Add custom log records in Django

I've added the following logging configuration to my Django App's settings.py file: LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { ...
0
votes
0answers
19 views

Django - save changes made to model objects and render when published

I am new to Django and working on my first project in Django. I am providing a simpler example for my application where - I have 3 different types of users for the application. Teacher's Assistant - ...
0
votes
1answer
12 views

How to use Google Drive to save media files for a Django app that is deployed in Heroku?

Is it possible to use Google Drive to save all the media files (image files which users will upload) from a Django app? This app will be deployed in Heroku (free). I am also aware of Amazon S3 but I ...
0
votes
1answer
14 views

How to transfer GeoQuerySet.distance(geom, **kwargs) from Django 1.8 to Django 3.0?

I found this example in the Django 1.8 documentation. And it’s very important for me to follow the same steps, but in Django 3.0 (or 2.2). class AustraliaCity(NamedModel): point = models....
0
votes
1answer
21 views

Is there a way to filter for more than one value in the same column of a table?

I am realy frustrated and don't know what to do. I build a Website, where you can filter for beverages with many parameters, for example for the name of an Item, for the brand usw... But I also want ...
0
votes
0answers
12 views

unique_for_date parameter for SlugField

First, I am reading a book on django and from it have created the following models.py (entire models.py included at the end, the two fields related to the question are here): slug = models....
0
votes
0answers
9 views

django filling a text field based on a button it is redirected from

I am trying to create a project management app each user has multiple projects which he creates my projects app is as follows class projectsmodel(models.Model): added_by = models.ForeignKey(...
0
votes
2answers
30 views

Django: return list/tuple of element.id and min(element.price) from chunks of queryset

I've a cart_detail view that will be used to offer 3x2 discounts. So I'm making chunks of 3 elements from every element in my queryset. Using: def chunks(lst, n): """Yield successive n-sized ...
0
votes
0answers
18 views

How to check if a child in firebase database exists using Django?

the following code throws attribute error ''Database' object has no attribute 'exists''. from django.shortcuts import render from django.views import View from django.views.decorators....
0
votes
1answer
31 views

Django says SECRET_KEY must not be empty

I imported a Django project from a repo, and when I try to make the migrations with python manage.py makemigrations, I get the following exception: File "C:\Users\Iván\AppData\Local\Programs\Python\...
0
votes
0answers
11 views

Run a test on a Python/Django cronjob

I am trying to create some tests for my Django cronjobs. I have a file called cronjob.py: from apscheduler.schedulers.blocking import BlockingScheduler sched = BlockingScheduler() from mailer....
-1
votes
0answers
13 views

Django loading javascript static files

i am trying to load a javascript static file into my Django template but only the css file loads and not the javascript file. Ive ran through the Django documentation and i cant find any information ...
0
votes
0answers
7 views

Thermal Printing with ExpressJS and Angular

So, I have a client who needs restaurant billing software along with android app for the waiters to take the order. I am all ok with the android app and the related API Backend. I have planned to do ...
-1
votes
1answer
16 views

combine() argument 1 must be datetime.date, not str

When using queryset in Django date range getting error from_date = request.POST.get('from_date') to_date = request.POST.get('to_date') min_dt = datetime.datetime.combine(from_date, datetime.time.min) ...
0
votes
0answers
12 views

Creating hierarchical relationships like REST Api with Django

New to Django. I know there is Django to Swagger generator is there but what I want is other way around. I want to create REST API: GET api/job/{id} POST api/job/{id} GET api/job/{id}/status POST ...
0
votes
0answers
14 views

Cannot deploy django app - ImportError: No module named django.core.wsgi

So basically, I want to deploy django (wagtail) application on hosting in my country. Here's what I have done: I copied files of my project using FTP, to /home/ketohubp/KetoHub.pl. I created and ...
0
votes
1answer
15 views

Is it possible to create a single table for each model instance in Django?

I have a model called Schedule. A single schedule is a big table with 3 columns and maybe 500 rows. So, whenever a user saves an instance of a schedule, it needs to create a new table for that ...
0
votes
1answer
20 views

HIGHCHARTS POINTSTART TODAYS DATE

Hi I am using a line chart from HIGHCHARTS, can you please help me get the x-axis to show present month LAST on the x-axis - and the X-axis to automatically populate going back however many numbers of ...
0
votes
0answers
12 views

How can to load sccs styles from database?

I have field css_styles in Article model, in which writes scss styles for amp page. I try to include this styles as: <style> {{ object.css_styles }} </style> In the source code I ...
0
votes
2answers
20 views

Plain structure from OneToOne-related models (Django Rest Framework)

Models: class Person(models.Model): name = models.CharField(max_length=100) age = models.PositiveSmallIntegerField() # More Person fields class Student(models.Model): person = models....
0
votes
0answers
12 views

django - data preset in DB, but can't see through Model.objects.all()/Admin

I'm trying to save the Profile details for a user, who is already registered with email, phone number etc. My form submits successfully and redirect to profile page as desired. The profile data is ...