django

Django Signal via Decorator on Model Method?

Hi, I'm trying to do something like these proposed signal decorators. In addition to having a decorator that connects the decorated method to a signal (with the signal's sender as an argument to the decorator), I would like to use the decorator on class methods. I'd like to use the decorator like so: class ModelA(Model): @connec...

Django template context function without running automatically

Sorry or the confusing title! It's actually a lot simpler than it sounds. I've got a function: def get_messages(request): # do something expensive with the request return 'string' I want to be able to call that function from the template, so I've strapped in with a context processor: def context_processor(request): retur...

django-tinymce: Using different options for different instances

I have a model with an HTMLField which can be edited with a TinyMCE control in the admin. However, I would like to be able to give different options to TinyMCE depending on which instance of the model is being edited. How can I do this? (For example, if the user is editing the SimplePage instance whose slug is technologies, I want TinyM...

How to handle user mangement in Django for groups that has same access but different rules?

Background information: I have created an internal site for a company. Most of the work has gone into making calculation tools that their sale persons can use to make offers for clients. Create pdf offers and contracts that can be downloaded, compare prices etc. All of this is working fine. Now their sale persons have been divided into...

Django efficiency question

I am wondering would this make any real efficieny difference (ie computation time, memory etc..) This is my model: class FooUser(models.Model): name = models.CharField(max_length=50) sirname = models.CharField(max_length=50) Assume I have 2 different approaches while saving a FooUser at a view: First one, assigning retrieved ...

Using Javascript to change all textareas in an html page.

I am creating a project in Django, and I am using the Django Admin pages along with TinyMCE. But I would like to be able to toggle TinyMCE on and off like in this example: http://tinymce.moxiecode.com/examples/example_01.php but since the admin page is generated automatically I imagine I need to overide the base_site.html template whic...

How to upgrade Django on ubuntu ?

Not a Django developer. We did get Django from Ubuntu packages typing apt-get install python-django. This is the error we are getting : http://kiwigeraint.kodingen.com/test1/ I read that we need version 1.+ and our version is 0.96.1 Could you tell me an easy way to upgrade ? ...

Different 404 pages depending on the application in Django

We are developing a project with several applications using Django. It shares the database, but it has several applications targeting different very different users. Roughly, administrators and final users. The UI of each application is very different. I need to create a 404 error page, but seems that I can only create one for all the p...

Can the Django dev server correctly serve SVG?

I am trying to serve a svg map using: <object data="map.svg" type="image/svg+xml" width="400" height="300"> <embed src="map.svg" type="image/svg+xml" width="400" height="300" /> </object> In Firefox this leads to a plugin prompt. If I rename map.svg to map.xml it shows the image correctly. I assume this is because the Django's dev...

Return selection of fields from a Model in django

Hay guys, i want to use something like this users = User.objects.all() but i only want to return a couple of fields for each result, say 'name' and 'email'. This data is going t be turned into JSON data, and some fields in my model are sensitive. How would i do this in django? ...

Recommendations, thoughts, tips and tricks, or peanuts on moving from wordpress to django

I've been using wordpress for a few years to run a couple of community based sites. one of them is a blog, while the other is more of an app, and I use wordpress for the admin feature only. I'm thinking of moving to django as I'm familiar with python, I want to play with geodjango and I don't feel an urge or the need to do anything from...

Google apps login in django

Hello world, I'm developing a django app that integrates with google apps. I'd like to let the users login with their google apps accounts (accounts in google hosted domains, not google accounts) so they can access their docs, calendar, and whatnot. In order to do it, I downloaded and started using django_openid_auth (and thus, python-...

Django and Google App Engine Helper not finding the ipaddr module.

I'm trying to get Django running on GAE using this tutorial. When I run python manage.py runserver I get the stacktrace below. I'm new to both django and python so I don't know what my next steps are (This is Ubuntu Jaunty btw). It seems django isn't finding the GAE module ipaddr which comes with SDK 1.3.1. How do I get django to find ...

How does this decorator make a call to the 'register' method?

I'm trying to understand what is going on in the decorator @not_authenticated. The next step in the TraceRoute is to the method 'register' which is also located in django_authopenid/views.py which I just don't understand because I don't see anywhere that register is even mentioned in signin() How is the method 'register' called? def n...

[Django] In model save() how to get all field starting with 'foo'

Hi, I've this django model: from django.db import models class MyModel(models.Model): foo_it = model.CharField(max_length=100) foo_en = model.CharField(max_length=100) def save(self): print_all_field_starting_with('foo_') super(MyModel, self).save() So I want to get all field starting with foo (as an exam...

How can I use the Whirlpool hash with Django authentication ?

We have a system written in PHP where account passwords are stored as the first 128 chars of a whirlpool hash of the password. I'd like to transition to handling the logins with Django without changing the database or asking users to change their passwords. Also, I'd prefer to stick with whirlpool vs. the less secure hashes Django has b...

Django admin editing fields in a tabular fashion

I have a model with lots of say CharField fields, that I would like to edit in the admin. The problem is that each field takes up one line. How should I make them display like this (horizontally): (they are not foreign keys) ...

How do get the different values that takes an attribute with a django query ?

I have this Model in django : class Post(models.Model): title = models.CharField(max_length=255) category = models.CharField(max_length=255) I would like to get the different values that are used in the category attribute. For example, if we consider this db : Post(title = "title 1", category="foo") Post(title = "title 2", c...

Django: show/log ORM sql calls from python shell

Using the excellent Django-Devserver I'm finding all kinds of interesting and unexpected SQL calls in my code. I wanted to find where the calls are coming from, and so I'm looking for a way to get a log or print-out of all SQL calls generated by the Django ORM in the Python shell. That is, when I do a Django ORM call via the Python shell...

How can I determine if instance of class from Django model is subclass of another model?

I have a class called BankAccount as base class. I also have CheckingAccount and SavingsAccount classes that inherit from BankAccount. BankAccount is not an abstract class but I do not create an object from it, only the inheriting classes. Then, I execute a query like this: account = BankAccount.objects.get(id=10) How do I know if a...