django

Basic tree in Python with a Django QuerySet

Here's where I'm exposed as the fraud of a programmer I am. I've never created a data tree. Basically, I have a table with four fields: A, B, C, and D. I need to create a tree of unordered lists based on these fields. Ultimately, it would look something like this: A1 B1 C1 D1 D2 C2 D3 D4 B2 C2 D5 D6 C3 D7 D8 A2 B2 C1...

Django hitting MySQL even after select_related() ?

I'm trying to optimize the database calls coming from a fairly small Django app. At current I have a couple of models, Inquiry and InquiryStatus. When selecting all of the records from MySQL, I get a nice JOIN statement on the two tables, followed by many requests to the InquiryStatus table. Why is Django still making individual reque...

How can I use django with JSONP to load content from my other website?

I have two sites written with Django. What I want is to load a content from one site into another. I found out that best choice to do this would be using .getJSON and JSON-P but I have no idea how to put this things (Django, jQuery and JSONP) together. Any help from more expirienced users? EDIT I'm trying to achive an ongoing process ...

settings.py DATABASE_USER best practices for Django. Multiple domains/projects.

What are conventions that you recommend when I should use a new DATABASE_USER in settings.py? Should I use a new postgresql DATABASE_USER for each project database or each site on the same server? In the case of multiple projects on the same site(domain) should I use a unique DATABASE_USER per each project database? In the case of mu...

Django vs. Pylons

I've recently become a little frustrated with Django as a whole. It seems like I can't get full control over anything. I love Python to death, but I want to be able (and free) to do something as simple as adding a css class to an auto-generated form. One MVC framework that I have really been enjoying working with is Grails (groovy). It...

Caching of querysets and re-evaluation

Hi, I'm going to post some incomplete code to make the example simple. I'm running a recursive function to compute some metrics on a hierarchical structure. class Category(models.Model): parent = models.ForeignKey('self', null=True, blank=True, related_name='children', default=1) def compute_metrics(self, shop_object, metric_queryse...

External django redirect with POST parameters

I'm trying to create a redirect in a Django view to an external url with some get parameters attached to the request. After doing some looking around and some trying around, it seems I have hit a road block. So my view looks something like this def view(request): data = get.data(request) if something in data: return Htt...

WHoosh (full text search) index problem

iam having the following problem with whoosh full text search engine. 1.After syncdb i am creating the intial index from the database objects. 2.it is working fine.I can able to search the data and see the results. 3.after that in one of my view i have added another document (via signals) to the index (during a request --response) 4....

How to add a user to django-tagging

I'm looking for a way to add "user = models.ForeignKey(User, editable=False)" to django-tagging model with templatetags support but my django knowledge is too low to understand the code of django-tagging. ...

Confusion about the Python path in Python shell vs FCGI server: Why are they different?

I'm trying to deploy my Django app into production on a shared server. It seems I'm having problems with the Python path because I'm getting the error from the server: No module named products.models However, when I go to the root of the app and run the shell the modules load fine. '>>> from products.models import Answer '>>> import s...

What is a good way to package django apps?

I have a django project which is installed by customers on their servers. I've got a few more apps which are optional plugins of functionality that can be installed/uninstalled. I'd like a simple way to package these plugin apps to make the install/uninstall painless. I dont want them to copy the template files to one directory, app to...

Uploading multiple files with Django

How do I upload multiple files with Django? ...

How do you add a custom section to the Django admin home page?

In the Django admin each app you have registered with the admin gets its own section. I want to add a custom section for reporting that isn't associated with any app. How do I do that? ...

Is there any way to add a class attribute to an input tag generated by django.models?

I can't figure it out for the life of me. I don't think it's possible. Something so simple shouldn't be hard at all. Anyone? ...

ViewDoesNotExist: Tried login in module django.contrib.auth.views. Error was: 'module' object has no attribute '__file__'

I have deployed my django app using Apache and mod_wsgi. All of the settings load fine, but when I redirect the user to the login page, I get the following error: File "/opt/ActivePython-2.6/lib/python2.6/site-packages/django/core/handlers/base.py", line 83, in get_response request.path_info) File "/opt/ActivePython-2.6/lib/pyt...

Strategy for maintaining complex filter states?

I need to maintain a list of filtered and sorted objects, preferably in a generic manner, that can be used in multiple views. This is necessary so I can generate next, prev links, along with some other very useful things for the user. Examples of filters: field__isnull=True field__exact="so" field__field__isnull=False Additionally, a...

change default_charset in google app engine patch

when I do this in google native django, it's ok but when I change this setting in gae-patch it seems that it is not working ...E\common\zip-packages\django-1.1.zip\django\utils\safestring.py in _proxy_method(self=u'\n<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...rd 500 page.\n </p>\n</div>\n</body>\n</html>\n', *args=('gbk',), **kwarg...

Django regroup tag problem

Hello All, I have a custom filter user_tz which takes user as an argument. It works fine everywhere, but when I tried to use this filter in the regroup tag it fails saying that user does not exist. The code: {% regroup proj_messages.object_list by created_on|user_tz:user as proj_message_list %} This is the error I am getting: Caught ...

What are some of the core conceptual differences between C# and Python?

Hi everyone, I'm new to Python, coming from a C# background and I'm trying to get up to speed. I understand that Python is dynamically typed, whereas C# is strongly-typed. -> see comments. What conceptual obstacles should I watch out for when attempting to learn Python? Are there concepts for which no analog exists in Python? How impor...

Object store for objects in Django between requests

I had the following idea: Say we have a webapp written using django which models some kind of bulletin board. This board has many threads but a few of them get the most posts/views per hour. The thread pages look a little different for each user, so you can't cache the rendered page as whole and caching only some parts of the rendered pa...