django

Django: Is there a way to have the "through" model in a ManyToManyField in a different app to the model containing the ManyToManyField?

Lets say I have two django apps: competitions - which will handle competition data entries - which will handle functionality relating to entering competitors into competitions In the competitions app I have a model which represents a section of a competition: class Division(models.Model): competition = models.ForeignKey(Competit...

What is the best way to profile a view in Django?

I have developed an application using Django and everything is working fine but I don't know what's going on behind the scenes. I would like to know: How many times the database is being hit for each request? What was the execution time for each query? How long it took to render the template? Regular profiling info (ncalls, tottime per...

django performance on querying models with many foreign keys?

Am building up a service that needs to maintain something along the lines of a case tracking system. Here's our model: class Incident(models.Model): title = models.CharField(max_length=128) category = models.ForeignKey(Category) status = models.ForeignKey(Status) severity = models.ForeignKey(Severity) owned_...

How to implement translation for selection fields.

In my models, I have two options...when I get to a variable that necessitates a selection menu, I can either use a new class or use "choices"... ie. class Title(models.Model): title = models.CharField(max_length=4) def __unicode__(self): return self.title or LANG_CHOICES = ( ('E', 'English'), ('F', 'Francais'), ) W...

Django specific sql query

Hi guys, how can I execute such query in django: SELECT * FROM keywords_keyword WHERE id not in (SELECT keyword_id FROM sites_pagekeyword) In the latest SVN release we can use: keywords = Keyword.objects.raw('SELECT * FROM keywords_keyword WHERE id not in (SELECT keyword_id FROM sites_pagekeyword)') But RawQuerySet doesn't support ...

Using Django Navbar to create multilevel navigation?

I'm using Django Navbar http://code.google.com/p/django-navbar/ in the Mingus blog engine,, I realized that Multi level menus are not implemented (on Mingus) they appear to be implemented in Django navbar.. Have been trying to do it but not joy so far.. I have gotten the breadcrumbs in.. but when I go to a sub page the subpage menu item ...

Haystack / Whoosh Index Generation Error

I'm trying to setup haystack with whoosh backend. When i try to gen the index [or any index command for that matter] i receive: TypeError: Item in ``from list'' not a string if i completely remove my search_indexes.py i get the same error [so i'm guessing it can't find that file at all] what might cause this error? it's set to autodi...

How can I insert a new Event for non primary Calendar? Using python gdata

def addEvent(calendar_service): event = gdata.calendar.CalendarEventEntry() event.content = atom.Content(text='Tennis with John 30.12.2009 15:00-16:00') event.quick_add = gdata.calendar.QuickAdd(value='true') new_event = calendar_service.InsertEvent(event, '/calendar/feeds/default/private/full') This write to primary Ca...

Has anybody actually used django-mongodb?

I can't find any documentation on this or any forum discussions. Has anybody at least gone through their testapp? I feel like there are errors in their code (deprecated from the most recent version of pymongo), but I've just started with pymongo and am not entirely sure. Are there any good resources on django-mongodb or is this project k...

Django: RequestContext issues?

I'm new to Django and Python. When I move my code from my local dev box to my site on Webfaction it seems to break my code. If I then remove (context_instance=RequestContext(request)) from my main application views.py it seems to fix the problem. If later I put the line back in it works fine. return render_to_response('template.html',...

django:error with the custom inclusiong_tag, error info:Invalid block tag

I'm trying to write a custom inclusion_tag in django. Following the example on http://docs.djangoproject.com/en/dev/howto/custom-template-tags/ I'm just writing from django import template from libmas import models register = template.Library() @register.inclusion_tag('records.html') def display_records(book_id): book = models...

WMD Output Issue

I have an issue with my google app engine whereby I am using wmd to input text and save text. In preview mode, I can see the wmd formatted correctly as html, but when I switch to output, I just see unformatted wmd. I have python-wmd installed, but am assuming that there is some sort of issue whereby python-wmd is being bypassed and ign...

Good way to deploy django projecto to a testing sever?

This is specific to my current project. But maybe the answers will reveal some more generic solutions. Here is the situation: I develop django project on my Windows box I use SVN to commit to a SVN repository while developing I use development server that comes with django There is a testing server (apache) that runs somewhere else, a...

Using instance methods with Django Model

Hi all, I'm trying to implement for methods for eac Model object in my project. get_all() , get_by_id(),add(),remove() and maybe others. I need to use them by each object . When I declare an object automatically can call one of those methods. The problem , I don't want to duplicate the code of the four methods in each class . Is there ...

Problem with order_by in django sphinx

I have implemented django-sphinx search in my website. I need result set "order by end_time" but i got results oder by first "id" and then "end_time". My conf is: source main_event : main_civilengagement { sql_query = \ SELECT mc.id as id, mc.name as name, tt.name as ttname, mp.text as mptext, \ mc.descript...

Apache solr search part of the word

I'm using apache solr search engine for indexing my website database.. I'm using django+http://haystacksearch.org/ So let's say I have document that have word "Chicken" When I search for "chicken" - solr can find this document But When I search "chick" - it does not find anything.. Is there a way to fix this ? ...

django double "extends", problem with login

Hi:) I have got a small problem with template double extends system. I have got a scheme: base.html ---> index.html ---> something.html When I log in to the site I have got access to all invisible blocks (invisible blocks for anonymous users) like: {% if user.is_superuser %} blabla {% endif %} So "blabla" is visible for me, beca...

Django timer thread

Hello, I would like to compute some information in my Django application on regular basis. I need to select and insert data each second and want to use Django ORM. How can I do this? ...

django ajax filtered fields - searching the bug

hy! i m trying to use django ajax filtered fields for a many-to-many-relationship (outside the admin! for staff and non-staff users.). i walked through the introduction at the homepage of this add-in and the result is, that i can not make it run :-( i m wondering what i m doing wrong and hope to find some help here. thus i included al...

django, runserver_plus - admin media files served from wrong path

The configuration below works fine on my remote host (same dir structure, same django), all admin media are served properly settings MEDIA_ROOT = '%s/static/' % FS_ROOT STATIC_DOC_ROOT = '%s/static/' % FS_ROOT MEDIA_URL = '/static/' ADMIN_MEDIA_PREFIX = '%smedia/' % MEDIA_URL urls (r'^admin/', include(admin.site.urls)), (r'^static/(...