Questions tagged [django]

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

Filter by
Sorted by
Tagged with
-2
votes
0answers
10 views

how can i use two types of queryset models override save method? [closed]

i want to ask you if i POST an article with featured=True then the old featured=true get transferred to featured=false queryset. i just want two [:2] values in featured=true queryset. here is the ...
3
votes
1answer
34 views

My Django custom user model

I followed a video on YouTube to create a custom user model, this is my attempt: ...
2
votes
0answers
13 views

Representing LXC component configuration in django

I want to represent components of LXC in django; so I defined them in models: Container, Network, Profile and Devices where each one of them have a set of attributs, but when it comes to representing ...
1
vote
0answers
43 views

two foreign keys in one django model [closed]

I'm working on a project the scenario: teacher model then is the teacher has not a profile the institute which working at will upload the courses does this is written the way I have tried in the ...
0
votes
0answers
42 views
1
vote
1answer
27 views

Synchronize list of trees with DB using DRF serializer

Given the models below: ...
0
votes
0answers
20 views

Django model manager improvments

I'm trying to get a computed field at my Project model. It should calculate all foreign key data specific field. At first, I created a model property with a ...
0
votes
0answers
46 views

Django auditing fields created_by, created_at, etc

I wanted to add auditing fields to a model in Django and they would take care of themselves. The fields would be: created_by created_at modified_by modified_at I want to add new columns to existing ...
2
votes
1answer
35 views

Speed up Django migration that adds two fields into one

Currently trying to migrate two fields of information into one field. We have many, many objects to go through and it takes roughly 12 minutes to loop through all the objects. That would mean the ...
2
votes
1answer
39 views

Backend for chore management app

This is my first go at Django, so I'm looking first to learn how to make this more idiomatic. Also, is there a better way to set up my tests? To my HTTP status codes make sense? chores/tests.py <...
2
votes
0answers
53 views

Django add comment to article

I have recently finished a "django for beginners" book that ended with creating a small articles site. The last chapter adds a Comment model which is linked to <...
2
votes
0answers
30 views

Django View tests [closed]

I am working my way through a Django book and part of that covers the test cases. In the current chapter I have the following code form the start of the test cases but some of it feels like it ...
1
vote
0answers
27 views

Document storage models and Django Unit Testing

My question is about proper testing procedures for Django models. The project is for a startup building a very basic HR system due to excel sheet data integrity problems. I am trying to figure out the ...
4
votes
0answers
52 views

Download Fasta protein sequences as a file from the selected categories

I have the following function in Django to download the Fasta sequences (protein) through the selected categories as a file. This works well. I would like to improve the following script. ...
-3
votes
1answer
64 views

error with django collectstatic [closed]

I'm following this tutorial for setting up Django with Nginx and Gunicorn. One of the main components is the collecstatic command. This is the code I used: ...
1
vote
1answer
21 views

Django - Filtering with default

I have a method visible on a QuerySet class which should return all articles an user can see. If the user is not logged in, all ...
4
votes
1answer
63 views

Querying all items that are in a many-to-many relationship with a child of an object

I have the following Django models setup: ...
2
votes
1answer
53 views

Django Unified Method for Deleting Instances of Any Model

This code works, but I don't know if there are better and especially safer ways to do this. For context: this is a Django view (Python) and I wanted to unify the deletion methods because there were ...
1
vote
2answers
27 views

Django: App based at PolymorphicModel

I'm building a simple Django app for reviews of different objects (restaurants, car services, car wash etc). I started with the app, but soon I faced first problem. Every object has features (but ...
4
votes
1answer
66 views

Periodically synching data from an API to database is extremely slow

I have a scheduled task where I synch all the data from one table (via an API) to another. There are about 10,000 rows that are being updated and the new ones get created. This is what I came up with ...
1
vote
0answers
38 views

Listing all related details of a model object through Django ORM

How can my solution be improved / optimized? explaination of db models : thinkpad is a equipment of laptop subcategory.and ...
3
votes
1answer
51 views

Script that saving most relevant Youtube video for each database object

Due to the tightened Youtube API daily quota (that allows to use only ~ 98 search requests per project daily) I've implemented a multi-project system. For this to work you need to create a project/...
4
votes
2answers
63 views

Run the needle program for a query against the subject files and return the result

I have written the script to run locally the needle program for a query against the subject files. It returns the highest percentage result file as a string. In addition it also converts to html file (...
2
votes
0answers
64 views

Django Dashboard View

What does my code do? I use Django and in the following snippet, I use a class together with a TemplateView to render an HTML page. I already tried to simplify it with methods, but my code still looks ...
3
votes
1answer
202 views

Convert text file to html?

I have a script that converts a text file to html. The text file is an output of a program (needle). The function takes the text file as an input. I am aware the script is awful. I use this function ...
3
votes
1answer
136 views

Using a thread to update a table automatically in Django

For my portfolio app using Django I made a thread that pulls out the usd exchange rates for various currencies every 6 hours and updates the database. The program kicks in as soon as the module ...
4
votes
1answer
93 views

A small protein database

I am making a small database and these are the following files. The scripts are working. How can I improve my scripts? Are there any places where a problem could occur? I have yet to write tests for ...
2
votes
1answer
161 views

Django turn ChoiceField into a submit button

I have made a ChoiceField into a select and submit button and wondered if this is the correct approach. forms.py ...
1
vote
1answer
59 views

Code improvement suggestions for cost calculation [closed]

I have to calculate costs based on country code and city(optional). There is also a condition that countries in Asia have separate pricing logic depending on both country and city and they are stored ...
3
votes
0answers
46 views

Django project for events of the day, grouped by keywords in common

I have made a website where people write about their day and see it analyzed. In particular, the website takes event titles and groups them together if they have any common words (after stemming the ...
2
votes
2answers
76 views

Optimising two for loops in Python

I would like to make this code more efficient, I have isolated the problem as being these two for loops: ...
2
votes
1answer
197 views

Exporting data from PostgreSQL as CSV to S3 bucket

I have a general question regarding DRY. As you can see there are several parts such as io.StringIO(), csv.writer, ...
2
votes
0answers
29 views

Automatically filled multiple forms in one view

I have some question because in my project I have 4 models, and one of models is parent for other 3 and they are connected to parent by foreign key. Then I have view which is used for automatically ...
1
vote
1answer
34 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
1answer
79 views

Django view of reward points that heavily filters and sorts (many) database results

My page (even when it has no data) takes 10+ seconds to load. That's just too long, considering when you finally get to it there's no data. When it has data, it takes even longer. Here is my view, ...
3
votes
0answers
95 views

ProfileForm that collects extra fields on User Signup

I have a signupView that shows 2 forms: SignUpForm and ProfileForm. Basically, ...
1
vote
0answers
22 views

Trigger sirens on cameras in remote locations

Web-app summary: I'm a complete beginner in web development and I made a sample web application that can trigger sirens on security cameras located in remote locations. Here's the functionality seen ...
0
votes
0answers
22 views

Django: Better way to combine these two queries?

I combine two query sets (available_tickets_by_event and sold_tickets_by_event. My end goal is to combine it in ...
2
votes
0answers
43 views

Web app that triggers sirens on cameras in remote locations

Web-app summary: I'm a complete beginner in web development and I made a sample web application that can trigger sirens on security cameras located in remote locations. Here's the functionality seen ...
1
vote
1answer
66 views

Sign-up serialization in Python [closed]

I built a small project using Django-Rest-Framework. Please comment on the best practice style for the code below, which will make it simpler. ...
1
vote
1answer
37 views

Django export to xls format

I'm working on a Django project and I'm wondering if there is any way to improve the process time to export my data to xls format. Actually, it takes between 43 seconds and 49 seconds to create the ...
1
vote
0answers
97 views

Putting a multichoicefield under a dropdown button

I am building a web app in Django where one of the form fields is a multiplechoicefield from a many2many object that I use to select users that are allowed to edit the post. In standard form the field ...
0
votes
1answer
45 views

Simplify small pieces of code with Python/Django [closed]

I'm trying to make a code review for an external developer on my project. His code could be improved and I need your advices in order to know if my overwritten parts are better or not. Part 1 ...
1
vote
0answers
31 views

Python Elasticserch DSL integration with Django [closed]

There is a big Pull Request in django-elasticsearch-dsl. Can anyone take some time and review the pull request? We are changing from python MetaClass to a decorator ...
3
votes
0answers
854 views

Simple auction application in Django

I'm learning backend dev and python and django1. My first app is a basic auction site. Users sign up, submit an auction, and other users bid on the auctions. I would highly appreciate any ...
4
votes
1answer
70 views

Django view to display weather measurements for selected location and dates

I'm a crop scientist and am currently building a web app that collects weather data then generates and displays modeled agriculturally relevant output. My question centers around an increasingly ...
3
votes
1answer
72 views

Two cases for indicating consent for a ticket

I have two cases here: the person who ordered a ticket clicks on "Permission" and the OrderConsentUpdate View updates the database. is the attendee him- or herself ...
2
votes
0answers
109 views

Django authentication against Exchange server

I wrote an authentication app for Django and my worry is primarily about the security of my app. My Django authentication app uses exchangelib to authenticate ...
4
votes
1answer
89 views

Django model for real estate

I have built a real estate management system with Django. I want to know if my design database was wrong. Please let me know how to improve it. Should I make the models use more than two tables (...
2
votes
0answers
642 views

Django Restframework: Writable nested serializer with custom behavior

Context I am trying to get some practice with Django and Django REST framework. As a toy example I want to set up a server to which I can POST results of automated test runs. In the simplest version, ...

1
2 3 4 5 6