A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [django]

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

Filter by
Sorted by
Tagged with
3
votes
1answer
699 views

i18n translator using Jinja2

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 ...
11
votes
2answers
2k views

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

Here is the skeleton of my (first!) Django app: ...
10
votes
1answer
170 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 ...
8
votes
2answers
219 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
346 views

Converting an already-uploaded file and saving it to a model's FileField

Please review this: ...
1
vote
1answer
549 views

Django models: different methods on each instance? [closed]

Imagine I have code like this in (it's about the concept; this is example code): ...
3
votes
2answers
599 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. ...
3
votes
0answers
1k 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
59 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
124 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
466 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 ...
4
votes
0answers
2k 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
626 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 ...
1
vote
1answer
147 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? ...
-1
votes
2answers
117 views

Unpacking sequences for functions [closed]

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. https:/...
1
vote
1answer
438 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 ...
2
votes
1answer
134 views

Django how to make this view faster?

I have view and it works correct, but very slow ...
2
votes
1answer
564 views
2
votes
3answers
83 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
699 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
294 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 ...
2
votes
1answer
378 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. ...
1
vote
1answer
177 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. ...
2
votes
1answer
14k 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 ...
5
votes
1answer
650 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 ...
3
votes
1answer
5k 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 ...