Re: caching and authentication

2007-07-07 Thread Honza Král
On 7/7/07, patrick k. <[EMAIL PROTECTED]> wrote: > > > Am 07.07.2007 um 02:13 schrieb Jeremy Dunck: > > > > > On 7/6/07, patrickk <[EMAIL PROTECTED]> wrote: > >> > >> when having a header where the username and a logout-button is > >> displayed, how do you cache this page/view? > > > > There's a CA

Re: FormWizard and clean

2008-04-04 Thread Honza Král
ars that the clean() > is called on the first form again. This happens before the done() > method on the Wizard itself. Obviously with an expensive (time) > validation I don't want to do it twice. Is there some way to do once > only validation on the first form in a FormWizard ?

Re: FormWizard and clean

2008-04-04 Thread Honza Král
utside the scope of > FormWizard then maybe I should just code up a custom two-form signup. > However if you could see a way I could do this with FormWizard, I > would appreciate your help ! > > Thanks is advance, > > Greig > > > > > > On Apr 4, 9:08 pm, "H

Re: Using form wizard to complete form over multiple sessions

2008-04-11 Thread Honza Král
mplete over > multiple sessions. I am considering adding save_for_later() and > resume_form_wizard() functions that would save the serialized form > data to the database, and allow users to resume the wizard at a later > time. > > Has anyone tried this? Any advice/thoughts? > >

Re: Accessing data from previous steps in Form Wizard

2008-04-15 Thread Honza Král
orms for validation. Is it > possible to pass user-submitted data from previous forms to subsequent > forms in a form wizard? > > Thanks, > Leif > > > > > -- Honza Král E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~

Re: Users permissions

2007-02-15 Thread Honza Král
it's impossible at the moment, but it should be possible with the newforms-admin branch via a hook On 2/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, I'm thinking about create a website using django. One of the > apps would be a news section, where everybody can publish the news >

Re: Problems with session middleware

2007-02-15 Thread Honza Král
On 2/16/07, Almad <[EMAIL PROTECTED]> wrote: > > Hello, > > please...nobody have a clue? > > I've run into same issue again and it's somehow making django usuable > for me :-( > > (and yes, still with the freshest trunk) > > Thank You, > > Almad my guess would be that you are somewhere returning a

Re: rendering dynamic fields in newforms

2007-02-17 Thread Honza Král
for rendering you should use BoundField... I use something like this... for s in : name = 'stay_' + str( s.id ) bf = BoundField( self, self.fields[name], name ) output.append( u'%s' % bf ) On 2/17/07, Rubic <[EMAIL PROTECTED]> wrote: > > Hi, I'm th

Re: Custom model initializers - getting logged in user in django models

2007-02-17 Thread Honza Král
This doesn't seem very clean to me... I also need to have logged-in user available in my models, so I have written a custom middleware that stores the user in thread_locals: import threading _thread_locals = threading.local() def get_current_user(): return getattr( _thread_locals, 'user', No

Re: Help about saving two linked instances...

2007-02-17 Thread Honza Král
Hi Giuseppe, On 2/17/07, Giuseppe Franchi <[EMAIL PROTECTED]> wrote: > > Hello everyone! > I've approached Django and Python from a few time and i love them > both. > As i am newbie i have a noobish question. My problem is: i have to > store a Resource object splitted in two tables as following: >

Re: error pages ?

2007-02-17 Thread Honza Král
On 2/17/07, akonsu <[EMAIL PROTECTED]> wrote: > > hello, > > the tutorial on djangoproject.com explains how to set up views > generating error pages for responses such as 404 or 500. is there a > way to use mod_python functionality and make apache serve its own > error pages? in case when it is run

Re: newforms select field

2007-02-17 Thread Honza Král
On 2/17/07, paulh <[EMAIL PROTECTED]> wrote: > > I feel the following should work: > class Myform(forms.Form): > ...publ = forms.ChoiceField(label='Publisher', required=False) > > and then in handler I should be able to set the choices dynamically > by: > > def meth(request): > ...frm=Myform(initia

Re: newforms select field

2007-02-18 Thread Honza Král
On 2/18/07, paulh <[EMAIL PROTECTED]> wrote: > > Thanks for the replies. As always, reading the docs again teaches you > a bit more than the first time; I now see that that initial was not > what I was after. > > Arnaud, I think your method is more what I was after and as you say, > it does exactly

Re: Custom Admin save function

2007-02-18 Thread Honza Král
you simply override the save() function to do what you described: create another instance and mark this one as deleted... the only problem I can think of is with the instance for example if I do m = Model.objects.all()[0] m.some_field = 'new value' m.save() what is now in 'm' ?? the new obj

Re: django admin - too many sql-queries

2007-02-18 Thread Honza Král
On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote: > > Hi, > > I have db-model like this: > > class Action(models.Model): >name = models.CharField(maxlength=64, unique=True) >photo = models.ForeignKey('Photo', null=True, blank=True) > > class Album(models.Model): >action = models.ForeignK

Re: ordering - how to using relation or db function

2007-02-18 Thread Honza Král
AFAIK this is currently not possible with django's ORM, you can work around that by using: queryset.order_by().extra( where=[ ' 1=1 ORDER BY whatever' ] ) which means: on queryset, reset sorting and to where clause append 1=1 (so if the SQL has correct syntax) and ORDER BY whatever... but I consi

Re: ManyToManyField does not allow empty relations

2007-02-18 Thread Honza Král
On 2/18/07, akonsu <[EMAIL PROTECTED]> wrote: > > thanks for your response. > > specifying null=True for ManyToManyField will allow nulls in the > corresponding field in the association table, right? but since this > table is just a list of pairs this is not needed because having no > row at all h

Re: django admin - too many sql-queries

2007-02-18 Thread Honza Král
On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote: > > > > > http://www.djangoproject.com/documentation/model_api/#list-select-related > > > > a try add > >class Admin: > list_select_related = True > > to all models, but it has no effect - "Edit Action" is still very > slow. > > with this o

Re: Custom Admin save function

2007-02-18 Thread Honza Král
On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote: > > > you simply override the save() function to do what you described: > > create another instance and mark this one as deleted... > That's what I want to do > > > what is now in 'm' ?? the new object, the one merked for deletion? etc. >

Re: django admin - too many sql-queries

2007-02-18 Thread Honza Král
On 2/18/07, Tom� Pokorn� <[EMAIL PROTECTED]> wrote: > models.py attached. > > > On Sun, 2007-02-18 at 16:51 +0100, Honza Kr�l wrote: > > > > > that's odd can you post your Model definition? definitely odd, list_select_related appears to have no effect on the sql queries. even if I add photo to li

Re: django admin - too many sql-queries

2007-02-18 Thread Honza Král
On 2/18/07, Gary Wilson <[EMAIL PROTECTED]> wrote: > > On Feb 18, 10:48 am, "Honza Kr�l" <[EMAIL PROTECTED]> wrote: > > On 2/18/07, Tom? Pokorn? <[EMAIL PROTECTED]> wrote: > > > > > models.py attached. > > > > > On Sun, 2007-02-18 at 16:51 +0100, Honza Kr?l wrote: > > > > > > that's odd can you po

Re: Custom Admin save function

2007-02-18 Thread Honza Král
On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote: > > I got a few questions cause it is not working (I assume I am to > silly): > > def save( self ): > > old_data = self.__class__.objects.get(pk=self.id).__dict__ > I can substitue pk with id (this is my primary...) sure, that's exactly

Re: how to count many-to-many relations?

2007-02-18 Thread Honza Král
Hi, I believe you could use queryset.extra( select={ 'B_count' : 'SELECT COUNT(*) FROM myapp_a_bs WHERE a_id = myapp_a.id' } ) it will result in a slightly different, but equivalent, query: SELECT myapp_a.id, myapp_a, ..., ( SELECT COUNT(*) FROM myapp_a_bs WHERE a_id = myapp_a.id ) AS "B_

Re: global name '_get_deleted_objects' is not defined

2007-02-18 Thread Honza Král
On 2/18/07, Robin Percy <[EMAIL PROTECTED]> wrote: > Has anyone else run into the following error when deleting objects using the > newforms-admin branch? > > Exception Value: global name '_get_deleted_objects' is not defined > Exception Location: > /usr/lib/python2.4/site-packages/django/contrib/a

Re: Custom Admin save function

2007-02-18 Thread Honza Král
On 2/18/07, Florian Apolloner <[EMAIL PROTECTED]> wrote: > > 2007/2/18, Honza Kr�l <[EMAIL PROTECTED]>: > > I just wrote it into the email as an example of how I would go about > > doing something like this, I said you will have to tweak it a bit, try > > it in shell first and see how its behaving.

Re: django admin - too many sql-queries

2007-02-18 Thread Honza Král
On 2/18/07, James Bennett <[EMAIL PROTECTED]> wrote: > > On 2/18/07, VIK_Tomas <[EMAIL PROTECTED]> wrote: > > class Action(models.Model): > >name = models.CharField(maxlength=64, unique=True) > >photo = models.ForeignKey('Photo', null=True, blank=True) > > Set 'raw_id_admin=True' on the 'ph

Re: Admin without Auth

2007-02-19 Thread Honza Král
On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > On Feb 19, 11:40 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > > On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > > How do I generate a hashed password? > > > > The easiest way is actually to manually create the superuser once > > du

Re: Admin without Auth

2007-02-19 Thread Honza Král
On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > On Feb 19, 1:11 pm, "Chris Brand" <[EMAIL PROTECTED]> wrote: > > > I then erase my apps database and run 'manage.py syncdb' > > > > Are you aware that you don't have to erase the database before running > > syncdb ? If you don't erase the db,

Re: Admin without Auth

2007-02-19 Thread Honza Král
On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > On Feb 19, 12:46 pm, "Honza Kr�l" <[EMAIL PROTECTED]> wrote: > > > > > what exactly are you doing? > > this approach works perfectly for me... > > > I put the mentioned sql in a file in my Djano installation django/ > contrib/auth/sql/users.s

Re: Admin without Auth

2007-02-19 Thread Honza Král
On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > On Feb 19, 1:25 pm, "Honza Kr�l" <[EMAIL PROTECTED]> wrote: > > On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > > > > > > On Feb 19, 12:46 pm, "Honza Kr?l" <[EMAIL PROTECTED]> wrote: > > > > > > what exactly are you doing? > > > > this

Re: Admin without Auth

2007-02-19 Thread Honza Král
On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > On Feb 19, 1:25 pm, "Honza Kr�l" <[EMAIL PROTECTED]> wrote: > > On 2/19/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > > > > > > On Feb 19, 12:46 pm, "Honza Kr?l" <[EMAIL PROTECTED]> wrote: > > > > > > what exactly are you doing? > > > > this

Re: Binary Data fields?

2007-02-19 Thread Honza Král
On 2/19/07, voltron <[EMAIL PROTECTED]> wrote: > > How would I go about saving images in a database? The imageField saves > images in the file system, how can I cleanly in a Djangoish way > override this? django currently doesn't support BLOBs so there is no way to do that in a clean django way...

Re: Database changes

2007-02-20 Thread Honza Král
On 2/20/07, kbochert <[EMAIL PROTECTED]> wrote: > > > > On Feb 19, 5:27 pm, "Lawrence Oluyede" <[EMAIL PROTECTED]> wrote: > > > All I can think of is to create a new model, say Poll1, with the > > > correct fields, do a syncdb, write and execute a python function to > > > transfer the data from Po

Re: how to get a reference to a authenticated user

2007-02-20 Thread Honza Král
On 2/20/07, Benedict Verheyen <[EMAIL PROTECTED]> wrote: > > Hi, > > i have some tables that i want to link with an authorized user. > Right now i use the login mechanism of django. > > 1. Is it possible to specify a foreign_key to the auth_user database? > If not, what is the best way to have a "u

Re: how to get a reference to a authenticated user

2007-02-20 Thread Honza Král
On 2/20/07, Honza Kr�l <[EMAIL PROTECTED]> wrote: > On 2/20/07, Benedict Verheyen <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > i have some tables that i want to link with an authorized user. > > Right now i use the login mechanism of django. > > > > 1. Is it possible to specify a foreign_key to t

Re: Database changes

2007-02-20 Thread Honza Král
On 2/20/07, Mike H <[EMAIL PROTECTED]> wrote: > > > For me, if there was a way to simply add missing columns that would be > enough. Any data manipulation should be done by a patch runner that can > be tested and automated, but simply adding missing columns to a table I > think should be done by sy

Re: username in the database

2007-02-22 Thread Honza Král
On 2/22/07, Mary <[EMAIL PROTECTED]> wrote: > > hi all; > > I am creating a model that will create a table that will contain some > articles that will be filled by admin people so i need to know how can > i create a > > field in the database that adds the user name of the logged person > when he ad

Re: Aggregate class: a first-attempt

2007-02-22 Thread Honza Král
On 2/22/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > Below I've pasted my first attempt at an aggregate function > class. Its __init__ takes a queryset (and an optional list of > aggregate functions to perform if, say, you only want the "sum"s > rather than min/max/avg/sum). Thus you should be ab

Re: Aggregate class: a first-attempt

2007-02-22 Thread Honza Král
On 2/23/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > >> I haven't yet figured out a way to suppress the order_by portion, > >> so what's currently in there is an ugly hack. But it would need > >> to prevent the standard methods from inserting an ORDER BY clause > >> against a non-aggregated field.

Re: Aggregate class: a first-attempt

2007-02-23 Thread Honza Král
On 2/23/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > >> quseryset = Model.objects.all() > >> queryset.aggregate( ( 'name', 'city' ), sum=( 'pay', > >>> 'some_other_field' ), avg=( 'pay', 'age' ), count=True ) > >> I like this calling interface as an alternate method for its > >> fine-tuned

Re: Admin page: is it possible?

2007-02-23 Thread Honza Král
Hi enrico, for most of the things you want to do, it would be better to write your own app, using generic_views, it shouldn't require much coding and it would give you the desired functionality without horribly abusing the admin app. ;) On 2/23/07, morellik <[EMAIL PROTECTED]> wrote: > > Dear all,

Re: session variable

2007-02-23 Thread Honza Král
On 2/23/07, Seth Buntin <[EMAIL PROTECTED]> wrote: > > So I can have for instance: > > request.session["order_items"] = [] > > and then in different view I can have: > > request.session["order_items"].append(1) > > and that append to the session variable? yes, but the session itsel

Re: Aggregate class: a first-attempt

2007-02-24 Thread Honza Král
I created a ticket for this: http://code.djangoproject.com/ticket/3566 any comments are welcome On 2/23/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > >> items.aggregate((,), sum=( > >> 'field1', > >> 'field2', > >> ... > >> 'field20', > >> 'field21', > >> )

Re: Newbie: Accessor and Definition help

2007-02-25 Thread Honza Král
On 2/25/07, DuncanM <[EMAIL PROTECTED]> wrote: > > I have 2 classes: > > class Player(models.Model): > team = models.ForeignKey(Team) > forename = models.CharField(maxlength=50) > surname = models.CharField(maxlength=50) > age = models.PositiveIntegerField() > sex = models.CharField(maxle

Re: Models Causing Admin to Crash

2007-02-26 Thread Honza Král
On 2/26/07, DuncanM <[EMAIL PROTECTED]> wrote: > > Hi, > I have some models related to a football (soccer) team, I had models > for everything working fine except my Results model. I tried adding > it yesterday and encountered a few problems with it, which was solved > due to the help from these g

Re: Models Causing Admin to Crash

2007-02-26 Thread Honza Král
On 2/26/07, oggie rob <[EMAIL PROTECTED]> wrote: > > I can't tell if this is the cause, but you should remove the "pass" > right under "class Admin": pass is just an empty command, it doesn't do anything > > -rob > > > > > -- Honza Kr�l E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420

Re: Using HTML/CSS as templates

2007-02-27 Thread Honza Král
On 2/27/07, MattW <[EMAIL PROTECTED]> wrote: > > Dear Group, > > I've got an HTML page with associated CSS that I want to use as my > template. Just to test it, I call: > > return render_to_response('about.html') > > and I get the page, but with no CSS info. I've checked the page > source, and it h

Re: models.TimeField()

2007-02-27 Thread Honza Král
On 2/28/07, DuncanM <[EMAIL PROTECTED]> wrote: > > When you use this field type, django automatically places a clock next > to the field which is very handy with quick links: 6am, noon, > midnight, now() or something similar. > > Is there any way I can get the list that is displayed then to be set

Re: how to get object after form.save() ?

2007-03-01 Thread Honza Král
On 3/1/07, grahamu <[EMAIL PROTECTED]> wrote: > > Hi all, > Two newforms questions... > > 1. Is there an easy way to get the new object created by form.save()? obj = form.save() > 2. Is is true that one should not call form.save() if the form was > instantiated from a class resulting from form_fo

Re: how to get object after form.save() ?

2007-03-01 Thread Honza Král
On 3/2/07, grahamu <[EMAIL PROTECTED]> wrote: > > > On Mar 1, 12:53 pm, "Honza Kr�l" <[EMAIL PROTECTED]> wrote: > > > > 1. Is there an easy way to get the new object created by form.save()? > > > > obj = form.save() > > Thanks, I finally saw that after perusing the django source code. > > > > 2. Is

Re: Unique Id's across several classes/tables

2007-03-01 Thread Honza Král
On 2/28/07, jzellman <[EMAIL PROTECTED]> wrote: > > Thanks for the reply. > > What I am trying to do is have subclasses. So this is what i would > like to do: > > class Parent(models.Model): > #stuff common to all child types > > class ChildA(Parent): > #... > > class ChildB(Parent): >

Re: select_related?

2007-03-01 Thread Honza Král
On 2/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Could somebody explain the difference between lets assume you have models Article Author Category where every article has one author and one category > > Foo.objects.all() and this will do something like select * from articles; > Foo.o

Re: newforms: no attribute 'form_for_instance'

2007-03-01 Thread Honza Král
On 3/2/07, stevelewis <[EMAIL PROTECTED]> wrote: > > So I've developed on my laptop, and am trying to deploy to a unix box, > and most things work fine, but I'm using the newforms form for > instance method, and it can't find it: > > 'module' object has no attribute 'form_for_instance' > > It appea

Re: newform: Post_add Submission not working

2007-03-02 Thread Honza Král
it would seem that the form still have some errors, try outputting form.errors in the template to see if its empty On 3/2/07, johnny <[EMAIL PROTECTED]> wrote: > > When I submit the information with the form, for some reason, I keep > coming back to the form, with data I entered. I am not sure wh

Re: How to modify form error messages.

2007-03-02 Thread Honza Král
On 3/2/07, Michael Lake <[EMAIL PROTECTED]> wrote: > > Malcolm Tredinnick wrote: > > On Fri, 2007-03-02 at 15:27 +1100, Michael Lake wrote: > > > >>Hi all > >> > >>I see in the documentation for forms that the HTML output will include the > >>validation > >>errors as a near the field. How does on

Re: newform: Post_add Submission not working

2007-03-02 Thread Honza Král
On 3/3/07, johnny <[EMAIL PROTECTED]> wrote: > > I did place form.errors in the template. If I type the invalid data, > then it displays the errors. Problem is when I type in valid data, it > doesn't display anything and brings me back to the form with the data > I have entered. Every frustratin

Re: Problem with get_current_user via middleware

2007-03-26 Thread Honza Král
On 3/26/07, Gilhad <[EMAIL PROTECTED]> wrote: > > I am trying to get current user, but I have some problem with it. I got > different '_local' object each time ... > > I followed the example at > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > > and make my model such way: > > clas

Re: Database migration

2007-03-26 Thread Honza Král
On 3/27/07, Jonas Maurus <[EMAIL PROTECTED]> wrote: > > On Mar 26, 11:10 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > I apologize for the vague newbie question, but I'm gonna ask it > > anyway... > > > > I'd like to switch DBs from mysql to postgres... how does one do so? I > > assume o

Re: Problem with get_current_user via middleware

2007-03-26 Thread Honza Král
On 3/27/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Mon, 2007-03-26 at 21:56 +0200, Gilhad wrote: > > I am trying to get current user, but I have some problem with it. I got > > different '_local' object each time ... > > > > I followed the example at > > http://code.djangoproject.com/

Re: Time length - Long and relative TimeField

2007-03-29 Thread Honza Král
On 3/29/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > On 3/29/07, Gilhad <[EMAIL PROTECTED]> wrote: > > > > > > Hello, is there something to use for long time periods like 30 hours or 2 > > years, which can be displayed as time? > > > 240:00:00 (alternatively 10d 00:00:00) >

Re: Time length - Long and relative TimeField

2007-03-29 Thread Honza Král
On 3/29/07, Gilhad <[EMAIL PROTECTED]> wrote: > > > > > 240:00:00 (alternatively 10d 00:00:00) > > > > > > Does the timesince filter do what you require? > > > > If I understand correctly, gilhad wants to specify an interval. > > > > Possible solutions: use two PositiveIntegerFields t

Re: Dynamic query building

2007-04-02 Thread Honza Král
something like this works for me... q = Q( tag__name=first_tag ) for tag in other_tags: q = q | Q( tag__name=tag ) Model.objects.filter( q ) On 4/2/07, Christian Hoppner <[EMAIL PROTECTED]> wrote: > > Hi there! > > I've been thinking about including in my new app a kind of tag browser. The > u

Re: Newforms: adding a date picker

2007-04-15 Thread Honza Král
creating a widget might be an overkill in this case adding a custom class to the input field via the attrs parameter should cover it nicely. i use this approach without the need for a special widget. On 4/15/07, Ray Cote <[EMAIL PROTECTED]> wrote: > > Thanks, that is very helpful. > > At 11:45 AM

Re: Session support

2007-04-18 Thread Honza Král
On 4/18/07, James Bennett <[EMAIL PROTECTED]> wrote: > > On 4/18/07, SlavaSh <[EMAIL PROTECTED]> wrote: > > This is wrong "intentional design decision". > > There few more web clients in the world besides the IE and Firefox. > > Part of them does not support cookies. > > Django provides a sessions

Re: Cache missunderstanding?

2007-04-22 Thread Honza Král
On 4/22/07, aaloy <[EMAIL PROTECTED]> wrote: > > 2007/4/22, Honza Kr�l <[EMAIL PROTECTED]>: > > On 4/22/07, aaloy <[EMAIL PROTECTED]> wrote: > > > > > > Hello All! > > Hello, > > > > > > > > I have a view like > > > > > > def record(request, id, type): > > > # some database code here > > > # some

Re: SQL Debug middleware

2007-04-22 Thread Honza Král
Hi, try http://www.djangosnippets.org/snippets/93/ with the standard debug context preprocessor shipped with django (see the snippet for how-to) it seems cleaner to add this to your base template than to hackishly replace the tag. If you, however, don't use django templates, you might want to use

Re: filtering by if a date field is empty

2007-04-22 Thread Honza Král
On 4/22/07, drackett <[EMAIL PROTECTED]> wrote: > > I am trying to grab objects from a model only if they are not complete > using a context processor. This is the code I have right now, but it > doesn't work. Is there an easy way to filter by if a date field is > empty/null? > > def event_open(req

Re: get the latest # of objects

2007-04-22 Thread Honza Král
just slice it: entry_list[:5] just bear in mind that slicing will actually query the database, so you need to do it when working with the data (e.g. not in urls.py when providing parameters for generic views) On 4/22/07, drackett <[EMAIL PROTECTED]> wrote: > > I love the ability to get the latest

Re: get the latest # of objects

2007-04-22 Thread Honza Král
On 4/22/07, drackett <[EMAIL PROTECTED]> wrote: > > hm. I'm trying to do this in a context processor and its not working: > > def entry_latest(request): > from app.entries.models import Entries > return {'entry_latest': Entries.objects[:5]} yeah, you have to slice the queryset: Entries.obje

Re: Newforms and CSS classes

2007-04-30 Thread Honza Král
gt; a class="vTextField required" to make CSS styling easier. > > Am I overlooking something, or is newforms missing this? > > -- > Christian Joergensen | Linux, programming or web consultancy > http://www.razor.dk | Visit us at: http://www.gmta.info &g

Re: Compound newforms

2007-05-01 Thread Honza Král
Hi, I use something similar to this. What I did was override the __init__ to take extra arguments with the instances it's editing and store them for future use. so it would look something like this: class MyForm(forms.Form): def __init__(self, objects=[], *args, **kwargs): super(Form, self).

Re: Added a column

2007-05-01 Thread Honza Král
On 5/1/07, gsmith <[EMAIL PROTECTED]> wrote: > > I'm using sqllite as my database. I've added a Image Field to one of > my tables. I am wondering how i get my database to register this new > column. I thought running the command 'python manage.py syncdb' would > update my database. However, aft

Re: ERROR: invalid input syntax for type boolean: ""

2007-05-01 Thread Honza Král
On 5/1/07, Baurzhan Ismagulov <[EMAIL PROTECTED]> wrote: > > Hello, > > I have a class Object(models.Model) which contains model.BooleanFields. > I'm trying to add rows to it, like this: > > o = Object() > o.a1 = 'a1' > o.a2 = 'a2' > o.save() > > I don't set boolean values here. save() results in t

Re: newbie -- trouble using Postgres

2007-05-02 Thread Honza Král
are you sure you are using the correct backend, note that there are two backends for postgreSQL, you want the one with psycopg2 in it On 5/2/07, BasicSci007 <[EMAIL PROTECTED]> wrote: > > Can't seem to get django and postgres to hook up. MySQL or sqlite3 > work fine. postgres seems to work fine

Re: union of two QuerySets

2006-12-12 Thread Honza Král
contains already a lot of Qs. > > > > I am looking for a way to combine "a" and "b" without going into their > > filters. > > QuerySets are lazy. There's no downside to combining two > arbitrarily-complex querysets either before or after the filter &g

Re: newforms - updating ChoiceField choices at runtime

2007-01-02 Thread Honza Král
Hi gordy, I worked around this issue by using: class MyForm( forms.Form ): . customer_id = forms.Field(widget=forms.HiddenInput,required=False) def __init__( self, data=None, **kwargs ): super( MyForm, self ).__init__( data, **kwargs ) self.fields['employee_id'] = forms.ChoiceField(

Re: [Django-users] how about a subject prefix???

2007-01-03 Thread Honza Král
if you are using gmail, you can set up a filter to put all django related stuff to a specific label, even skip the inbox so that it wouldn't interfere with your normal mail... just search for django-developers@googlegroups.com in To: field... that should do the trick... (if you are using some ot

Re: Newforms clean_data

2007-01-03 Thread Honza Král
On 12/30/06, Waylan Limberg <[EMAIL PROTECTED]> wrote: On 12/29/06, Vadim Macagon <[EMAIL PROTECTED]> wrote: > > Adrian Holovaty wrote: > > > > Would it help if the form automatically called its validation the > > first time you accessed form.clean_data? I'm trying to decide whether > > that wou

Re: psycopg installation error: C compiler cannot create executables

2007-01-03 Thread Honza Král
On 1/3/07, Abe <[EMAIL PROTECTED]> wrote: Hey all. Im trying to get django up and running on my Mac (powerbook, powerpc chip, 10.4 OSX). I got postgresql v 8.2.0 up and going, along with Python 2.4. I go to install psycopg to get the two communicating with one another, and, following the direc

Re: where does the old manipulator go?

2007-01-04 Thread Honza Král
Hi Ramdas, the "Right Way (tm)" how to solve this using newforms is: 1) subclass Field to create a field representing (and validating) username: class UserField( forms.Field ): def clean( self, value ): do what you must to verify username, throw validation error if you are not satisfied with

Re: quick admin view question

2007-01-10 Thread Honza Král
(s.a. "Library Documents" without > changing the name "Reference" in the model. > > Can I do this? How? > > Thanks, > Mae > > > > > -- Honza Král E-Mail: [EMAIL PROTECTED] ICQ#: 107471613 Phone: +420 606 678585 --~--~-~--~~

Re: Newforms 'preferred practice'

2007-01-12 Thread Honza Král
there any thoughts about form inheritance? I'd like to be > able to create a form base on another but with some more fields. At > the moment this doesn't seem to work as expected... it works but only for dynamic fields added via self.fields['name'] = forms.Field(...) I

Re: Creating a "wizard"

2007-01-12 Thread Honza Král
gt; paginated generic object_lists. So the user can navigate through the > resulting information no problem. > > In your case, you could keep shoving stuff in the request.session if > you had several pages of forms that they user had to go through. > > --gordy > > > >

Re: order_by with Foreign Keys

2007-01-12 Thread Honza Král
elease_notes=models.TextField(blank=True) > > class Product(models.Model): > name=models.CharField(maxlength=128) > > > Note that kindledb_product is the name of the database table that > stores the information from the Product. &

Re: how to do SQL SUM

2007-01-13 Thread Honza Král
On 1/13/07, Picio <[EMAIL PROTECTED]> wrote: Hello, in my custom view, when I retrieve a query set, I need to add (i mean do the sum) of all the values in a column. Is there a built in django-way to do it, instead to write python code myself? In the db_api I saw order_by but I cant see something

Re: Newbie question

2007-01-13 Thread Honza Král
just a thought: do you have DEBUG turned off in your settings? if not, django will store all qeuries it made in memory so that it is accessible for debugging purposes... On 1/13/07, Rob J Goedman <[EMAIL PROTECTED]> wrote: Hi, We converted an access system written in VB to a Django app. The pu

Re: Latex Rendering

2007-01-13 Thread Honza Král
or you can simply output the latex code using templates... its just a text file and thus can be rendered via the standard mechanism... we use this approach to generate RTF files On 1/12/07, Kjell Magne Fauske <[EMAIL PROTECTED]> wrote: Anush Shetty wrote: > Hi, > I want to build a wiki with t

Re: newforms and dynamic choices

2007-01-13 Thread Honza Král
On 1/13/07, Brian Victor <[EMAIL PROTECTED]> wrote: Let's say there's a Room model. And let's say there's a ManyToMany relationship with User to specify which users can schedule certain rooms. How should a person in such a circumstance create a SelectField on a form with a user's rooms as choi

Re: generic views and non-editable foreign keys

2007-01-13 Thread Honza Král
I would recommend you reading this blog by James Bennet: http://www.b-list.org/weblog/2006/11/16/django-tips-get-most-out-generic-views it has some great tips on using and extending generic views... On 1/14/07, qhfgva <[EMAIL PROTECTED]> wrote: So far I've been using generic views for everyth

Re: Please help me use "views.django.views.static"

2007-01-13 Thread Honza Král
How does your ENTIRE urls.py look? it looks like you supplied a prefix (mysite.www) to the patterns function, so that it is prepended to every view name you put there... remove it and it should be OK On 1/14/07, rzimerman <[EMAIL PROTECTED]> wrote: I want the Django development web server to s

Re: django.contrib.auth.decorators._checklogin didn't return an HttpResponse object.

2007-01-13 Thread Honza Král
the problem is not in django, it is more likely in your code... you have probably applied the login_required decorator to a view function, that does not correctly return the HttpResponse object... again if you would post the function we could tell you more... Honza On 1/14/07, rzimerman <[EMAIL

Re: add manipulator with current user field

2007-01-14 Thread Honza Král
On 1/14/07, James Tauber <[EMAIL PROTECTED]> wrote: I have a model with a required field of ForeignKey(User) What's the easiest way to write an add manipulator that automatically provides the current authenticated user for that field? do not write it at all, use generic views and wrap it in y

Re: how to do SQL SUM

2007-01-14 Thread Honza Král
On 1/14/07, Mark Striebeck <[EMAIL PROTECTED]> wrote: Hey, that's exactly what I needed too. But when I tried it, I got a OperationalError: (1140, 'Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause') my bad... sorry try qset.extra(

Re: add manipulator with current user field

2007-01-14 Thread Honza Král
On 1/14/07, James Tauber <[EMAIL PROTECTED]> wrote: On 14/01/2007, at 10:29 AM, Honza Kr l wrote: > On 1/14/07, James Tauber <[EMAIL PROTECTED]> wrote: >> >> I have a model with a required field of ForeignKey(User) >> >> What's the easiest way to write an add manipulator that automatically >> p

Re: newforms : how to display as_ul from views.py

2007-01-15 Thread Honza Král
maybe I am missing something but why don't you use {{ form.as_ul }} in your template?? On 1/15/07, Ramdas S <[EMAIL PROTECTED]> wrote: How do I get the templates to render the following form from the views.py given below as as unordered list, instead of the standard table formt. This is a simple

Re: Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread Honza Král
On 1/16/07, jfagnani <[EMAIL PROTECTED]> wrote: I'm just starting to learn newforms myself, but it looks like form_for_model returns a class, so shouldn't you be able to subclass it? I'm not sure how that would work though, since the class doesn't exist when defining your subclass, but that's b

Re: Customizing the class returned by newforms.form_for_model()

2007-01-15 Thread Honza Král
plus you can supply a super class that the resulting class will subclass via the form keyword argument... On 1/16/07, Honza Kr l <[EMAIL PROTECTED]> wrote: On 1/16/07, jfagnani <[EMAIL PROTECTED]> wrote: > > I'm just starting to learn newforms myself, but it looks like > form_for_model returns a

Re: mod_python/sqlite status

2007-01-16 Thread Honza Král
On 1/16/07, Guillaume Valadon <[EMAIL PROTECTED]> wrote: Hi, What is the status of mod_python and sqlite ? Do you think that I should switch to another database instead ? definitely, if you have more that one user, you should definetely run a dedicated db server, preferably one that supports

Re: mod_python/sqlite status

2007-01-16 Thread Honza Král
On 1/17/07, Honza Kr l <[EMAIL PROTECTED]> wrote: On 1/16/07, Guillaume Valadon <[EMAIL PROTECTED]> wrote: > > Hi, > > What is the status of mod_python and sqlite ? > Do you think that I should switch to another database instead ? definitely, if you have more that one user, you should definetely

Re: order_by not working with foreign keys:

2007-01-23 Thread Honza Král
it occured before on the mailing list... if you add select_related(), it will work... the problem is that specifying ordering like this doesn't force the join in the query so you might end up with a query that sorts on something that just isn't there... On 1/23/07, Bram - Smartelectronix <[EMAIL

  1   2   >