django

What's your favorite way to test the javascript in your djangoapp?

Hi, I've been working with django a lot. Now I have an app with JavaScript integrated which I want to test. What's your favorite way to integrate real-browser-tests in the django unittest environment? twill? selenium? windmill? ...

Trouble getting code parameter on facebook oauth callback

Hello, I'm writing a Django app requesting permission to post on facebook. I can access authorization and callback, but I can't get the parameter 'code' that facebook needs to continue with oauth. def connect_fb(request): return redirect("https://graph.facebook.com/oauth/authorize?" +"client_id=MY_ID&" +...

django error: 'unicode' object is not callable

hi all, im attempting to do the django tutorial from the django website, and ive run into a bit of an issue: ive got to adding my __unicode__ methods to my models classes, but when ever i try to return the objects of that model i get the following error: in __unicode__ return self.question() TypeError: 'unicode' object is not call...

django image storage cdn

Hi. I have been using rackspace CDN for the last few months with django-imagekit and django-cumulus. And I am not really happy with the results. I seem to get load of errors because of timeouts etc. File "/www/django_test1/omu2/src/python-cloudfiles/cloudfiles/connection.py", line 347, in get_container return Container(self, cont...

Error using a base class field in subclass unique_together meta option

Using the following code: class Organization(models.Model): name = models.CharField(max_length="100",) alias = models.SlugField() ... class Division(Organization): parent_org = models.ForeignKey(Organization) class Meta: unique_together=['parent_org', 'alias'] ... Trying to syncdb give me this err...

IntegrityError with Django m2m relations

I have a relatively simple Django app, with quite heavy usage that is responsible for quite some concurrency in the db operations. I have a model Post with a m2m to a Tag model. A single line in my code, p.add(t) is repeatedly causing mysql exceptions (where p is a Post instance and t is a Tag instance.) IntegrityError: (1062, "Dupli...

How do I replace the current working MySQL database with a .sql file?

Hello, I'm trying to restore the current working database to the data stored in a .sql file from within Django. Whats the best way to do this? Does django have an good way to do this or do I need to grab the connection string from the settings.py file and send command line mysql commands to do this? Thanks for your help. ...

Django admin site: how to create a single page for global settings?

I would like to create a single page in the admin site of django where I can change some global variables of the website (title of the website, items in the navigation menu, etc). At the moment I have them coded as context processors but I would like to make them editable. Something similar to what happens in WordPress. Is this possible...

Unexpected keyword argument 'faceted'

I am trying to implement search with Django haystack and solr, but I get this error when trying to implement faceted searching on a SearchIndex and then trying to run the server: TypeError: init() got an unexpected keyword argument 'faceted' Here is the SearchIndex: import datetime from haystack.indexes import * from haystack impo...

Django: trans and blocktrans not escaping modulo (%)

I'm trying to makemessages on a template that has a translation which contains a modulo, like this; {% trans "100% escaping problems sucks" %} But I get this error: Error: errors happened while running xgettext on site.html ./templates/site.html.py:34: warning: 'msgid' format string with unnamed arguments cannot be properly localize...

Why do I have to put the project name when importing tasks when using Django with Celery?

I just installed and configured Celery with RabbitMQ for a Django project and I was having an issue running tasks when I imported them like so: from someapp.tasks import SomeTask It worked when I added the project name: from myproject.someapp.tasks import SomeTask I tried adding this into the settings.py file but it doesn't change ...

Django threadedcomments and voting

I'm using django-threadedcomments and django-voting in my project to achieve a Reddit-like comments voting system. I've set everything up correctly and I'm able to successfully record votes for each threaded comment and its children, however I'm a bit stuck as to how to sort the comments so that the comment with the highest score rises ...

To get Analytics data and show on page what's the most popular items, should the code belong to Model, Controller, or View?

Suppose there is a call to get Analytics data from a third party or through our cache data on a server, for the "most popular items", and we show these items' names on all of our pages, should we put this code in Model, Controller, or View (Helper) component? Maybe it is not strictly Model, because it is not directly in our data store. ...

Django ModelForm fails validation with no errors

Ok, I have been staring at this for hours trying to figure out what's going on, to no avail. I am trying to create a ModelForm using the 'instance' keyword to pass it an existing model instance and then save it. Here is the ModelForm (stripped considerably from the original in my attempts to identify the cause of this problem): class ...

django-fts: How to create indexes for psql

Hi, I am investigating how the http://code.google.com/p/django-fts/ application works. I am trying to setup psql FTS to work with the application, but can't understand how to create index correctly. Don't understand how to create the GIN index as it was specified in doc. My model is following: class Product(fts.SearchableModel): ...

Django inline for model inheritance target

Hi, I am trying to solve problem related to model inheritance in Django. I have four relevant models: Order, OrderItem which has ForeignKey to Order and then there is Orderable model which is model inheritance superclass to children models like Fee, RentedProduct etc. In python, it goes like this (posting only relevant parts): class Ord...

Django complex filtering of related objects

Hello, I've faced with following issue, basically I do it like this: class Account(models.Model): TraffPerMonth = models.IntegerField(default=0) Tariff = models.ForeignKey('Tariff') class Tariff(models.Model): InetTraff = models.IntegerField(default='0') and here is the select: for user in Account.objects.all(): t_traf...

Django model inheritance problem. How to solve?

Hello all, I have an existing app with the following model class Contact(models.Model): lastname = models.CharField(max_length=200) firstname = models.CharField(max_length=200) ... class Journalist(Contact): pass I have a Contact in my database and I would like that it becomes a Journalist. In raw sql, it seems...

approaching models from the other side of a foreign key

Working with Django docs' sample Blog and Entry models, how would one get a queryset of all Blog objects that have name = "a" and that are not associated with any instance of the Entry model? In raw (My)SQL terms, what is the Django ORM equivalent of: SELECT * FROM blog_table bt WHERE bt.name='a' AND bt.id NOT IN (SELECT et.blog_id FRO...

Title field in admin

I have a model: class Review(models.Model): name = models.CharField(max_length = 50) link = models.CharField(max_length = 100) book_id = models.IntegerField() review_id = models.IntegerField() content = models.TextField() rating = models.IntegerField() author = models.CharField(max_length = 50) If I open ad...