How to make delete() more clever?

2006-08-12 Thread
I want to override delete() === from django.db import models class Person(models.Model): first_name = models.CharField(maxlength=20) last_name = models.CharField(maxlength=20) def delete(self): if ( A ): super(Person, self).dele

Re: How to make delete() more clever?

2006-08-13 Thread
First I should thank Ivan for your help. But I think Malcolm figured out what I really want. Maybe django should catch Exception when calling a model's save / delete method. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Goog

Problem of render context

2006-08-13 Thread
When use something like this in a template {{ message }} X and render it in this way: c = Context({'message':s}) # s is an string encoded in utf-8 Response(template.render(c)) What I got is: '\x??\x??..\x??\x??' What's the problem?? --~--~-~--~~~-

Re: Problem of render context

2006-08-13 Thread
Actually, it's not the problem of encoding, I think. For example, if s is a string, the render() method should treate {{ s }} in the way print() does. But now what I see on the page is something like you see in a interactive python console. >>> print s XXX #Some text >>> s '\x0f\xde' #thi

list_display containing ForeignKey create a dead loop.

2006-08-14 Thread
Hi all, I met a problem. When I added a Foreign Key field to list_display, django falls into a dead loop and used up memories. When I removed the field, it's all OK. I don't think it's my code's problem because I've tested the __str__ function of both models related by the Foreign Key. Could

Re: Problem of render context

2006-08-15 Thread
Eh, I've figured it out. The message I sent to the template is not a string "XXX" but a list ["XXX"]. That's why I see "\x??\x??" on the rendered page --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: list_display containing ForeignKey create a dead loop.

2006-08-15 Thread
^C dose not help me. I think it's because django is multithreaded. But after I have inserted a lot of print in the codes, I found where the program stopped. django.db.models.QuerySet.__repr__ called repr(self._get_data()) And it stopped there. I will trace down to see what happenned tomorrow

Re: list_display containing ForeignKey create a dead loop.

2006-08-15 Thread
Hah! I've just found what happened! django.db.models.fill_cache_table is a function that calls itself until it processed all table connected by FK. But if there is a loop in FK relations, it will never stopped! I will see if I could make a simple patch for it. --~--~-~--~~--

Re: list_display containing ForeignKey create a dead loop.

2006-08-16 Thread
1Name, Col1Name, table2Name, ColName], ] And before any FK to be processed, it must be check that if it's already in this para. Perhaps it's not so efficient, but I think it will work. I will fill a ticket as soon as possible. Malcolm Tredinnick wrote: > On Tue, 2006-08-15 at 23:2

How to build a tree on the page?

2006-08-16 Thread
I have a table like this id | name | parentid And parentid is a Foreign Key to ID. So I have a tree in my database. My question is that, how can I represent it on the web as a tree. Something like this : http://community.csdn.net/ or simply this : http://www.smth.org/frames.html Is there

Re: list_display containing ForeignKey create a dead loop.

2006-08-17 Thread
Here is my fix for fill_table_cache === def fill_table_cache(opts, select, tables, where,old_prefix,cache_tables_seen,processed = {}): """ Helper function that recursively populates the select, tables and where (in place) for select

Re: list_display containing ForeignKey create a dead loop.

2006-08-17 Thread
Hehe, but again, there would be a infinite loop in django\db\models\query.py in get_cached_row That's because this record in Here's my patch = def get_cached_row(klass, row, index_start, processed={}): "Helper function that recursively returns an object

How to create my own Field Types ?

2006-08-17 Thread
Hi all! Django provides a Ip Address Field. But actually it's a CharField with some IP formate check. But in my database, ip addresss are stored in 4 bytes int form. So I was considering if it's prossible to SubClass Field to create my own Field Type. I will post my code here if I found it's

How to use Django as a web interface for another program?

2006-09-04 Thread
Hi all In most cases, web application has a database for it's own use. It allow users to change data and present data to user. It dose not have to know any other programs but the database. I think Django is perfect for this kind of use. I hope my problem would be the same. I have to write a