django

Filter ForeignKey by Boolean value in django

I have these models: class Client(models.Model): is_provider = models.BooleanField() class Billing(models.Model): client = models.ForeignKey(Client) I want to limit the choices of ForeignKey to show only the clients with is_provider=True. Is there something like: limit_choices_to = {'is_provider': True} Or anything I can u...

Custom views in Django admin panel.

Hi All, I am working on a Django project where I need to change almost half the features and the way Django admin manages the models. For e.g. I have to create an application and then create an administrator and assign that application such that this admin can manage only that particular application. The administrators would be create...

Annotate a queryset with the average date difference? (django)

I searched all over place for an answer to this but couldn't find anything. Perhaps this is just a stupid question or a really tricky one. Here it is: Let's say my model is this (pseudo django code): Event type = ForeignKey(EventType) name = CharField date_start = DateField date_end = DateField EventType name = CharField W...

Is there an sql admin panel made with Django? - Django

Hi folks, I'm using SQL Server 2005 with Django, I'm wondering if anyone has ever attempted to create an admin panel for SQL using Django. Would be quite useful to have! ...

Changing default date printing format in python

Can I change the default __str__() function of the datetime.datetime object? By default, it returns something like '2010-06-28 12:43:56.985790', and i need it to print something like '2010-06-28T12:44:21.241228'(which is the isoformat() function). I need this for JSON serializing of a django model. My model is: class Transport(model...

django mulitidb

Hi i am using django 1.2 .I my case i have few models which are present in one db and others on second db.I have changed my settings.py file with the two database details But when i run the server it says relation not exist. How can i tell that for this model refer 'a' database and for others refer 'b' database. #models.py ### this c...

Traversing multiple lists in django template in same for loop

I want to travere multiple lists within a django template in the same for loop. How do i do it? some thinking link this - {% for item1, item2, item3 in list1, list2 list3 %} {{ item1 }}, {{ item2 }}, {{ item3 }} {% endfor %} Is something like this possible? ...

Problem with import custun storage. Django

Hi I'm siting with my custom storage system 1 day. And now when I'm trying import it it gives me this Error. I put in file models.py from FTPStorage import FTPStorage import datetime from django.db import models fs=FTPStorage() class Upload(models.Model): """Uploaded files.""" file = models.FileField(upload_to='uploads', store...

Convert Unix Timestamp to human format in Django with Python

Hi, I'd like to a convert unix timestamp I have in a string (ex. 1277722499.82) into a more humanized format (hh:mm:ss or similar). Is there an easy way to do this in python for a django app? This is outside of a template, in the model that I would like to do this. Thanks. edit I'm using the python function time.time() to generate the...

Django models : Inverted index on timestamp with query for 'n' latest rows

I have the datetime filled with auto_now=True Database is mysql. Range queries won't work for me directly. Is there any one liner for this? For simplicity, how can I get 10 rows with highest values for a field(let it be Integerfield) ? ...

Automatic email notifications based on date in django

I have to implement a way to send automatic notification emails based on a model DateFields. I'll put an example. I have a DateField with 2010-07-23 stored in it and I want django to send an email to a designated user when the current date reaches a week before (send it in 2010-07-16). Is there any way to accomplish this? ...

Django request XML file with SSL IO error

I'm making a Django website and am fairly new. In this webapp I need to use this API which will spit out an xml file with the requested data from the database. Basically the API URL is: https://adminuser:[email protected]/database.getdata?arg=1&arg2=0 So in my python views.py I have: def fetch_xml(url): import urllib ...

How do I tell django to not escape % and _ in a query

I want to be able to use wildcards in my django queries used for searching. However as the documentation says: Entry.objects.filter(headline__contains='%') Will result in SQL that looks something like this: SELECT ... WHERE headline LIKE '%\%%'; How do I tell django to not escape % and _ in a query. Or is there another way to...

How to print mysql statements executed / to be executed on a statement in django ?

I want want to examine what django does with databse when I execute some statement with a django model For instance Group.members.all() with manage.py shell. Is there any way of doing this? ...

Amazon FPS vs PayPal vs Google Checkout

I'm in the very early stages of planning a new website. I would like to offer payment processing for two distinct use cases: Accepting payments from users to me for SaaS functionality on a recurring basis. Facilitating payments between users of the website. The ratio of users making payments to users receiving payments will be appro...

Django url configuration for DRYness

Hi All, Most views in my project accept an optional username parameter and if exists, filter the querysets passed to the templates for that user. So, for example: the index view handles both the following url patterns: '^$' # general index page '^(?P<username>[-\w]+)/$' # index page for the user '^photos/$' # photo index page '^(?P<u...

Logging Django Errors instead of returning them to inspect API callback

Hi I'm working on a project that gets callbacks from some other sites' API. I expect my code to have a few errors, because I'm new to Python & Django. My site in development is using mod_wsgi and Apache with Debug = True ;) The API I get the calls from adds a parameter to the querystring to my callback that is built using their own pri...

Is Python (Django) experience professionaly comparable to Ruby on Rails?

I ask this because there seems to be a few more jobs available (at least by telecommute) in RoR. If an employer sees significant Python/Django experience on a resume, would it be plausible to believe that the developer would be able quickly learn Rails? ...

In Django, how do I set the default so that every model is created with INNODB?

Right now, Django defaults to MYISAM...but I want to change it so that everytime I create a new table it is innodb. ...

Trying to install Django via Macports on Leopard

I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again..... ...