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

learn more… | top users | synonyms

3
votes
1answer
68 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
48 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
55 views

Django how to make this view faster?

I have view and it works correct, but very slow class Reading(models.Model): meter = models.ForeignKey(Meter, verbose_name=_('meter')) reading = models.FloatField(verbose_name=_('reading')) ...
0
votes
0answers
22 views

Optionality fields in Django model?

I have this model: class Artist(models.Model): name = models.CharField(max_length=50) pseudo = models.CharField(max_length=50) birth_date = models.DateField() country = ...
2
votes
0answers
23 views

Is there a neater way of 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 named UserProfile so when I was ...
3
votes
1answer
137 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: %ul#atheletes - for ...
1
vote
1answer
48 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
110 views

Need advice of refactoring views.py

I setup simple CRUD in Django from django.shortcuts import render_to_response from django.template import RequestContext from django.core.urlresolvers import reverse_lazy from django.http import ...
2
votes
3answers
63 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 product_<id>_property to grab the value of it. Then in my view I end up ...
0
votes
1answer
43 views

Django app proposal for father app probleme [closed]

I have a proposal for manage father apps urls, object and context in reusable apps (django). I want to know if you think is a right aproache or if you see disadvantages or better ways to deal with ...
1
vote
2answers
66 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. # -*- coding: UTF-8 -*- from django.db import models from django.contrib.auth.models ...
3
votes
1answer
162 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
185 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 ...
4
votes
2answers
136 views

Refactoring advice needed for jQuery post

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
2answers
187 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). def ...
1
vote
1answer
203 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 ...
-1
votes
1answer
421 views

Can you review 1 line of code here?

Hi I hope you can comment when I include the largest file of my largest project. There is more available if you feel like code review. I think my project needs daily code review for some time. The ...
1
vote
1answer
2k 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 ...
0
votes
2answers
123 views

Review of 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 ...
0
votes
1answer
123 views

Django Team Sport class

So this isn't EXACTLY my code but it is close enough to show what I have. Also the naming is only for this site so if its not really clear forgive me. Its much clearer in the actual code. class ...
1
vote
1answer
138 views

Separating a view function by action

I have one large view function where a user can Add, Edit, Delete, and Update his education. I am currently doing this all in one view because I haven't yet learned how to split up views by function. ...
1
vote
1answer
1k views

Multiple forms in django

I have an account page where I have three forms. A user can change his name, his email address, and his password. There are two difficulties I am having from trying to do this: 1) the request.user ...
3
votes
1answer
484 views

How would you rate this python code? (Django AJAX)

This code comes straight out from the example code in a Django book. I find it quite bad, mainly because the use of flags (if ajax then again if ajax) and unnecessarily bigger variable scope (set ...
3
votes
3answers
452 views

How to optimize the code?

q_sent = False sent_failed = False if request.method == 'POST': form = FaqForm(request.POST) if form.is_valid(): form.save() q_sent = True else: sent_failed = ...
2
votes
1answer
606 views

Three-table queryset (full outer join?) in Django

I've got three tables I need query to display to a user for a web application I've written. Each table (Url, Note, Quote) has a foreign key relation to the User table. For every User, I need to sort ...
4
votes
3answers
208 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 list of pairs (header, list of ...
4
votes
2answers
135 views

Review Request: Snippet of code that tries to convert an already uploaded file & save it into a model's FileField. Python + Django

from os import path, remove try: video = Video.objects.get(id=original_video_id) except ObjectDoesNotExist: return False convert_command = ['ffmpeg', '-i', input_file, '-acodec', ...
3
votes
1answer
1k 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 but I can't figure out the template syntax. ...
7
votes
2answers
296 views

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

Here is the skeleton of my (first!) Django app: # models.py class Task(models.Model): description = models.CharField(max_length = 200) ... # forms.py class AddTaskForm(forms.ModelForm): ...
12
votes
2answers
502 views

Beginner Django Model code review

I'm learning Django as I go. I know this model is missing user authentication, registration, comments/comment threading, and voting. But this is my starting code for my model. What are some of the ...