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

learn more… | top users | synonyms

2
votes
0answers
38 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. ...
3
votes
0answers
24 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 reference. The code does the following ...
4
votes
0answers
88 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 ...
3
votes
0answers
30 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, ...
2
votes
1answer
44 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 ...
2
votes
1answer
64 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
3answers
411 views

An idiom to use the same view function to create or edit an object?

Here is the skeleton of my (first!) Django app: ...
8
votes
1answer
85 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 ...
1
vote
0answers
56 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. ...
7
votes
2answers
104 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 ...
4
votes
2answers
154 views
3
votes
1answer
4k views

Django query_set filtering in the template

Can I make my template syntax simpler? I'm hoping to eliminate the if and maybe also the for block. This worked in the shell ...
0
votes
2answers
138 views

Django view function

I have a view function that allows a user to Add / Edit / Delete an object. How does the following function look, and in what ways could I improve it? I was thinking about separating aspects of the ...
4
votes
2answers
162 views

Application for allowing a user to “follow” another user

I have taken a stab at creating my first jQuery script from scratch. I use this to post an update to a Django application that allows a user to "follow" another user. I am sure that there are better ...
3
votes
0answers
31 views

Finding the profile name for a join in my Facebook auth backend

I've written a project for handling various Facebook things and I ran into the issue where one project named the users profile Profile while normally they would be ...
2
votes
0answers
70 views

Django template block name changing function

I created a reusable function for changing block name in Djago templates. I want to know if the code is good or is there any probable issues in it. I developed the function as a hack for the following ...
2
votes
1answer
42 views

Django models: different methods on each instance?

Imagine I have code like this in (it's about the concept; this is example code): ...
1
vote
0answers
239 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: ...
1
vote
0answers
42 views

How to design a user defined graph structure?

First, my code to review: ...
4
votes
2answers
99 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. ...
1
vote
0answers
200 views

Implementing “day wise task management” system using Django and AngularJS

I have a Task model in Django which looks like the following: ...
4
votes
1answer
52 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. ...
6
votes
2answers
91 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 ...
8
votes
2answers
229 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 ...
2
votes
0answers
119 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 ...
3
votes
0answers
72 views

Split Django into apps

I am thinking about how to split my website into smaller reusable apps. I've finally figured out something and need your opinion. My main problem was that each app uses ...
1
vote
1answer
77 views
2
votes
1answer
262 views

Can you review my i18n/Jinja2/python code?

I'm learning to Jinja2 and what's important in this case isn't speed but i18n translations and functionality. With python 2.7 Jinja2 and not django seems to preferred way to go so I'm rewriting much ...
2
votes
0answers
171 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
178 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 ...
5
votes
3answers
229 views

Am I doing too much in my template?

The main view in my (toy!) Todo app is, of course, to display the list of tasks. These are grouped by some criterion, and the tasks structure below is actually a ...
2
votes
2answers
88 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 ...
3
votes
1answer
134 views

Using a .csv file to insert data into the Django model

I have a script that uses a .csv file into insert data to the Django model. Now, I wonder if there's a better way of doing this. ...
1
vote
1answer
118 views

modifying local environment in python

I need to inject same variables into settings.py for multiple django apps.hence i wrote a module which takes in output of local() and modifies. This works but is it the right way to do things? ...
2
votes
0answers
199 views

Django Celery Task for all objects in model with datetime operations

I created this quite important piece of code. But I am not pretty sure is it good enough. Description: I have big task for database and decided to use django-celery. I want to go through all objects ...
2
votes
1answer
972 views

faster Django csv generation on the fly

I am writing a csv file generator that's filtering through about seven million db entries. {mySQL backend} This part is especially slow and I was wondering if ...
-1
votes
2answers
88 views

Unpacking sequences for functions

After watching Raymond Hettinger, I decided to go through my code and make it faster and more beautiful. The example given on the slides is, unfortunately, not good enough to get me going (ref. ...
3
votes
1answer
299 views

Python/Django Script - Is it crap? Objects duplicated or passed?

I've written a script using the Django ORM to store 'configuration settings' and interacting with the Google Drive API and another API. The script creates a base project folder and subfolders in ...
1
vote
1answer
163 views

POST data handler

I have written a function to handle post data received from a web page. The Emphasis is on making getting post data easy: using the function allows the coder to specify the required data, type, and ...
1
vote
1answer
88 views

Django how to make this view faster?

I have view and it works correct, but very slow ...
3
votes
1answer
196 views

Feedback on a small Python parser

I'm working on a feature for the HamlPy (Haml for Django) project: About Haml For those who don't know, Haml is an indentation-based markup language which compiles to HTML: ...
1
vote
1answer
68 views

Any issues with injecting data into a django form after creating an instance?

I have a django form CreateQuoteRequestForm and I wanted to populate a list of items from a query set. So I created a list and then assigned as seen below. The form and select box work well. Are ...
2
votes
1answer
200 views

Need advice of refactoring views.py

I setup simple CRUD in Django ...
2
votes
3answers
70 views

Building and getting a form of objects that have multiple properties

I'm building a form dynamically in a web app where I'm using product_id to keep track which product I'm reading and then ...
1
vote
2answers
94 views

Doubts about db_index, primary_key and unique parameters

I'm trying to improve my code. I've some doubts about db_index, primary_key and unique parameters. ...
3
votes
1answer
220 views

Am I being too redundant in this Django view (or can I reduce the repetition in my code)?

I'm new to Django and learning my ways around it. I'm writing a fake basic CRUD app to get me started. In the following code I pretty much copy and paste the same code four times with minor ...
3
votes
1answer
354 views

Polymorphism in Django models

For flexing my newly acquired Django & Python muscles, I have set up to do a mobile content delivery system via Wap Push (Ringtones, wallpapers, etc), old fashion but it is an exercise! I have a ...
3
votes
2answers
239 views

Is this a good python design?

I'm using django and i wrote this decorator to take away some of the repetitive code i found for ajax views and i want to know your opinion (too basic, bad design, try this instead, ok, etc). ...
1
vote
1answer
3k views

Python XML parsing and data presentation in Django

I hope this is not a duplicate. For some time now, I've been using a pattern which I think could be done more elegantly. I have a lot of XML files that need to be represented in a Django views. My ...