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

learn more… | top users | synonyms

1
vote
1answer
34 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
31 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
64 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
41 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: ...
3
votes
0answers
70 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 ...
15
votes
1answer
213 views

Modeling a Mage character from nWoD, using Django

Goal Design a representation of a mage character from the World of Darkness RPG, as well their associated spells. Here is a visual representation of the schema. You can see it more closely ...
1
vote
0answers
61 views

Use of get queryset and using pass to ignore an exception and proceed in my django view

I wrote a view to update my draft object. Before updating my draft I need to see if any draft exists for package(draft.package) in db or not. If any draft is ...
1
vote
1answer
36 views

Dynamically calculate status in MLM

Problem: dynamically calculate status in MLM only based on a structure. It works correctly but it's so slow. Only test processing takes about 20 seconds. I tried to replace some lists by generators, ...
4
votes
0answers
72 views

Finding Facebook Friends on app, and not on app

This code gets all of a user's Facebook friends who use our app and returns a dictionary with keys that are their id's in our database and values that are a default connection level. The code should ...
1
vote
2answers
89 views

Class for multithreaded insert into database

Here I have class that supposed to take dictionaries of product objects and their articles (kind of unique identifier) from queue and insert or update them in database table. Received dictionary ...
2
votes
1answer
93 views

Django template filter - sort by multiple keys

I have prepared an implementation of sort_by_keys filter: ...
1
vote
1answer
69 views

Efficient Django model for blog post

I'm currently trying to create a travel blog using Django whereby users will be able to create a travel plan with the following features: Each user can create a travel event based on the start date ...
1
vote
1answer
50 views

A `get_context_data` method for selecting and updating images displayed to a user over a multi page form

Below are the get_context_data method and the done method of a SesionWizardView. A SessionWizardView is designed to split a form over multiple pages. The ...
3
votes
1answer
27 views

URL selection function that is designed to randomly assign users to different surveys until full

I'm trying to condense some of my code to make it more maintainable and to learn a few new tricks. Below is a Python 2.7 / Django 1.6 function which is designed to assign users to one of three ...
1
vote
0answers
128 views

Django Model field naming convention for lookup tables

I'm currently in the process of refactoring a Django app to use Django REST Framework. Within the existing code there are 15 models for lookup tables. The structure of each model is as follows (using ...
4
votes
1answer
59 views

CRM for a web host

I wrote an application which runs correctly, but I just want to have some feedback on it. Is there something unnecessary, or could there be something more pythonic, or did I write some code which ...
0
votes
2answers
131 views

Django ListView with MySQL query for the queryset

(Note: Even if you don't know Django, it's probably the query that needs work anyway, so you probably don't need to know Django/Python) I have a ListView that ...
3
votes
1answer
241 views

jQuery slider in a Python/Django SessionWizardView

I have created a Data Verification page in a Django SessionWizardView where a user has to confirm an earlier submitted rating of an image using a jQuery UI Slider ...
3
votes
1answer
170 views

Simple Django website with no authentication. For auth/testing tutorial — Model, model-tests, urls.py, and settings.py only

I am writing a simple Django project which has no authentication at all. It's going to be used as the basis of a tutorial I'm writing, on the full authentication lifecycle (create account, login, ...
6
votes
2answers
129 views

What are the latest Odds?

The main problem the following query is solving, is the following: Each Offer has multiple Odds (...
3
votes
2answers
66 views

Optimising and condensing Django View Class

This follows on from a previous question I asked which was of huge help to me. I am still only learning Python and Django and I would love to learn how to code better. The below is a ...
1
vote
1answer
86 views

Book database for a library system

I am writing a book database, and ultimately a library system, in Django. When a book is created without a title set, the ISBN will be used to automatically fetch book data from WorldCat I have just ...
2
votes
1answer
106 views

Reduce and condense a non standard SessionWizardView

As I'm slowly getting the hang of Python and Django I'm becoming increasingly worried about the volume/quality of code I have. This is my first time building a Python/Django Application and I'm ...
2
votes
1answer
50 views

Are 2 Django URLs pointing at 1 view unorthodox?

I'm in the process of writing a private messaging system and I have 2 URLs which go to the same view (is that bad?). The logic behind this madness relates to the way user relationships are structured ...
2
votes
2answers
436 views

Upload and resize image

I have implemented following code to upload and resize image in Django. Please suggest ways to make it more pythonic. ...
2
votes
1answer
131 views

Try to implement comments tree for Django

I've tried to create an implementation of a tree for comments. I want use it in Django to store comments. Please tell me how to implement it much simpler, without recursion, to find child nodes. ...
4
votes
1answer
92 views

Recursive Django filter to output a list from user hierarchy

I need to create an HTML unordered list (to display with jstree) to display the hierarchy of users, along with a list underneath the user's "subusers" of their comments. Each user could have many ...
2
votes
2answers
678 views

Django Custom Decorator for user group check

I wrote a custom decorator to check whether user is in particular group of not. Please provide the feedback on optimizing code. I currently moved from Java to Django-Python so I wasn't able to ...
7
votes
1answer
98 views

School applicant form

I have created, in Django 1.6, a site for a school, where an applicant can get registered. It's a form that requests some information from the registrant and creates a random code for each applicant. ...
5
votes
1answer
96 views

Personal Project for managing Bookmarks - View Part

The code is the view part of my bookmarker - project for managing bookmarks by categories. It uses Python 3.4/Django 1.6. I have also included models.py for ...
5
votes
1answer
464 views

Improving models for a Django quiz

I'm working on a little django quiz taking app. Currently I'm making it's models. So far I've got Quiz, Question, ...
10
votes
1answer
662 views

Replacement for commit_on_success

I am porting an application from django 1.4.5 to django 1.6.1. I found that commit_on_success has been deprecated. Moreover I found specific incompatibilities when ...
2
votes
1answer
83 views

Adding, deleting elements as per autocomplete results - updated

I am working on a Python/Django project which has turned into a JavaScript/jQuery project due to the amount of asynchronous functionality that I thought to add. There is a JavaScript file which is ...
8
votes
1answer
109 views

Speed up my search

I have a django app with search powered by haystack. The general search goes very quickly, but I need to filter the results by their model type. It works but is very slow. I've never really worked ...
3
votes
2answers
212 views

Django class-based generic views - am I doing it right?

I am working on a simple "to do list" app in Django (two models: List and Item). I'm trying to learn and make use of ...
1
vote
0answers
119 views

Adding, deleting elements as per autocomplete results

I am working on a bookmarker project for replacing storage of bookmarks in webbrowser. It will be storing bookmarks as per categories in a database. I have written some jQuery for the WIP search page. ...
1
vote
0answers
50 views

How to design a user defined graph structure?

First, my code to review: ...
1
vote
0answers
235 views
2
votes
1answer
113 views

Django models: different methods on each instance?

Imagine I have code like this in (it's about the concept; this is example code): ...
4
votes
1answer
53 views

Code efficiency with many records

I have a bunch of functions that return strings based upon score ranges. Then I have another function that sums everything up and assigns a numeric weight. ...
7
votes
2answers
142 views

How to DRY up my forms.py?

I have two ModelForms that are the same, except that one of them has its form layout built in a view and one has a submit button. These are pretty long and I have a ...
3
votes
0answers
2k views

Django Rest Framework - add/remove to a list

I have a model Collection which has a many to many relation to a model Item. I want to be able to add or remove items to this collection using Django Rest Framework. Option1 - make an action: ...
6
votes
2answers
104 views

Building SQL query

I wrote a messy function and I am wondering if you see any way I could clean it up. Essentially it takes in a list e_1=2&e_2=23&e_3=1 and makes a queryset ...
2
votes
0answers
274 views

Django on virtual machine - watching changes in static files and autocompiling LESS without inotify

I'm setting up a Django development environment using Vagrant to run an Ubuntu virtual machine on VirtualBox. As this is a student project run mostly be very amateur coders and I want everyone to be ...
8
votes
2answers
339 views

Django API Implementation

I am building a backend to a mobile application that will be hosted on a Django site connected to a PostgreSQL database. I have never built anything to accomplish this before and this is my first go ...
1
vote
1answer
105 views

Is this the correct way of handling Json? [closed]

So, I have this table generated by Django: ...
2
votes
0answers
478 views

Django form validation based on the contents of uploaded files

I have a Django form with a lot of fields, including some FileFields. I want to validate the form based on the contents of the files: they must be valid gdal datasets, and if both are present (one of ...
6
votes
1answer
230 views

Creating a pythonic snippet to read and clean .csv files

I am trying to import a .csv file, clean the contents, and make sure all the errors are eliminated. IO error file format error data error I am using the snippet below. Could someone help me clean ...
3
votes
2answers
155 views

Beautify / Refactor some Python / Django Code

So, in the following code, I am getting the best available set of rates. It gets the job done, but I think it's too long for what it does. How could I shorten this code and still get the same thing ...
4
votes
2answers
139 views

Is one view that handles two sibling models a good idea?

I am using Django multi-table inheritance: Video and Image are models derived from Media. ...