FormWizard: how to pass in extra keyword arguments into a form's __init__?

2009-08-31 Thread Berco Beute
One of the forms I'm using in a FormWizard takes an aditional keyword argument in its __init__, e.g.: = def __init__(self, arg1=None, *args, **kwargs): pass = I'm at a loss how to make FormWizard construct my form while passing in the extra keyword argument (arg1).

Re: How to show the email field in a UserCreationForm?

2009-08-11 Thread Berco Beute
To reply to my own question...I've extended UserCreationForm as follows: == class UserCreationFormExtended(UserCreationForm): def __init__(self, *args, **kwargs): super(UserCreationFormExtended, self).__init__(*args, **kwargs)

How to show the email field in a UserCreationForm?

2009-08-11 Thread Berco Beute
Hi, I'm using the UserCreationForm for creating users, but I would like to show the email, firstname and lastname fields as well (and they should be required). Much like the view you get when adding a user through the admin interface. What's the best way to do this? Extend UserCreationForm? Or

Re: Django/ Python 3 - nervous about starting large project

2009-08-05 Thread Berco Beute
No worries, Python 2.6 will be actively supported for many, many years to come and the differences between 2.6 and 3 are not that huge. You can program for 2.6 while keeping in mind the code will be ported to 3 one day. It'll make a shift a breeze. 2B On Aug 5, 10:47 pm, snfctech

Re: Multiple instances of the same form on one page: how to get the right POST data?

2009-08-05 Thread Berco Beute
> You forgot to set the prefix here, so the form that the user is > submitting their data from doesn't have the fields named correctly. You > need to set it up exactly the same way at this point as you did in the > POST path, with the exception of not prepopulating with data. Thanks, the missing

Multiple instances of the same form on one page: how to get the right POST data?

2009-08-04 Thread Berco Beute
I'm trying to add multiple instances of the same form on one page, each with its own submit button. I know how to use the 'prefix' argument for a form to differentiate between forms, but I can't figure out how to get the right data when it is POST'ed back (see view.py below). Somehow the form

Group-permission inheritance

2009-07-12 Thread Berco Beute
What's the recommended way for implementing (group)permission inheritance in Django? What I want to accomplish is a a hierarchy of groups where subgroups inherit permissions from the parent group. I have seen 'comaie' (http://code.google.com/p/comaie-django-groups/) but that is based on

Re: Your IDE of choice

2009-01-06 Thread Berco Beute
On Jan 6, 2:35 pm, Pigletto wrote: > So, Netbeans is currently my IDE of choice. Good svn integration, > faster than eclipse and komodo, stable, nice markup highlighting. +1 I'm using SciTe and emacs for simple, single file editing. I've used pydev for a while but eclipse's

Re: Redirect parent from within iframe without losing session

2009-01-05 Thread Berco Beute
for iFrames to give back control to the parent page? 2B On Jan 5, 10:43 am, Berco Beute <cybe...@gmail.com> wrote: > The iFrame is from a different domain, which is likely causing the > problem. I can see that the session is lost since the logged in user > is suddenly logged out. > >

Re: Port large webapp from PHP to Django: tips, experiences, links needed

2009-01-05 Thread Berco Beute
Still looking for some feedback. :) In the meantime I've collected a few links that might be useful for others with the same questions: http://www.egenix.com/library/presentations/EuroPython2008-Designing-Large-Scale-Applications-in-Python/ http://highscalability.com/ebay-architecture

Re: Redirect parent from within iframe without losing session

2009-01-05 Thread Berco Beute
The iFrame is from a different domain, which is likely causing the problem. I can see that the session is lost since the logged in user is suddenly logged out. 2B On Jan 5, 1:15 am, Daniel Roseman wrote: > Personally, I can't see how that redirect could be

Re: Redirect parent from within iframe without losing session

2009-01-04 Thread Berco Beute
I'm still searching for a solution for this problem. Which other forums should I try? Thanks, 2B On Jan 3, 5:33 pm, Berco Beute <cybe...@gmail.com> wrote: > My page shows a (logged in) user an iFrame but when the iframe > redirects the browser after it's done, the ses

Redirect parent from within iframe without losing session

2009-01-03 Thread Berco Beute
My page shows a (logged in) user an iFrame but when the iframe redirects the browser after it's done, the session is lost. The redirecting of the parent (by the iframe) is done as follows: = function load() { parent.location.href='

Port large webapp from PHP to Django: tips, experiences, links needed

2009-01-02 Thread Berco Beute
I'm looking for additional information that could help me decide whether I should port a large web application to Python/Django. The application handles transactions, which often come in bursts. Peaks may go up to tens of thousands of transactions per second. There are 3 views on the system:

Re: Form stays invalid even after required field has been set

2008-12-10 Thread Berco Beute
On Dec 10, 7:24 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > You say you excluded 'product' from the form but the code you posted has not > excluded 'product', it has excluded 'parent' and 'usePrice'. Ahem[hides under a rock in shame]...I guess copy/paste got me there. > Also, the

Re: Form stays invalid even after required field has been set

2008-12-10 Thread Berco Beute
> Try adding this to your template: > > {% if form.non_field_errors %} > {{form.non_field_errors.as_ul}}{% endif %} > > This will tell you form errors that aren't specific to a field. > > Tim > > On Dec 10, 8:26 am, Berco Beute <[EMAIL PROTECTED]> wrote: > >

Form stays invalid even after required field has been set

2008-12-10 Thread Berco Beute
Here's the code: http://dpaste.com/97758/ My modelform stays invalid although the required fields of the instance are set. The 'product' field is excluded from the form because it shouldn't be edited. When the form is posted I'm trying to set the product on the form instance again, but that

Re: range-like template tag?

2008-12-08 Thread Berco Beute
Ah! Of course, why didn't I think of that! Works like a charm. Thx! 2B On Dec 8, 7:23 pm, Adi Sieker <[EMAIL PROTECTED]> wrote: > Couldn't you add a method get_range() (or whatever name makes sense in   > your context) > to the class the object is an instqnce of. > The method would look

Re: range-like template tag?

2008-12-08 Thread Berco Beute
better to pass it in the context--why can't > you do that? > > -Jeff > > On Dec 7, 5:12 pm, Berco Beute <[EMAIL PROTECTED]> wrote: > > > Is there a template tag to turn an int into a sequence (like 'range')? > > What I want to do

range-like template tag?

2008-12-07 Thread Berco Beute
Is there a template tag to turn an int into a sequence (like 'range')? What I want to do is populate a select widget with the numbers up to the int, like: == {% for i in someInt.range %} {{i}} {% endfor %} == Passing the sequence

Re: Sending HTML email

2008-09-23 Thread Berco Beute
> You might try reading the > documentation:http://docs.djangoproject.com/en/dev/topics/email/#sending-alternativ... Oops, completely overlooked that. Thanks for the pointer. 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Sending HTML email

2008-09-23 Thread Berco Beute
Currently I'm sending plain text mails using: ### from django.core.mail import EmailMessage email = EmailMessage('hi', 'howdy', host, to) email.send() ### But now I want to use HTML in the body of the email. How do I format such a message and can I just send it like above? 2B

Access help_text in template (for a custom form field)

2008-09-23 Thread Berco Beute
I have one custom field in my form and I can't get the help_text in a template. In the admin the help_text shows up fine so I assume it has something todo with my custom field: ###template {{ form.guests.help_text }} #where 'guests' is a CommaSeparatedEmailField as specified

verbose_name in template?

2008-09-19 Thread Berco Beute
Is the fieldname or verbose_name of a instance-field (not a form- field) accessible in a template? 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Login a User instance

2008-09-16 Thread Berco Beute
Thanks Rajesh, I got a similar tip from someone else. I now specify the backend in settings.py: AUTH_BACKENDS = ('django.contrib.auth.backends.ModelBackend', ) where 'django.contrib.auth.backends.ModelBackend' is the default backend. In my view I can then set the backend on the User

Login a User instance

2008-09-16 Thread Berco Beute
I have a User instance that I want to login. Normally in a view I could just invoke authenticate() followed by login(), where the former takes the username and password from the incoming request. In my case I retrieve the User object from the db and only have the username, not the plain password

Documentation for 'django.core.files.images.get_image_dimensions'?

2008-08-28 Thread Berco Beute
28, 12:13 am, Berco Beute <[EMAIL PROTECTED]> wrote: > Thanks, that works great! I didn't know about 'from > django.core.files.images import get_image_dimensions'. Where can I > find documentation about that? I've tried a custom 'clean_image' > before using PIL, but that was just p

Re: setting a form to invalid after having called form.is_valid()

2008-08-27 Thread Berco Beute
Thanks, that works great! I didn't know about 'from django.core.files.images import get_image_dimensions'. Where can I find documentation about that? I've tried a custom 'clean_image' before using PIL, but that was just plain ugly. I never knew about 'get_image_dimensions'. 2B > It's much

setting a form to invalid after having called form.is_valid()

2008-08-27 Thread Berco Beute
I have an image upload form and I want to INvalidate the form if the uploaded image it too big. How can I get an error message in the form saying the uploaded image is too big? ===Model== class Image(models.Model): image = models.ImageField(upload_to='imageupload')

Re: Discard an uploaded image when returning a form with errors

2008-07-03 Thread Berco Beute
To answer my own question, I now moved the validation code to the form and create a PIL image using Image.open(StringIO(uploadedFile.content)): ===forms.py class ImageForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ImageForm, self).__init__(*args, **kwargs)

Re: Discard an uploaded image when returning a form with errors

2008-07-03 Thread Berco Beute
Something tells me the validation actually belongs to the form, but how can I get to the image size from within the form? ===forms.py class ImageForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ImageForm, self).__init__(*args, **kwargs) def clean_image(self):

Re: custom template tags

2008-07-03 Thread Berco Beute
It should be in: /project/application/templatetags/ 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from

Discard an uploaded image when returning a form with errors

2008-07-03 Thread Berco Beute
I have a form for uploading images. When uploaded I check for a maximum size, see snippet below. If it's too big I return the same form but without the uploaded (big) image. Unfortunately the big image is part of the returned form (I can tell since I display the image for a form). Is there a way

Re: Multiple instances of same form: how to only saved the filled in ones?

2008-07-02 Thread Berco Beute
is_empty() was indeed what I was looking for. :) For the time being I got it working using any(form.cleaned_data.values()) Thanks for your great help! 2B On Jul 2, 5:02 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Wed, 2008-07-02 at 07:58 -0700, Berco Beute wrote: > >

Multiple instances of same form: how to only saved the filled in ones?

2008-07-02 Thread Berco Beute
I have multiple instances of same the form (of which all fields are optional), but I only want to save the form in case something is filled in. How can I test that in my view? 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: Remove empty value ('---------') from HTML SELECT choices

2008-06-08 Thread Berco Beute
Great! A cleaner solution. Thanks! Is there any effort underway for making overriding default widgets simpler? I think that's really needed (especially for beginner like me). 2B On Jun 8, 1:20 am, Nathaniel Whiteinge <[EMAIL PROTECTED]> wrote: > On Jun 7, 4:18 pm, Berco Beute <[EMA

Remove empty value ('---------') from HTML SELECT choices

2008-06-05 Thread Berco Beute
My model has a ForeignKey that renders as a SELECT field in HTML. The problem is that there's an empty value ('-') that I would like to hide. I've tried adding 'null=False' and 'blank=False' to the ForeignKey but the empty value still appears. Any suggestions? 2B

Re: Use variables inside an 'include' tag (and/or: how to set a variable in a template)

2008-06-03 Thread Berco Beute
Passing a complete context to a simple_tag doesn't (yet?) work, as described here: http://groups.google.com/group/django-users/browse_thread/thread/ee830466be465704/a41d89fd476becb1#a41d89fd476becb1 I finally solved my problem by defining my own tag as follows: === from

pass complete context from template to simple_tag

2008-06-02 Thread Berco Beute
I've written a simple tag that renders a template, but to do so it needs the complete context. How can I pass that from a template? Thanks, 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: Use variables inside an 'include' tag (and/or: how to set a variable in a template)

2008-06-02 Thread Berco Beute
That's seems to be working, the only thing I've left to do is passing the complete context from the template to the simple_tag, else the simple_tag won't be able to render the template. How is that normally done in Python? 2B On May 31, 7:32 am, Alex Morega <[EMAIL PROTECTED]> wrote: > Create

Re: Use variables inside an 'include' tag (and/or: how to set a variable in a template)

2008-05-30 Thread Berco Beute
Unfortunately that doesn't work. This works: {{ include dir|concat:"/tag.html" }} But not this: {% include dir|concat:"/tag.html" %} Thanks, but I'm still searching for a solution... 2B On May 29, 11:18 pm, Johannes Dollinger <[EMAIL PROTECTED]> wrote: > You could use a filter: > >

Re: Use variables inside an 'include' tag (and/or: how to set a variable in a template)

2008-05-29 Thread Berco Beute
I can surely pass the path variable into the context from within my view, but the view doesn't know which filename to include. So in the template, I would still have to combine path and filename when creating an include tag such as: {% include "dir/tag.html" %} But how can I combine the path

Re: Use variables inside an 'include' tag (and/or: how to set a variable in a template)

2008-05-29 Thread Berco Beute
Inclusion tags sound good, but I'm not sure how it could solve my problem. In my template I would like to use an inclusion tag this way: ###template {% showTag 'tagName' %} ###inclusion tag @register.inclusion_tag('tag.html') def showTag(tagname): #... ###tag.html bla But

Use variables inside an 'include' tag (and/or: how to set a variable in a template)

2008-05-27 Thread Berco Beute
In the following 'include' tag the 'dir' may vary: {% include "dir/tag.html" %} so I would rather use something like: {% include {{ dir }}"/tag.html" %} which of course doesn't work. Is there a way to accomplish this? Being able to set a variable inside a template would solve the problem, but

how to test whether an 'include' yields an empty string?

2008-05-27 Thread Berco Beute
How can I test whether the following (example) 'include' tag returns any text? {% include "dir/tag.html" %} 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: Django learning management application

2008-05-15 Thread Berco Beute
Sounds interesting. It would be great if you could share some details on how you combined Django and Moodle. 2B On May 15, 4:35 am, "Ariel Mauricio Nunez Gomez" <[EMAIL PROTECTED]> wrote: > Moodle and Django can coexist happily (Using same database and writing > django models for some of the

Re: capturing keyword and non-keyword arguments from urls

2008-05-15 Thread Berco Beute
#the-matching... > > What the second paragraph means is that the URL handler is trying to call > new(request, name = 'default') and (understandably) it is not working.  You > should change the id into a named argument. > >   -- Scott > > > > On Wed, May 14, 2008 at 11:32

Re: Django learning management application

2008-05-14 Thread Berco Beute
I've been using Moodle (moodle.org), which offers the functionality you are looking for, and would prefer to use a Djange-based system as well. I haven't found one though. 2B On May 14, 5:26 pm, Wes Winham <[EMAIL PROTECTED]> wrote: > Does anyone know of any learning management application

capturing keyword and non-keyword arguments from urls

2008-05-14 Thread Berco Beute
I want to capture an 'id' and a 'name' from a url (slug) and pass them to a method with signature new(request, id, name='default'). For example I want to capture '8' and 'newname' from: /new/8/newname Somehow the following url dispatchers work and don't work. The error says there is a

Re: CommaSeparatedEmailField

2008-04-22 Thread Berco Beute
Ah, Django's documentation is a treasure: http://www.djangoproject.com/documentation/newforms/#a-simple-example --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

CommaSeparatedEmailField

2008-04-21 Thread Berco Beute
Is there something like a 'CommaSeparatedEmailField'? I know there is a CommaSeparatedIntegerField, which is rather handy... 2B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this

Re: Custom form field overrides model attributes?

2008-04-20 Thread Berco Beute
Django. After returning to Django now I remember again what was so cool about it: the community around it. :) Thanks, everyone! 2B PS: I'm using this widget: http://www.djangosnippets.org/snippets/391/ On Apr 20, 12:19 pm, "Phil Davis" <[EMAIL PROTECTED]> wrote: > On 20/0

Custom form field overrides model attributes?

2008-04-20 Thread Berco Beute
Using: Latest from trunk I'm using a custom widget for datetimefields: == #models.py class Event(models.Model): endDateTime = models.DateTimeField('Finish', blank=True, null=True) #forms.py class EventForm(forms.ModelForm): endDateTime =

Re: Form for model: how to inline-edit associated objects within the same form?

2008-03-08 Thread Berco Beute
Thank you very much, that was exactly what I was looking for! 2B On Mar 3, 11:58 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-03-03 at 14:23 -0800, Berco Beute wrote: > > I want to create a form for editing existing Poll objects and their > > associate

Form for model: how to inline-edit associated objects within the same form?

2008-03-03 Thread Berco Beute
I want to create a form for editing existing Poll objects and their associated Choice objects (see below). Editing the Poll objects is no problem, the 'name' textfield shows up nicely. But I also want to edit the associated Choice objects with the same form (much like you can do on the