I am attempting to get a customer logo to load when a user signs into my app. To do that I am using the views function below to generate the logo url: Views: def view_company_logo(request): print("GETTING LOGO") client = Client.objects.get(user=request.user) …
Good afternoon, I am struggling with a query. Ultimately, I have some records I want to query and get a count by month. Ultimately, my goal is to come up with a data set that looks like: Month, opened, closed …
I want to use a POST request to create an object with file fields. At the same time, at the model level, I declared that fields can be null. But Django does not allow me to save this object with …
I am using simple JWT (django-rest-framework-simplejwt). I have an auth server which authenticates users. Each user can belong to a single or multiple Tenants and each tenant is represented by a subdomain. I am trying to generate django secret for …
Im trying to allow the user to edit an existing entry. But when I include new_entry.html `{% extends "learning_logs/base.html" %} {% block content %} <p> <a href="{% url 'learning_logs:topic' topic.id %}">{{ topic }}</a></p> <p>Add a new entry:</p> <form action="{% url …
I'm using auto-py-to-exe to convert my django project in an exe file but I couldn´t: Traceback (most recent call last): File "C:\Users\gerar\AppData\Local\Programs\Python\Python312\Lib\site-packages\auto_py_to_exe\packaging.py", line 132, in package run_pyinstaller(pyinstaller_args[1:]) File "C:\Users\gerar\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 215, in run run_build(pyi_config, spec_file, **vars(args)) File "C:\Users\gerar\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 70, …
So I am following this guide: https://www.youtube.com/watch?v=_sWgionzDoM and am at around 55 mins so far I have the login stuff all working however I am unable to get the dashboard to show my data from the database. …
I defined a model (File) in core app(uploader) and tried to register it for admin page but didnt work. then i tried adding core apps name to installed_apps in setting . after that admin page shows model but when i …
I am building a React Native app with Django as the backend. I have set up the login screen in React Native and configured JWT authentication with rest_framework_simplejwt in Django. However, I encounter an error when trying to log in. …
I have a Django app hosted on Heroku. Some user requests to this app require making long-running queries to external resources. In order to get around the Heroku 30 request timeout, I created a system where these long running queries …
I am a newbie to this. settings.py file is: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'postgres', 'USER': 'postgres', 'PASSWORD': 'password', 'HOST': 'db', 'PORT': 5432, } } Docker file is: FROM python:3 ENV PYTHONUNBUFFERED=1 COPY . /usr/src/app WORKDIR …
In my django Account app I have a model for Account class Account(AbstractBaseUser): wallet_value = models.DecimalField(max_digits=10, decimal_places=2, default=0.00) first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) username = models.CharField(max_length=100) email = models.EmailField(max_length=200, unique=True) phone_number = models.CharField(max_length=20) """SOME OTHER REQUIED FIELD""" date_joined = …
Manage.py file looks like this: #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you …
I am working on a Django project and get the problem with sending email. This is my code in views.py class ForgotPasswordView(APIView): def get(self, request): return render(request, 'login/forgot_password.html') def post(self, request): email = request.data.get('email') if not email: return Response({"message": …
I have a custom login_required decorator that looks like this: def login_required(function): """ Ensure that user is logged in """ def wrap(request, *args, **kwargs): if request.user.is_anonymous: message = { "status": "error", "message": "user login error", "data": "user is not logged …
I have a problem on my store site, when I want to confirm my order, when I click on confirmation on the payment page, it gives this error instead. the error Internal Server Error: /verify/ Traceback (most recent call last): …
Запускаю django проект на вм cloud.ru, в качестве субд postgresql, возникают ошибки с "соединением" c бд psycopg2.OperationalError: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: database "vitrina" does not exist django.db.utils.OperationalError: connection to server at "localhost" (127.0.0.1), port …
I am using Django OAuth toolkit and using the following code for OAuth implementation import requests from django.http import JsonResponse from django.shortcuts import redirect, render from django.contrib.auth import authenticate, login, logout from django.contrib.auth.decorators import login_required from .forms import AuthenticationForm, UserProfileForm …
I am currently developing a Wagtail project where I use the ModelAdmin to create custom admin interfaces for my models. When using ModelAdmin, the total object count of a model is displayed below the model name in the list view. …
So I have my model: from django.db import models x_default_coordinate = 0 y_default_coordinate = 0 class Model(models.Model): location1 = gis_models.PointField( srid=4326, default=Point(x_default_coordinate, y_default_coordinate) ) location2 = gis_models.PointField( srid=4326, default=Point(x_default_coordinate, y_default_coordinate) ) Where would be an appropriate place to store …
I'm trying to achieve the following SQL query in Django: (The table contains the purchases per each day per each location. I want to get the biggest amount of each location, then group them by state to see how much …
We are working with Django to perform an asynchronous export task that will populate a CSV with information and then download the CSV automatically to the user's Downloads once a user hits the button 'Start Export.' When it comes time …
I'm trying to create a simple Django app, using websockets for sending data. According to the documentation: I've added 'channels' in settings.py's INSTALLED APPS: INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "channels", "serial_mouse", ] ASGI_APPLICATION = …
) I hope you be well... well! I just installed debug toolbar for my django project like allways. but I don't know why doesn't the debug toolbar display?! and I have to add that I'm using docker and it's my …
I want to create User using User.objects.create_user and I am using some fields of a form Utilisateurs to do that. The image field and username field from this form are also used to populate a model UserProfile. In views py …
My PyCharm always shows: "No errors found by the IDE" I don't open power save mode. I don't know why. I even reinstalled PyCharm …
I have a django project and I'm trying to run it with '''python manage.py runserver ''' but nothing really happens. I was working on it just 5 mins before this happens. Now, I'm unable to run anything, my project doesn't …
I'm trying to return UserSerializer after successful login through dj-rest-auth. I followed the steps that were told in After login the `rest-auth`, how to return more information? which has a similar issue, but it still doesn't show information about …
Hey I am currently going through the Django tutorials and I am trying to display all of my Post objects in the python shell using from blog.models import Post Post.objects.all() my model is from django.db import models from django.utils …
Django Example # urls.py url = [ path('password_reset/<uidb64>/<token>/', views.password_reset_confirm, name='password_reset_confirm'), ] # views.py def password_reset_confirm(request, id, token): print(id) print(token) pass How would I create an equivalent for ReactJS?? // App.js <Route path='password_reset/:uid/:token' element={<PasswordResetPage/>} /> // PasswordResetPage.js ????
I'm trying to create a custom django lookup as_int so that you can easily compare and order the contents of text fields when they contain only a number, and treat them as NULL when they have the wrong format. For …
The situation is as follows: I am building a form where I fetch data for some fields from an API. I have tried debugging in every possible way, but I cannot understand why the data is not being persisted in …
#HTML <div class="container-promo"> {% for obj in promo_objects %} <img src="{{ promos.img.url }}" class="promo" /> {% endfor %} </div> #Корневой urls.py urlpatterns = [ path('dj-admin/', admin.site.urls), path('', include('customadmin.urls')), path('', include('main.urls')), ] urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) #models.py class …
Проблема в том, что форма не хочет ни при каких условиях проходить валидацию. Т.е. я ее заполняю, а данные не добавляются. Что я делаю не так? Минимально воспроизводимый пример ниже. urls.py from django.urls import path from . import views from …
I have an app with React frontend and Django backend. I'm trying to make a POST request from my react client but I get "Bad Request" error. I checked my request url and it matches with my api url. Therefore …
I'm trying create customs validations to my serialiazer but Django just ignore them and return me DRF default errors. {'message': 'Erro ao criar camião', 'data': {'plate': [ErrorDetail(string='This field may not be null.', code='null')]}} That's the answer i get view.py View …
In my server,django and nginx is deployed on ECS fargate and connected to loadbalancer, but URL is transferd by Akamai https://www.example.com/company/playground/* -> https://amazonloadbalancer/* However, there comes a few problem,such as Problem 1 static Access https://www.exmplae.com/company/playground/top will be …
I have created an inline formset which works exactly as I planned on the frontend side- However I can't seem to access any of the data- it seems like the …
I am working on migrating a function implemented in Java Spring Boot to Python Django. I encountered an issue while migrating a function that retrieves a list of keywords through a select query and updates these keywords using an update …
I'm integrating payment gateway APIs in my application (Django). I have written a class PaymentGateway that provides all the methods for all payment related utility. The __init__ initialises the payment gateway client as self.client so that it's available across all …