django

Django annotate query set with a count on subquery

This doesn't seem to work in django 1.1 (I believe this will require a subquery, therefore comes the title) qs.annotate(interest_level= \ Count(Q(tags__favoritedtag_set__user=request.user)) ) There are items in my query set which are tagged and tags can be favorited by users, I would like to calculate how many ...

Django unit testing failures related to authentication settings

In Django, when I run "manage.py test", I get a lot of authentication related failures. Some examples: FAIL: test_password_change_succeeds -- AssertionError 200 != 302 FAIL: Logout without next_page option renders the default template -- AssertionError 200 != 302 And: Failed example: form.non_field_errors() Expected: [u'This...

Django Delete all but last five of queryset

I have a super simple django model here: class Notification(models.Model): message = models.TextField() user = models.ForeignKey(User) timestamp = models.DateTimeField(default=datetime.datetime.now) Using ajax, I check for new messages every minute. I only show the five most recent notifications to the user at any time. Wh...

Productive Django Web Development

Hi, I am just starting Django by reading the online django book. Could you provide productivity tips for Django web development.Code snippest? Which IDE you use? I am MySQL guy are there any benefits using PostgreSQL? I am using Linux(Ubuntu). Thanks a lot. ...

Why is pdb displaying "*** Blank or comment" when I try to set a Break?

I'm working with my Django app. For some reason an element of a list is being assigned incorrectly. I'm trying to set a break where I think the error is occurring. ( line 20 ) I'm invoking pdb with this line of code: import pdb; pdb.set_trace() However, inside the code, I can't seem to set a Break. (Pdb) b 20 *** Blank or comment ...

How to put an InlineFormSet into a ModelFormSet in Django?

Hi, I'd like to display a number of forms via a ModelFormSet where each one of the forms displays in turn InlineFormSets for all objects connected to the object. Now I'm not really sure how to provide the instances for each ModelFormSet. I thought about subclassing BaseModelFormSet but I have no clue on where to start and would like t...

Django application deployment help

I'm using Capistrano to deploy a Django application (it uses Nginx as the web server), using instructions I found at http://akashxav.com/2009/07/11/getting-django-running-on-nginx-and-fastcgi-on-prgmr/ (I had to look at a cached version earlier today) and was wondering about the last command in there, which is python manage.py runfcgi ...

fast lookup for the last element in a Django QuerySet?

I've a model called Valor. Valor has a Robot. I'm querying like this: Valor.objects.filter(robot=r).reverse()[0] to get the last Valor the the r robot. Valor.objects.filter(robot=r).count() is about 200000 and getting the last items takes about 4 seconds in my PC. How can I speed it up? I'm querying the wrong way? ...

Django vs PHP+framework

Hi, I am in the process of choosing a web framework for an application that will contain: an ajax heavy user interface for administration and configuration subsite accessed by mobile terminals (like cellphones, windows mobile, etc) that will include Google Gears for offline support a reporting site Since I know basic PHP as well as ...

Django: Access model through another model

class Project(models.Model): title = models.CharField() class Job(models.Model): name = models.CharField() user = models.ForeignKey(User) project = models.ForeignKey(Project) I have many jobs for each project. How do i get a list of all users of all jobs of a project? I came up with this: users = set() for job in pr...

Django model property geo distance

I am trying to implement a proximity search based on latitude and longitude using Django and Postgresql. Here's the abstract version of the Model I have. class Item(models.Model): """docstring for Item""" uuid = UUIDField(primary_key=True, auto=True) name = models.CharField(_("name"), max_length=200) address = models.CharField(_('street...

Mac OS X web sharing and Django

I created a web app with Django and I have it running on localhost (http://127.0.0.1:8000/), my question is, how can I make it available to the world, using Mac OS X's web sharing or something? Thanks! ...

Django edit form based on add form?

I've made a nice form, and a big complicated 'add' function for handling it. It starts like this... def add(req): if req.method == 'POST': form = ArticleForm(req.POST) if form.is_valid(): article = form.save(commit=False) article.author = req.user # more processing ... Now I don'...

Django logging with user/ip

Hello I am using the "logging" module to log a very large amount of messages. I would like to add "user" (request.user) to the log. But while it is available in the view function, I don't want to pass it to all helpers. Does anyone know a way to this ? [I was thinking of maybe somehow walking the trace until I find a function with "req...

Error when using Tag Cloug in Django

There are my code: {% load tag_cloud %} {% tag_cloud_for_model blog.Entry as tags with steps=6 min_count=1 distribution=log %} {% for tag in tags %} <span class="tag-{{tag.font_size|add:"1"}}"><a href="/blog/tag/{{tag.name|slugify}}/">{{tag.name}}</a></span> {% endfor %} Everything looks normal until I have 6 tag "django" in 6 di...

Trying to use a Google Maps user interface to caputre Lat/Lon in Django

I'm a Django newbie, and learning quickly. But I just can't figure out how to get this simple Google Maps user interface to pass the resulting lat/lon into my database. Can anyone help? ...

Google App Engine Application Extremely slow

I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch. Even though it is just a very simple web page, it takes long time and often it times out. Any suggestions to solve this? Note: It is responding fast after the first call. ...

Django FlatPages vs Django-CMS

Without going into too much detail, I'm building a Django site and I wanted to implement a CMS solution, while having a lot of flexibility with page layouts, navigation, and organization. It'd be mainly used for our documentation, and so far I've had a lot of headaches trying to figure out the ins-and-outs of Django CMS. Would an exp...

Template Inheritance in Django

I'm using Django 1.1, and I have this template, a base template, that all the other pages inherit from. It defines a bunch of things that are constant throughout pretty much all of the website, like this navbar: <div id="navbar"> {% block navbar %} <a href="">Link 1</a> <a href="">Link 2</a> <a href="">Link 3</a> <a h...

Dealing with URLs in Django

Hey all! So, basically what I'm trying to do is a hockey pool application, and there are a ton of ways I should be able to filter to view the data. For example, filter by free agent, goals, assists, position, etc. I'm planning on doing this with a bunch of query strings, but I'm not sure what the best approach would be to pass along t...