django

Multilanguage URLs in Django

What is the best way to support multilanguage URLs in Django? Like: http://myenglishwebsite.com/user/foo http://mygermanwebsite.com/benutzer/foo Should I use multilang in urls.py like: (r'^%s/(?P<slug>[-w]+)/$' % _('user'), 'myapp.view.relatedaction') It doesn't seem like a good solution and I couldn't make it work :)) ...

Get related (via ForeignKey) object in my view

I have a model like this: class database(models.Model): db_name = models.CharField('Name', max_length=20) server = models.ForeignKey(dbServer, unique=True) user = models.ForeignKey(User) In my view I want to grab every database realated to the current user (has to be logged in at that point). I'm sure there is an easy way to do ...

amara and django

Hello I am trying to do webservice calls with django views using Amara library. However anytime I do import amara (by simply importing it!) and call a django view with it imported, I get such errors: Environment: Request Method: GET Request URL: http://127.0.0.1:4444/test Django Version: 1.2.1 Python Version: 2.6.5 Installed Applicati...

How to properly collect and manage admin media files from django?

Collecting the admin-media files from different django application is one of the not-so-good things about django. Usually you have to file copying from the module distributions to your directory every time one you install/update/remove a module. When you are using several django application that do have their own media/admin files, som...

Django manage.py doesn't work with IPython

I am on MacOSX Snow Leopard and I'm using python 2.6.5 installed with macports. I'm inside a virtualenv. I can't run python manage.py shell after installing IPython but I can run IPython standalone. I figured out that the following line is what causes the issue: (status, result) = commands.getstatusoutput("otool -L %s | grep libedit" %...

Python converting - [<Location: London>] to London

Excuse my total newbie question but how do I convert: [<Location: London>] or [<Location: Edinburgh>, <Location: London>] etc into: 'London' or 'Edinburgh, london' Some background info to put it in context: Models.py: class Location(models.Model): place = models.CharField(max_length=100) def __unicode__(self): ret...

Problem using generic views in django

I'm currently working with django generic views and I have a problem I can't figure out. When using delete_object I get a TypeError exception: delete_object() takes at least 3 non-keyword arguments (2 given) Here is the code (I have ommited docstrings and imports): views.py def delete_issue(request, issue_id): return delete_obj...

I cannot access suggestions? - Django Haystack + Whoosh

Hi folks, I'm using Whoosh 3.18. 1) I'm following the docs here. from whoosh.store import FileStorage is not working and therefore anything else I try to accomplish with it. 2) I cannot figure out how to include suggestions within my search templates. I'm using the template provided within the docs' tutorial. Help would be g...

Django template generation time

How can I measure time taken for template generation? I know i can collect time Context.render() takes but can i do it unobtrusive way? Something like Page Stats Middleware do for Python and DB time... But split Python time to code/view time and template time? ...

How to change SQLite DB path for each request in Django?

I would like to dynamically change path to sqlite database depending on currently logged user using Django framework. Basically each user should have his own sqlite database file. Anyone with experience? Thanks. ...

Hiding a django website while developpment

hi, I developped a django website on my local machine and now is the time to upload it on a server. I would like that during the time i work on it, only logged in users can see it. I thought about a {% if is_logged_in %} {% else %} {% endif %} structure in my base.py template but not all my views return a Context so it doesn't always...

Django: Calling another modules function passed through a parameter

I have a list of functions as: FUNCS=[{'someattr':'somedetail', 'func':baseapp.module.function_name}, {...}, ...] Unfortunately it doesnt work if i try calling the func with FUNCS[0]['func'] I get the error Tried function_name in module baseapp.module Error was: 'module' object has no attribute 'function_name' I presume there mus...

Is it possible to include a custom 404 view for a Django app without changing anything at the project level?

I'm creating a Django app and trying to have it touch the containing project in as few places as possible. I've created a custom 404 view which works as expected but only when I add handler404 to the project-level urls.py. I want the custom 404 view that I've written to apply to this particular app only, but from the information I've c...

Where and how do I set an environmental variable using mod-wsgi and django?

I'm trying to use this env variable to specify the path for my templates and it will probably be easier to do this using git or svn. ...

In Django, how to properly access through a proxy model to related proxy models

Hello, I wanted to override the get_absolute_url method in the Django User and Group models from the auth app. My first idea was to define a proxy model, but then I noticed that the elements in usuario.groups were instances of Group instead of Grupo and it also happened the same in the grupo.user_set case. So I expanded the proxy models...

Installing a python + django open source project on my server and making it work?

I'm trying to install an open source python + django project: http://github.com/coulix/Massive-Coupon---Open-source-groupon-clone on a server to play with. I'm using mediatemple.net grid-server hosting. I uploaded the files in my html folder but I can't seem to run the program. I'd love to talk this out with someone and figure it out. ...

How does 'manage.py test' work? (pdb problem)

I develop my django app on a mac with the dev server. When I run manage.py test I am able to break execution with pdb (as I can also when just running the site). When I push the app to my linux production server (Ubuntu) running apache2/nginx pdb it no longer works on the site. It throws a BdbQuit Exception. I figured it would work whe...

django URL reverse: When URL reversig a username it fails when username has a '.' literal in it

I didn't expect this to occur [since I didn't know when django changed to allow _ and . in usernames], but when I attempt {% url feed_user entry.username %} I will get a 500 error when the username contains a '.' In this case rob.e as a username will fail. Any ideas how to deal with this? ...

How to display choices in my form using django forms?

Hi, I have a model that looks like this in my application: class Member(models.Model): name = models.CharField(max_length=200) telephone_number = models.CharField(max_length=200) email_address = models.CharField(max_length=200) membership_type = models.CharField(max_length=1, choices=MEMBERSHIP_TYPES) membership_num...

Django Celery implementation - OSError : [Errno 38] Function not implemented

I installed django-celery and I tried to start up the worker server but I get an OSError that a function isn't implemented. I'm running CentOS release 5.4 (Final) on a VPS: . broker -> amqp://guest@localhost:5672/ . queues -> . celery -> exchange:celery (direct) binding:celery . concurrency -> 4 . loader -> djce...