django

Django + basic http auth

Hi, I am using Django via FastCGI. I have a non-django part of my website and I need to protect it with basic apache auth. Here is a part of my config: RewriteEngine On RewriteBase / RewriteRule ^media(.*)$ - [L] RewriteRule ^SUPERSECRET(.*)$ - [L] RewriteRule ^images(.*)$ - [L] RewriteRule ^robots.txt$ - [L] RewriteRule ^(admin_media/...

How to syndicate comments subscriptions in Django

I have been trying to search for the right way to go about creating a "subscribe to comments feeds" with an email subscription, seen on many blog. I have got an RSS feed working, but would prefer to use a cleaner email subscription. What is the right way to go about this. Should I create a new class in the models.py file to create new...

Internationalization for Flex/Flash Apps

What options are there for storing and accessing translated strings in a Flex/Flash application? Ideally, I would like to share translation data with my Django website's internationalization data. This leads me to believe that some version of gettext would be best. But what is the industry standard, and the best implementation and docume...

Django ModelFormSet: How to post-process edited and new records differently

I am trying to take a modelformset, then process the records that have been changed after the form is submitted. For new records, I need to do certain action like set one form field equal to a hidden field and add some time stamps. For edited records, I do not need to do these actions, just to save the model's edited data. For unchaged r...

How to get an attribute just from the current class and not from possible parent classes?

How to get an attribute just from the current class and not from possible parent classes? If I use getattr it traverses class hierarchy but I would like to get None if attribute is not defined in the current class (even if it is defined in some parent class). ...

Remove items with checkboxes in Django forms

I'm writing a form with Django. The form is a model form for a certain model, Experiment. Each Experiment has several TimeSlot models associated with it, defined with a ForeignKey('Experiment'). I'd like to have a form with the option to remove one or more TimeSlot instances from the EditExperimentForm by checking boxes. Currently, I d...

Mapping the same first-level URL path to different models

I have two models with slug fields: class Book(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() class Author(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() I would like to map them to the first-level path: (r'^(?P<slug>[a-zA-Z0-9_-]+)/$', 'book_detail'...

Installing MySQLdb on Snow Leopard

I'm having all sorts of trouble trying to instal MySQLdb (1.2.2) on snow leopard. I am running python 2.5.1 and MySQL 5.1 32bit. Python and MySQL are running just fine. I've also installed django 1.2.1, although I don't think thats all that important, but wanted to give an idea of the stack i'm trying to install. I am using python 2.5....

Django: Specifying HASH instead of BTREE for indexed column

Is there a good way within Django models to specify a specific index storage type? For example, the default storage type for MySQL is BTREE, when for my particular column it may be more efficient to have HASH(hash table) as the storage type. I can't find a good way without creating a custom field, or modifying django core, that will d...

Exception Value field is blank when throwing custom exceptions in django

I have custom exceptions in my django project that look like this: class CustomFooError(Exception): def __init__(self, msg="Something went wrong with Foo."): self.msg = msg def __str__(self): return repr(self.msg) At various points in my code I will raise exceptions like this: raise CustomFooError("Things a...

help using the django built in comments app

Just learning django and trying to use the built in comments app. I have a model named foo that is passed into the template with the same name. {% get_comment_count for foo as comment_count %} seems to work okay as {{ comment_count }} comes back as "0". Next I try displaying the comment form by {% render_comment_form for foo %} exp...

How do customize django-registration (pass parameters, use other built-in forms)

Hello, I a new to django and python. I have however managed to build a small part of my application and I am in the point where I want to add a user registration feature. I have downloaded and installed django-administration and so far I have been impressed with the basic and default configuration. BUT upon trying to customize some of...

Django forms: Changing help_text dynamically

Is this even possible? So let's say that I have two forms, one inherits from the other because they have similar fields with the same validation. But the only difference is they have different help text. How could I have two different help text on these forms? ...

Cron and virtualenv

I am trying to run a Django management command from cron. I am using virtualenv to keep my project sandboxed. I have seen examples here and elsewhere that show running management commands from within virtualenv's like: 0 3 * * * source /home/user/project/env/bin/activate && /home/user/project/manage.py command arg However, even thoug...

Issue with PPT conversion using python-Django

I was just trying to convert a PPT using the following URL http://code.google.com/p/qifei/wiki/PDFConverter python code I could see the same thing happening with the command line option too python documentconverter.py /home/rajeev/Desktop/Downloads/Industry2.ppt /home/rajeev/Desktop/test.pdf It appears that the image overlaps on some ...

How can I exclude a declared field in ModelForm in form's subclass?

In Django, I am trying to derive (subclass) a new form from ModelForm form where I would like to remove some fields (or to have only some fields, to be more correct). Of course obvious way would be to do (base form is from django.contrib.auth.forms): class MyUserChangeForm(UserChangeForm): class Meta(UserChangeForm.Meta): fields =...

Publishing ics feeds in Django

I'm attempting to publish an ICS feed using django + vobject. As a test run, I have the following view defined: def ical(request, user_id=None): cal = vobject.iCalendar() cal.add('method').value = 'PUBLISH' cal.add('calscale').value = 'GREGORIAN' cal.add('x-wr-calname').value = 'TestCal28' cal.add('x-wr-timezone').va...

How can I get fields in an original order?

I have a code like: class Ordered(object): x = 0 z = 0 b = 0 a = 0 print(dir(Ordered)) it prints: [ ......., a, b, x, z] How can I get fields in an original order: x, z, b, a? I've seen similar behavior in Django Models. ...

Unable to change session variable through AJAX in IE

I'm getting some weird behavior from IE when trying to change a session variable on the server using AJAX. It works fine in FF, Chrome, Safari, and all the others I've tested but not in IE. I'm maintaining a list of variables (integers) in a session variable for anonymous users so I can keep their data when/if they register on the site....

django 1.1 permission question in template

I have an app that makes user of filtering certain things for users with different permissions. Django 1.1 does for some reason not seem to recognize these. I have a group called corporate and permissions are granted as needed. now in my template I am render the following. {% if perms.corporate %} ...show the following {% ...