Re: Eclipse + PyDev + Aptana - Anybody??? Need some pointers

2007-07-04 Thread Tom Smith
that I need to step through line at a time watching variables... good luck tom -- Tom Smith --- [EMAIL PROTECTED] http://everythingability.comhttp:// theotherblog.com mobile: +44 (0)7720 288285 land: +44 (0)1904 870565

Re: MySql Workbench

2007-06-12 Thread Tom Smith
reign key relationships weren't shown.. The first base for me would be able to view a model in Workbench, that'd be great... regards tom ---- Tom Smith http://www.everythingability.com yahoo, aim, skype: everythingab

Off topic (Logging into django with cookies and webcrawler)

2007-04-06 Thread Tom Smith
5/') print resp2.read() ---- Tom Smith http://www.everythingability.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 413 ---

DB Super Model (ahem)

2007-03-27 Thread Tom Smith
I'd like to be able to "catch" when creating a new object... fix a few things up then let the normal thing happen... for example... class myObj(models.model): def __init__(self, **kwargs): t = kwargs['title'] t =

Fwd: Different subdomain for each application (again)

2007-03-24 Thread Tom Smith
gards tom ---- Tom Smith http://www.theotherblog.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 413 --- usability, findability, profitability, rem

Different subdomain for each application (again)

2007-03-23 Thread Tom Smith
gards tom ---- Tom Smith http://www.theotherblog.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 413 --- usability, findability, profitability, rem

Re: manage.py startapp suggestions

2007-03-23 Thread Tom Smith
s > in django core later. Where's the code? ^_^;;; I'm working on it ;-) -------- Tom Smith http://www.everythingability.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 41

Re: Suggestions for Django Presentation

2007-03-22 Thread Tom Smith
On 21 Mar 2007, at 22:58, Scott Paul Robertson wrote: > > I've got an hour and a half. I was planning to only hit the high > points, > then leave references to other things, and maybe mention briefly why > they should care. > > Thanks for the suggestions (this goes to everyone) For me... the

Re: manage.py startapp suggestions

2007-03-22 Thread Tom Smith
> It becomes less useful as you get more > experienced, because there is no "one size fits all" approach to > application layout. You wouldn't say that if you'd seen my code... I'd love to be guided on application layout, in fact, it was only at the end of my first django project that I

Re: manage.py startapp suggestions

2007-03-22 Thread Tom Smith
On 22 Mar 2007, at 06:57, Malcolm Tredinnick wrote: > > On Wed, 2007-03-21 at 23:36 -0700, [EMAIL PROTECTED] wrote: >>> Hmm... if we do it, this feels like something that should be kept >>> separate from the standard manage.py; I don't mind "where" this functionality "lives"... and really don't

manage.py startapp suggestions

2007-03-21 Thread Tom Smith
avigation goes here{%endblock%} {%block content%}{%endblock%} ''') f.close() # create a template that extends that template, not used anywhere... f = open( app + "/" + "templates/example.html" , 'w') f.write('''{% extends "base.html" %} {% load humanize %} {%block header%} {%endblock%} {%block content%} Bla bla {%endblock%} ''') f.close() do("mkdir " + app + "/" + "static") #DO URLS ### CREATING FOLDERS AND FILES print r"remember to add... (r'^"+ app +"/', include('"+project+"." + app + ".urls'))," print " to your main urls.py file!" print print "Now edit your models and views and urls before running python manage.py syncdb" Tom Smith         http://www.theotherblog.com   

Re: Related "order by" problems (Solved-ish)

2007-02-05 Thread Tom Smith
On 4 Feb 2007, at 16:44, Ramiro Morales wrote: > See tickets #2210 and 2076 where a patch is proposed to solve the > problem. I tried to patch it.. like this... >>cd /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/ site-packages/Django-0.95-py2.4.egg/django/db/models

Re: Related "order by" problems

2007-02-04 Thread Tom Smith
On 4 Feb 2007, at 17:51, Don Arbow wrote: > class Meta: > ordering = ('pagerank',) Except that I'd have quite like to sort by other attributes as well... default ordering is ok but it'd be nice to be able to swap ordering on the fly wouldn't it... I kinda half expected this to work...

Related "order by" problems

2007-02-04 Thread Tom Smith
I have a model that looks roughly like this... class Client(models.Model): name = models.CharField(maxlength=200, default='') class Competitor(models.Model): client = models.ForeignKey(Client) site = models.ForeignKey(Site) class Site(models.Model): client =

Shell question (simple)

2007-01-25 Thread Tom Smith
I'm probably missing some basic python convensions about importing modules, but...I've been trying to work with my model and get it all working before working with the views. Normally, when working with normal python scripts I'd do something like this.. import google_utils as g print

Re: Help with getting connection.queries info

2006-11-29 Thread Tom Smith
I have a similar solution/problem... Firstly, my "solution" was to create a method in my vews.py like this... def my_render(request, template, dict): url_time = 0 try: for query in connection.queries: log( query['time'] + "\t" +

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
Essentially I think the problem is this... I am trying to do an ORDER BY on a pre-populated (and indexed) column called random_number... I created this column because RAND() is so slow... It is the ORDER BY which is causing all the slow downs... If I do a select without the order by it

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
Really what I need to do is "re-order" the database rows (for good) by the random_number column... note.. I am not using RAND() at all... Hey, this gives me an idea... Given I have price ranges 1-2, 2-5, 5-10 etc... and the prices are all like 1.99, 1.96 etc... What if I precalculate a

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
On 18 Nov 2006, at 19:35, Jeremy Dunck wrote: > This isn't a Django question, but indexes only work well when there's > a large distribution of values. If lots of your products are in that > price range, you're still ordering by loads of randoms. Try assigning > (as a column value) a random

Re: Database optmization guru needed...

2006-11-19 Thread Tom Smith
On 18 Nov 2006, at 18:59, tonemcd wrote: > > Perhaps something from here will help? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59883 > > Where your list is an xrange(min...max) of id's from your database > table. That is, do it in python, not with your database... Ah sorry,

Re: Django + FastCGI Problems

2006-11-19 Thread Tom Smith
On 19 Nov 2006, at 05:35, coulix wrote: > mikeb i have the same problem it takes few minutes to come back and i > see a lot of python process waiting for whatever. > kill kill all ect have no effects. > But once it runs its all good. I have never found that the "touching" thing ever worked, but

Database optmization guru needed...

2006-11-18 Thread Tom Smith
Hello. When in mysql I do a... explain select title from burningahole_product where ( price >10 and price<20) order by random_number limit 10; ... I get... ++-+--+--- +++-

Re: How to restart Django/FastCGI/Lighttpd?

2006-11-16 Thread Tom Smith
On 16 Nov 2006, at 02:29, Jay Parlar wrote: > Well, here's the way I do it. On my development machine, I do all my > hacking out of a SVN working directory. When I get everything working > how I want it locally, I do my 'svn commit', then login to my > production server. > > From there, I have

Re: How to restart Django/FastCGI/Lighttpd?

2006-11-15 Thread Tom Smith
On 13 Nov 2006, at 17:21, Jay Parlar wrote:If you're on a unix-like system, you should be able to just do a 'touch' on your .fcgi file.I tried the touching trick (on main.fcgi and django-fcgi.py) and it doesn't work... is there another way to "refresh" django without having to kill the root python

Re: Django lighttpd concepts question

2006-11-13 Thread Tom Smith
On 13 Nov 2006, at 13:14, Ivan Sagalaev wrote:Tom Smith wrote: For example, I have made a change to my models.py file and I am   logging all sql to a log file... But when I sit and watch it, the OLD   sql is still getting executed... Could it be that having caching turned on is causing this?

Django lighttpd concepts question

2006-11-13 Thread Tom Smith
Hello... I am running Django using Lighttp and FCGI and I am not quite sure about it conceptually, For example, I have made a change to my models.py file and I am logging all sql to a log file... But when I sit and watch it, the OLD sql is still getting executed... Could it be that

Bug?

2006-11-09 Thread Tom Smith
I get this on a page called, funnily enough, "amp" Is it a bug? TemplateSyntaxError: Caught an exception while rendering: Original Traceback (most recent call last): File "/users/home/tomsmith/domains/burningahole.co.uk/django/ django/template/__init__.py", line 706, in render_node

Running Django with Lighttpd on TextDrive...

2006-11-08 Thread Tom Smith
Now I know that it is always hard to comment on specifics but I have just discovered something very strange on my server and could someone please help... I am running Django on Textdrive which requires Lightpd. I went through the setup... and boy that was difficult, so many config

Re: Still really struggling with JOINS

2006-10-27 Thread Tom Smith
> Just to establish that we are all on the same page: are you seeing the > error when you use exactly the model example you posted yesterday and > cut and paste the queryset constructor that Rajesh posted? That should > be working. No, it fails for me, we are on the same page. > If that is

Re: Still really struggling with JOINS

2006-10-11 Thread Tom Smith
On 11 Oct 2006, at 18:59, Rajesh Dhawan wrote:Hi, This still works for me! The only change I made to your model was to add a "class Admin: pass" to your ProductWord class so that I could add a ProductWord test object through the Admin UI. My results in the shell: from my_app.models import

Re: Still really struggling with JOINS

2006-10-11 Thread Tom Smith
Oops... replied to wrong thread... here it is... It has a lot of stuff... but the core is simple enough, like this... class Product(models.Model): title = models.CharField(maxlength=200, db_index=True) url = models.URLField(maxlength=250, db_index=True, unique=True)

Re: Adding new columns to an existing application's Tables

2006-10-11 Thread Tom Smith
It has a lot of stuff... but the core is simple enough, like this... class Product(models.Model): title = models.CharField(maxlength=200, db_index=True) url = models.URLField(maxlength=250, db_index=True, unique=True) class Word(models.Model):

Re: Still really struggling with JOINS

2006-10-10 Thread Tom Smith
On 10 Oct 2006, at 22:11, RajeshD wrote: > > See if this helps: > > Product.objects.filter > (productword__fk_word__value__exact='thomas').distinct() When I try that... I get... TypeError: Cannot resolve keyword 'productword' into field --~--~-~--~~~---~--~~

Re: Still really struggling with JOINS

2006-10-10 Thread Tom Smith
Or to put it more simply... all I'm trying to do is this... Select * from myapp_product, myapp_productword, myapp_word where myapp_productword.fk_product_id = myapp_product.id and myapp_productword.fk_word_id = myapp_word.id and value = 'assam' order by title ..returning Product objects...

Re: Adding new columns to an existing application's Tables

2006-10-10 Thread Tom Smith
On 10 Oct 2006, at 17:51, Ramdas S wrote: > Hi, > > > I need to add a few columns to some of the tables in a live > application. We have new requirements. > > I propose to do the same by adding a column to the MySQL table using . > > > > ALTER TABLE table_name ADD new_field_name VARCHAR(60);

Still really struggling with JOINS

2006-10-10 Thread Tom Smith
My model is like this... class Product(models.Model): class Word(models.Model): value = models.CharField(maxlength=200, core=True, unique=True) class ProductWord(models.Model): fk_word = models.ForeignKey(Word , core=True) fk_product =

Re: sorting QuerySets

2006-10-10 Thread Tom Smith
With about a million records I can't imagine doing it any other way... I want to find my top 100 words (by product_count) then sort them alphabetically to make a tag cloud... thanks... --~--~-~--~~~---~--~~ You received this message because you are

Re: sorting QuerySets

2006-10-10 Thread Tom Smith
On 10 Oct 2006, at 15:08, Tom Smith wrote: > > Sorry for what is probably a simple python question, but if I have a > list of Products and I have searched for 100 of them ordered by x... > > then how do I then sort the QuerySet returned by title? > > I can't

sorting QuerySets

2006-10-10 Thread Tom Smith
Sorry for what is probably a simple python question, but if I have a list of Products and I have searched for 100 of them ordered by x... then how do I then sort the QuerySet returned by title? I can't do an .. object_list = products.items().sort('title') because I have already done a [:100]

Re: Joining Foreign Keys

2006-10-10 Thread Tom Smith
Hang on... I realise I should have a ManyToMany thing going on... apologies --~--~-~--~~~---~--~~ 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

Joining Foreign Keys

2006-10-10 Thread Tom Smith
I am really struggling with this... class Product(models.Model): snip... class Word(models.Model): value = models.CharField(maxlength=200, core=True, unique=True) class ProductWord(models.Model): fk_word = models.ForeignKey(Word, core=True) fk_product =

Custom SQL mayhem...

2006-10-09 Thread Tom Smith
In trying to do some custom SQLto search for words (so "Three" but not "Threesome") ... but because the call adds quotes.. I have had to do this... for word in words: sql = """select count(*) from myapp_product WHERE title LIKE (%s) AND title RLIKE %s """

Re: DB question: OR-ing LIKES

2006-10-06 Thread Tom Smith
On 6 Oct 2006, at 21:26, RajeshD wrote: > >> for word in words: >> q = q.filter( Q(title__icontains=word) ) >> > Try something like this instead of the above: > > q_fragment = Q(title__icontains=words[0]) > for word in words[1:] > q_fragment = q_fragment |

DB question: OR-ing LIKES

2006-10-06 Thread Tom Smith
I am trying to iterate through a list of strings to create... OR titile LIKE '%This%' OR title LIKE '%That%' q= Product.objects.filter( some stuff ) for word in words: q = q.filter( Q(title__icontains=word) ) return q[:10] ...but the contains Queries get AND-ed together...

Caching bug?

2006-10-06 Thread Tom Smith
When I turn on caching... and use... CACHE_MIDDLEWARE_ANONYMOUS_ONLY= True ...then, if I am logged into the admin part of my site... all pages are not cached... Is this right? I'd prefer it if the Admin screens weren't cached but the rest were regards tom

Caching weirdness (very tricky question)

2006-10-05 Thread Tom Smith
I am trying to get the best out of the caching abilities of Django but I have unusual needs...And the caching is showing unusual behaviour... When I added caching... a url like this /x/y/z/ returned results OK... but I wanted the cache to work for MOST pages but not ones where some

Re: Anal not Analog, Analysis: DB Question

2006-10-05 Thread Tom Smith
On 4 Oct 2006, at 17:09, Andy Dustman wrote:On 10/4/06, Tom Smith <[EMAIL PROTECTED]> wrote: If I am looking for titles like "Anal Sex" or "Being Anal" then howdo I construct this, ahem, query... to not return "Analysis" or"Analog"? Two options:

Re: Anal not Analog, Analysis: DB Question

2006-10-05 Thread Tom Smith
s (Spanish))     The Complete Psychological Works of Sigmund Freud: "New Introductory Lectures on Psycho-analysis" and Other Works Vol 22..probably...On 4 Oct 2006, at 17:01, John DeRosa wrote:heh.  so do we get to guess what your django-based site is about? Tom Smith wrote: If I am looking f

Re: global template tags

2006-10-05 Thread Tom Smith
I couldn't quite work out how to do that... there's not enough guidance... so I created a method in Views.py like this... def add_defaults(the_dict={}): the_dict['BASE_URL'] = "/burningahole/" the_dict['STATIC_URL'] = STATIC_URL ...etc return the_dict

Anal not Analog, Analysis: DB Question

2006-10-04 Thread Tom Smith
If I am looking for titles like "Anal Sex" or "Being Anal" then how do I construct this, ahem, query... to not return "Analysis" or "Analog"? I tried adding spaces to the end of the word but it doesn't seem to help... object_list = Product.objects.filter( Q(title__contains=word + " ")| Q

Serious Question... Web2.0

2006-09-29 Thread Tom Smith
As everyone knows (or as yet to learn) the success of many technologies is down to how snazzy the end result is... So it surprises me that I can't find any reference to anyone uses MochKit (or any other client-based toolkit) with Django... in fact that seems to be be the key differentiator

Here's an idea for the Django ninjas...

2006-09-28 Thread Tom Smith
Wouldn't it be nice if I could... >>> python manage.py sync-urls-to-views.py ...and have some output that creates all the functions (with params) called for me... even if only splatted to screen Wouldn't it be nice if if perhaps in reverse I could... >>> python manage.py

Re: Pickling Sessions (or lists of instances)

2006-09-27 Thread Tom Smith
On 28 Sep 2006, at 00:56, Steven Armstrong wrote: > > On 09/27/06 23:49, Tom Smith wrote: >> Thanks, it all seems to work except for when I store a list of >> objects in the database and try to get it out I get a string (that >> looks like a list of ob

Re: Pickling Sessions (or lists of instances)

2006-09-27 Thread Tom Smith
Thanks, it all seems to work except for when I store a list of objects in the database and try to get it out I get a string (that looks like a list of objects) >>> products = Product.objects.filter(title__contains='Dog')[:10] >>> sub = Subscription(email="[EMAIL

Can Django's Send Email handle SSL... or is it something else?

2006-09-27 Thread Tom Smith
My service provider requires it for SMTP... I have set the EMAIL_PORT but the email doesn't seem to go... My message content is HTML (is this ok?) My last error is... Connection unexpectedly closed, but I've also had...SMTP AUTH extension not supported by server (for gmail)... (60,

Pickling Sessions (or lists of instances)

2006-09-27 Thread Tom Smith
Hello currently I am storing a list of python instances in the request.session but would like to make a persistent copy of this list and store it permanently... I don't want to just make the timeout of the session a long time in the future, because each user could have multiple lists of

Re: serving static images

2006-09-26 Thread Tom Smith
On 10 Sep 2006, at 16:52, Allan Henderson wrote: > > Complete newbie problem here but i can't seem to get django to show > any images or stylesheets etc. > > In urls.py: > > (r'^images/(?P.*)$', 'django.views.static.serve', > {'document_root':

Remote Images and Django

2006-09-26 Thread Tom Smith
Hello, I'm trying to write a very simple script that takes a list of URLs for images and gets their data... resizes them to 110x110 (hopefully preserving aspect ratio) and then puts that data into an ImageField obj... any pointers gratefully received tom

Re: Remote Images and Django

2006-09-26 Thread Tom Smith
Nearly there with this code... from PIL import Image,ImageFile def get_image(src): import urllib fp = urllib.urlopen(src, "rb") p = ImageFile.Parser() while 1: s = fp.read(1024) print ".", if not s:

Simple Template Syntax Question: ljust

2006-09-25 Thread Tom Smith
Can someone show me how to get x number of chars from a variable in a template please... I've tried... {{product.title | ljust 40}} and other formats but can't get it to work... thanks --~--~-~--~~~---~--~~ You received this message because you are

Re: The Holy Grail of Web Development

2006-09-24 Thread Tom Smith
On 24 Sep 2006, at 19:41, [EMAIL PROTECTED] wrote:File > Launch > give it the path to manage.py runserver and debug from there Sorry but when I do that... it just sits there doing nothing.. --~--~-~--~~~---~--~~ You received this message because you are subscribed

The Holy Grail of Web Development

2006-09-24 Thread Tom Smith
For me at least is... A long time ago, I used to use a programming language that let me set breakpoints and when the code stopped, I could inspect all the variables, change them (the code would roll back to where the earliest change was)... call non-existent functions which would raise

DB Table Join problem

2006-09-23 Thread Tom Smith
I have a model that is trying to join (sloppily) across 3 tables. KnownCategories are a "group by catalog" reduction of Product.catalog (because I thought it would be quicker but I don't know if I'm right)...they should join like this... Product.catalog <--> KnownCategory.fk_name

models: There has to be a better way.

2006-09-23 Thread Tom Smith
At the moment I am learning django and so far, almost everything about it feels fantastic. Except for this...A lot of the time I need to change the database model as I go... I have millions of records and have problems dumping all the data out re-sync-ing the database and then importing the data

Dumb MySQL Question: Views

2006-09-23 Thread Tom Smith
Whilst playing with the MacOS X Gui Tools, I re-discovered mysql Views. They would be massively useful to me... for example I could have a query that inserted into a view which would mean django wouldn't have to be performing complex queries on-the-fly. The questions are: 1. Can

Re: settings.py help please

2006-09-23 Thread Tom Smith
My MacOS X Django Development environment. I have found the easiest to be to install MAMP, which has Apache (which at the moment I don't use) and MySQL built in ... It has a nice GUI.. http://www.mamp.info/ Then install the MySQL python module mentioned//

Admin interface question

2006-09-22 Thread Tom Smith
If I have a class Catalog which relates to a class Product... in the admin interface I'd like to specify a function (to be used to navigate to related products) rather than a field... like this... class Catalog(models.Model): name = models.CharField(maxlength=200, core=True,

Template traumas... (Crashes server... ignore this)

2006-09-19 Thread Tom Smith
Whilst writing what is below I realized that if a template extends itself (accident...oops!) it completely crashes the server... maybe this could be trapped somehow... > I have a base.html template which has HTML and defines a block > "content", like this... > > Hello > {% block

Re: Database query question

2006-09-18 Thread Tom Smith
On 18 Sep 2006, at 16:26, James Bennett wrote:p.exclude() returns a new QuerySet with the filtering, so you need to grab the return value, like this: if len(notsitelist)>=1:     print "excluding sites: ", notsitelist     p = p.exclude(fk_site__in=notsitelist) That was it... silly me, just missed

Re: Database query question

2006-09-18 Thread Tom Smith
On 18 Sep 2006, at 16:27, Michael Radziej wrote: Is there way to do p.get_query(.)p.show_sql() I really don't get what this is supposed to mean, it just looks like seriously broken syntax. Not really.. having built and manipulated (with exludes, filters, order etc.) I'd quite like to peep at the

Re: Database query question

2006-09-18 Thread Tom Smith
> Query sets are not executed on the database until you iterate, or > otherwise try to extract data from them. > > o = Recipe.objects > o2 = o.filter(xx) > o3 = o2.filter(yy) > o4 = o3.filter(zz) > > print o4 > > will result in just 1 query getting issued to the database - the final > query with

Re: Database query question

2006-09-16 Thread Tom Smith
On 16 Sep 2006, at 12:42, Malcolm Tredinnick wrote: > > On Sat, 2006-09-16 at 12:25 +0100, Tom Smith wrote: >> How would I build an "AND" query... >> >> for example... >> >> words = ['chicken', 'beef', 'lamb'] >> Recipe.objects.exclude(title

Re: Redirecting in Django...

2006-09-16 Thread Tom Smith
On 16 Sep 2006, at 13:39, Malcolm Tredinnick wrote:Are you sure it's really getting to that last line and not returning somewhere earlier?Yes... Does request.META['HTTP_REFERER'] contain something sensible? This won't be the cause of the problem, but it's worth checking.Most of the time...

Redirecting in Django...

2006-09-16 Thread Tom Smith
I would really like to be able in my views.py file to do a... def do_something(request, x): #do something that changes some session vars here... #now go back to where you were return HttpResponseRedirect(request.META['HTTP_REFERER'] ) .. but I always get... ValueError

Database query question

2006-09-16 Thread Tom Smith
How would I build an "AND" query... for example... words = ['chicken', 'beef', 'lamb'] Recipe.objects.exclude(title__contains=words) I don't want to do 3 queries... thanks tom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: MySQL Django Wildcard bug...

2006-09-08 Thread Tom Smith
On 8 Sep 2006, at 22:53, James Bennett wrote: > > On 9/8/06, tom smith <[EMAIL PROTECTED]> wrote: >> Then because the sql has a % in it.. django complains... > > The '%' needs to be escaped, because it's a special character in this > context. Make it '%%'

MySQL Django Wildcard bug...

2006-09-08 Thread tom smith
So... Because there aren't quite enough examples that show how to build pythonic model queries... I'm using the pump-raw-sql at django... The only problem is that when my sql contains wordsql = wordsql + " AND (title not like ' %" + word +"%') " cursor.execute(sql) Then because the sql has a