django

Django database reconnect

Django's backend (firebird) reconnecting to database was fixed as here by disabling request finishing signal. It works with development server. But when project was deployed with mod_wsgi connections again reinitialize for each request. How to fix it? Thanks. p.s my connection is very expensive (about 1sec.) p.p.s sorry for my english....

Comparison of Date in database against current date

Hi, In my application I have the date of a talk and I want to compare this against the current date to see whether it should display View Attendance Record in my html page. What I am thinking is: if (dateInDB <= currentDate) display View Attendance Record else don't display view attendance record How would i convert this to ...

AttributeError - type object 'Services' has no attribute 'service_price'

Hi there, I'm trying to create something like an invoice program, to create invoices and calculate prices. I am still on the models part and I am trying to calculate all the services includes in a single invoice and update them in Invoices.subtotal. My problem is that I cannot pass the summary value of Services.service_price to Invoice...

Subprocess.Popen hangs with interactive programs when called from inside Django

Hi, I have written a small Django App, that executes an interactive program based on user input and returns the output as the result. But for some reason, the subprocess hangs. On verification of the logs I found that a place where a '\n' has to be given as repsonse to a challenge, the response seems to have never been made. Interesting...

django comments why is the field is_public being set to false

I am using the django comments system and everything is working ok apart from the comments are being added into the table with is_public being set to false. Does anyone know why this is and how I can fix it, i.e. have them set as true edit, this is the code I have: {% load comments %} <ul> {% get_comment_list for entry as comment_lis...

How to check for entity that haven't got attribute in table

In my application I need to check up on people's attendance and I want to know who hasn't attended two or more meetings. I have the following models: class Talk(models.Model): title = models.CharField(max_length=200, primary_key=True) speaker = models.CharField(max_length=200) date_of_talk = models.DateField('date_of_talk')...

django: sort table data according to other table data

Hi. I have read the (excellent) documentation but I can't figure out how to do this. I have a table which represents user friendships called "Shortlist" (with fields "from_user" and "to_user": both Foreign Keys to the classic auth_user table. Namely, from_user befriends to_user). I have another table into which I log user events/acti...

Django Deployment: Handling data in database

Right now I am using git for Django deployment which seems satisfying to me. My only problem is still how to handle the data in the database properly. Eg. I need often to edit data coming from the prodution site locally and put the data back on the production site (please note I'm talking about data changes and not schema migrations!). I...

Django-Haystack/Whoosh - Rebuild Index Error

Python 2.5, Django 1.2.1, most recent haystack, most recent whoosh This is my first delve into Django-Haystack. I was following the "Getting Started" guide from Haystack and everything seemed to be going along fine, until I went to build the index. So, running "manage.py rebuild_index" shot this back at me: Traceback (most recent call...

Custom Form for Group Permission with filtered Queryset

I need to offer a from in which a user can manage the permission associated to some Group. I'd like to use the forms.ModelForm feature which comes from django, but I cannot understand how to modify the queryset over which the field cycles. I've also taken a deep look in contrib.admin and contrib.auth to discover where those forms are ge...

Spurious failures in django.contrib.messages.tests when running manage.py test

I've recently added authentication (via django.contrib.auth of course) to my application, along with appropriate "signin"/"signup" links to my base.html. The problem comes when I run manage.py tests, and I get 4 failures, all from django.contrib.messages.tests: ERROR: test_middleware_disabled_anon_user (django.contrib.messages.tests.co...

A simpler i18n for Python/Django

Hi all, My question is regarding i18n in Python. From what I understand, it involves: Create a messages file per language (ONLY ONE?!). in this file, each message will be of the format English message here Message en Francais ici (yea crappy french..) then have this file compiled into another faster binary format repeat for all othe...

Accessing initial value of django forms when iterating over the fields

I'm trying to do something pretty simple; I'd like to apply a "hidden" style to a form field inside a django template when I've passed in some initial value like this: form = form_class(initial={'field':data}) Normally, it would be like this: <li class="{{form.somefield.name}} {% if form.somefield.initial %} hidden{% endif %}> .....

Django: Get all blogs and their latest blog entries

Suppose I have these two models: class Blog(models.Model): name = models.CharField(max_length=64) # ... class Entry(models.Model): blog = models.ForeignKey(Blog) added = models.DateTimeField(auto_now_add=True) # ... Now I want to get a list of all blogs along with the latest blog entry for each respective blog. Wh...

Django "evaluate" filter?

I've got a view func like this: def user_agreement(request): return response(request, template='misc/flatpage.html', vars={'fp':FlatPage.objects.get(key='user-agreement')}) And then the template looks like this: <h2>{% block title %}{{ fp.title }}{% endblock %}</h2> {{ fp.content|markdown }} This works pretty well,...

Is there a way to automate restarting the python process after every change I make to Django models?

I am using Django with Passenger on Dreamhost. Every time I make a change to models, settings or views I need to pkill python from a terminal session. Does anyone know of a way to automate this? Is this something that Passenger can do? Thanks. ...

django shell triggering Postgres idle transaction problems

It's not the fault of the django (iPython) shell, actually. The problem is developers who open the django shell ./manage.py shell run through some queries (it often only generates selects), and then either leave the shell running or somehow kill their (ssh) session (actually, I'm not sure if the latter case leaves the transaction open - ...

Django user proxy models fast access

I have proxy model for user: class MyUser(User): class Meta: proxy = True How can i get it in templates without pass from view? can i get it only from request.user instance? I am using template context processor for this: def m_processor(request): from main.models import MyUser mu = MyUser.objects.get(id = reques...

FastCGI, Apache, Django and 500 Error

I am getting 500 Internal error with Apache and FastCGI. Spent the whole day to find the reason :-/ /etc/apache2/vhost.d/mysite.conf FastCGIExternalServer /home/me/web/mysite.fcgi -socket /home/me/web/mysite.sock Listen 80 <VirtualHost *:80> ServerName os.me #That's my localhost machine DocumentRoot /home/me/web ...

Django auth system: adding user to group via "invites"

I want to use the Django default auth system to manage users and groups. Is there an existing Django app/module that adds users to groups by invites? I.e. some existing user of the group sends an invite with a secret key in a URL, and another user that clicks on the URL joins the group. I can write one, but figured I ask before doing th...