Questions tagged [django]
Django is a Python-based framework for creating web applications.
323 questions
-4
votes
1
answer
583
views
Python - Performance of this code very slow [closed]
This is an excerpt of my html code
...
4
votes
1
answer
256
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 ...
1
vote
1
answer
66
views
script that imports only data that is not in the database yet
I want to write a script that imports data into a database (in django). The database has a Company class with a name (CharField) instance. Additionally, it has a Person class with name (CharField), ...
2
votes
1
answer
125
views
Validating and saving a user profile, using fat model vs. view code
I heard that fat models are good idea and I should avoid operations on database in my views so I do something like this below. Can you tell me if it's good idea and which version is better? Please ...
4
votes
1
answer
150
views
Django model design to analyse user activities on external websites
I am working on an app that analyses the activities of users on some external sites. The contents of the target sites fall into three types:
Forum post: A user can either start a thread or reply to ...
3
votes
1
answer
60
views
Ordering colors into a multidimensional list
The code below works fine but seems really hard coded and I feel like I over-complicated the way it should be, I have a list containing hex and non-hex colors.
example : ...
7
votes
1
answer
177
views
Database modeling for products and store
I am planning to develop a virtual shopping mall where stores of any kind can be registered, such as in a physical shopping mall. First I want to develop an efficient and effective database modeling ...
3
votes
0
answers
39
views
Django-Python Db-access optimization
Is is possible to make this function more efficient and possibly more readable?
In addition, Am I doing this right? I mean, it works, but would it be better to do a complex query (with annotations) ...
1
vote
0
answers
536
views
Using 12-Factor Configuration Standard in a Python (Django) Project
I am currently learning practices from the 12-Factor guide using one of the Django apps that I am running in production.
In short, after reading the theory and doing my best to understand the work ...
0
votes
1
answer
411
views
Django query to find all items without a FK relationship except for excluded list
I have a Book model and an Author model that has a FK relationship to Book (I realize that ...
3
votes
0
answers
175
views
Converting YouTube channels to podcasts
I created a Django app that converts YouTube channels to podcasts. It uses the actual YouTube paths for the URLs. The idea is that the user can just find the YouTube address of the desired channel (...
1
vote
1
answer
27
views
DRY for rendering same header table for different content
I'm trying to make the following code DRY. The code outputs a table that shows violations. If there is any violation.status = resolved they go in separate table for ...
6
votes
1
answer
831
views
Showing different forms for user type with Django/Python in views.py
I have 4 user account types, realtor, insurance broker, auto insurance agent, and mortgage broker. Each one of the users will have a different form for each to submit. I have the following in views.py ...
2
votes
1
answer
31
views
Scraping website for book listings, checking if database contains relevant listings, and displaying result in a Django view
This code works but is very slow. I am scraping a website for urls for various books, and then checking to see if we have complete records of those books in our database. After I process the URL to ...
2
votes
1
answer
2k
views
Speed up performance of nested for loops to get all related format of all Authors' Books
This works but is very slow. I have an Author table that foreign keys to all books by that author. Each book has a variety of formats it can appear in (html, pdf, etc), which its linked to by its ...
10
votes
1
answer
1k
views
Python application to create Google Map image
I have written a Django app that would get some input and give you an image as output. The output image has 3 layers:
Google Map image
rosreestr (russian docs layer)
data from geojson layer
I hear ...
17
votes
2
answers
13k
views
Django Rest Framework - ManyToMany relationship through intermediate model
I'm new to Django and have just started to learn the basics. I have some questions about how to structure the code, how relationships should be written, and where the business logic should live.
I ...
5
votes
2
answers
3k
views
Validation methods to ensure start and end date come after existing instances
We have a "Committee" class and I need to ensure that any new committee has start and end dates (don't know why they're CharFields instead of Dates or even Ints, but that's not my call) that are after ...
3
votes
1
answer
2k
views
Django REST Framework - PDF Generator
I created a new endpoint for an API (Django REST Framework) that generates a PDF from an HTML template. I follow the example from the plugin django-easy-pdf.
It's working, but I would like to improve ...
2
votes
1
answer
312
views
Creating Docker network with REST API using Python Django
This solution is to create a docker network using Docker supported APIs. For achieving this, I am using Python and Django framework for providing RESTful APIs.
...
4
votes
1
answer
1k
views
Model classes for an expense tracking app in Django
I want to build a simple expense tracking app in Django. Each user can create categories, and each category can have multiple expenses:
Additionally, I wanted to have a ...
8
votes
1
answer
8k
views
CreateView set foreign key from URL parameter
I want to be able to create a lorum, using a ipsum_id (ForeignKey) that has been supplied in the URL. Using Django's class based views.
Given the following URL:
...
6
votes
1
answer
2k
views
Django Rest Framework Totaling API values in different ways
I am working on a stats website for my softball teams that I manage/play for.
Here is my current Stat model:
...
2
votes
1
answer
516
views
Authenticate users in Django
I'm writing a social networking site in Django. I created an account application which is part of site project. I implemented an authentication mechanism in the project. Every user has different ...
5
votes
0
answers
575
views
Django blog application - views, urls, models, forms
I want to learn how to create websites and I have started learning Django web framework. I think Django is very good alternative for PHP and it isn't too complex as JEE. I'm very satisfied learning ...
3
votes
1
answer
349
views
Set time zone from cookie
Is the set_cookie variable the correct way to signal that the cookie should be set? It does not seems pythonic to me:
...
4
votes
1
answer
664
views
TDD Django - Shopping Cart
I'm new in Python TDD and I would like to ask you about some feedback for Django unit testing.
...
7
votes
2
answers
936
views
Implementation of lru_cache for daily "top categories" query
In my website, I want to show top categories by products' view / sell counts.
Since this is not something changes every hour, I want to fetch real results only once a day from database (may be once a ...
0
votes
3
answers
6k
views
Button to dynamically clone a form field
I am very new to javascript and started with a very basic add button to my django app. Everything I found was using jQuery but for only one small script jQuery seems to be a too big overhead for me. ...
2
votes
1
answer
226
views
customSignupForm code to allow signup for only the invited user
I am developing a feature where the user has to request for invitation if he/she wants to sign up on the site. When the request is accepted by the admin, the user gets to sign up, otherwise it shows ...
2
votes
1
answer
10k
views
Update model Django
How can I improve this? It's large and ugly. Any advice?
I'm receiving a POST from a API, and I want to update only the fields that are not null.
...
2
votes
1
answer
721
views
Simplify multiples request.GET.get and filter conditions with Django [closed]
I'm writting my Django website and I created a view function which let to filter data before filling my Django form.
It works pretty well but I would find a way to simplify this function. It seems ...
3
votes
1
answer
53
views
Returning information about searches performed by a user
I have this simple piece of code from my django project. I feel that it isn't very well written.
Maybe it possible to write this simple function in a better way? Maybe could you give me any advices ...
6
votes
1
answer
1k
views
Model structure for Player Team and Match in football application
I'm creating an application for foosball matches.
I have models like below:
...
2
votes
1
answer
51
views
Is this "smart" way of populating the admin page ok code-wise?
I am currently hooking a large database up to a django site and want to populate the admin page with a number of models. I am using inspect to get a list of classes from each model file (one file per ...
4
votes
0
answers
93
views
Duplicate vote checking
I am new to Django and added a vote duplicate check to the tutorial application. I set a cookie in the vote view:
...
5
votes
2
answers
215
views
Test Driven Development with Django
I'm learning TDD with Django and currently I'm testing my CreateView class. I feel like I'm not using best practices but am not sure on how to improve my code.
...
4
votes
2
answers
9k
views
Raise error when slug already exists
I looked into possible ways to raise an error to generate an error when a slug already exist.
This is the model:
...
5
votes
1
answer
570
views
Raising an error for slug unique in django
I have the following model in models.py:
...
2
votes
0
answers
224
views
Django view for both AJAX and normal request
I'm starting with new project where there will be used to delete product using AJAX, but sometimes with normal request. What do you think about this view? I'm trying to make it as universal as ...
2
votes
0
answers
208
views
A Django EAV attempt
This seems to do the job of the EAV tables. Besides being EAV, is there room for improvement? Maybe there is something obvious, but how about indexing certain columns?
...
3
votes
2
answers
1k
views
Unpacking tuple from Django's get_or_create function
Django's get_or_create function returns 2 values: the object and a boolean whether it was freshly created or not. I'm only really interested in the object it ...
6
votes
2
answers
3k
views
Password generator in Django
I am a system admin, not a developer, so this might be pretty horrible code. This is a password generator. The point of the attempt was to become more familiar with Django at a lower level. I current ...
4
votes
0
answers
998
views
Working with multiple currencies in Django
I'm working on a project where user adds many products and compare their prices, average price, minimal and many other statistics.
There are two currencies for now, EUR and CZK.
I'm here to ask ...
2
votes
1
answer
232
views
Django BaseController
A working example of mine, trying to streamlining my Django views, with absolute inspiration from Laravel:
...
4
votes
1
answer
8k
views
Django query ManyToMany for tagged items
I've got a item inventory that each inventory item is tagged with multiple tags. What I've got is an API that takes a query parameter with multiple comma separated query items and returns a list of ...
2
votes
1
answer
309
views
Django Forms and handling
I'm really new with Django and I would like to get your minds, advices, ... in order to improve the first part of my project.
For the moment, I created a model form which is named ...
5
votes
1
answer
161
views
Civil status database with Django
I'm beginning with Django and I have a Civil Status project.
I created my first models.py in order to get a Form, but I had some advices in order to normalize my database.
I made this process and I ...
5
votes
2
answers
3k
views
Abstracting celery tasks with class based implementations
Background
I want to send emails with a rendered template (django template, that is) but I also want to be able to control the QuerySets, and context provided.
The goal is to make a task whose ...
3
votes
1
answer
556
views
Storing database references to files/media
This is an extension of this question due to it not covering an important role of my setup that I think needs more attention.
The files are stored on a different server for separation and convenience....