Re: dynamic method calling

2008-11-22 Thread Ivan Sagalaev
Ivan Sagalaev wrote: > if hasattr(self, 'get_%s_content' % self.name): > raise Exception('Method does not exists') Typo: there should be `if not hasattr`, obviously. --~--~-~--~~~---~--~~ You received this message because you ar

Re: dynamic method calling

2008-11-22 Thread Ivan Sagalaev
Chris wrote: > try: > push = getattr(self, 'get_%s_content' % self.name) > except AttributeError: > raise "Method does not exist" > if callable(push): > push(**argv) There are a couple of problems with this code. 1. It's more readable to call hasattr than to catch an exception from

Re: Subtle Memory Leak Finally Found! (DEBUG is off)

2008-11-18 Thread Ivan Sagalaev
7timesTom wrote: > cars = Car.objects.filter(...) #upto 2000 items > msg =... len(cars) # can you see the massive memory use here? This is actually well documented: http://docs.djangoproject.com/en/dev/ref/models/querysets/#when-querysets-are-evaluated --~--~-~--~~~-

Re: Custom upload handlers: Potential multi threading, session, etc issues. Take a look!

2008-10-20 Thread Ivan Sagalaev
truebosko wrote: > What I found though, is that the view that is being called from JS > will finally have access to the session variable after the upload is > complete Looks like you're doing it with development server. It's single-process and can't handle and upload and another view simultaneou

Re: DJANGO 1.0 : How to avoid converting to entities

2008-09-21 Thread Ivan Sagalaev
Malcolm Tredinnick wrote: >> Better yet, the thing that creates colorizedCode should mark it as >> "safe" (i.e. not requiring escaping) in this fashion: >> >> from django.utils.safestring import mark_safe >> def colorize(): >> # ... >> return mark_safe(result) > > Alt

Re: DJANGO 1.0 : How to avoid converting to entities

2008-09-20 Thread Ivan Sagalaev
tsmets wrote: > OK ! > I found it : http://code.djangoproject.com/wiki/AutoEscaping > > {% autoescape off %} > {{ body }} > {% endautoescape %} Or just {{ body|safe }}. Better yet, the thing that creates colorizedCode should mark it as "safe" (i.e. not requiring escaping) in this fashion:

Re: ANNOUNCE: Django 1.0 released

2008-09-04 Thread Ivan Sagalaev
dankelley wrote: > In other words, should I (or typical users) download the official 1.0 > version, or will it still be advised to track the development version? Nothing can stop you from using trunk :-) I'm not a core developer so don't take it as an official advice. But I do think that living

Re: Slovkian speakers? Help wanted with #8709

2008-08-31 Thread Ivan Sagalaev
Frantisek Malina wrote: > Sadly, I am not aware of any current Slovak Django users. > E.g. First 50 results on http://google.sk/search?hl=sk&lr=lang_sk&q=django > won't return a single blog-post about Django web framework in Slovak. May be contact one of those: http://djangopeople.net/sk/ ? Gábo

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev
fabio natali wrote: > For the sake of clarity, my django project is named arteak, the models > we are using belong to an app called "management". Ah! Then there should of course be get_model('management', kwargs.pop('model')). I thought 'arteak' was the name of the app. This is why it returns N

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev
fabio natali wrote: > That's right! So here comes my current urls.py: > > http://dpaste.com/72638/ > > then the traceback I get at http://localhost:8000/: > > http://dpaste.com/72639/ Oy! I've found it :-). It has nothing to do with model_view decorator or anything that we're talking here abo

Re: Generic Views and ModelAdmin: too much code?

2008-08-20 Thread Ivan Sagalaev
fabio natali wrote: >> import models > > I added the line > > import arteak.management.models It's not the same thing :-). This line won't load the name "models" into your local environment. If you want import from some path this should be: from arteak.management import models

Re: Generic Views and ModelAdmin: too much code?

2008-08-19 Thread Ivan Sagalaev
fabio natali wrote: > This is the urls.py I created: http://dpaste.com/72138/ > It doesn't work though: I get a > KeyError at /manufacturer > u'manufacturer' > when accessing http://localhost:8000/manufacturer > (manufacturer being one of my model) KeyError says that it can't find a key 'manufact

Re: Multi DB question

2008-04-17 Thread Ivan Sagalaev
shabda wrote: >> You could use SQLAlchemy to access your forum database, as long as you >> don't need it in the admin. > > As, I just need to access the other DB in one place, I think this is > the way to go here. Come on guys! If you just need to create a record in a DB you certainly don't nee

Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread Ivan Sagalaev
fizban wrote: > On 12 Apr, 12:54, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: >> It sounds like you're using markdown 1.7. We haven't yet incorporated >> the patch necessary to handle markdown 1.7 along with the earlier >> versions. That will go in soon, though -- there's already a ticket in Tra

Re: Error Message Best Practice Question

2008-01-27 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > This seems kind of hacky, but it really seems like it makes sense to > show this as a form error. The only other way I could think to solve > this was to pass the request to the model and then check the above in > the clean method, however this seems just as bad as it br

Re: Django auth user relation to other connected objects

2007-12-15 Thread Ivan Sagalaev
Przemyslaw Wroblewski wrote: > When I started using django I create sth like this in my views: > > Somemodel.objects.filter(user = request.user) > > But I don't like that scheme, I just want to create something similar > to rails like: > > "current_user.somemodel.find_by_name('x')" You want th

Re: Understanding autoescape-aware filters

2007-11-21 Thread Ivan Sagalaev
Thanks for clarification! I have couple more things to iron out though... Malcolm Tredinnick wrote: > If we didn't have is_safe, every filter that did some kind of string > manipulation such as input = intput + 'x' would need to end with lines > like > > if isinstance(orig_input, SafeDat

Re: Understanding autoescape-aware filters

2007-11-18 Thread Ivan Sagalaev
Malcolm, first of all, I should apologies. I actually intended my letter being 'funny' but after your answer I understand that it was just harsh :-(. I'm sorry. And let me again express that I never stopped to wonder how you manage to do so many great things in Django. Thank you very much! Sti

Re: Understanding autoescape-aware filters

2007-11-17 Thread Ivan Sagalaev
SmileyChris wrote: > It's explained here: > http://www.djangoproject.com/documentation/templates_python/#filters-and-auto-escaping Yes, I've asked the group after I've read those docs, twice :-). First time I thought that I was just slow but the second time I didn't understand again and asked f

Re: advice on template shortcomings

2007-11-17 Thread Ivan Sagalaev
Ken wrote: > For instance, I > cant pass a dict or a list of lists to the template. Actually it's not true, you can perfectly pass and access dicts and lists and whatever in templates. Can you describe your specific case that didn't work? --~--~-~--~~~---~--~~ Y

Understanding autoescape-aware filters

2007-11-17 Thread Ivan Sagalaev
Hello! I'm about to convert my apps to play well with recently introduced autoescaping but I have to confess that I don't get mark_safe, is_safe and needs_autoescaping. First, I don't get why .is_safe attribute is needed at all. If my filter returns any HTML I should escape it and mark_safe

Re: Using {% ifequal %} in my template is not working

2007-11-10 Thread Ivan Sagalaev
Greg wrote: > request.session['info'].update(shape=ProductShape.objects.get(id=request['shape'])) > return render_to_response('search.htm', {'pinfo': > request.session['info']} This might be because of your first line here doesn't work as expected. Session is not exactly a dict and one of the th

Re: ascii decode error bites again

2007-11-01 Thread Ivan Sagalaev
Kenneth Gonsalves wrote: > ProgrammingError at /web/admin/web/fosscalendar/add/ > ERROR: character 0xe28099 of encoding "UNICODE" has no equivalent in > "LATIN1" INSERT INTO > "web_fosscalendar" ("name","year","startdate","enddate","city_id","venue > ","organiser","scope","website","contact")

Re: Reversing a url with a get parameter

2007-10-17 Thread Ivan Sagalaev
Rufman wrote: > hey guys > > I need a little help reversing urls with a get parameter. > > I'm using urlresolvers.reverse() in my view to reverse the url as > follows: > reverse(pageName, kwargs={'page' : page}) > > If i try passing thre request.GET object as so: > > reverse(pageName, args=[re

Re: why HTML output in unicode?

2007-10-12 Thread Ivan Sagalaev
Ken wrote: > Sorry if this is a stupid question, but why do forms output HTML as > unicode strings? Is this arbitrary or is there some grand convention > we are all supposed to be following? The general convention is that all strings inside your project are supposed to be unicode. They are only

Re: @url tag - getting rid of urlpatterns

2007-08-30 Thread Ivan Sagalaev
Ilya Semenov wrote: > Second, I think the use of generic views is over-estimated. Generic > views do not even support access restrictions (@user_passes_test) and > thus are most of the time proxied via custom one-line views. Actually they support decoration perfectly well, right in urls.py:

Re: @url tag - getting rid of urlpatterns

2007-08-29 Thread Ivan Sagalaev
Ilya Semenov wrote: > === apps/app1/views/__init__.py === > @url(r'^index/$') > def index(request): > ... > > @url(r'^news/$') > def news(request): While the decorator looks nice it creates in my opinion at least as many problems as it solves. 1. You can apply decorators only to custom v

Re: unicode characters garbled on dumpdata / loaddata using postgres

2007-08-22 Thread Ivan Sagalaev
Wiley wrote: > I was wondering if anyone else had trouble or a workaround for dumping > and loading data with mixed character sets using a postgres backend. > My data has quite a few Chinese characters, they run from my normal > installation fine, but when i dump and reload the data, it's all > co

Re: Don't Repeat Yourself!

2007-08-11 Thread Ivan Sagalaev
sago wrote: > The feed approach for routing urls is everything that django's url > system was designed not to be: it imposes a hierarchical structure on > the url, distributes the configuration over multiple representations, > and could be avoided by having a feed view that behaves more like > gen

Re: XML output

2007-08-11 Thread Ivan Sagalaev
Alex Nikolaenkov wrote: > Hello guys, > I like just about everything in django, but at this point of me reading django > book I can't imagine the way of xmlizing django. There are serializers in Django: http://www.djangoproject.com/documentation/serialization/ > Is there a way to use XSLT templ

Re: Random character in rendered HTML

2007-07-24 Thread Ivan Sagalaev
brutimus wrote: > {% block content %} > > {% include "whatever.html" %} > {% endblock %} This is most certainly a BOM -- Byte Order Mark of a UTF-8 charset that your text editor has added at the beginning of the 'whatever.html'. It's a part of UTF-8 and those symbols are normally not seen

Re: Per-domain ROOT_URLCONF and TEMPLATE_DIRS

2007-06-30 Thread Ivan Sagalaev
Jeremy Dunck wrote: > Two settings files being used by a single process? > > How would that work? Oh... I missed the bit about a single process. But now I wonder why require this? One server can happily serve two sites either from separate mod_python handlers or separate FastCGI servers. Vlad

Re: Per-domain ROOT_URLCONF and TEMPLATE_DIRS

2007-06-30 Thread Ivan Sagalaev
Vladimir Pouzanov wrote: > Hi all, > > I have two sites that run nearly identical django instances. I wonder > if it's possible to somehow set per-domain ROOT_URLCONF and > TEMPLATE_DIRS to serve both sites from one django process. Why not just have two settings files? If you have common setting

Re: Mysql sleeping queries

2007-06-21 Thread Ivan Sagalaev
Malcolm Tredinnick wrote: > Perhaps read the remainder of the thread? :-) Sorry, I was too impatient this time :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send em

Re: Mysql sleeping queries

2007-06-21 Thread Ivan Sagalaev
Malcolm Tredinnick wrote: > Thanks, Ilya. I'd gotten that far, too. Unfortunately, though, it isn't > quite that easy. Well, it is that easy for mod_python, however for WSGI > compliance, we can't do that (since the WSGI handler returns an > iterable). But a WSGI server calls "close()" on the ite

Re: Mysql sleeping queries

2007-06-21 Thread Ivan Sagalaev
Malcolm Tredinnick wrote: > One other thing that I forgot in my earlier email: it's not actually > clear why the database connections get "lost" in the current > implementation. We close the connection too early, but when the template > rendering needs to access the database, it just opens a new o

Re: Too many queries generated by ChangeManipulator

2007-05-31 Thread Ivan Sagalaev
Russell Keith-Magee wrote: > On 6/1/07, char <[EMAIL PROTECTED]> wrote: >> Obviously, the performance deteriorates rapidly as the number of >> GamesOfInterest added to a Profile increases. Is there any way to >> avoid this? > > This is a known problem, and one of the many reasons that the forms >

Re: ChangeManipulator and default value not working.

2007-05-30 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Oh..I meant to mention that this is using the default > ChangeManipulator for the class. Then set to the field 'editable=False' and manipulator won't touch it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to

Test DB creation parameters

2007-05-28 Thread Ivan Sagalaev
Michal wrote: > It seems like the test database is created in SQL_ASCII encoding. I > looked into psql terminal and found: > > List of databases >Name | Owner| Encoding > -++--- > gr4unicode | pgsql | UNICODE > te

Re: Unicode-branch: testers wanted

2007-05-24 Thread Ivan Sagalaev
Malcolm Tredinnick wrote: > The unicode branch, [1], is now at a point where it is essentially > feature-complete and could do with a bit of heavy testing from the wider > community. Switched my site today to the branch. Works like a charm (translations, admin, multilingual content). --~--~

Re: LIKE '%something%' custom queries

2007-05-23 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > I'm reimplementing an in-database tree system and I'm using custom SQL > queries. I want to use % in LIKE but Django doesn't let me. > > The code: > ## > def getBranch(table_name, parent_depth, parent_cutLevel, max_depth): > cursor = connection.cursor(

Search options

2007-05-11 Thread Ivan Sagalaev
Hello! I'd like to ask everyone's opinion on implementing a search functionality in an app. The app is a forum that tends to be simple and pluggable. Now I'm on a quest of picking a right solution for searching and have stuck. My current thoughts and decision: - Searching using "like" db que

Re: TextInput({'onKeydown': 'some javascript code'} problem

2007-05-02 Thread Ivan Sagalaev
hoamon wrote: > no.setAttribute("onKeydown", 'Element.update("NO_CHECK", " src=http://mydomain/arrows.gif>");'); Instead of assigning a raw onkeydown attribute it's better to attach an event. Look into prototype.js' docs, I bet it can do this in a cross-browser fashion. Something like Event(

Re: TextInput({'onKeydown': 'some javascript code'} problem

2007-05-01 Thread Ivan Sagalaev
hoamon wrote: > how can i customize the fields in the newforms, or i walk the wrong > way ?? What you described is an issue but I want to advice a different technique that doesn't suffer from this issue and also considered more robust. You shouldn't mix your HTML with Javascript, instead you s

Syntax highlighting

2007-04-28 Thread Ivan Sagalaev
I am developing a non-intrusive javascript syntax highlighter for use in blogs. Recently I've added support for highlighting Django templates and now I feel it can be indeed useful for people writing about Django. Check it out: http://softwaremaniacs.org/soft/highlight/en/ --~--~-~--~-

Re: Implementing OpenID in your Django app

2007-04-24 Thread Ivan Sagalaev
Simon Willison wrote: > Hi all, > > I've just released the first version of an OpenID consumer package for > Django. The idea is to make it ridiculously easy to add OpenID > consumer support to any Django application - and hence allow users of > OpenID to sign in without having to set up a new us

Re: Variable value in template

2007-04-11 Thread Ivan Sagalaev
Kai Kuehne wrote: > With this > > Team: > {% for team in object.squad.team_set.all %} > {% appearance_count_for_team team.id %} > > and > > class AppearanceCountForTeamNode(template.Node): > def __init__(self, team_id): > print team_id > ... > > I get "team.i

Re: Django Set HTTP Error manually

2007-04-09 Thread Ivan Sagalaev
johnny wrote: > What I want to do is set HTTP Error manually in my view, when a > request is made to certain url, without post data. > > At a particular url, my view is looking for XML document to be sent > over http, by post. If a request come in without post, I want to > raise an error "405 Me

Re: Newbie problem with view/model interaction

2007-03-24 Thread Ivan Sagalaev
Ross Burton wrote: > then in the view: > > {% for paper in object_list|dictsort:"title" %} > {% if paper.has_voted( TODO ) %} > Not related to your question, but this is called 'template' in Django. 'View' means a different thing (a controller). > I then discovered that you can't pass a

Re: models.ManyToManyField: Multi-relationship in one table

2007-03-20 Thread Ivan Sagalaev
hoamon wrote: > Course|Trainee|Company > C1| T1 | Com1 > C1| T2 | Com1 > C1| T3 | Com1 > C2| T1 | Com2 > C2| T3 | Com1 > C2| T4 | Com2 > C3| T1 | Com2 You really can't do it using standard ManyToManyField. The common way is to create this r

Re: problem with template {% url string %}

2007-03-19 Thread Ivan Sagalaev
Paul Rauch wrote: > Template: > {% url cvh.view.login %} Here you have "view". > urlpatterns = patterns('mysite.cvh.views', > (r'^$','index'), > (r'^login/$','login'), > ) And here you have "views". {% url %} doesn't find your pattern and returns '' (empty string) that browser translates to

Re: low performance of FastCGI deployment

2007-03-14 Thread Ivan Sagalaev
Alexander Boldakov wrote: > Django deployment documentation claims the need of flup as the FastCGI > library. Are there any flup features that Django relies on? Nothing specific. Flup is recommended because it's pure Python and easier to install. Also documentation *strongly* recommends not to

Re: {% url %} problem

2007-03-13 Thread Ivan Sagalaev
akonsu wrote: > thank you Ivan, > > the problem with collapsing is that the 'name' parameter in my view > does not get the default value then if the url is empty. Oh... Indeed :-( Then may be just checking the value inside the function is your best bet for this case. --~--~-~--~~--

Re: {% url %} problem

2007-03-13 Thread Ivan Sagalaev
akonsu wrote: > i think the reason is two entries in the urlpatterns with the same > view. is this a bug? Well, not exactly a bug but a limitation of "reverse" function that {% url %} uses to do actual resolving. Incidentally there is a thread in django-developers[1] about solving a similar iss

Re: BooleanField won't update

2007-03-13 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > def update_snip(request): > u = User.objects.get(id=request.session['userid']) > snip = Snippet.objects.filter(id=snippet_id,user=u) > snip[0].active = 0 > snip[0].save() > print "Active = %s" % snip[0].active > > This NEVER works. What am I doing wr

Re: getting raw SQL queries

2007-03-09 Thread Ivan Sagalaev
Iapain wrote: > Hello, > > I am writing a SQL logviewer for sql queries fired by django. If I use > below code then i get an empty list of dictionary. > > from django.db import conneciton > from django.conf import settings > debug = settings.DEBUG #btw its always True, because i set it to true >

Re: select_related() and null=True

2007-03-06 Thread Ivan Sagalaev
Ilya Semenov wrote: > What different approach could I choose? I'm writing real-life model - > a Ticket can either have a User (who resolved it), or not (if the > ticket has not been yet resolved). Listing all resolved Tickets with > corresponding Users is a simple real-life task, too. Indeed... H

Re: Persistent connections

2007-02-27 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Is this truly the case? I thought Django used a persistent db > connection. No, Django closes connections upon each request. There were some discussions about it in the early days and some consensus was along the lines that a simple ad-hoc solutions like "just don't c

Re: installation-wide fixed language

2007-02-26 Thread Ivan Sagalaev
omat * gezgin.com wrote: > Yes, but I want the application to be internationalized. I want only > one of the installations to have only one translation. I had this problem on my site. I don't know if it's a bug or not but I managed to make it work by choosing English as a default language and R

Re: unicode in filters

2007-02-19 Thread Ivan Sagalaev
Dirk Eschler wrote: > you can try to add this as first line in your file: > > # -*- coding: utf-8 -*- And after this there's no need to write u'ç'.encode('utf-8') but is enough to write just 'ç'. --~--~-~--~~~---~--~~ You received this message because you are su

Re: {% url %} syntax in templates

2007-02-18 Thread Ivan Sagalaev
omat * gezgin.com wrote: > And url pattern that matches the view is > (r'^photo/(?P[-\w]+)/(?P\d+)/$', > 'artist.views.artist_photo'), > > Images are displaying fine but the links does not appear. (i.e. {% url > artist.views.artist_photo slug=artist.slug,id=photo.id %} does not > render anything.

Re: Model instance identity

2007-02-14 Thread Ivan Sagalaev
David Abrahams wrote: > I just wrote some code that used Model instances as keys in a dict, > and was surprised to find two instances in the dict that represented > the same object in the database. Shouldn't that be impossible? If > you can't guarantee that a given object in the database is alwa

Re: Having trouble with my M2M relationship.

2007-02-08 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > sponsor = models.ManyToManyField(Sponsor, > filter_interface=models.HORIZONTAL, related_name="section") > > > What I'm trying to do in a template is show all the sections that > sponsor is in. It seems to me I should be able to do something like > > {% for sec

Re: IPython Shell does not see database changes made by views.

2007-01-31 Thread Ivan Sagalaev
Paul Childs wrote: > I wanted to do some checks through the shell, which I was opened > during my unit testing, and found that after making some queries using > Django objects there appeared to be no changes in the database. When I > checked the database using its admin tool the changes were there

Re: Euro Sign raise UnicodeEncodeError

2007-01-26 Thread Ivan Sagalaev
Christian Schmidt wrote: > Do I have to encode (or decode) the string before I put it into the > database First, it depends on database backend. As far as I know MySQL wants byte strings (and for example psycopg2 lives happily with unicode strings). If you use newforms then you have data in uni

Re: how to list all Tags for Blog? or simple m2m filtering...

2007-01-20 Thread Ivan Sagalaev
natebeaty wrote: > ..but apparently this will only populate the tags once, when I start up > Django, correct? Do I need to add the extra_context in a wrapper around > a generic view in views.py? Or would something like this be best > implemented as a template_tag? > > Am I correct in assuming it

Re: how to list all Tags for Blog? or simple m2m filtering...

2007-01-17 Thread Ivan Sagalaev
natebeaty wrote: Tag.objects.filter(blog__id__isnull=False) Perfect! Yeah, "all tags that have relation to any blog" -- that's what I was trying to say! Actually I've forgot 'distinct' yet again: Tag.objects.filter(blog__id__isnull=False).distinct() ...or there would be dupes in

Re: how to list all Tags for Blog? or simple m2m filtering...

2007-01-17 Thread Ivan Sagalaev
natebeaty wrote: SELECT t.value FROM `blog_blog_tags` b LEFT JOIN `tags_tag` t ON (b.tag_id=t.id) but that feels like cheating.. besides, I'd like to better understand the ORM. Ah... You mean "all tags that have relation to any blog". This is it: Tag.objects.filter(blog__id__isnull=False

Re: how to list all Tags for Blog? or simple m2m filtering...

2007-01-16 Thread Ivan Sagalaev
natebeaty wrote: I'd like to throw this in as extra_context along the lines of: "tag_list" : Tag.objects.filter(this_is_where_my_brain_is_shorting) This is in fact pretty standard Django ORM, nothing special to TagsField: blog.tag_set.all() (assuming blog is an instance of Blog). You ca

Re: Design Q: Foreign keys from object.values()

2007-01-10 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Thanks; this works for me -- though I have to do > > Author.objects.filter(story__id__isnull=False).distinct() > > Or it repeats each author for each of his stories. > > This still confuses me, because there is no "story" field in the Author > model to specify ho

Re: Design Q: Foreign keys from object.values()

2007-01-10 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Hi guys, > > I'm trying to get a better grip on Django design philosophy, and I'm a > little confused as to why calls to a manager's " values() " function > returns foreign keys as the value of their primary key rather than as > django objects. For example: > > class

Re: Hi! Here's a new Django beginner with a few questions.

2007-01-10 Thread Ivan Sagalaev
Sebastien Armand [Pink] wrote: > class Person(models.Model): > ... > mother = models.ForeignKey('Person') > ... > > Will this work? Use models.ForeignKey('self') > For example if I've got a Body class and a Legs class, I know that I'll > never have a body with more than 2 legs Did

Re: Inner Join

2007-01-08 Thread Ivan Sagalaev
Russell Keith-Magee wrote: table1.objects.filter(table2_attribute_name.field='foo') Did you mean table1.objects.filter(table2_attribute_name__field='foo') (i.e. '__' instead of '.')? --~--~-~--~~~---~--~~ You received this message because you are subscri

Re: Extending ManyToMany managers

2007-01-08 Thread Ivan Sagalaev
Gulopine wrote: Yeah, I guess I see the biggest obstacle here is the simple fact that the ManyToMany manager is generated each time it's referenced, rather than persisting on the model. I can replace the add() method of the generated manager to get it to work immediately, but the next time I ret

Re: dynamically changing URLS

2007-01-08 Thread Ivan Sagalaev
James Bennett wrote: However, in your specific case I wonder if it wouldn't be better to just have a separate settings file Another approach (simpler in my view) is to have a middleware like this: class EmergencyMiddleware: def process_request(request): return render_to_resp

Re: Types of projects Django is not well suited for?

2006-12-27 Thread Ivan Sagalaev
Kenneth Gonsalves wrote: that has already been answered in the django documentation. Django is not a tool for endusers to create quicky web applications. It is not a ready made CMS/blog/BBs etc. I didn't say anything like this. Your question was why we would list Django's restrictions. I r

Re: Types of projects Django is not well suited for?

2006-12-27 Thread Ivan Sagalaev
Kenneth Gonsalves wrote: Why on earth would any web framework make a list of web apps that it is not suitable for? To be kind to a potential user when he might acquire a need to do something the framework *is* suitable for. No framework can do everything. And what is the best place to ask

Re: How would you implement this?

2006-12-21 Thread Ivan Sagalaev
Eric Floehr wrote: How would you recommend having the first table go against context variable 'table' and the second go against 'secondtable' (for example)? You're looking for inclusion_tag: http://www.djangoproject.com/documentation/templates_python/#inclusion-tags --~--~-~--~~

Re: CSS Basics

2006-12-21 Thread Ivan Sagalaev
Fredrik Lundh wrote: are you trying to say that Django's static server doesn't filter the URL before adding it to the document root ? Sure it doesn't. Mainly because there is no such thing as "Django static server". That view is just a debugging shortcut to let people develop a site when the

Re: Duplicate Related Records

2006-12-11 Thread Ivan Sagalaev
Ned wrote: > ==Template== > {% for status in form.status %} > > > {{ status.date }}{% if status.date.errors %} class="error">{{ > status.date.errors|join:", " }}{% endif %} > Somewhere in the first include {{ status.id }}. It's a hidden field that actually different

Catching m2m chnages

2006-12-11 Thread Ivan Sagalaev
Hello! I have two models linked through m2m relation. I want to hook a code that will be executed on each change in this relation (adding and removing). If it wasn't about m2m then I would just override a save() method of a model but with m2m an intermediate table is not represented as a mode

Re: Anonymous Sessions

2006-12-06 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > It is a problem. It hits the db if it has to create it. Sorry I still don't understand :-). You say that you do need authentication but don't need anonymous sessions. Then in default Django setup you never hit a database unless you try to store something in session.

Re: Anonymous Sessions

2006-12-06 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Well we obviously need authentication, we just don't need anonymous > session handling. Then it shouldn't be a problem. Sessions are created and hit db only if you store something in it. Or if you have SESSION_SAVE_EVERY_REQUEST = True. Otherwise request.session is ju

Re: Anonymous Sessions

2006-12-06 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > I'd like a simple option to disable this, any plans to implement > something of the sorts? The intended way is to remove SessionMiddleware and those depending on it (AuthenticationMiddleware) from MIDDLEWARE_CLASSES and 'django.contrib.sessions', 'django.contrib.auth'

Re: can't figure out how to call a generic view inside my own view

2006-12-06 Thread Ivan Sagalaev
Anton Daneika wrote: > Hello, everyone. > > I am trying to call django.views.generic.list_detail.object_list from my > own view, but I get the error page saying "dict' object has no attribute > '_clone'" > > Here is the function: > def my_gallery_listing(request, gallery_id): > d = dict(qu

Re: using manipulators without defining fields again

2006-12-04 Thread Ivan Sagalaev
Milan Andric wrote: > I have a long application form for a workshop (name, employment, > resume, ... 65 fields). The user logs in to the site via > django.contrib.auth.view.login, standard django fare. Then the user is > allowed to apply for workshop xyz. If the user clicks save but does > not

Re: How to default checkboxfield in customer manipulator

2006-12-04 Thread Ivan Sagalaev
jeffhg58 wrote: > I am trying to set the checkboxfield default value to checked but not > sure how you do it. > > Here is my formfield for the checkbox > > forms.CheckboxField(field_name="current"), > > I tried ading checked="checked" but that did not work. It's a bit non-obvious... The actual

Re: i18n & server_name

2006-12-04 Thread Ivan Sagalaev
Alexander Solovyov wrote: > Sorry, I found answer - META['HTTP_HOST']. :) Documentation keeps > silence about this. :( Another way is to use 'sites' app and keep domain in a table separately for each site. --~--~-~--~~~---~--~~ You received this message because

Re: File downloads

2006-12-03 Thread Ivan Sagalaev
marksibly wrote: > I couldn't find a 'HttpResponseStaticFile' class or anything, so what > other options do I have? You can pass an open file to a usual HttpResponse: f = open(filename, 'rb') return HttpResponse(f, mimetype='application/octet-stream') > Also, how efficient would it be

Re: Calling model-functions in template

2006-12-03 Thread Ivan Sagalaev
Kai Kuehne wrote: > models.py: > def genres_title_list(self, separator=', '): > return separator.join([x.title for x in self.genres]) If I reconstruct the case correctly and `genres` is a relation to child objects with ForeignKey to a Movie then `self.genres` by default should look

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Ivan Sagalaev
Brian Beck wrote: > I don't understand how this is related to the admin interface. Admin interface won't display a login page if you already have request.user set to an existing user. (if I'm not mistaken :-) ). > Anyway, > shouldn't it go after the standard auth middleware, so that > django.co

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Ivan Sagalaev
Brian Beck wrote: > I just wanted to add that if you want to use this method in combination > with the bundled admin interface, you're gonna have to intercept any > admin requests and do the authentication ... which is achieved by placing this middleware before standard auth middleware. --~--~-

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Ivan Sagalaev
Ivan Sagalaev wrote: > request.user = User.objects.get_or_create( >username=username, >defaults={...}) This one should be: request.user, created = User.objects.get_or_create(...) `get_or_create` returns an object and a flag if it was newl

Re: Auto-login with REMOTE_USER

2006-12-01 Thread Ivan Sagalaev
dchandek wrote: > I've looked at authentication backends and middleware, but it looks > like the default Django installation expects users to login through a > Django form. Default system insist on storing logged user credentials in a session (though they can be of any nature). In your case you

Re: using manipulators without defining fields again

2006-12-01 Thread Ivan Sagalaev
Milan Andric wrote: > I was told in IRC to extend AutomaticManipulator. But I don't really > know what this means in terms of Django/Python code. Basically you create a manipulator class inherited from an automatic manipulator of a model. It will create all the needed FormFields based on model

Re: [validators] - access to object.id field

2006-12-01 Thread Ivan Sagalaev
Marcin Jurczuk wrote: > Hello, > I'm writing my own validator based on shipped with django and wondering > how get validated object.id field ? Validators come in two varieties: those linked to field definitions in models and those that linked to field definitions in custom manipulators. With fi

Re: import problems?

2006-12-01 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Sorry if this is poorly explained, but how do you efficiently get > around circular dependency problems like this in Python? I'd hate to > have to drop my import of functions_db to the individual methods on > "Object" to avoid whatever collision is happening. Another (i

Re: best place to put dispatcher.connect code?

2006-11-29 Thread Ivan Sagalaev
Le Roux Bodenstein wrote: > Surely if I put it > in a model or a view or whatever somewhere it will only be called the > first time that module gets loaded? The settings module is always imported so you can import your handling code there and put dispatch.connect beside the handling code. --~--

Re: manage.py webserver

2006-11-28 Thread Ivan Sagalaev
[EMAIL PROTECTED] wrote: > Now with django, I am trying to run through the "Are you generic" > tutorial. When I go out to the URL, I get a 404 "Page not found" > message, but absolutely no more information as to where to look! I > thought by using the devel version with the verbosity flag, i

Re: How to get request.user in templatetag?

2006-11-27 Thread Ivan Sagalaev
Rob Hudson wrote: > The place I need it is the: > class CommentFormNode(template.Node): You probably need it in this node's 'render' method. There you have a context passed to it and this context is exactly the thing that holds all the variables including 'user'. So this is it: class

  1   2   3   4   >