Re: Scaling Thumbnails instead of Cropping or Squashing.

2009-08-23 Thread Mike Ramirez
On Sunday 23 August 2009 06:48:33 pm The Danny Bos wrote: > Hey, so I've got this code to quickly create thumbnail files, below. > When I give it a value, it squishes the image to those dimensions, I'm > hoping to keep the correct proportions of a book instead of cropping > to a square or

Scaling Thumbnails instead of Cropping or Squashing.

2009-08-23 Thread The Danny Bos
Hey, so I've got this code to quickly create thumbnail files, below. When I give it a value, it squishes the image to those dimensions, I'm hoping to keep the correct proportions of a book instead of cropping to a square or squashing. Mainly as books can be portrait, landscape or square. So keep

Re: Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos
Much nicer. Thanks so much Mike ... d On Aug 24, 12:17 pm, Mike Ramirez wrote: > On Sunday 23 August 2009 05:36:13 pm The Danny Bos wrote: > > > > > > > Hey there, I've got the below code. > > Can someone help me fill in the gaps to rename the image to the > > 'SLUG'? >

Re: Renaming an image to the SLUG after upload

2009-08-23 Thread Mike Ramirez
On Sunday 23 August 2009 05:36:13 pm The Danny Bos wrote: > Hey there, I've got the below code. > Can someone help me fill in the gaps to rename the image to the > 'SLUG'? > > In the end I'm hoping for images like so: > > ...com/books/book-title.jpg > ...com/books/thumbs/book-title.jpg > >

Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Andrea Zilio
And what about doing the same way the Comment application (bundled with Django) works? I think that looking the way Comment app works could inspire you On Aug 24, 12:39 am, Richard Marko wrote: > Simple approach for this is to use try catch block to create proper > field like

Re: Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos
Worked this one out. For anyone interested ... def save(self): super(Book, self).save() file_ext = os.path.splitext(str(self.cover.name))[1] new_filename = '%s%s' % (self.slug, file_ext) new_filepath = os.path.join(settings.MEDIA_ROOT, new_filename)

Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos
Hey there, I've got the below code. Can someone help me fill in the gaps to rename the image to the 'SLUG'? In the end I'm hoping for images like so: ...com/books/book-title.jpg ...com/books/thumbs/book-title.jpg Here's my save() definition from models.py: def save(self):

Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Richard Marko
Simple approach for this is to use try catch block to create proper field like this: from django.db import models try: from photos.models import Photo photo_field = models.ManyToManyField(Photo) except ImportError: photo_field = None class Standalone(models.Model):

request.FILES empty... only with IE!

2009-08-23 Thread OnurCelebi
Hi all, I have a very strange behaviour. I have an upload form like this: var upform = document.createElement('form'); upform.setAttribute('action','/engine/users/avatar/'); upform.setAttribute('enctype','multipart/form-data'); upform.setAttribute('method','post'); created dynamically with JS.

saving M2M with through table behavior change - (r.10189 vs. r.10190)

2009-08-23 Thread David Haas
Hi: Yet again, I've run into a behavior change which seems to be linked to svn revision 10190. I've figured out a workaround for my code, but I'm wondering if someone could provide some feedback if the change is just a definition of previously undefined behavior, or a bug. I've pasted some

multi-tenant website

2009-08-23 Thread Fernando
Is there a Django app that helps with handling multitenancy, that is, having a single website and a single database serving multiple organizations in a software-as-a-service fashion while avoiding one tenant to interact with another's data? I'm talking about the "Shared database, shared schema"

Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Joshua Russo
You need to remove the references on one side or the other. You need to make a choice. will events manage photos, or will photos manage events, and so on. Then if events manage photos, you need to remove all references to events from the photos app. It sounds like it will take some reworking of

Re: Image Location

2009-08-23 Thread When ideas fail
Seems to be working now. Thanks. On 23 Aug, 18:28, When ideas fail wrote: > I changed it to post_img.url but i assume thats a different way of > doing the same thing. > > 1.The html source gives the image location as "http://www.mysite.net/ >

Re: Appeding entire table to a backup table

2009-08-23 Thread Tim Chase
> The raw SQL is something along the lines of "INSERT INTO backup SELECT > * FROM today; DELETE FROM today;". > > Is there a Django way of doing this? I would required something > similiar to this: > todays_records = Today.objects.all() > for record in todays_records: >

Re: Best practice on data security .. on record, table (model) db or url

2009-08-23 Thread Gerard
I did find a nice sidewide middleware login system which takes care of one aspect of my 'problem'. http://www.djangosnippets.org/snippets/1158/ Not completely to my taste, because it (me?) requires some css file in PUBLIC_URLS. Figured I'd start on the manual @login_required for now to get

Re: Custom field types and newforms admin

2009-08-23 Thread Hanpan
Hi, thanks for the reply. ImageWithThumbsField is custom field which extends ImageField. It creates a thumbnail. I am using it in my model definition, nothing to do with a form. syncdb is ignoring this field when it creates the table completely. On 23 Aug, 18:39, Daniel Roseman

Re: Test client following redirects despite follow=False?

2009-08-23 Thread Karen Tracey
On Thu, Aug 20, 2009 at 2:19 PM, ringemup wrote: > > I'm running the test listed below, and the test client is submitting a > request to /test2/ despite the follow=False parameter in > self.client.get() -- am I doing something stupid? > >def

Re: Custom field types and newforms admin

2009-08-23 Thread Hanpan
Hi, thanks for the reply. ImageWithThumbsField is custom field which extends ImageField. It creates a thumbnail. I am using it in my model definition, nothing to do with a form. syncdb is ignoring this field when it creates the table completely. On 23 Aug, 18:39, Daniel Roseman

Appeding entire table to a backup table

2009-08-23 Thread xocekim
Hello, I have a MySQL table that gets cleared in the morning, populated during the day, appended onto a backup table and the contents then deleted. The raw SQL is something along the lines of "INSERT INTO backup SELECT * FROM today; DELETE FROM today;". Is there a Django way of doing this? I

Re: Custom field types and newforms admin

2009-08-23 Thread Daniel Roseman
On Aug 23, 3:44 pm, Hanpan wrote: > Hi, > > I have created a custom field type, which I am using like so: > > image_thumb = ImageWithThumbsField(_('preview image'), > upload_to='uploads/projects') > > But for some reason, when I run syncdb this custom field is being >

Re: Image Location

2009-08-23 Thread When ideas fail
I changed it to post_img.url but i assume thats a different way of doing the same thing. 1.The html source gives the image location as "http://www.mysite.net/ content/imgs/newMessage.jpg" 2. I am using a RequestContext. Its an apache server and these are the related directives: SetHandler

Re: Image Location

2009-08-23 Thread When ideas fail
I changed it to post_img.url but i assume thats a different way of doing the same thing. 1.The html source gives the image location as "http://www.mysite.net/ content/imgs/newMessage.jpg" 2. I am using a RequestContext. Its an apache server and these are the related directives: SetHandler

Re: Image Location

2009-08-23 Thread J. Cliff Dyer
On Sun, 2009-08-23 at 06:54 -0700, When ideas fail wrote: > Hello, i'm having a problem getting images to display so I was > wondering if someone would be kind enough to help? > > I have my settings.py set up as follows (content is the folder where > my static images are stored): > > MEDIA_ROOT

Re: Complex query in model manager

2009-08-23 Thread CrabbyPete
or another words can I use a Q object in a model manager? On Aug 23, 12:05 am, CrabbyPete wrote: > I have the following code in model manager > > class SpotMessageManager(models.Manager): > >       def for_user(self, user, start = 0, end = None, friends ): >            

Custom field types and newforms admin

2009-08-23 Thread Hanpan
Hi, I have created a custom field type, which I am using like so: image_thumb = ImageWithThumbsField(_('preview image'), upload_to='uploads/projects') But for some reason, when I run syncdb this custom field is being completely ignored. I tried using the 'widget' argument, but that caused an

Re: Image Location

2009-08-23 Thread Matthias Kestenholz
On Sun, Aug 23, 2009 at 3:54 PM, When ideas fail wrote: > > Hello, i'm having a problem getting images to display so I was > wondering if someone would be kind enough to help? > > I have my settings.py set up as follows (content is the folder where > my static images

Image Location

2009-08-23 Thread When ideas fail
Hello, i'm having a problem getting images to display so I was wondering if someone would be kind enough to help? I have my settings.py set up as follows (content is the folder where my static images are stored): MEDIA_ROOT = '/home/mysite/content/' MEDIA_URL = 'http://www.mysites.net/content/'

Re: Dates with varying specificity?

2009-08-23 Thread Doug Blank
On Sat, Aug 22, 2009 at 12:24 PM, ringemup wrote: > > Has anyone here ever written an application that needed to be able to > take a date field where the month or day was sometimes but not always > known? How would you handle this? Using separate day/month/year > fields

Re: TypeError: execute() takes at most 3 arguments (4 given)

2009-08-23 Thread Bryan
Daniel is right on. And for future reference, it says "3 arguments" which may seem misleading, but keep in mind that the cursor object itself is the first argument. On Aug 22, 4:14 pm, kevin wrote: > cursor.execute("SELECT a,b,c FROM Table_Name WHERE a = %s AND b = %s

Re: Permissions issue with image uploads

2009-08-23 Thread Ramdas S
chowning www-data will work. Make sure the directory has chown -R and chmod -R, suppose you are uploading to media/images chown -R www-data media/images chmod -R 777 media/images On Sun, Aug 23, 2009 at 11:17 AM, Anogar wrote: > > I'm trying to implement a simple image

Permissions issue with image uploads

2009-08-23 Thread Anogar
I'm trying to implement a simple image upload inside my blog, and I had it working on my local machine, but when I deployed it threw this error: OSError at /path/ (13, 'Permission denied') So, it's clearly a permissions issue - but I can't quite figure out how to fix it. Just to confirm my

Re: Reusable/plugable apps integrations best practices

2009-08-23 Thread Andrea Zilio
I'm intrested in the answer too On Aug 23, 1:36 am, "Chris H." wrote: > So I'm trying to get my head around making my small, tightly focused > apps reusable.  I've done this, but right now still have > "dependencies" between one another, that I'd like to remove.  For

Re: TypeError: execute() takes at most 3 arguments (4 given)

2009-08-23 Thread Daniel Roseman
On Aug 22, 9:14 pm, kevin wrote: > cursor.execute("SELECT a,b,c FROM Table_Name WHERE a = %s AND b = %s ", > [string1],[string2]) > > gives me the following error: > > TypeError: execute() takes at most 3 arguments (4 given) > > Where did i go wrong? You have got

Re: Django ORM and Google Gears (or alternatives?)

2009-08-23 Thread Russell Keith-Magee
On Sun, Aug 23, 2009 at 11:23 AM, Victor Hooi wrote: > > heya, > > I've got a small project involving an ordering system web application. > One of the requirements is offline functionality (i.e. it will > function without a direct internet connection, at least on a limited >