Skip to main content

Questions tagged [django]

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

Filter by
Sorted by
Tagged with
-4 votes
1 answer
583 views

Python - Performance of this code very slow [closed]

This is an excerpt of my html code ...
Srinivas's user avatar
  • 103
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 ...
user149459's user avatar
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), ...
Tom's user avatar
  • 241
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 ...
Florovit's user avatar
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 ...
eN_Joy's user avatar
  • 143
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 : ...
Horai Nuri's user avatar
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 ...
Tushant's user avatar
  • 231
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) ...
VirtApp's user avatar
  • 131
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 ...
MadPhysicist's user avatar
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 ...
thumbtackthief's user avatar
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 (...
user avatar
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 ...
newdimension's user avatar
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 ...
jeffci's user avatar
  • 248
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 ...
thumbtackthief's user avatar
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 ...
thumbtackthief's user avatar
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 ...
Denny's user avatar
  • 141
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 ...
Matt's user avatar
  • 311
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 ...
thumbtackthief's user avatar
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 ...
crazy_sec's user avatar
  • 131
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. ...
Here_2_learn's user avatar
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 ...
Tom's user avatar
  • 241
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: ...
Penguin Brian's user avatar
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: ...
Shak3nNotStur3d's user avatar
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 ...
user avatar
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 ...
user avatar
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: ...
user avatar
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. ...
martinstastny's user avatar
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 ...
alioguzhan's user avatar
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. ...
user avatar
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 ...
pythonBeginner's user avatar
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. ...
Marcos Aguayo's user avatar
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 ...
Essex's user avatar
  • 293
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 ...
django11's user avatar
  • 131
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: ...
Robson's user avatar
  • 163
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 ...
arlyon's user avatar
  • 23
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: ...
user avatar
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. ...
intelis's user avatar
  • 171
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: ...
stetim94's user avatar
5 votes
1 answer
570 views

Raising an error for slug unique in django

I have the following model in models.py: ...
stetim94's user avatar
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 ...
Milano's user avatar
  • 191
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? ...
Simon's user avatar
  • 1,012
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 ...
Stupid.Fat.Cat's user avatar
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 ...
digitaladdictions's user avatar
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 ...
Milano's user avatar
  • 191
2 votes
1 answer
232 views

Django BaseController

A working example of mine, trying to streamlining my Django views, with absolute inspiration from Laravel: ...
Simon's user avatar
  • 1,012
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 ...
koblas's user avatar
  • 193
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 ...
Essex's user avatar
  • 293
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 ...
Essex's user avatar
  • 293
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 ...
theWanderer4865's user avatar
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....
Sebastian Olsen's user avatar

1 2 3
4
5
7