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

learn more… | top users | synonyms

0
votes
0answers
13 views

Rendering a confirm page before saving form to db

I would like to hear your opinions on this approach. The thing I do is that I have one page where the user can fill the form - order. I want user to fill the form, then click on the 'next' button. ...
1
vote
0answers
20 views

Creating multiple objects using two forms

I would appreciate if you check my code and tell me what should I change. The code finally works but it could be much clear in my opinion. This is all about creating an ...
6
votes
2answers
90 views

Django controller method to list the top characters, guilds, and killers

I've been reading the Chapter 8 of this book. Here's the view I'm currently coding. It list all characters/guilds according to the type of URL. ...
3
votes
1answer
32 views

simple form validation

i've just started to learn python /django .. im coming from php world ...i mostly struggle with None values which are new to me .. in php i mostly did my boll checking with true/false but in python ...
-1
votes
1answer
22 views

Idiomatic Django conditional filter queryset

I am sharing a viewset between two types of routes in Django: one is a nested route (/users/:id/comments/:id/), and a regular route (...
1
vote
1answer
82 views

Validating Email Addresses without DB

I wanted to put this out here and see if there were any security vulnerabilities that I'm not seeing. Also, if I can improve performance without sacrificing security, that's always a plus. Thanks in ...
-1
votes
1answer
69 views

Django query filter on count in one to many relation

I have the following models: ...
1
vote
1answer
47 views

Get time slots based on multiple workshops

I have a list of Workshops, each having open days (Monday, Tuesday etc.) and open time and close time (which will be same for each day). Now, Based on the current time, I need to find out next 7 days ...
2
votes
1answer
110 views

Loading data from a text file into the database as fast as possible

I'm building a Django (1.8.12) application that parses a .bc3 file (Standard Interchange Format for Databases of Construction and Real State) and loads all the data into the database (PostgreSQL 9.3.9)...
2
votes
1answer
18 views

Auto registering class registry

I built this auto registering registry to look into a package and import all modules and register any classes that are a subclass of a base class. I use it as a registry for a model's choices in ...
1
vote
1answer
30 views

improvement of a database register function

Here is a function in a django rest api, that takes data in json and registers a category for a given website. I'd like to merge two try...except parts that check <...
4
votes
0answers
208 views

Ajax bootstrap modal form function

I made a few functions to handle an Ajax post request for a form inside a bootstrap modal, and then update the form errors / display a success message disappearing with a timer countdown upon valid ...
4
votes
1answer
79 views

LRU caching decorator that caches in the instance and in a shared cache

I needed a caching decorator, that could be used with methods and functions, that could take typed args and kwargs, and that was Python 2.7 compatible. Therefore I started with a backport of the <...
4
votes
1answer
47 views

Selecting all posts created by user that actual user follows

I have a view that displays posts created by users that actual logged in user follows. It works, by I think the way I've done it isn't good. BTW, UserProfile is my default user model. UserFollower ...
1
vote
1answer
79 views

Registration in Django

Can you say, is this a bad code for registration in Django? Do I need to fix something or use a pip instead? (I am learning) ...
5
votes
1answer
72 views

FIFO inventory allocation method

I am an owner of a small industrial business startup and I am learning to write software in order to efficiently keep track of our inventory and finances, as our needs have outgrown the capabilities ...
5
votes
1answer
92 views

Handling SMS replies to register/unregister phone numbers

I'm working on a Django Twilio app, and I believe it's coming along well. I just want to improve my code writing skills. How can I improve the below code? ...
3
votes
2answers
68 views

Object oriented architecture with an image processing code

This code is python 3X code (in django). It takes an instance of user entry, and process images: it creates a resized version of original image, 2 thumbs, saves all, and update instance fields to ...
4
votes
2answers
139 views

Django views for banking operations

How can I Pythonize/Djangoize/DRY my Django code? views.py ...
3
votes
2answers
129 views

Bank account model implementation in Django

There is a draft of my models.py. What can I do for code quality and readability increase? ...
5
votes
1answer
360 views

Model classes for a quiz app in Django

I am creating simple quiz app in Django. It works, but I think that way I've done it is not the best. I have Exam detail view, which display questions related to that exam and answers for these ...
1
vote
0answers
38 views

Delivering groups of online reports

As part of my present project, I revived the task to deliver group of online reports. As per a report's complexity and best performance on my radar, I decided to write SQL view on PostgreSQL and next ...
3
votes
1answer
56 views

Mapping different classes to the same database table

I have several very similar subclasses that I (think I) want to be stored in the same database table. Most of the fields are identical, with each subclass adding 1 or 2 custom fields. My code is using ...
1
vote
1answer
54 views

Ad filtering in Angular factory

I'm an 'old school' programmer (C, C++), and I have step-by-step, algorithmic thinking. I'm writing some code in Angular + Django and I know that this code is ugly but I don't have any idea how to ...
3
votes
2answers
95 views

SOAP request in a while loop

I am developing a service where the user need to sign the seller agreement with Mobile BankID (Swedish e-sign service). To make this work I need to make SOAP request to get the progress status of the ...
1
vote
2answers
137 views

Django search method

I have done this small piece of code used to search for a given word across several fields of a Django model. Goal was to have first entries equals to the word, then entries starting by the world ...
3
votes
1answer
155 views

Serving a growing audio file with Django

I would like to serve a growing audio file (raw PCM audio for now) with the possibility of seeking. I tried to manage it with Apache, but in the end wasn't able to achieve what I wanted. Now I ...
3
votes
0answers
34 views

Platform to buy services, where you can receive notifications

I am developing a website, where people can buy services, also it has a notification system; I do this in views to show log in and sign up, on index.html. views.py ...
2
votes
0answers
380 views

A web crawler for scraping images from stock photo websites

I created a web crawler that uses beautiful soup to crawl images from a website and scrape them to a database. in order to use it you have to create a class that inherits from Crawler and implements 4 ...
0
votes
2answers
79 views

How should I arrange my imports?

I inherited a project that has many imports. Is there any way to refactor it so that we don't have this many imports? ...
2
votes
2answers
72 views

Excluding an element from a dictionary

I was asked to change code that I maintain (but didn't write) for a learning management system that previously listed an examed course both under examed courses and other courses and now my task was ...
1
vote
1answer
61 views

Changing attributes in Django Objects outside of iteration

I'm adding three attributes to a Django QuerySet that represents a hierarchical tree structure: a display_name which is added to all objects the id of the object'...
3
votes
1answer
33 views

Updating multiple membership plan expiration dates at once

I have model action in RequestAdmin like this: ...
3
votes
1answer
46 views

Django view and template for a virtual zoo

I have a Django view and template that work together, but I think I probably did things in a crappy way. I basically have many dynamic values that I want to display on the page, and in two different ...
3
votes
1answer
98 views

Transaction.atomic with continuations

I have a view that looks like this: ...
3
votes
1answer
45 views

Optimisation of a views.py for survey application

I have developed a small survey application in Django 1.6.2 which requires that the participants fill out a number of questions over 27 pages using a ...
2
votes
2answers
59 views

Optimisation of a forms.py for a survey application

This is my forms.py for a small survey application I am developing. I previously posted some of my models.py. I am completely self-taught and am just looking for advice on how to improve. Any advice, ...
2
votes
2answers
144 views

Django Person Model created from forms.ModelForm

This is the current iteration of my first model of a Person. The model is populated by a survey application using forms.ModelForm and a ...
3
votes
2answers
39 views

Fetching BasicInfo, BillingInfo, and DocumentInfo objects

The repetition is super obvious here. How can I rewrite this code? I need one base method in which I pass a Django model, to call objects.filter, but I can't figure ...
8
votes
1answer
74 views

Save 2 related models through a single form

Here are two models - Property and Developer: ...
5
votes
1answer
108 views

First attempt at weighted search

My concern is speed, since this may be used in an e-commerce website I want it to be as quick as possible. Where can I improve? ...
0
votes
1answer
44 views

User and Score models

I have a couple of models - User & Score. I am displaying data from those models to my template. Data from ...
1
vote
1answer
48 views

Determine what hazard type does the building belong using GeoDjango Intersects

Below is my query to identify what hazard type does the buildings belong: ...
1
vote
0answers
125 views
1
vote
1answer
54 views

Organizing museum artwork

I have a small Django project to help organize museum artwork. In my models.py file, my museum object is defined as follows: ...
2
votes
1answer
124 views

Return JSON data based on GeoDjango Queryset

My code below returns a JSON data based on user's input or query in my HTML page or template. However, I need to modify or do some tweaking with my JSON data in order for me to use it in my datatables ...
1
vote
1answer
2k views

An array of dictionaries; comparing each {key, value} pair; and combining dictionaries

I'm trying to optimize a nested for loops that compares an element in the array with the rest of the element in the array. There's two part, the first part is for example, an Array has 3 elements, ...
1
vote
0answers
58 views

Correct, DRY, and efficient use of Django Managers?

I'm writing a custom Manager for my django app that lets you group django-enumfields: ...
5
votes
1answer
252 views

Create user with profiles and send emails

I am learning Python (3) and Django (1.7) after a while in PHP (not POO). I am rebuilding my own website that has public members. My members have a user account, a public profile and a private profile....