Questions tagged [django]

Django is a Python-based framework for creating web applications.

Filter by
Sorted by
Tagged with
1 vote
1 answer
82 views

Python Django image upload API with 6 fixed slots

I built an image upload API with Python Django. There are a fixed number of 6 slots, which can either be null or filled with something. There are two entities, Profile, which contains the six photos, ...
1 vote
1 answer
59 views

Django Code Repetition due to Multiple objects in JSON

I have the following code which works as expected i.e saves data to the db as I would like it to, however, there is a lot of code repetition and I am unable to find a way to shorten the code I have ...
3 votes
1 answer
116 views

Django User Model to authenticate using email address and password

This is my second Django project for an actual client and I want some review on one of my important models. This model will be responsible for authenticating users using their E-Mail Addresses and ...
5 votes
1 answer
1k views

Python Class to represent a Pokemon

I have been programming with Python on-and-off for about 2 years now, even now I still find that when I look at other applications I struggle to follow along with their classes/objects. Please help me ...
0 votes
0 answers
66 views

Optimizing Django / Wagtail Queries for a Blog

I'm using Django and Wagtail 5.x to build a blog. At this point, I'm trying to increase my understanding of query optimization and decrease the number of necessary db queries by implementing ...
0 votes
0 answers
33 views

Contact form with serializer

This app collects info via form that is rendered by Django. The code posts data with JavaScript to viewset. Anybody can post to viewset but only admin users can view or edit them. Please review my ...
10 votes
2 answers
8k views

Faster Django CSV generation for several million database entries

I am writing a CSV file generator that's filtering through about seven million database entries (MySQL backend). This part is especially slow and I was wondering if there is a way to make it much ...
0 votes
3 answers
139 views

Reset user's password fine

I wrote a code to reset user password. I just want to ask if it is a good and secure way to do this? Can I make any improvements here? I use ...
1 vote
2 answers
53 views

Filter based on different criteria until a match is found

We get the most relevant feedback about a doctor depending on the speciality, intervention_type and ...
2 votes
2 answers
4k views

Django, filtering on reverse foreign key

We have Projects, which can each have many Entries. We want a report where we see the completion_date of the newest Entry associated with a given Project. However, ...
1 vote
0 answers
62 views

Two steps changing email system Django + Redis

I created a two steps changing email system. Firstly I show You the concept how it should work and then the code. I am using Django and React. Main question: is it a good way to do it? Is it fine to ...
0 votes
0 answers
31 views

Is this the right way to write 'add contact' view

I'm using DRF. I have a User model and contacts field in it and contacts are also User instances. ...
3 votes
1 answer
174 views

Summing categories of financial records per month in a query

My program is working properly but I'm unconfortable with code repetition. ...
0 votes
1 answer
120 views

Get Gzip file from endpoint, extract data and add to database

I currently have a script that fires a request to an API endpoint which returns a csv.gzip file - which roughly contains 75,000 rows and 15 columns. I download this ...
1 vote
2 answers
1k views

Django functions to sanitize URL, return welcome message, redirect, compute HMAC, and manage profile picture

I wrote this code to to perform the following: I will remove the "spaces" within the url. Return welcome message. Redirect the user to different url. Compute HMAC for the request. Return and revoke ...
3 votes
0 answers
272 views

Django form for product stock, where products from the same batch must be merged

Here is the context first. I have a 'Stock' table, in which I record all the stocks with as information: the product, the ...
2 votes
1 answer
103 views

Custom model to count user interaction in application

In language dictionary application users can add new words and do other staff with this word such as adding additional information to the word (description, etymology, speech parts, noun class etc.) I'...
1 vote
0 answers
29 views

Django data migration - worked, but far from performant

Background: I am learning web dev and decided on the Django framework as an excuse to learn Python at the same time. (Background is stats with lots of R and ...
3 votes
1 answer
608 views

Email verification resend implementation Django

I'm trying to build an email verification for user signup using CreateView. This view check whether the user is a new or already existing inactive user? and resend ...
1 vote
1 answer
104 views

Python module to generate context for Django template using data requested from API

As part of a university assignment, I have been tasked with populating and rendering a provided Django template with COVID-19-related quarantine data retrieved from a government API. To challenge ...
2 votes
0 answers
42 views

Create a more efficient and performant csv import function with Python Django

I am creating a website for users to track their Magic the Gathering inventory. I have created some functionality to import a csv to easily add cards to their inventory. The functionality works as ...
1 vote
0 answers
48 views

Reduce db queries

my models ...
1 vote
0 answers
119 views

Execute a third party API call for every object in my queryset in a Django ListView

I have a ListView that displays every customer (class Cliente in my code) of a company. Every ...
1 vote
1 answer
1k views

React + Django (session) authentication

Is authentication implemented correctly? At the entry point to the app, which is App.js, query the Django server, which responds whether the current user is ...
6 votes
1 answer
207 views

Get list of claims based on priorities

I have written the following function which works as expected but I still see there is some room for improving its readability ...
2 votes
0 answers
390 views

Generate breadcrumbs from URL in Django

For Django sites with URLs structured in a hierarchical way I found it helpful to have an app to quickly transform an URL like ...
2 votes
1 answer
64 views

Wanted to eliminate the repetition in the classes created to reduce duplication

Can some one help me on how to eliminate repetition to reduce duplication score on the below classes created in the code ...
1 vote
0 answers
13 views

Check if Profile name is contained in Tagged Profile names: added link

I have a function which checks for a profile name and determines if it is in a tagged profile name. ...
-1 votes
1 answer
175 views

django multiple if else refactor

I have a function with multiple if else statements that I'm trying to simplify in Django Is there a pattern or maybe a better modeling approach that I could use here? The idea behind is to have a ...
1 vote
0 answers
22 views

processing webhook request coming from a 3rd party application

I need some help to evaluate whether I am doing it right. The scenario is, a 3rd party application is sending a webhook request after a successful payment but the problem is that sometimes this ...
2 votes
1 answer
2k views

Test django URLs

I started learning Django and now I want to write some tests for my application. After reading some blog posts and watching youtube tutorials I wrote tests for URLs. Look at below. urls.py ...
3 votes
0 answers
47 views

Logical next step in Django newsfeed web app

I'm hoping to get feedback on my current code from someone more experienced in Django, and in the concepts I'm trying to implement. Let me preface by saying that I am a novice to Django. This is my ...
3 votes
1 answer
336 views

Node backend to run user-submitted code in a virtual machine

As per the title, I'm making a webapp that is intended to use as a JS exercise platform. Problems are shown to users, they submit code, that code is run against a few test cases, and a report of the ...
1 vote
0 answers
28 views

Django Models for an ESL school

I am working on building a management interface for an ESL (English as a Second Language) institute, basically it is a language school where people learn English. I have prepared my models for each ...
0 votes
0 answers
144 views

Managing friend requests on a social media website in Django

So i created a social media website in django and here is how i managed accepting friend requests and showing friends posts in home page. Would it be better to do this operation in models.py file, ...
3 votes
1 answer
389 views

eLearning webapp made with Django

I've been working on probably my biggest project yet, and I'd like you guys to give me some feedback on the code I wrote so far. It's an eLearning app which offers users a host of functionalities to ...
1 vote
2 answers
91 views

Click a link to delete targeted content using Ajax

I used a glyphicon as a link to delete a comment: ...
3 votes
1 answer
63 views

Find best candidates in efficient way, Django

I'm beginner in django and python. I have models : ...
1 vote
0 answers
54 views

Global Dictionary Class

For a Django-Server I use several custom Error-Codes, error-titles and descriptions, possibly other fields might follow. I'm using right now a basic global dictionary. ...
2 votes
0 answers
40 views

Set logged-in USER in a Form requiring Current User Credentials

Currently, I can set the the current_user in the views.py for a form, which requires the user...
3 votes
1 answer
226 views

How can I refactor the validation code to minimize it?

I am using Django Rest Framework and below is the code of one of the API Endpoints. The code creates generates the PUBLIC and SECRET Values based on Stellar SDK. ...
2 votes
3 answers
205 views

Task-list app, which allows to add and remove tasks from list

I wrote my first web app. Please let me know what I should improve. I want to write as clean code as possible. App is about adding and removing tasks from list. Backend is written in Django, frontend ...
3 votes
0 answers
52 views

Handling System Check message identifiers with Django

Django implements a System Check framework that enables apps to perform checks on settings, runtime, etc. When creating an app, one can plug checks with the framework by following some requirements, ...
0 votes
2 answers
31 views

Template file for creating formatted webpages

This is my working template file which I manually edit to create new properly formatted webpages for my personal website. I am interested in what advantages if any could be realized by placing the CSS ...
5 votes
2 answers
922 views

Mapping column names and values of a csv using another csv

I have two csv files, pricat.csv which contains objects I need to populate my DB with, and mapping.csv which specifies how the ...
1 vote
0 answers
112 views

Get user and users of ancestors of a model instance if it has `organizationmember` attribute or else only user of the instance in Django

I have the following models: ...
4 votes
1 answer
245 views

Cleaning service API using Django REST framework

I am trying to write a cleaning service API using the Django REST framework, but I think how I defined this model is not robust enough for production and in turns will make any application using this ...
2 votes
0 answers
35 views

Google Mailer app inside Django using OAuth 2.0

I have built this Django Package which is an alternative for sending mail to users using Gmail API. Everything is working fine. But the verify(self, request) method inside ...
3 votes
1 answer
686 views

Django Calendar Model

I am building a doctor appointment app with Django and Django Rest Framework. The app will have the functionality for secretaries to add appointments to a Doctor's calendar, and each Doctor may have ...
1 vote
0 answers
22 views

Django: View method that outputs large context data into an html dashboard template

I'm a beginner in Django3 and just wrote an overview function to pass on some data to the template in a context variable. I am definitely passing a lot more than I should as I only need only a few ...

1
2 3 4 5
7