Re: Saving File/Image in tmp. I'm in trouble ...

2010-07-13 Thread The Danny Bos
Good point re: if I can upload it to tmp, surely I can delete it. I'll give that another crack. Kenneth, It doesn't delete it from tmp by default in my case, which is why they're on my back. Turned out there were 40,000 files in there, they were a bit pissy. My script that saves it where I

Re: Saving File/Image in tmp. I'm in trouble ...

2010-07-13 Thread The Danny Bos
Yeh, understood. It's saving a copy of the file to the directory set by "upload_to", which is where I'm getting the file to push toward S3. But alongside this it seems to be storing a copy of the file in the servers '/tmp' directory, this is the step I need to skip or similar. I'm getting my ass

Re: Saving File/Image in tmp. I'm in trouble ...

2010-07-13 Thread The Danny Bos
I can't get access to the servers own tmp path, only my own "/home/ 72999/data/tmp" which the file isn't saving to. Madness. -- 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

Re: Saving File/Image in tmp. I'm in trouble ...

2010-07-13 Thread The Danny Bos
Forgot to mention, my files are all under 20k. Very small JPGs. Cheers, Danny -- 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

Saving File/Image in tmp. I'm in trouble ...

2010-07-13 Thread The Danny Bos
Hey there, Is there any way to skip saving a file to the /tmp directory on a server? I got in a lot of trouble from my host when they found 10,000 files just sitting there from a Django script I'd been running to import book covers from an API. So far, the guts of my save code are: Save the

Modify Content-Type to play MP3?

2010-04-17 Thread The Danny Bos
Heya, I'm trying to modify the content-type of a page to play an MP3. Basically, instead of pointing directly to an MP3, I'm pointing to a view in Django to add some stats to the database etc, after all that baloney is done, I want to go ahead and stream the track. Is there a way to do this, I

Re: GROUP results in views.py

2009-10-30 Thread The Danny Bos
Any ideas anyone? I'm completely stumped ... On Oct 30, 12:59 pm, The Danny Bos <danny...@gmail.com> wrote: > If helpful, here's the table structure. > > class ItemOwned(models.Model): >         user = models.ForeignKey(User) >         item = models.ForeignKey

Re: GROUP results in views.py

2009-10-29 Thread The Danny Bos
= models.CharField(max_length=50, unique=True) On Oct 30, 11:52 am, The Danny Bos <danny...@gmail.com> wrote: > Hey there, I've got the below query, generating the below JSON. But I > want to group them by "setId", can I do this in my query or in > views.py to create

GROUP results in views.py

2009-10-29 Thread The Danny Bos
Hey there, I've got the below query, generating the below JSON. But I want to group them by "setId", can I do this in my query or in views.py to create a JSON file like the one at the bottom? Regroup in a template would be great, but doesn't work in views ... views.py: items =

If search string contains a number ... Do this ...

2009-10-22 Thread The Danny Bos
Hey guys, In a view, is there a way to check if a search/querystring has a number in it? If number in string: do this otherwise: do this instead ... Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Inner Join perhaps?

2009-10-22 Thread The Danny Bos
Actually, that's no good as it craps out if there's no matching records in CollectionUser. Back to the drawing board ... Any better ideas? d - - - On Oct 22, 9:01 pm, The Danny Bos <danny...@gmail.com> wrote: > Hey there, I want to loop through all items in CollectionItem >

Re: Inner Join perhaps?

2009-10-22 Thread The Danny Bos
: %s - %s' % (item.title, useritems.grade) On Oct 22, 9:01 pm, The Danny Bos <danny...@gmail.com> wrote: > Hey there, I want to loop through all items in CollectionItem > (models.py below), build a list of the items, then get > CollectionUser.grade if that exists where (us

Inner Join perhaps?

2009-10-22 Thread The Danny Bos
Hey there, I want to loop through all items in CollectionItem (models.py below), build a list of the items, then get CollectionUser.grade if that exists where (user=request.user) and it's associated with the item in CollectionItem list. eg: "Item 1" - "" "Item 2" - "Grade = 89" "Item 3" - ""

Re: Django Admin: DateField (Year and Month) only

2009-10-19 Thread The Danny Bos
APologies for my naivety, how would I do that. Any examples you can point me toward? Thanks for the fast reply, d On Oct 20, 10:38 am, Joshua Russo <josh.r.ru...@gmail.com> wrote: > On Mon, Oct 19, 2009 at 10:28 PM, The Danny Bos <danny...@gmail.com> wrote:

Django Admin: DateField (Year and Month) only

2009-10-19 Thread The Danny Bos
Hiya, In the Django Admin for the DateField I only want to display the Year and Month as select lists. I'll default the day to the 1st every time. Is this possible? I want to keep the dates very simple, as I'll be adding many items from 1900 to now. So using the current DateField calendar in

Re: Data Looping with a Join? Perhaps ...

2009-10-19 Thread The Danny Bos
Will this display all CollectionTypes even if there is no record for a user in CollectionUserPile? As I'd want to set a default item if there isn't, but still loop through all Types. d On Oct 20, 1:35 am, Javier Guerra <jav...@guerrag.com> wrote: > On Mon, Oct 19, 2009 at 6:53 AM,

Data Looping with a Join? Perhaps ...

2009-10-19 Thread The Danny Bos
K, I've got one for ya. I've created a new table to handle Users latest "owned" item, how would I get this joined data up in my views.py where I'm currently just looping through CollectionTypes. Tables and current Query is below: models.py class CollectionType(models.Model): title =

Re: Paging, 0-50, 51-100, 101-132

2009-10-11 Thread The Danny Bos
': counter, 'end': counter_end, 'selected': selected}) counter += 50 counter_end += counter_end On Oct 11, 8:18 pm, Sam Lai <samuel@gmail.com> wrote: > 2009/10/11 The Danny Bos <danny...@gmail.com>: > > > > > I had a read of that, is good

Re: Paging, 0-50, 51-100, 101-132

2009-10-11 Thread The Danny Bos
, basically the record count "132". d On Oct 11, 7:41 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Oct 11, 9:22 am, The Danny Bos <danny...@gmail.com> wrote: > > > > > > > Heya, thanks for all the help of late, I'm about four late nights fr

Paging, 0-50, 51-100, 101-132

2009-10-11 Thread The Danny Bos
Heya, thanks for all the help of late, I'm about four late nights from finishing my first big app I'm guessing. Anyway, I'm working on paging in my app and am completely stuck (again), here's what I'm trying for: eg: http://www.domainname.com/card/pokemon/0-50/ Which would obviously

Re: Show first available Image in a loop

2009-10-10 Thread The Danny Bos
Good point. Here's the models I'm talking about as they're slightly different than your aforementioned solution. class Collection(models.Model): title = models.CharField(max_length=50, unique=True, help_text="eg: Pokemon, Kiss, Baseball ...") slug =

Re: Show first available Image in a loop

2009-10-09 Thread The Danny Bos
I had a feeling this was a pain in the ass. I might try and work out another way around it, maybe a default image for each 'trading card' set? d On Oct 9, 9:54 pm, The Danny Bos <danny...@gmail.com> wrote: > Hey there, > > I'm looping through an array of 'trading card' title

Show first available Image in a loop

2009-10-09 Thread The Danny Bos
Hey there, I'm looping through an array of 'trading card' titles. For instance: - Pokemon - Kiss - Baseball Instead of showing just the title of the 'trading card', I'd like to display an image of each instead. But not all images are available for every card in a title, for instance

Re: Scaling Thumbnails instead of Cropping or Squashing.

2009-08-24 Thread The Danny Bos
Thanks again Mike, this solved everything. d On Aug 24, 1:02 pm, Mike Ramirez <gufym...@gmail.com> wrote: > 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. > >

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 <gufym...@gmail.com> 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

Re: Renaming an image to the SLUG after upload

2009-08-23 Thread The Danny Bos
) old_filepath = os.path.join(settings.MEDIA_ROOT, self.cover.name) shutil.move(old_filepath, new_filepath) self.cover.name = os.path.join('p/', new_filename) super(Book, self).save() On Aug 24, 10:36 am, The Danny Bos <danny...@gmail.com> wrote: > Hey there,

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: Caught an exception while rendering: Error binding parameter 0 - probably unsupported type.

2009-07-27 Thread The Danny Bos
How did you solve it? I'm having the same issue. d On Jul 27, 12:09 pm, nixon66 wrote: > problem solved. Type > > On Jul 26, 10:05 pm, nixon66 wrote: > > > > > ran into this error. Anyone familiar with it. > > > TemplateSyntaxError at

Re: Cross Table Query. List Books based on Author.

2009-07-27 Thread The Danny Bos
, 4:13 pm, The Danny Bos <danny...@gmail.com> wrote: > > > > > > > Heya, > > > I'm currently displaying an 'Article' on a page, using the below. My > > tables are Article, People, Book. I'm in the 'Article' table, trying > > to get a list of 'Books' based on

Cross Table Query. List Books based on Author.

2009-07-27 Thread The Danny Bos
Heya, I'm currently displaying an 'Article' on a page, using the below. My tables are Article, People, Book. I'm in the 'Article' table, trying to get a list of 'Books' based on the person "selected" in Articles, that person needs to be the Author of the 'Books'. Dig? # views.py def

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
fallback, you could rely on raw SQL I > suppose.http://docs.djangoproject.com/en/1.0/topics/db/sql/ > > Sorry I couldn't be more helpful here. > > -- Andrew > > On Jul 20, 10:30 am, The Danny Bos <danny...@gmail.com> wrote: > > > > > I'm not able to use an

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
though. As a fallback, you could rely on raw SQL I > suppose.http://docs.djangoproject.com/en/1.0/topics/db/sql/ > > Sorry I couldn't be more helpful here. > > -- Andrew > > On Jul 20, 10:30 am, The Danny Bos <danny...@gmail.com> wrote: > > > > > I'

Re: Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
r = models.ForeignKey(User) > >     score = models.IntegerField(default=3) > >     book = models.ForeignKey(Book) > > > Try this: > > > from django.db.models import Sum > > Book.objects.filter(rating__user__is_staff=True).annotate(score=Sum > > ('rating__

Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
Hey there, I'm looking at getting a Top 10 of all Books on a site, but only where rated by users of a certain Group. Here's what I've got so far: book = Book.objects.all() Somewhat impressive, hey? - So, my tables/models are Book, Rating, User. - I save all ratings in Rating like so

Get Top 10 Books by Rating and User

2009-07-20 Thread The Danny Bos
Hey there, I'm looking at getting a Top 10 of all Books on a site, but only where rated by users of a certain Group. Here's what I've got so far: book = Book.objects.all() Somewhat impressive, hey? - So, my tables/models are Book, Rating, User. - I save all ratings in Rating like so

Checking a User in another Table ...

2009-07-19 Thread The Danny Bos
Hey there, this should be easy, but my code just won't play along. I've let a logged in user Rate a music record. I'm saving it like so 'rating | user | record'. (Rating model) What I need to do is only display the Rating form if the logged in user hasn't rated the record yet, know what I mean.

Using AVG

2009-07-17 Thread The Danny Bos
Heya, If I wanted to get the Average of all ratings (in a Rating table) for a single record. Would I use something like this: ratings_avg = Rating.objects.aggregate(Avg('rating')) And where does this live? In models.py or views.py and how is it called. I've been reading a lot about it, but

Re: Saving Data To Your DB. Simple?

2009-07-16 Thread The Danny Bos
So, I'm guessing this is impossible. Any ideas would be great ... d On Jul 16, 11:52 am, The Danny Bos <danny...@gmail.com> wrote: > Hopefully my last question on this, > How do I get back to the page with the form, perhaps with a "Thank > You" message, with

Re: Saving Data To Your DB. Simple?

2009-07-15 Thread The Danny Bos
ecord-name',)' and keyword arguments '{}' not found. And even if it does get passed back to the original page, how would I have a "Thank You" message? Thanks again, d On Jul 16, 10:49 am, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > On Thu, Jul 16, 2009 at

Re: Saving Data To Your DB. Simple?

2009-07-15 Thread The Danny Bos
Russ, this makes a lot of sense, thanks so much. I'll give it a go now ... d On Jul 16, 10:49 am, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > On Thu, Jul 16, 2009 at 8:36 AM, The Danny Bos<danny...@gmail.com> wrote: > > > Any ideas on this one guys? &g

Re: Saving Data To Your DB. Simple?

2009-07-15 Thread The Danny Bos
Any ideas on this one guys? I gave up on it last night. I feel way off ... d On Jul 15, 11:33 pm, The Danny Bos <danny...@gmail.com> wrote: > Agreed, I should get used to using Forms. > So I gave it a go, the new problem I have is out of my three fields, > two need to be

Re: Saving Data To Your DB. Simple?

2009-07-15 Thread The Danny Bos
ave to coerce the record_id and user_id into int before assigning > to the model fields, for it to save. > > On Tue, Jul 14, 2009 at 9:45 PM, The Danny Bos <danny...@gmail.com> wrote: > > > > > > > > > Heya, am trying to simply save 3

Saving Data To Your DB. Simple?

2009-07-14 Thread The Danny Bos
Heya, am trying to simply save 3 values to a database, without using Forms. In the Template: Rate This: {% for n in numbers %}{{ n }}{% endfor %} In the View: from mysite.rating.models import Rating def critics_rating(request): try:

Re: Count from 1 to 50

2009-07-14 Thread The Danny Bos
Great idea. Don't know why I didn't think of that ... Thanks man, d On Jul 15, 12:48 am, Shawn Milochik <shawn.m...@gmail.com> wrote: > On Jul 14, 2009, at 10:27 AM, The Danny Bos wrote: > > > > > Is there a way to create a simple list using Django to go from 1 to &g

Count from 1 to 50

2009-07-14 Thread The Danny Bos
Is there a way to create a simple list using Django to go from 1 to 50. Eg: 1, 2, 3, 4, 5 ... 49, 50 I figured it'd be easy, but I can't get it. I tried ... {% for i = 1 in 10 %} {{ i }}, {% endfor %} No go. --~--~-~--~~~---~--~~ You

Re: Database Model Layout Advice

2009-07-14 Thread The Danny Bos
So the Author and Illustrator tables would stay as is. How would the Interview table talk to both of those tables at once, to allow me to assign an interview to who I'm interviewing. Whether it's an Illustrator, Author or even down the track a Publisher. Like so? class Interview(models.Model):

Database Model Layout Advice

2009-07-14 Thread The Danny Bos
Hey there, this may not be appropriate, but I'm building in Django so here goes ... I'm creating an Interviews app/table in my Django 'Books' (test) project. Just wrapping my head around it before I start on my music based website ... Anyway, For my 'Interview' table, how would I assign an

Re: Display Data From Multiple Tables

2009-07-02 Thread The Danny Bos
? d - - - On Jul 3, 12:13 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Jul 2, 2:55 pm, The Danny Bos <danny...@gmail.com> wrote: > > > > > > > K, I think I have it. > > > Just having trouble getting the Author loop from within my Review >

Re: Display Data From Multiple Tables

2009-07-02 Thread The Danny Bos
DR. Bingo!! Thanks man, And thanks for the tip on "_set" being for ForeignKeys. d On Jul 3, 12:23 am, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Jul 2, 3:20 pm, The Danny Bos <danny...@gmail.com> wrote:> Daniel, > > > {% for author in review.it

Re: Display Data From Multiple Tables

2009-07-02 Thread The Danny Bos
gt; Alex > > On Jul 1, 1:34 pm, TiNo <tin...@gmail.com> wrote: > > > > > On Wed, Jul 1, 2009 at 16:59, The Danny Bos <danny...@gmail.com> wrote: > > > > Hi there, > > > > Seems easy, but I'm having an ass of a time. I think once

Display Data From Multiple Tables

2009-07-01 Thread The Danny Bos
Hi there, Seems easy, but I'm having an ass of a time. I think once I wrap my head around how to do this, I'll be rolling through Django like it's building sprites on a Commodore 64. So, I have four tables. Book, Publisher, Author and Review. A classic scenario. I want to display a loop on the