django

Django form redirect using HttpResponseRedirect

So this can't be too hard but I can't figure it out... I want my form in django (located at /file_upload/) to upload a file, add it to the database, and then redirect to a new page where the parameter is the id of the field that I've added in the database (located at /file/163/, say). I've set up urls.py so that /file/163/ works just f...

Django: Reversing a URL with a different template

How can I reverse a url but with a different template name? I specifically have to use urlresolvers.reverse To be more specific: I have one view but two urls from which it could be accessed (r'^url/$', 'view1', {'template1':'template1.html'}, 'access-url1'), (r'^url_dynamic/$', 'view1', {'template1':'template_dynamic.html'}, 'url-dyna...

Django - Custom SQL in the connection string

Hello, I have had some issues with downtime as a result of hitting the max_user_connections limit in MySql. The default connection timeout is 8 hours, so once we hit the limit (and having no access to kill the connections on our shared hosting) I simply had to wait 8 hours for the connections to time out. I would like to add the follow...

Django: create Index: non-unique, multiple column

Given the following model, I want to index the fields (sequence,stock) class QuoteModel(models.Model): quotedate = models.DateField() high = models.FloatField() #(9,2) DEFAULT NULL, low = models.FloatField() #(9,2) DEFAULT NULL, close = models.FloatField() #(9,2) DEFAULT NULL, closeadj = models.FloatFi...

Self join with django ORM

Hello, everybody! I have a model: class Trades(models.Model): userid = models.PositiveIntegerField(null=True, db_index=True) positionid = models.PositiveIntegerField(db_index=True) tradeid = models.PositiveIntegerField(db_index=True) orderid = models.PositiveIntegerField(db_index=True) ... and I wa...

Django admin won't let me delete a user in its auth admin application.

This may be more of a serverfault question I'm not sure. I have two practically identical servers - I cloned the DB from one to the other, and now when I try to delete a user in the Admin > Auth application Django gives the following error: {code} File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", line 206, in resul...

Build a compare list

I want to have a vehicle comparison view for my Django app where the user checks off several vehicles from the list then all the chosen vehicles are displayed on another page with their individual features alongside each other. How should I go about this? ...

How to debug Django NoReverseMatch errors?

Folks, I am getting a NoReverseMatch error for a particular url call. I'd like to know: are there any good tools to debug these in general? For example, some way to list out which URLs are registered? My particular example: Template: <a href= "{% url django.contrib.auth.views.redirect_to_login blarg %}">log in</a> Error: NoRevers...

Django returning HTTP 301?

Hi, I have a django view that returns HTTP 301 on a curl request: grapefruit:~ pete$ curl -I http://someurl HTTP/1.1 301 MOVED PERMANENTLY Date: Fri, 16 Oct 2009 19:01:08 GMT Server: Apache/2.2.9 (Win32) mod_wsgi/2.5 Python/2.6.2 PHP/5.2.6 Location: http://someurl Content-Type: text/html; charset=utf-8 I can't get the page's content ...

Use Django and MySQL on Windows

I am just starting to get into Python and decided to download the Django Framework as well, I have that working just fine but then I tried to create my first "Django App" (the tutorial at the Django website) and when I ran into the "Database setup" I start having issues I am using Windows 7 and I've always played around with MySQL in WAM...

Django: One project for integrated blog, forums, and custom web app?

Howdy Im still fairly new to Django, so please explain things with that in mind. I'm trying to create three websites using 2 subdomains and 1 domain: for the blog, blog.mysite.com for the forums, forums.mysite.com for the custom web app, mysite.com When building the custom web app, I used contrib.auth to make use of the built-in dja...

Django inheritance: how to have one method for all subclasses?

I have a model BaseModel and several subclasses of it ChildModelA(BaseModel), ChildModelB(BaseModel), ... using multi-table inheritance. In future I plan to have dozens of subclass models. All subclasses have some implementation of method do_something() How can I call do_somthing from a BaseModel instance? Almost identica...

eliminating unnecessary database hits in django

I'd like to reduce actual database hits when working in django so I've created this artificial example to outline the problem. The model looks like this: class Car(models.Model): name = models.CharField(max_length=10) user = models.ForeignKey(User) In my view I want to do something like this: def cartest(request): cars = ...

How to perform a "Group By" query in Django 1.1?

I have seen a lot of talk about 1.1's aggregation, but I am not sure how to use it to perform a simple group by. I am trying to use Django's sitemap framework to create a sitemap.xml file that Google can crawl to find all the pages of my site. Currently I am passing it all the objects, as in Model.objects.all() - however all that really...

(Django) Sharing authentication across two sites that are on different domains

I have two sites say foo.com and bar.com and are both Django based. Primary registration occurs on foo.com (I'd like the main user db to be here) and I'd like for three things to happen: 1) User that logs in to foo.com is automatically able to access bar.com without logging in again 2) User that logs in to bar.com directly is authentic...

Best photo app for Django to sell photos online

I have a client who is an events photographer and they want to be able to sell photos online. The major differences from personal photo apps would be: Need to upload 100s of photos at a time Easy ability to tag photos by event name in batches (prior to upload or after) Integration with PayPal Does anyone know of an existing app that...

phpDocumentor goes to PHP, as X goes to Python (Django)

What is the X? Thanks ...

Django: Making model with undefined number of fields

Hi I am trying to create a model for Article site. I want to link each article with 3-5 related articles, so what I am thinking of is creating code this way: class Article (models.Model): # Tiny url url = models.CharField(max_length = 30, unique=True) is_published = models.BooleanField() author = models.CharField(max_le...

SOAP service in Django with soaplib

Hi I am looking to create a SOAP service within my Django App, but have come across a few hitches. Firstly I have been able to successfully follow the soaplib Hello World tutorial (google "soaplib hello world" since I only can use 1 hyperlink as this is my first question) which uses a CheryPy WSGI server to run the service, and the soapl...

Long, slow operation in Django view causes timeout. Any way for Python to speak AJAX instead?

I've been programming Python a while, but DJango and web programming in general is new to me. I have a very long operation performed in a Python view. Since the local() function in my view takes so long to return, there's an HTTP timeout. Fair enough, I understand that part. What's the best way to give an HTTPresponse back to my users ...