Re: Save Handlers and a newbie to Django

2010-10-15 Thread Blue Cuenca
 On 10/15/2010 9:01 PM, Devin M wrote:
> Hello everyone,
> I am writing a save handler in my models.py file to run a few
> actions after a save. to do this I have a function called make_photos
> and a connection to the post_save signal.
> Here is my code:
>
> 
> The only problem i have with this code is that it runs every save. So
> it creates a infinite loop of sorts and I dont know how to make it
> perform this action once. Is there another signal I should use? Any
> ideas?
>
> Regards,
> Devin M
>
You may want to look at this:
http://snipt.net/danfreak/generate-thumbnails-in-django-with-pil/

The snippet above overrides the save method.  Before calling the actual
save (super), the thumbnail fields is dynamically created (using PIL). 
I am sure you can add code that will do the same thing for your "large"
photo field.


regards,
Blue C

-- 
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: sorl thumbnail

2011-06-10 Thread Blue Cuenca
Is your cache, readable and writable to other groups/users as well?

On 6/11/2011 1:11 AM, Greg Donald wrote:
> On Fri, Jun 10, 2011 at 11:59 AM, Greg Donald  wrote:
>>  File "/usr/local/lib/python2.6/dist-packages/PIL/ImageFile.py", line
>> 52, in raise_ioerror
>>   raise IOError(message + " when reading image file")
>>
>> IOError: broken data stream when reading image file
> 
> 
> And then more baffling is the fact that it works using `manage.py shell`
> 
> 
> In [1]: from sorl.thumbnail import get_thumbnail
> 
> In [2]: im = 
> get_thumbnail('/myproject/static/images/user_profiles/1/11-20-2010-2_5.jpg',
> '32x32', crop='center' )
> 
> In [3]: im
> Out[3]: 
> 
> In [4]: im.url
> Out[4]: 'http://example.com/cache/ff/31/ff318b4a995ff345d1d48e79b67ec62b.jpg'
> 
> It made the thumbnail, just won't make one via the template code.
> 
> 
> 


-- 
Your eyes are weary from staring at the CRT. You feel sleepy.  Notice
how restful it is to watch the cursor blink. Close your eyes. The
opinions stated above are yours. You cannot imagine why you ever felt
otherwise.

-- 
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: Help getting started.....I think it is installed correctly

2011-01-01 Thread Blue Cuenca
/home/mycode or /home is a linux location.  Apparently, you are using
windows.

I would suggest creating a folder for all your django projects, say
C:\DjangoProjects\ , and run django-admin.py from there.

You do not want to put your django project folder in your www folder,
since that may allow access to the sources themselves, instead of
running them to create the html.


On 1/2/2011 12:14 AM, Anthony Pearce wrote:
> Quote from "Writing your first Django app, part 1":
> 
>>From the command line, cd into a directory where you’d like to store
> your code, then run the command django-admin.py startproject mysite.
> This will create a mysite directory in your current directory.
> 
> Put your code in some directory outside of the document root, such as /
> home/mycode.
> 
> 
> OK, please explain where /hom/mycode should be located.  Is it
> directly on the C:, or like I have a www folder for playing with html,
> or within the Python directory somewhere?   Sorry, but I'm looking at
> this again for the first time in over a year, and need a bump start.
> 

-- 
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.