django

google app engine: new version doesn't appear

I have made an update on Google App Engine with a small fix and I got: Closing update: new version is ready to start serving. However, when I open the website, there is still old version. I have changed version to 2 in app.yaml, before running update. What am I missing? ...

Quickly implement a sortable table of objects in Django

Hey all. I have a question on how to implement the following with Django. I'd like to display a tabular view of my objects with each column corresponding to a particular model field. I'd like to be able to have the user sort the columns or search through all of them. Basically just like the admin, but client facing and read-only. It's si...

Django query with related models

For the below models: class Customer(models.Model): id = models.IntegerField(primary_key=True) class OrderA(models.Model): name = models.CharField(max_length=20) foo = models.FloatField() customer = models.ForeignKey(Customer) type = models.IntegerField() class OrderB(models.Model): name = models.CharField(max_...

How to filter a query by property of user profile in Django?

I have two models,Design and Profile. Profile is hooked up in settings.py as the profile to be used with the User model. So I can access it via user.get_profile(). And each Design instance has an author property that is a ForeignKey to User. So, when I'm any view, I can get the screenname (a property of Profile) by: user.get_profile()...

Django model forms

hi can any body send me a complete tutorial about how to create a model form in django. i tried to create a form from here . "http://docs.djangoproject.com/en/dev/topics/forms/modelforms/" but it returns an error saying "name 'ModelForm' is not defined" any suggestions plzzzz ...

How do you paginate results from a dynamic search in Django?

I'm currently building a simple search method for some designs. The query searches both the name of the author and the text of the design. The problem: what happens when the database has 300,000 designs and I want to paginate the results? If I pass a page variable, then each time a user switches to a different page, the query is executed...

DTD parser for Django/Python

Is there a tool that can generate Django models from a DTD? Failing that, are there any decent DTD parsers available for Python? ...

Confusion on using django socialauth

http://github.com/uswaretech/Django-Socialauth/tree/master/socialauth/ I'm a bit confused on how I should use this. Of course, I read the notes at the bottom but I'm a Django novice so I'll need a little hand holding. The structure of this looks like a project structure since it contains a urls.py but I'm also aware that applications ...

How to Check if request.GET var is None?

Hey, I'm getting into django and this is getting me a headache. I'm trying to get a simple GET variable. URL is site.com/search/?q=search-term My view is: def search(request): if request.method == 'GET' and 'q' in request.GET: q = request.GET.get('q', None) if q is not None: results = Task.objects.filter( ...

Django filter vs exclude

Is there a difference between filter and exclude in django? If I have self.get_query_set().filter(modelField=x) and I want to add another criteria, is there a meaningful difference between to following two lines of code? self.get_query_set().filter(user__isnull=False, modelField=x) self.get_query_set().filter(modelField=x).exclude(u...

Filter across three tables using Django

I have 3 django models, where the first has a foreign key to the second, and the second has a foreign key to the third. Like this: class Book(models.Model): year_published = models.IntField() author = models.ForeignKey(Author) class Author(models.Model): author_id = models.AutoField(primary_key=True) name = models.Char...

Best practices for logging in django project.

Hi It is always good to utilize existing patterns for solving the given problem rather then reinventing the wheel. This time it is about doing logging stuffs in django based project. Can you please share your ideas with me and other about how do you prefer to implement logging in django based project in the following context? What f...

creating a frame to put pictures in it and saving back to database

Hello, I'm working on a mobile site and what I have to do is 1.create a picture frame 2.add to it pictures posted by users individually, then save each picture back to the database. Does anyone know how to go about this ...

Sum computed column in Django QuerySet

Given the following Contribution model: class Contribution(models.Model): start_time = models.DateTimeField() end_time = models.DateTimeField(null=True) is it possible, using the Django database API, to reproduce the following SQL statement? SELECT SUM(end_time - start_time) AS total_duration FROM contribution; I've figured...

is django version 0.96 is compatiable with pyscopg2-2.0.7

am not able to sync the db... manage.py syncdb is not working am getting follwing error D:\deepak\py\ifrnds>manage.py syncdb Traceback (most recent call last): File "D:\deepak\py\ifrnds\manage.py", line 11, in <module> execute_manager(settings) File "C:\Python25\Lib\site-packages\django\core\management.py", line 1670, in ex...

Problem with Django setup using mod_wsgi and apache on centos 5.4

I am trying to setup apache with mod_wsgi to serve Django through a nginx proxy on CentOS 5.4. I want to start by configuring Apache with Wsgi to serve on a local port, but I get a 403 error when I run curl localhost:8080 # Httpd config: Listen 127.0.0.1:8080 NameVirtualHost 127.0.0.1:8080 <VirtualHost 127.0.0.1:8080> ServerName st...

How do I select from multiple tables in one query with Django?

I have two tables, one "Company" and one "Employee": class Company(models.Model): name = models.CharField(max_length=60) class Employee(models.Model): name = models.CharField(max_length=60) company = models.ForeignField(Company) And I want to list every Employee in a table, with the Company next to it. Which is simple eno...

Translate model fields' attributes from a Database with Django?

I'm trying to create a Model that has fields that have the following attributes translatable: verbose_name and choices. I can easily do this by tagging the strings and using the i18l middleware. The problem is that I don't want to define the translation in po/mo files. Is there a way to pull this data from a database table? If so, any ex...

django forms MultipleChoiceField reverts to original value on save

Hi, I have wrote a custom MultipleChoiceField. I have everything working ok but when I submit the form the selected values go back to the original choices even though the form validates ok. my code looks something like this: class ProgrammeField(forms.MultipleChoiceField): widget = widgets.SelectMultiple class ProgrammeForm(forms...

Django deployment. Error loading MySQLdb module. Trouble reading/writing from /tmp directory

I'm deploying my Django app to another host/server using mod_wsgi and MySQLdb. Right now, I'm getting a 500 error with the following log: ImproperlyConfigured: Error loading MySQLdb module: /tmp/MySQL_python-1.2.3c1-py2.4-linux-i686.egg-tmp/_mysql.so: failed to map segment from shared object: Operation not permitted Did some research a...