Creating an object with a FileField programmatically

2009-04-14 Thread Vincent Foley
Hello, I want to be able to add files inside a model to test that model. However, I'm unable to find in the documentation any mention on how to do so. I asked on IRC and somebody suggested the following: from django.core.files import File from myproject.myapp.models import MyModel fd =

What happened to the template engine in SVN?

2008-03-26 Thread Vincent Foley
Hello, I have been looking at the Jinja templating engine lately to be used in our web sites. Their web site claims that it is in average three times faster than Django's templating engine. I decided to see that for myself by designing a few, simple test cases. The biggest surprise came not

ManyToMany fields in database lookups

2008-03-04 Thread Vincent Foley
Hello, I have a curious problem with a complex filter in 0.96: Merchant.objects.filter(Q(categories_fr__name__icontains=s) | Q(categories_en__name__icontains=s)) this returns an empty queryset even when 's' is in categories_fr. Changing categories_fr__name with an attribute directly in the

Re: Float Field not displaying the two zeros at the end of a price

2007-08-19 Thread Vincent Foley
{{ price|floatformat:2 }} On Aug 19, 4:44 pm, Greg <[EMAIL PROTECTED]> wrote: > I have a FloatField called price that stores the price of different > elements. When the price is 19.99, 19.79, 19.01 etc... everything is > displayed correctly. However, when I have a price of 19.00. The > price

Generalizing media files URLs

2007-08-14 Thread Vincent Foley
Hello, My coworker and I have a sizable Django project called Gestio. We're pretty much done writing it, so now we're making sure that it'll work without hitches wherever we may install it. Thanks to the {% url %} tag, we can choose to place the application under /, /gestio, /webapps/ gestio

Re: Multilingual site best practices

2007-08-10 Thread Vincent Foley
There's django-multilingual for that. On Aug 10, 1:05 pm, Grupo Django <[EMAIL PROTECTED]> wrote: > Vincent Foley ha escrito: > > > > > Hello, > > > I work for a company who develops web sites and web applications for > > clients in Quebec

Re: Presentations about Django?

2007-08-10 Thread Vincent Foley
Has your "Django Master Class" at OSCON 07 been taped? Vincent On Aug 10, 11:12 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]> wrote: > On 8/10/07, Brian Rosner <[EMAIL PROTECTED]> wrote: > > > I saw the video of you presenting Django to Google at one of their Tech > > Talks and I am not sure if I

Multilingual site best practices

2007-08-10 Thread Vincent Foley
Hello, I work for a company who develops web sites and web applications for clients in Quebec. People in Quebec mainly speak french, but there are english speaking people too. Most sites we make eventually want to have a french and english version with french being the "main" version. I would

SQLite + float vs MySQL + Decimal

2007-08-09 Thread Vincent Foley
Hello, I found a curious problem in my application when I put it into production this week: when a models.FloatField is "extracted" from the database, its type changes depending on the database. With SQLite in development, I got back floats, while on MySQL in production I have decimals. As

Re: Will Django.core.validators remain stable

2007-08-08 Thread Vincent Foley
Use validators in newforms. class MyForm(newforms.Form): secret_phrase = newforms.CharField(label='Secret phrase', required=True) def clean_secret_phrase(self): if self.cleaned_data.get('secret_phrase') == 'xyzzy': return True else: raise

Re: Object list generic view + list

2007-07-12 Thread Vincent Foley
My problem is that I need to sort on a field in a another table. I found a workaround: File.objects.select_related().filter(...).order_by('app_table.column') It works for me because the foreign key cannot be NULL. Vincent. On Jul 11, 6:27 pm, Drasty <[EMAIL PROTECTED]> wrote: > Have you

Re: Hard-coded sting in IFEQUAL

2007-07-10 Thread Vincent Foley
It works fine with me: >>> from django.template import Template, Context >>> t = Template('''{% ifequal s "Some Thing" %}Equal{% else %}Not equal{% >>> endifequal %}''') >>> t.render(Context({'s': 'foo'})) 'Not equal' >>> t.render(Context({'s': 'Some Thing'})) 'Equal' What version of Django

Re: Developing without tempplates

2007-06-18 Thread Vincent Foley
There's more than one way to do it (with apologies if you don't like Perl). One thing I like to use is IPython which allows you to start a Python interpreter from any point in your code with the entire context. So to test a function, you could add the following lines at the bottom of the