No exception when there's problems with CACHE_BACKEND?

2010-08-12 Thread julianb
Hi,

I just discovered that my memcached deamon died and apparently Django
does not throw exceptions when something is wrong with the cache
backend. Is that correct and should it be that way?

Not even with DEBUG=True there's any information if my cache is
working or if I e.g. just made a typo in the CACHE_BACKEND URL so it's
not even possible to connect to memcached in any way.

Julian

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django beta slower with some queries?

2009-04-28 Thread julianb

On Apr 27, 10:41 pm, Malcolm Tredinnick 
wrote:
> > Reading the part "Performance considerations" got me in the right
> > direction but didn't help me very well, because if you do it like
> > that, it will still do a subselect.
>
> That's a documentation bug. There should be a list() call wrapped around
> the rhs of the first line in the fragment in "Performance
> considerations". If you open a ticket for that, we'll fix it.

I'll do that. Thanks Malcolm!
--~--~-~--~~~---~--~~
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 this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django beta slower with some queries?

2009-04-27 Thread julianb

On Apr 24, 6:05 pm, Karen Tracey  wrote:
> I'd start by using a couple of Python shells (one using 1.0.2 and one using
> 1.1 beta) and connection.queries to see if you can see the difference in SQL
> generated for whatever model queries your view is using:
>
> http://docs.djangoproject.com/en/dev/faq/models/
>
> Karen

Hi Karen,

I wouldn't have written the post if I had not already done that. At
least so I thought. Comparing the resulting queries once more, I found
the difference. Django is using subselects now.
http://docs.djangoproject.com/en/dev/ref/models/querysets/#in

In my code, I just used a queryset as parameter for __in and in
previous Django versions it would evaluate to a list of numbers
whereas now it does a subselect. I don't think that's very backwards
compatible.

Reading the part "Performance considerations" got me in the right
direction but didn't help me very well, because if you do it like
that, it will still do a subselect. I had to explicitly rewrite the
ValuesListQuerySet to a list to really get a list of IDs into my
query. Looks like a bug, but I'm too busy to confirm that right now.

Julian
--~--~-~--~~~---~--~~
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 this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django beta slower with some queries?

2009-04-24 Thread julianb

Hi,

I have used Django 1.0.2 but moved to beta, because I badly needed
some new features. I want to "report" that I found some queries to
take considerably longer, while not having changed anything in the
code at all. I talk about a rather simple query, but one which
involves some joins with tables containing > 1 million rows. On the
"old" Django version everything was running absolutely smoothly.
However, once I switch to a later Django revision, the specific page
with it's queries comes to halt. It's like someone hit the brakes.
Whithin minutes the site is not usable at all and MySQL is still busy
with the initial queries. Just switching Django back to old makes
everything run fine again.
I'm using MySQL and with the latest version the queries take seconds
and are displayed in the processlist as being prepared, sorted, sent
and so on while on the old version it was running whithin miliseconds
as I sad.
Now, I don't know where I should start looking for something going
wrong, or if any db conenction/MySQL/ORM things have been changed
lately. I appreciate any help in solving this. Something that
definitely worked should get working again with the latest Django,
too. Thanks!
--~--~-~--~~~---~--~~
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 this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Comma instead of dot in FloatField

2009-04-17 Thread julianb

On Apr 17, 9:04 am, Knut Nesheim  wrote:
> Hi all,
>
> I have a model with several FloatFields. Based on this, ModelForm  
> creates some form.FloatFields.These fields require the user to type  
> '3.2' instead of '3,2', which is the custom here(Sweden). We need to  
> allow the comma somehow, for obvious usability reasons.
>
> My first thought was to write a custom clean method on the form, which  
> would do a string replace, but this isn't working. The FloatFields  
> clean method is run before any custom method. If there's a comma in  
> the field, that method will raise an exception and my custom method  
> never gets called.
>
> Any ideas for a solution would be welcome.

You can subclass a RegexField and return a float in clean.
--~--~-~--~~~---~--~~
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 this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: blank=True on Char/TextFields

2009-04-07 Thread julianb

On Feb 12, 5:35 pm, tow  wrote:
> class TextData(models.Model):
>      text = models.TextField(blank=True)
>
> obj = TextData()
> obj.text = None
> obj.save()
>
> gives me an IntegrityError. Why? I don't care that whether that's
> saved as a Null or an zero-length string, I just want Django to save
> back my data according to whatever convention it's using for this
> field - the docs tell me if I do blank=True, then it'll use an empty
> string and not bother distinguishing nulls; or at least so they imply
> to me. But apparently it is trying to distinguish nulls, because it's
> given me an IntegrityError. I was expecting Django to coerce the None
> to an empty string before saving.

The key to success here is using default="".
--~--~-~--~~~---~--~~
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 this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I use more than 24 hours in TimeField?

2008-12-01 Thread julianb

On Dec 1, 11:03 am, "K*K" <[EMAIL PROTECTED]> wrote:
> As you know time data type in mysql allow to be used more than 24
> hours, but when there is a more  than 24 hours record in the table
> such as 72:00:00, and then query the table with Django ORM, it will
> report 'ValueError hour must be in 0..23'.
>
> I'm porting a old program that record rum times of the machines to
> Django, so 24 hours is not enough for my new program.
>
> How can I resolve it ?

What you want is probably an integer field, to store the run time in
seconds.
A TimeField is for the time of the day, so that's why the hour can't
be larger than 23.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django site speed - I think I have a problem with my config!

2008-10-03 Thread julianb

On Oct 3, 10:08 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Is there anything really obvious that I may be missing? Any debug
> settings I may have forgotten to turn off? I've set
> MaxRequestsPerChild to 10 so I don't think that it's that.
> PythonDebug is off in httpd.conf.

Did you try setting it to e.g. 500?
My site behaves slow with higher values, dunno why.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: form get with special characters

2008-09-21 Thread julianb

On Sep 21, 4:01 pm, "Alessandro Ronchi" <[EMAIL PROTECTED]>
wrote:
> It seems now It works, becausehttp://www.animalisenzacasa.org/ricerca/?s=forlì
> is converted to:http://www.animalisenzacasa.org/ricerca/?s=forl%C3%AC
>
> I don't know what's changed, because this morning the result was an
> empty page (with source code white, and a correct http header).

I once discovered that you will get a blank page if a string like
"forlì" is not first encoded to UTF-8 and then percent-encoded by the
browser, but just percent-encoded from e.g. latin-1 directly... maybe
that's the problem here, could happen with older browsers.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to prevent URL HTML encoding?

2008-09-12 Thread julianb

A '+' doesn't have to be encoded, but it should be if it has no
special meaning, maybe that's the problem here.
http://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters

Why does APPEND_SLASH even percent-encode?
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to cache form request in Django?

2008-09-12 Thread julianb

On Sep 12, 4:17 pm, Ross <[EMAIL PROTECTED]> wrote:
> If you create restful URLs that your forms forward to, the restful
> URLs could be cached. (I'm not sure if restful is the real term, but
> that's what I've heard them called.) Instead of your form directing to
>
> /url?param=search=baseball=sosa
>
> have a view accept POSTs and return HttpResponseRedirect to /search/
> baseball/sosa.

You cannot just change from POST to GET, that is bad advice. GET and
POST are used for a reason. If you have a search feature for example
it would be correct to use GET parameters, not making restful URLs or
redirecting stuff. But in that case, the response is not getting
cached, that's true.
I'd recommend not using the per-site cache, but rather try working
with template cache tags.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to prevent URL HTML encoding?

2008-09-12 Thread julianb

On Sep 12, 4:22 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
>
> http://docs.djangoproject.com/en/dev/topics/templates/#id2

HTML escaping doesn't make %2B out of '+'...
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Field type for 13 digit positive integer?

2008-09-03 Thread julianb

On Sep 2, 10:00 pm, coan <[EMAIL PROTECTED]> wrote:
> For now I was planning to store ISBN13 and 13 digit ean codes.
>
> In mysql a bigint field would hold these, but I see no corresponing
> fieldtypes in django for bigints -
> the positiveintegerfield sets itself up as an int(10) signed field
> type in mysql. -

I use bigint(13) usigned in MySQL and positiveintegerfield in Django.
You have to change it manually in the db after the tables got created.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Image thumbnail and save

2008-08-31 Thread julianb

On Aug 31, 6:45 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Can someone please point me in the right direction

I got problems after the refactoring, too:

http://groups.google.com/group/django-users/browse_thread/thread/230a8601a4839bd9/b707f7fe40e03537#b707f7fe40e03537
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using File storage

2008-08-28 Thread julianb

On Aug 28, 8:53 pm, julianb <[EMAIL PROTECTED]> wrote:
> I tried several things, I think Marty's solution was among them. It
> did not throw errors, but the file I got was 0 bytes. I will try again
> and check if I made a mistake or so...

Okay, I solved the puzzle. The following works:

big = StringIO.StringIO() # you have a StringIO
...
image.save(big, "JPEG", quality=70) # write something to the StringIO
...
# Photo is a model that has an image field
photo = Photo(user=creator)
# use getvalue because ContentFile just needs content
big_file = ContentFile(big.getvalue())
# use save method of image field, no other function!
photo.data.save("%s.jpg" % name, big_file)
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using File storage

2008-08-28 Thread julianb

On Aug 28, 8:44 pm, "Tim Kersten" <[EMAIL PROTECTED]> wrote:
> This should fix the error you got:
>
> import StringIO
> from django.core.files import File
> f = StringIO.StringIO()
> f.name, f.mode = 'data.xml', 'r'
> f.write(data)
> myfile = File(f)
> Chart.objects.create(xml=default_storage.save(f.name, myfile))
>
> However, Marty's solution seems a lot nicer. Did that not work? I've
> never done anything like what I've shown you - it was more or less a
> straight guess as to how it might work. Marty's solution looks a lot
> more correct and a lot cleaner too. Perhaps you should be trying to
> make that work instead?

AttributeError: StringIO instance has no attribute 'name'

I tried several things, I think Marty's solution was among them. It
did not throw errors, but the file I got was 0 bytes. I will try again
and check if I made a mistake or so...
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: using File storage

2008-08-28 Thread julianb

On Aug 28, 6:03 pm, "Tim Kersten" <[EMAIL PROTECTED]> wrote:
> There's probably a better way than this though so you might want to
> wait for other replies.
>
> import StringIO
> from django.core.files import File
> f = StringIO.StringIO()
> f.write(data)
> myfile = File(f)
> Chart.objects.create(xml=default_storage.save('data.xml', myfile))

That's not working for me, I get AttributeError: StringIO instance has
no attribute 'name'...
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Form validation

2008-08-25 Thread julianb

On Aug 23, 11:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> This seems to have done the trick. Thanks for your help.
>
> def index(request):
>     if request.method == 'POST':
>         form = pasteForm(request.POST)
>         if form.is_valid():
>             name = form.cleaned_data['name']
>             log = form.cleaned_data['log']
>             return HttpResponseRedirect('/success/')
>         else:
>             return render_to_response('pastebin.html', {'form': form})
>     else:
>         form = pasteForm()
>         return render_to_response('pastebin.html', {'form': form})

Why not

def index(request):
if request.method == 'POST':
form = pasteForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
log = form.cleaned_data['log']
return HttpResponseRedirect('/success/')
else:
form = pasteForm()
return render_to_response('pastebin.html', {'form': form})

like in the docs?
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using CheckboxSelectMultiple with a many to many relationship.

2008-08-22 Thread julianb

On Aug 22, 4:32 pm, acreek <[EMAIL PROTECTED]> wrote:
> I just have not figured out the correct way to pass along the coupons
> that are a part of the Flyer model. Can anyone give me a hint on how
> to go about this properly?

Here's how I'd do it:
http://dpaste.com/hold/73229/

Now you just have initialize OrderForm with the flyer_id.

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Save raw data to an ImageField?

2008-08-22 Thread julianb

On Aug 22, 2:54 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> If, however, you mean that the file is already a StringIO, rather than
> a file, and you'd like to save it to a file, I hope to have a fix up
> for that this weekend. It's possible right now, but it's not very
> easy, much less pretty.

Yes, I "generate" new files/images that are StringIOs and I want them
in my ImageFields. Saving them in temporary files just to insert them
in the ImageFields would be bad. Cool that you are working on that.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Slash appended for URLs ending in .html?

2008-08-22 Thread julianb

On Aug 22, 12:55 pm, janedenone <[EMAIL PROTECTED]> wrote:
> Which version of Django do you use?

Using trunk, 8129 to be exactly.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Save raw data to an ImageField?

2008-08-22 Thread julianb

On Aug 14, 1:31 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote:
> You'll want to skip StringIO now, because Django provides its own
> file-like object you can use directly. When you want to save the file,
> you can open up a new File and just use that instead.
>
> from django.core.files.storage import default_storage
>
> file = default_storage.open('path/to/file', 'wb')
> pil_image.save(file, format='png')

What if the file never has a path and exists just as StringIO? I can't
seem to get it to be a "Django file"...
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Field with RadioSelect widget instead of Select widget

2008-08-22 Thread julianb

On Aug 21, 7:30 pm, Bela Hausmann <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I'd like to use the RadioSelect widget for some of my model fields with
> choices. But django always uses Select and if I change it manually in the form
> class, than I have to specify the choices again and if it's optional or not.
> So thats not very DRY?!
>
> Anyway to do this the right way?

Maybe you can change the widget after the form got declared:

form = BlaForm()
form.fields['field'].widget = forms.RadioSelect()

But I'm not quite sure what it does with the "--" line you have in
a Select field.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Slash appended for URLs ending in .html?

2008-08-22 Thread julianb

> It's not a bug. If you want URLs that end in .html you have to turn
> APPEND_SLASH off.

This can't be true. I have APPEND_SLASH set to default (=True) and it
works with URLs ending in .htm, so there has to be something wrong
with Jan's URL configuration.
--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---