django

Django: Nested Queries from Non-Nested Models

I'm trying to figure out the best way to derive a nested menu from a set of non-nested models. Given a layout something like this: class Beverage(models.Model): country = models.ForeignKey(Country,null=True,blank=True) region = models.ForeignKey(Region,null=True,blank=True) subregion = models.ForeignKey(SubRegion,null=True,...

Can I merge Django local flavor add on fields?

Django has great fields under the local flavors package for specific local form fields like state and postal code. However, I need to merge two or more of them together(e.g. merge Canadian provinces and American states into one field, or have Canadian and American postal/zip codes validate on the same field) or some how instantiate form...

Django admin, inlines populate field's

Hi guys, there is something that i would like do. i have 4 class: class delivery(models.Model): name= models.CharField(max_length=100) date_join= models.DateField() .... class Town(models.Model): delivery_guy = models.ForeignKey(delivery) name = models.CharField(max_length=100) .... class...

Page Not Found error

Hi all, Why I get this error? Page not found (404) Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order: ^admin/doc/ ^admin/ The current URL, , didn't match any of these. I just uncomment the related lines in urls.py to enable admin and admindoc. They both work; but when I go to the root...

Error importing a python module in Django

In my Django project, the following line throws an ImportError: "No module named elementtree". from elementtree import ElementTree However, the module is installed (ie, I can run an interactive python shell, and type that exact line without any ImportError), and the directory containing the module is on the PYTHONPATH. But when I a...

Django and Nginx try_files problem for site root page

I use such Nginx configuration for the domain: server_name_in_redirect off; listen 80; server_name ~^(www\.)?(.+)$; root /var/www/$2/htdocs; location / { try_files $uri $uri/ $uri/index.htm @django; index index.html index.htm; } location @django { fastcgi_pass 127.0.0.1:8801; fastcgi_param PATH_I...

Django DB API equivalent of a somewhat complex SQL query

I'm new to Django and still having some problems about simple queries. Let's assume that I'm writting an email application. This is the Mail model: class Mail(models.Model): to = models.ForeignKey(User, related_name = "to") sender = models.ForeignKey(User, related_name = "sender") subject = models.CharField() conversat...

Python : email sending failing on SSL read

I keep getting this intermittent error when trying to send through 'smtp.gmail.com'. Traceback (most recent call last): File "/var/home/ptarjan/django/mysite/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/var/home/ptarjan/django/mysite/registratio...

django admin overriding save method at inlines?

Hi guys, theres is a way to overriding the save method for inlines form and parent in the same time? i would like to change the value of a field when the use save the edited inlines form... Thanks :) ...

django fuzzy string translation not showing up

1)why sometimes i got 'fuzzy' item in django.po language file . Actually i have checked in my project the 'fuzzy' string item is totally unique. #: .\users\views.py:81 .\users\views.py:101 #, fuzzy msgid "username or email" msgstr "9988" 2) It is ok to be fuzzy but my translation of fuzzy item not showing up on the page , only English...

html to pdf for a Django site

For my django powered site, I am looking for an easy solution to convert dynamic html pages (generated using django views and templates datas generated using GET forms) which also contains some graph charts from google visualisation api(it is javascript, yet including these graphs is a must for me) to pdf. Cheers ...

question about admin.py list_display

#admin.py class GameListAdmin(admin.ModelAdmin): list_display = ['game', 'position'] ordering = ('position',) class GameAdmin(admin.ModelAdmin): list_display = ['name', 'status'] actions = [make_published] #models.py class Game(models.Model): name = models.CharField(max_length=200) status = models.CharField(max_...

App won't show up in django admin

I've just installed django on my mac os x snow leopard and got some issues with it. I just made a very simple project that only contains a simple app. The app contains just one model and it's a task. When running syncdb the table for tasks is created without any problems and I'm requested to create new user. Everything works fine and I...

Tell if a Django Field is required from template

I'm rendering a form. I would like to put a mark next to all the fields that must be filled in. Simple stuff usually... but I've no idea how to access that information! {% if field.required %}REQUIRED!!{% endif %} doesn't bring any love... ...

Django admin, section without "model" ?

H guys, Django admin, all section (menu links) come form models with database table, but, what happen if i need a section without model (no database table) that bring me data from other section with model? Any idea? Thanks ...

Are there any cpython libraries that work with jsr168 and/or jsr286?

On a Java portal you can have portlets that include data provided by other applications. We want to replace our existing Java portal with a Django application, which means duplicating the Java portal's ability to display portlets. The two Sun specifications in question that we want to duplicate are JSR168 and JSR286. I need a cPython so...

Django and weird legacy database tables

Hi, I'm trying to integrate a legacy database in Django. I'm running into problems with some weird tables that result from horribly bad database design, but I'm not free to change it. The problem is that there are tables that dont have a primarykey ID, but a product ID and, here comes the problem, a lot of them are multiple in case of...

web2py in the future?

Given the size of web2py and the lack of resources and corporate support, do you think it would be advisable to learn web2py as the only web development frame work I know. I'm considersing learning ror or web2py for a website i need to create for as a school project. this is not the 'ruby vs python' question. I just want to know what dis...

Django SESSION_COOKIE_DOMAIN

I'm seeing something mysterious with the SESSION_COOKIE_DOMAIN setting in django. Normally, when I have this set to ".mydomain.net" it works fine. But occasionally cookies don't seem to be being set, because when I log in, I'm not remembered in the session and I become AnonymousUser when I get to the next page. In these circumstances, ...

Restricting admin model entry

I have a such model named Foo: class Foo(models.Model): name = models.CharField() entry = models.DateField() I have 2 types of users who can login to the admin panel, regular and superusers. I want to disallow the edition/deletion of Foo entries that are older than 2 days (by using the entry date field) but superusers may edi...