Questions tagged [django]
Django is a Python-based framework for creating web applications.
332
questions
3
votes
1
answer
56
views
Scraping weather conditions for mountain peeks
I have built a website in Django in which I tried for the first time to create a complex app. It's an app that scrapes weather conditions on a peak in mountains, which are 17. I wanted to show a ...
2
votes
0
answers
2k
views
Limit choices for Django admin filter_horizontal interface
The Django ModelAdmin offers a filter_horizontal (or filter_vertical) interface for many-to-many relations, which allows the ...
3
votes
1
answer
164
views
Python REST API and Mongo - Aggregation Pipeline/Stage classes
This has been my approach for "simplifying" MongoDB aggregation queries in a pythonic syntax - was my intent, at the very least:
...
1
vote
1
answer
1k
views
Best practice for URL's architectural Design in Django [closed]
I have been designing websites with Django for a while and I have also designed various sites. But here is a question that comes to mind at the beginning of any new project:
What is the best URLs ...
3
votes
2
answers
204
views
Make django, weasyprint code object oriented
Please ignore the comments in the code for the purpose of reviewing. I just require tips on using SOLID principles and how classes can be used in this code.Comments in the code are for mapping the ...
3
votes
0
answers
1k
views
Product inventory database with attributes and variants
I have design a model for product apps. This is the first time I am trying to create a product's database schema and then model it in Django. My code handles the following:
A product type can have ...
4
votes
1
answer
610
views
Use django engine to fill in a .html file on storage (no template) and use weasyPrint to convert it to PDF
I 'm new here. I wrote the following django code. I 'm opening, closing files here and saving them temporarily and deleting them. I tried to use Python's tempfile and was getting Permission Error and ...
1
vote
1
answer
41
views
Statistics function
I have created a database using Django. I have a small statistics page as shown below. Can I improve this code?
View file
...
1
vote
0
answers
3k
views
One form for multiple models in Django
I must allow user to add city, state and country if it is not already present in the drop-down. Then I must create the respective model instances and then update the city in the userprofile. The below ...
1
vote
1
answer
1k
views
Am I dynamic filtering correctly in Django?
I needed a way to get URL parameters and put them and their values into a query set's .filter() if they exist. After a day of piecing together information from the ...
1
vote
0
answers
42
views
normalizing django models
i try to make an app for a mobile store
...
1
vote
0
answers
32
views
Modelling articals and authors in Django
I need to understand if the way I am modelling data in a Django application is correct. The idea is of a news site that has sources, authors and articles.
I want:
...
3
votes
1
answer
82
views
Speed up Python Script to populate MongoDB
How would I go about making this script much faster? Essentially it reads from a file and the slowest part is populating the words. In the words file there are over 100k words and I was looking for a ...
3
votes
0
answers
52
views
Django migration script to add metadata
I made a simple django migration that adds two field to our Invoices model : first_payment and first_paying_month.
...
3
votes
1
answer
70
views
Django voting implementation
I am creating a translation application and the users can add new translations to the "core" language, e.g. a Latin translation of the German word, and other users can vote on this translation. A ...
2
votes
1
answer
64
views
My Django custom user model
I followed a video on YouTube to create a custom user model, this is my attempt:
...
2
votes
0
answers
35
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
0
answers
859
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 ...
1
vote
1
answer
54
views
Synchronize list of trees with DB using DRF serializer
Given the models below:
...
2
votes
1
answer
280
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
1
answer
62
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
0
answers
536
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
0
answers
37
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
0
answers
119
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
0
answers
66
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
1
answer
368
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
1
answer
36
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
1
answer
108
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
1
answer
71
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
2
answers
60
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
1
answer
79
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
0
answers
48
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
1
answer
60
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
2
answers
86
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
0
answers
92
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
1
answer
3k
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
1
answer
1k
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
1
answer
121
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
1
answer
1k
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
1
answer
73
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
0
answers
65
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
2
answers
121
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:
...
3
votes
1
answer
2k
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
0
answers
30
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 ...
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
1
answer
235
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
0
answers
98
views
ProfileForm that collects extra fields on User Signup
I have a signupView that shows 2 forms: SignUpForm and ProfileForm.
Basically, ...
1
vote
0
answers
28
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 ...
2
votes
0
answers
62
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
1
answer
77
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.
...