Re: a clean_tarfile() for my form

2008-12-23 Thread Alan
Sorry guys, apparently I found a solution, but... Well I swear I tried it before, but now it's working. I did this: try: tarfile.open(fileobj=file) except: raise forms.ValidationError(msg2) Anyway. Cheers, Alan On Tue, Dec 23, 2008 at 21:18, Alan wrote: > Hi, >

Re: Problems when searching acute or tilde letters in a textfield under tiny_mce.js

2008-12-23 Thread Vizcayno
I want to share the solution to my problem. I appreciate the kindness of Malcolm for the suggestions. After some searching in tinyMCE site, I found a note that recommends to explicitly leave option "entities" to empty, I show you a sample: tinyMCE.init({ // General options

Re: "Building you first Django app, Part 1" example not working

2008-12-23 Thread Chris
Thanks :-) On Dec 22, 4:01 am, leveille wrote: > You're 14.  You recognize that you're having a problem and you post to > the Django group for help.  You're not stupid at all.  I would say > you're very intelligent! > > On Dec 21, 2:43 pm, Chris

Serializing QuerySets and Python objects best practices

2008-12-23 Thread vernon
Hi, I'm trying to do something fairly simple (and doable), but I was wondering if there was a "best practices" approach. I'm developing a client-heavy app, and I'd like to return something like this to my JavaScript: {"posts": Post.objects.all(), "comments": Comment.objects.all()} Right now,

Re: Serializing QuerySets and Python objects best practices

2008-12-23 Thread Jeff Anderson
vernon wrote: > Hi, > > I'm trying to do something fairly simple (and doable), but I was > wondering if there was a "best practices" approach. I'm developing a > client-heavy app, and I'd like to return something like this to my > JavaScript: > > {"posts": Post.objects.all(), "comments":

admin sorting in ManyToMany fields

2008-12-23 Thread Aaron Lee
Hi I have a ManyToMany field names in my class and I would like to show the names in sorted order (according to 'name') in the admin interface when I edit a Person. Right now it's showing by the pk order of Name. What's the right way to override this order? Thanks class Name(models.Model): name

Re: where are the code that handle image file upload in Django admin page?

2008-12-23 Thread krylatij
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ here is a sample how to handle file upload And have tried: MyForm.save()? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post

Re: problem with adding foreign key to table

2008-12-23 Thread SteveMc
The other reply was correct; it's a character encoding issue. Take a look at http://www.postgresql.org/docs/8.3/static/multibyte.html - I suspect you will need to run initdb -E UTF8 to set the default character set for the postgres install. Alternatively that page instructs how to create a

a clean_tarfile() for my form

2008-12-23 Thread Alan
Hi There, So I have a form where users can upload zip and tgz file. In my def clean_file() for class MyForm, I can clean zip files smoothly and now I am trying the same for a tgz file but missing things. First, fileobj = self.cleaned_data['file'] will return a fileobj, so I tried: tar =

Re: login_required redirects always to LOGIN_REDIRECT_URL?

2008-12-23 Thread Jarek Zgoda
Wiadomość napisana w dniu 2008-12-22, o godz. 20:40, przez Matias: > You can add a hidden input named "next" where you put the value of > next in the GET variable. > Like this > > > > > > > Or you can change the action variable of the form to include the > current GET variables.

ModelAdmin and the ghost datas !

2008-12-23 Thread degans...@gmail.com
Hello :) (sorry I'm French) When I create a ticket (for a blog), I select various tags. I would save these with the save_model and save_tagged_items methods below : class TicketAdmin(admin.ModelAdmin): # ... def save_model(self, request, ticket, form, change): # Save the

Re: Complete layout (template) switching.

2008-12-23 Thread Kura
Thanks. Sadly though I don't want it to extend base.html, I want it to replace base.html but only under certain circumstances. As an example, base.html will have the current structure: __header__ | | nav | content | content | | __footer___

Re: Subprocess module in Python CGI

2008-12-23 Thread Anurag
I have also missed out a last line at the end of the Traceback ... this may be important in fishing out the error. The last line is: OSError: [Errno 2] No such file or directory Looking forward to some kind of suggestions. Thanking you all once again and with Regards. On Dec 22, 11:51 am,

Re: How to access SplitDateTime field elements in template

2008-12-23 Thread rtmie
I have found a workaroud to this, by using the AdminSplitDateTime widget and then rendering field in the template, the right thing happens: in form code: from django.contrib.admin import widgets as adminWidgets class Dummy1Form(forms.ModelForm): name = forms.CharField(max_length = 100)

Re: a clean_tarfile() for my form

2008-12-23 Thread Paul van der Linden
Hi, look at the module reference at python documentation: http://www.python.org/doc/2.5.2/lib/module-tarfile.html You can see there an is_tarfile to check if it is a tar file, or you can use TarFileCompat to check if it is a tar_gzipped file. Alan wrote: > Hi There, > > So I have a form where

Re: Model with CharField primary key, force_update=True to prevent saving other object

2008-12-23 Thread Jeff Kowalczyk
Jeff Kowalczyk wrote: > I'm working with a model using a CharField primary key, ... > I need to prevent other objects from being created/updated > if save() is called with a changed pk value. > > class Widget(models.Model): >     identifier = models.CharField(primary_key=True, max_length=10) I

Re: Subprocess module in Python CGI

2008-12-23 Thread Kenneth Gonsalves
On Monday 22 Dec 2008 4:21:31 pm Anurag wrote: > comd = [\ >         "tar -xf x.tar.gz", \ nothing to do with python: [law...@localhost programs]$ tar -xf x.tar.gz tar: x.tar.gz: Cannot open: No such file or directory tar: Error is not recoverable: exiting now btw, there is no need to put '\'

Re: dynamic mod wsgi

2008-12-23 Thread Ben Eliott
Strange, that thread is down for me. Maybe it has something to do with cacheing in a different locale... Anyhow, the idea is to create a new django instance and point to different settings.py files for different wildcard subdomains. here is current Vhost: ServerAlias

Customizing ModelForm fields appearance

2008-12-23 Thread sagi s
I really like the concept of generating a form from a model using ModelForm but would like to customize the apprearance slightly (e.g. size of the TextInput etc.). Any suggestion as to how to do this? I looked at the forms module code but got lost in the maze of the meta programming... Thanks

Django site - CSS doesn't render in Safari/Webkit

2008-12-23 Thread Alfonso
Hey, I'm getting a weird issue in Django with my css and Safari - displays great in all browsers except for Safari. Happens in two different django installations on two separate servers so clearly I'm doing something wrong. CSS files are accessible directly via URL in both cases... odd Apart

Re: Django site - CSS doesn't render in Safari/Webkit

2008-12-23 Thread Alfonso
OK tracked it down - appears Safari doesn't sit well with a master .css file and @import url(blah.css); I guess that's because of the way I'm serving up static files. Direct " wrote: > Hey, > >

Re: dynamic mod wsgi

2008-12-23 Thread Ben Eliott
I just saw your message below after sending the vhost. I don't think i'd mind whether it's separate processes or one really fat one. I think perhaps separate processes with a quite a short inactivity timeout might work quite well? I'd rather keep the overall footprint as small as

Dynamic age count

2008-12-23 Thread Alfonso
Hi, Trying to implement a very simple template tag that will output a company's age. So idea being if company was established in 1860 then it should output '148 years old' if my math is right ;-) this is what I've got: from django.template import * register = Library() @register.filter def

Re: Complete layout (template) switching.

2008-12-23 Thread bruno desthuilliers
On 23 déc, 11:57, Kura wrote: > Thanks. Sadly though I don't want it to extend base.html, I want it to > replace base.html but only under certain circumstances. Either I don't get you or you didn't get what I said... > As an example, base.html will have the current

Re: problem with adding foreign key to table

2008-12-23 Thread Ana
Thank you all for your response. I will try the encoding resolution. Ana On Dec 23, 1:29 am, SteveMc wrote: > The other reply was correct; it's a character encoding issue. Take a > look athttp://www.postgresql.org/docs/8.3/static/multibyte.html- I > suspect you will need

Re: order_with_respect_to fail any workaround ?

2008-12-23 Thread Thierry Stiegler
I answer django developpers (http://groups.google.com/group/django- developers/t/280bca5001faca07) so wait and see. On 6 déc, 09:34, Thierry Stiegler wrote: > Hello, > > I got some errors by using the Meta optionsorder_with_respect_to: > > class

Serving Static Pages with Dev server.

2008-12-23 Thread tom.s.macken...@gmail.com
Hello, I am having some trouble serving static files with the development server. I have read the docs and various blogs out there and nothing seems to work. I am going nuts over this :) I have tried tweaking the values in my settings.py but I reverted them back to their defaults. Below is the

Re: Serving Static Pages with Dev server.

2008-12-23 Thread tom.s.macken...@gmail.com
Sorry... ADMIN_MEDIA_PREFIX=/media/admin/ On Dec 23, 9:38 am, "tom.s.macken...@gmail.com" wrote: > Hello, > > I am having some trouble serving static files with the development > server. I have read the docs and various blogs out there and nothing > seems to work. I

Re: Serving Static Pages with Dev server.

2008-12-23 Thread Rajesh Dhawan
On Dec 23, 10:38 am, "tom.s.macken...@gmail.com" wrote: > Hello, > > I am having some trouble serving static files with the development > server. I have read the docs and various blogs out there and nothing > seems to work. I am going nuts over this :) I have tried

Re: Customizing ModelForm fields appearance

2008-12-23 Thread Rajesh Dhawan
sagi s wrote: > I really like the concept of generating a form from a model using > ModelForm but would like to customize the apprearance slightly (e.g. > size of the TextInput etc.). > > Any suggestion as to how to do this? A standard way to do this is via CSS. When you render your form in your

Re: Dynamic age count

2008-12-23 Thread Rajesh Dhawan
On Dec 23, 9:53 am, Alfonso wrote: > Hi, > > Trying to implement a very simple template tag that will output a > company's age. So idea being if company was established in 1860 then > it should output '148 years old' if my math is right ;-) > > this is what I've got:

Slowness on a Mac with 10.5.6

2008-12-23 Thread bmclaughlin
Hello, I am having slowness issues with my local set-up. My system was 10.4.x when django was set up and everything was fine. I upgraded to 1.5.6 (went from a 10.5.4 install disc to 10.5.6 via updates). After the update my local django is very slow. It seems to struggle with serving up the css

Re: Serving Static Pages with Dev server.

2008-12-23 Thread tom.s.macken...@gmail.com
Thanks Rajesh! it works! On Dec 23, 10:47 am, Rajesh Dhawan wrote: > On Dec 23, 10:38 am, "tom.s.macken...@gmail.com" > > > > wrote: > > Hello, > > > I am having some trouble serving static files with the development > > server. I have read

Re: MultiValueDictKeyError when accessing POST items

2008-12-23 Thread DragonSlayre
Cheers :) Damn, I must have been a bit tired coding that up lol Here's my working code (incase anyone else is as stupid as me): Login: Username: Password: On Dec 23, 4:23 pm, Malcolm Tredinnick wrote: > On Mon, 2008-12-22 at 19:03 -0800,

Re: Customizing ModelForm fields appearance

2008-12-23 Thread sergioh
You can always add your own custom fields, by default they override the default fields that becomes with the modelform, and there is an optional parameter "attributes", which is used to add css class to your fields. On Dec 23, 9:47 am, sagi s wrote: > I really like the concept

How to set defaults['empty_permitted'] = False in a BaseFormSet

2008-12-23 Thread sergioh
Hi, I would like to find a straightforward way to get the defaults ['empty_permitted'] = False in a BaseFormSet to True, which means that all forms in a formset should be not empty by default. Thanks in advance, Sergio Hinojosa --~--~-~--~~~---~--~~ You received

Re: Problem with url tag

2008-12-23 Thread patrick91
Almost resolved :) I tried everything to find the error and finally I did, but I don't know how to resolve :( the error is casued by this line in a imported script: CITY_URL = reverse('get_city_list') if I remove that line the project works fine, but I need that line :( Ps. the url

saving unicode data in file

2008-12-23 Thread Matias Surdi
Hi, I'm trying to save on a FileField some generated data (a text file obtained from a template): The relevant code is: out = Template(open("/path/to/template").read()) context = Context({}) if request.POST["name"] != "": name =

dynamically instantiate a model at run time

2008-12-23 Thread dick...@gmail.com
i'm trying to do some instantiation of models, based on run time parameters. i'm new to django/python so not sure the term, but the relative java term is reflection. for example, if i have a model, in my django models.py: class Foo(models.Model): name = models.CharField(max_length=20) now

xml -> django model

2008-12-23 Thread dick...@gmail.com
i'm working on a simple concept i'm sure others have solved, but i can't get it. basically, given some input, i parse it, find which objects to create, and do it. so with a model: class Foo(models.Model): name = models.CharField(max_length=20) and input xml of bar my view would parse

Re: xml -> django model

2008-12-23 Thread Colin Bean
On Tue, Dec 23, 2008 at 12:11 PM, dick...@gmail.com wrote: > > i'm working on a simple concept i'm sure others have solved, but i > can't get it. > > basically, given some input, i parse it, find which objects to > create, and do it. > > so with a model: > > class

Re: xml -> django model

2008-12-23 Thread dick...@gmail.com
yeah, but that's hardcoding in the "Foo" and "name" value, where they may be dynamic. Ie, imagine the xml is today would require the python code to instantiate a Bar(date="today") class. > Does this work? > > from myproject.test.models import Foo > f = Foo(name="bar") > f.save() > > Colin

Re: xml -> django model

2008-12-23 Thread Daniel Roseman
On Dec 23, 8:11 pm, "dick...@gmail.com" wrote: > i'm working on a simple concept i'm sure others have solved, but i > can't get it. > > basically, given some input, i parse it, find which objects to > create, and do it. > > so with a model: > > class Foo(models.Model): >      

Re: a clean_tarfile() for my form

2008-12-23 Thread Alan
Hi, Thanks for the hint, however, they only applies to tar archive file (give by path) and not to 'file objects' as you get from "file = self.cleaned_data['file']" in django models. More specifically, how to make class tarfile to handle django.core.files.uploadedfile.InMemoryUploadedFile objects.

django deserialize and save new model object from xml

2008-12-23 Thread dick...@gmail.com
looking at the serialization serializers, is is possible to save "new" instance of a model object represented in xml? i'm getting an error: node is missing the 'pk' attribute, but basically, there isn't one, because i don't want the object retrieved from the db, i want to instantiate it from

Re: xml -> django model

2008-12-23 Thread dick...@gmail.com
thanks DR! yeah, i'm just learning python, and was fuzzy on the object model stuff. works perfect. On Dec 23, 1:09 pm, Daniel Roseman wrote: > On Dec 23, 8:11 pm, "dick...@gmail.com" wrote: > > > > > i'm working on a simple concept i'm sure

Re: dynamically instantiate a model at run time

2008-12-23 Thread bruno desthuilliers
On 23 déc, 20:23, "dick...@gmail.com" wrote: > i'm trying to do some instantiation of models, based on run time > parameters. i'm new to django/python so not sure the term, but the > relative java term is reflection. The term in Python is... well, it isn't. With a dynamic