django

Filtering inherited objects

Hi all, I have a base class A . Two derived classes B , C. Now I have a global class witch contains a many-to-many relation to object A. Class D: aObjects : ManyToMany("A") how could know the real object the filter query return in object D. I mean : d.objects.get(id=5) now d has n objects of class A, but they are a mix of A,B or ...

Django user get_all_permissions() is empty while user_permissions is set

Hello I added some permissions to a user via the admin interface. From some reason all the perm functions fail, e.g >>> user.get_all_permissions() set([]) But accessing the table directly, works: >>> user.user_permissions.all() (list of permissions as expected) What can cause the "get_all_permissions" (and all the perm functions ...

How to add django modules to pydiction dictionary?

I'm trying to use pydiction to autocomplete Python/Django statements in VIM Editor. When I try to add django modules to complete-dic using this: python pydiction.py /usr/lib/pymodules/python2.6/django or: python pydiction.py /usr/lib/pymodules/python2.6/django/__init__.py I receive this error: Couldn't import: (...). Import by fi...

Custom create_user() value?

Registration usually takes 3 arguments. -Username -Password -Email But when i try to add a 4th value, it returns this error: create_user() got an unexpected keyword argument 'hobby' Any idea how to solve this? Here's the form i'm using: def save(self): new_user = User.objects.create_user( username=self.c...

Technique for multi-language support of big static portions text in Django

For small portions of text we use django standart {% trans %} tag What to do with big texts such as FAQ, terms and other static pages ...

Django template tag + template with user.is_authenticated doesn't work

Hi all, I have a strange problem, in my settings file everything is enabled that needs to be enabled for user.is_authenticated use in a template. I have the following template tag code: from django import template from progmatic.cms.models import navigation, navigation_item from django.template.defaultfilters import slugify from djang...

Output location of images for django-imagekit

I'm trying to output a list of images that belong to each record in my app as below: pri_photo = vehicle.images.all()[:1] sec_photos = vehicle.images.all()[1:] This first part is OK. The part I'm having issues with is when I try pri_photo.original_image.url sec_photos.original_image.url The above two lines of code give me a 'Query...

Couldn't find package libapache2-mod-wsgi

Hello, I have developed a website in Django, and now it must go into production. This i want to do with mod_wsgi and apache2. Unfortunately i get the error 'Couldn't find package libapache2-mod-wsgi' when running the next command: sudo apt-get install libapache2-mod-wsgi I am using apache2 on ubuntu server kermic(9.10). I will enter...

How to create a custom django filter tag

I am having trouble in getting my site to recognise custom template tags. I have the following dir structure: project_name project_name templatetags _ _init _ .py getattribute.py views _init _ _.py index.html views settings.py main.py manage.py urls.py nbproject Then I have added this to the INSTALLED_APPS: INSTALLED_APPS ...

How to refuse an upload before it completes in Django?

I would like my Django application to decide whether to accept or reject an upload based on request headers and/or session data. If the upload is to be rejected, I would like the app to reset the connection rather than waste time receiving and storing the potentially large file that is going to be rejected anyway. Django middleware look...

What method/property in a django field is called from the template?

I want to subclass models.TextField so I can return the text to the template with occurences of \r\n replaced with <br />. I don't want the <br />'s stored in the database, however. What method is called to retrieve the field's data when invoked from the template? I tried this, but it doesn't seem to work: class HTMLTextField(models.Te...

FileField Size and Name in Template

How do I get the size and name of a FileField in a template? My model is setup like this: class PDFUpload(models.Model): user = models.ForeignKey(User, editable=False) desc = models.CharField(max_length=255) file = models.FileField(upload_to=upload_pdf) My template is setup like this: {% for download in downloads %} ...

django access related user model value in template

Hi, I have a model looking like this. class ProjectMembership(models.Model): member = models.ForeignKey(User, related_name='project_membership_member_set') Edit: In a template I want now to access the last_name of the User model. I thought it should work like the following line, but it does not. {{ project_membership.member.last...

Getting from a model to the model type's verbose name

I've got an instance of a model FooBar - how do I get the naturalised type Foo Bar for display to the user, making sure to use the class's verbose_name if one is set in the Meta options. e.g.: class FooBar(models.Model): title = models.CharField(max_length = 100) class Meta: verbose_name = 'Spaghetti Monster' How do I get 'Sp...

Django: Why can't I get my development server to work?

I'm on Windows XP with the latest install of Python 2.6 (and the development server has been working up until last night). I have the path and Python path stuff all set up, and my dev server has worked forever. I recently replaced my django-trunk with a new pull from the Django trunk. I thought maybe there was an import error or somethin...

what does OpenID 'Sign in with OpenID using simple registration' mean?

I used openid, and when after successfully authenticating, it returned: You are signed in as http://zjm1126.myopenid.com/ Sign in with OpenID | Sign in with OpenID using simple registration | Sign in with OpenID, testing ?next= param | Sign out I want to know the meaning of: Sign in with OpenID using simple registration Sign in with...

Django: Why does this custom model field not behave as expected?

The following field is meant to format money as a two places decimal (quantized). You can see that it returns a <decimal>.quantize(TWOPLACES) version of the stored decimal. When I view this in the Django admin however, it doesn't do that. If I put in 50 to a field that is using CurrencyField() and view it in the admin, I get 50 vs 50.00....

Why Aren't Django Static Generator & Nginx Giving Me Boss Speed?

So there have been lots of articles like this one recently, extolling the virtues of Django Static Generator when used in combination with a light front-end Web server. It makes a whole lot of sense to me. However, I get nothing like the results that other people are reporting -- thousands of requests per second -- and I don't know why ...

Running syncdb on Django project not working

When I run: $ python manage.py syncdb I get the following output: Creating table auth_permission Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager utility.execute() ...

Database password requested when running "manage.py test"

When I try to run manage.py test a database password prompt shows. Previously, tests would run without me having to enter the db password manaually. I just updated my database to postgres 8.4. I assume it's some setting I'm forgetting. How can I configure it to run tests without asking for the password? Additional Info: I create...