Re: My Ratings System

2006-09-23 Thread [EMAIL PROTECTED]

I went through GenericRelation's today as I was harassed several times
to, and I found nothing that would help at all for what I'm trying to
accomplish.

Here are the updated models:

class Score(models.Model):
content_type = models.ForeignKey(ContentType, db_index=True)
object_id = models.PositiveIntegerField(db_index=True)

score = models.IntegerField(default=0)

class Meta:
unique_together = (('content_type', 'object_id'),)
verbose_name = _('score')
verbose_name_plural = _('scores')

class Rating(models.Model):
score = models.ForeignKey(Score, db_index=True)

user = models.ForeignKey(UserExt, null=True, db_index=True)
ip = models.IPAddressField()
rating = models.SmallIntegerField(maxlength=1, choices=SCORE_CHOICES)
post_date = models.DateTimeField(auto_now=True, editable=False)

class Meta:
unique_together = (('score', 'user'),)
ordering = ['-post_date']
verbose_name = _('rating')
verbose_name_plural = _('ratings')


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



Re: One-To-Many doesn't return a list.

2006-09-23 Thread Jay Parlar

On 9/23/06, Tyson Tate <[EMAIL PROTECTED]> wrote:
> I've reduced it to the barest components:
>
> Model: http://paste.e-scribe.com/1671/
>
> And it still gives me the "iteration over non-sequence" error as well
> as the "'SignupSlot' object has no attribute 'set_signups'" crashing
> error I get in the admin interface when I try to add a new object.
>
> It looks like Django refuses to allow me to use a Many-To-Many field
> inside of a ForeignKey relationship.
>
> I can't possibly be the first person to run in to this bug, can I?


By making some small changes to db/models/manipulators.py, I've been
able to get your models working, both in the Admin, and in the
templates.

I did the following:

Index: django/db/models/manipulators.py
===
--- django/db/models/manipulators.py(revision 3809)
+++ django/db/models/manipulators.py(working copy)
@@ -215,7 +215,11 @@
 # Save many-to-many objects.
 for f in related.opts.many_to_many:
 if child_follow.get(f.name, None) and not
f.rel.edit_inline:
-was_changed = getattr(new_rel_obj,
'set_%s' % f.name)(rel_new_data[f.attname])
+#was_changed = getattr(new_rel_obj,
'set_%s' % f.name)(rel_new_data[f.attname])
+func = getattr(new_rel_obj, 'set_%s'
% f.name, None)
+was_changed = False
+if func:
+was_changed = func(rel_new_data[f.attname])
 if self.change and was_changed:
 self.fields_changed.append('%s
for %s "%s"' % (f.verbose_name, related.opts.verbose_name,
new_rel_obj))


Three **BIG** disclaimers about this:

1) I'm running off the row-level-permissions branch, so the trunk's
manipulators.py might be a bit different.

2) Until a few minutes ago, I'd never even opened
db/models/manipulators.py before. All I did was apply some fairly
basic Python techniques to add some robustness to the existing code. I
have no idea if what I did is the *proper* thing, all I know is that
in this case, it works, and that the end result is what you want to
see. Hopefully someone who's actually familiar with this code can take
a look at it.

3) In my *quick* tests, it seems that the getattr() is *always*
returning None with this code. This could mean that the getattr is
looking for the wrong thing. It could also mean that the object isn't
being setup properly, meaning the getattr can't find what it's
supposed to be looking for.

I know this doesn't really solve your problem (in a long-term useable
way), but hopefully it can give the core team some ideas.

Jay P.

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



Re: One-To-Many doesn't return a list.

2006-09-23 Thread Tyson Tate

On Sep 23, 2006, at 12:45 AM, Malcolm Tredinnick wrote:

> What happens when you reduce the example to something smaller? Does it
> go away? What is the last thing you change before it goes away? If the
> problem never goes away, you should end up with a two line example you
> can paste in an email that we can turn into a test case, but I suspect
> it won't get that far.

I've reduced it to the barest components:

Model: http://paste.e-scribe.com/1671/

And it still gives me the "iteration over non-sequence" error as well  
as the "'SignupSlot' object has no attribute 'set_signups'" crashing  
error I get in the admin interface when I try to add a new object.

It looks like Django refuses to allow me to use a Many-To-Many field  
inside of a ForeignKey relationship.

I can't possibly be the first person to run in to this bug, can I?

(I'm using Django 0.95 on MacOS X 10.4 using Python 2.4.3, sqlite  
3.3.7, and py-sqlite 2.3.1.)

Regards,
Tyson

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



Re: DB Table Join problem

2006-09-23 Thread Malcolm Tredinnick

On Sat, 2006-09-23 at 18:35 +0100, Tom Smith wrote:
> 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 <-->  
> MetaCategory.name
> 
> 
> class Product(models.Model):
>   asin = models.CharField(maxlength=200)
>   title =  models.CharField(maxlength=200, db_index=True)
>   catalog  =  models.CharField(maxlength=200, default='',  db_index=True)
> 
> 
> class MetaCategory(models.Model):
>   name =  models.CharField(maxlength=200, core=True,  db_index=True,  
> unique=True)
> 
> class KnownCategory(models.Model):
>   meta_category = models.ManyToManyField(MetaCategory)
>   fk_name = models.ForeignKey(Product, to_field='catalog')
> 
> 
> ...from the above... I was trying to do something like this...
> 
>  >>> p = Product.objects.filter(metacategory__name='Book')

Since the MetaCategory model has no direct connection to the Product
model, this query stands no chance, as you discovered. Django doesn't do
the routing through the KnownCategory model transparently (in the
general case, there isn't always going to be a unique path, for a
start). So you need to write something like

Product.objects.filter(fk_name_set__meta_category__name =
'Book')

Regards,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Dumb MySQL Question: Views

2006-09-23 Thread Malcolm Tredinnick

On Sat, 2006-09-23 at 18:24 +, [EMAIL PROTECTED] wrote:
> Tom Smith wrote:
> > 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.
> 
> Same goes for stored procedures, they're usually faster to execute
> since the db server can store a query execution plan. It would be
> interesting to see stored procedure and views support in Django.
> 
> PostgreSQL has updateable views[1] and I MySQL 5 has them too though
> with some restrictions[2]

We welcome patches. :-)

As far as I am aware, nobody is working on this at the moment (but that
may be because I'm just out of the loop and somebody is beavering away
in their attic writing a killer stored procedure API)

Regards,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Dumb MySQL Question: Views

2006-09-23 Thread Malcolm Tredinnick

On Sat, 2006-09-23 at 16:13 +0100, Tom Smith wrote:
> 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 Django use mysql Views? If so, how would I access them?

It might be possible to make a model that maps directly onto a view. You
would have to create the view manually in the database and then write
the model on top of that and there may be some corner issues with naming
related tables and the like, but it should be pretty close.

>   2. Are mysql Views what I think they are... are they a "live" take  
> on the data or just dumped into a table once?

They are rerun each time you query them, typically. Oracle has a way to
say "cache this view", PostgreSQL doesn't. I don't know about MySQL. If
you want a cached snapshot of something, you can use a temporary table
(but it sounds like you want the "liveness" feature anyway).

Regards,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: date filter behaviour

2006-09-23 Thread Rudolph

Thanks!

Rudolph


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



Composite FormFields

2006-09-23 Thread [EMAIL PROTECTED]

I'm sure this has been discussed before, but my google skills are
failing me.

I would like to create a FormField that is comprised of multiple other
FormFields.  For instance, I would like month, day, and year fields to
be converted to a single date object in html2python.

One solution is to add three fields and conversion code to every
manipulator that uses the composite.  This seems to violate DRY.

Another is creating a FormField subclass that renders as three input
elements.  This fails because html2python is called with the data from
the input element with only the specified name.

Are there better options?

-- 
Brian


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



Django Training

2006-09-23 Thread sago

Hi all,

I'm a pathological early adopter, long-time developer, consultant and
occasional technology trainer. And a Django user since the start of
September last year.

I recently did a 'what is Django' taster for the development team at
one of my clients, because I'd built a very neat asset management tool
for them in a week using it, and their interest was peaked to say the
least.

So now they're talking about a proper program on doing Lamp development
with Django. Which I'm more than happy to do for them.

So, given how this is a move from me as (very happy) Django consumer to
being somewhat of an evangelist, I thought it would be good to check in
with the community and see if anyone had any inspiration or
suggestions.

I guess some questions would be in order.

So if you were designing your perfect Django training program:

1. Any suggestions for material that would be good to cover? Typically
the guys I'd work with are not guru programmers, but are the guys who
need to churn out relatively simple, but good stuff for clients (I've
done Python training for them in the past so they are baseline familiar
there). Are there any useful tricks or gotchas that could save their
receding hairlines? Are there any neat but underused features of Django
that could benefit them?

2. What contrib.* packages do you think are must dos? (aside from the
admin interface, obviously).

3. How important is really understanding config and setup? I tend to
err on the side of thinking its pretty important, because someone
struggling to get MySQL to talk to mod_python (for example) can get
pretty stuck very quickly. But do you think programmers need to know
that stuff, if it can be set up once?

4. Any other advice or encouragement?

Thanks,

Ian.


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



Django leaving lots of open connection

2006-09-23 Thread Rafael SDM Sierra
Hi, I'm working with FreeBSD-6.0-RELEASE, Django-0.95, psycopg-1.1.21 and Apache-2.0.58, when I access the admin page, it leave lots of connection opened like say "ps ax":'''25593  p1  S  0:00.02 postmaster: user database 
127.0.0.1(58517) idle in transaction (postgres)'''What can I do to avoid this? Becouse the number of connections on postgresql at freebsd is not too larger (I can't put 100 like in the default instalation)
Should I turn off some keep-alive connection?Thanks-- SDM UnderlinuxGarimpar.com--PEP-8Só existem 3 tipos de pessoas no mundo, as que sabem contar, e as que não sabem.
CPFL - Compania Piratininga de FALTA de Luz (6 vezes em 5 dias!!)

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


Re: how do I tell which revision I'm using

2006-09-23 Thread Ivan Sagalaev

Tamara D. Snyder wrote:
> Hi all,
> 
> I'm sorry, I'm sure this is an extremely simple thing that I am just  
> stupidly missing.  But I can't seem to figure out which revision of  
> the django code I am using.  I use subversion to download the "latest  
> version" - but I only do it every so often.  Can anyone help me?

'svn info' in Django's directory should answer your question.

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



Re: How to test Validatidators

2006-09-23 Thread Maximillian Dornseif

Thanks for the enlightenment - seems I had some misconceptions about
how validators work. Based on this misconceptions I designed some tests
which somehow worked but not as I liked - hence my posting. My crude
first cut was like this:

# ripped out of django/db/models/base.py
def validate(instance):
error_dict = {}
invalid_python = {}
for f in instance._meta.fields:
try:
setattr(instance, f.attname, f.to_python(getattr(instance,
f.attname, f.get_default(
except ValidationError, e:
error_dict[f.name] = e.messages
invalid_python[f.name] = 1
for f in instance._meta.fields:
if f.name in invalid_python:
continue
errors = f.validate_full(getattr(instance, f.attname,
f.get_default()), instance.__dict__)
for v in f.validator_list:
try:
v(getattr(instance, f.attname, f.get_default()),
instance.__dict__)
except ValidationError, e:
errors = e.messages
if errors:
error_dict[f.name] = errors
return error_dict

class TestSanityChecks(unittest.TestCase):
def test_saneweight(self):
product = Product.objects.create(artnr='40003', name='Test',
package_weight='320', ve1_weight='232')
errors = validate(product)
self.assertEqual(errors['ve1_weight'], ['Das VE1 Gewicht darf
nicht kleiner als das Produktpaketgewicht sein.'])

This worked to a certain degree but resulted in all find of odd effects
because  the 'data string and all_data dictionary' the validators where
seeing different data when being called this way than when they would
be called by a form validator.

Now I'll try to rework this into something more realistic based on
Malcom's comments


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



how do I tell which revision I'm using

2006-09-23 Thread Tamara D. Snyder

Hi all,

I'm sorry, I'm sure this is an extremely simple thing that I am just  
stupidly missing.  But I can't seem to figure out which revision of  
the django code I am using.  I use subversion to download the "latest  
version" - but I only do it every so often.  Can anyone help me?

Thanks,

Tamara

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



Re: Django Cheat Sheet - Lost?

2006-09-23 Thread Don Arbow

On Sep 23, 2006, at 8:49 AM, Jon Atkinson wrote:
>
> Hi all,
>
> I've been looking for a copy of the Django cheat sheet (previous URL:
> http://www.dobbes.com/media/pdfs/django_reference_sheet.pdf), but that
> resource seems to have disappeared. Does anyone have a copy of this?



You can find a copy here, but it's not up to date - pre 0.91 from  
July 2005.

http://www.punteney.com/files/django/django_reference_sheet.pdf

Don



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



Re: Kate syntax highlighting for django html templates.

2006-09-23 Thread Matthew Marshall

I'd be glad to maintain it for kate!

I just uploaded a new version.  It highlights mismatched
block/for/if/etc tags as errors.  (Something I tend to do a lot.)

I also changed the priority to 9, so that it doesn't compete for the
html extention.

(Sorry it took me so long to reply... I've been pretty much without
internet access for the past two months.)

MWM


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



Re: Dumb MySQL Question: Views

2006-09-23 Thread [EMAIL PROTECTED]

Tom Smith wrote:
> 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.

Same goes for stored procedures, they're usually faster to execute
since the db server can store a query execution plan. It would be
interesting to see stored procedure and views support in Django.

PostgreSQL has updateable views[1] and I MySQL 5 has them too though
with some restrictions[2]

Lorenzo
--
[1] http://www.postgresql.org/docs/8.1/interactive/rules-update.html
[2] http://dev.mysql.com/doc/refman/5.0/en/view-restrictions.html


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



Re: Django Cheat Sheet - Lost?

2006-09-23 Thread Chris Long

Search on google gave:

http://www.woodpecker.org.cn:9081/classes/050925-CPUG/django_reference_sheet.pdf#search=%22django%20reference%20sheet%22
http://code.djangoproject.com/wiki/DjangoCheatSheet

Chris


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



Re: models: There has to be a better way.

2006-09-23 Thread [EMAIL PROTECTED]

I just do it like this

Backup the table ( ehem , i usually skip this )

Change the model
Run manage.py sql appname and see what fields are added.

Get the table name, column name and type

Then just run (postgresql, not much different in mysql i guess):

alter table appname_modelname add column "column_name" column_type;

if it is a not null column

update appname_modelname set  "column_name" "somedefaultvalue";
alter table appname_modelname alter column "column_name" set not null;

Then you are done :)


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



Re: My Ratings System

2006-09-23 Thread [EMAIL PROTECTED]

To add to this I wouldn't mind also making it include the ratingrel
table in the query (or seperate manager, maybe an option inside that
manager) so we can check if they user has already rated that object.


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



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


class Product(models.Model):
asin = models.CharField(maxlength=200)
title =  models.CharField(maxlength=200, db_index=True)
catalog  =  models.CharField(maxlength=200, default='',  db_index=True)


class MetaCategory(models.Model):
name =  models.CharField(maxlength=200, core=True,  db_index=True,  
unique=True)

class KnownCategory(models.Model):
meta_category = models.ManyToManyField(MetaCategory)
fk_name = models.ForeignKey(Product, to_field='catalog')


...from the above... I was trying to do something like this...

 >>> p = Product.objects.filter(metacategory__name='Book')
 >>> p
Traceback (most recent call last):
   File "", line 1, in ?
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 97, in __repr__
 return repr(self._get_data())
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 430, in _get_data
 self._result_cache = list(self.iterator())
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 171, in iterator
 select, sql, params = self._get_sql_clause()
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 444, in _get_sql_clause
 joins2, where2, params2 = self._filters.get_sql(opts)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 574, in get_sql
 joins2, where2, params2 = val.get_sql(opts)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 622, in get_sql
 return parse_lookup(self.kwargs.items(), opts)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 734, in parse_lookup
 joins2, where2, params2 = lookup_inner(path, lookup_type, value,  
opts, opts.db_table, None)
   File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Django-0.95-py2.4.egg/django/db/models/ 
query.py", line 835, in lookup_inner
 raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError: Cannot resolve keyword 'metacategory' into 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
-~--~~~~--~~--~--~---



Re: models: There has to be a better way.

2006-09-23 Thread [EMAIL PROTECTED]

Tom,
  Many of us are in the same boat.  I wish that functionality was
allready in Django, but for the moment it's in que.  Here is a link to
the Wiki entry talking about it:
http://code.djangoproject.com/wiki/SchemaEvolution

The SOC project has produced some code, but it needs some more testing.
 If you have any spare time, could you take this for a test drive?

Here is a link to the schema evolution branch:

http://code.djangoproject.com/browser/django/branches/schema-evolution

-- Nick Pavlica


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



Re: Django Cheat Sheet - Lost?

2006-09-23 Thread [EMAIL PROTECTED]

Jon,
  I'm not sure, but I think that it was removed because it wasn't up to
date.  I have been working on my own cheat sheet, but it isn't ready
for public consumption just yet.  

-- Nick Pavlica


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



Django Cheat Sheet - Lost?

2006-09-23 Thread Jon Atkinson

Hi all,

I've been looking for a copy of the Django cheat sheet (previous URL:
http://www.dobbes.com/media/pdfs/django_reference_sheet.pdf), but that
resource seems to have disappeared. Does anyone have a copy of this?

--Jon

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



Re: Akismet strikes again

2006-09-23 Thread [EMAIL PROTECTED]

Holger Schurig wrote:
> I tried to remove the link
>
>Django API (Beta): Automatic generated API using epydoc
>
> from the WikiStart page. However, some SPAM protection tool
> called "Akismet" prevented me from doing this.

I have run into the same issue.  It would be nice if someone would look
into this.

--Nick Pavlica


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



My Ratings System

2006-09-23 Thread [EMAIL PROTECTED]

I'm creating a digg-like rating system, where users can vote an object
up or down. The system is generalized as to where you can simply plug
it into any object you want.

I have 2 models:

class Score(models.Model):
content_type = models.ForeignKey(ContentType,
related_name="score_target_type", db_index=True)
object_id = models.IntegerField(db_index=True)
thumbs_up = models.SmallIntegerField(default=0)
thumbs_down = models.SmallIntegerField(default=0)

class Admin:
list_display = ('object_id', 'content_type')
list_filter = (['content_type'])

def get_score(self):
return self.thumbs_up / (self.thumbs_up + self.thumbs_down)

class RatingRel(models.Model):
content_type = models.ForeignKey(ContentType,
related_name="rating_target_type", db_index=True)
object_id = models.PositiveIntegerField(db_index=True)
object = models.GenericForeignKey()

user = models.ForeignKey(UserExt, null=True, db_index=True)
ip = models.IPAddressField()
score = models.CharField(maxlength=1, choices=SCORE_CHOICES)
post_date = models.DateTimeField(auto_now = True, editable = False)

It could also be setup where ratingrel just points to the row in score
(might change that yet). Anyways, it inserts a row into RatingRel,
score (by default) being 1 or 0, and it then basically does a replace
into on score, updating the tally (which we will probably remove
thumbs_up and thumbs_down and just replace w/ "score" so its more
generic).

Ok so this all works great, i can easily use my get_rating, or
set_rating on any object. Now my problem comes when I want to pull all
scores for all objects im selecting. To make this quick, I don't want
to query each object in my list, I want to do a join from my object and
the score's table.

The best solution I can see, is a manager, where you could do like
MyObject.objects_with_score.all(). Now this is my problem... how do I
do this?

I want the manager to basically select * from myobject a left join
score b (at least thats how I think it should be done).

Anyone?


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



Re: models: There has to be a better way.

2006-09-23 Thread Clint Ecker

Please do a  search for 'schema-evolution' on the dev list.  It's been
discussed ad nauseum and there was a project with Google's SoC to
address the issue.  The code, as far as i know, is complete and
waiting in a seperate branch for testing before being merged into the
main trunk.

Clint


On 9/23/06, Tom Smith <[EMAIL PROTECTED]> wrote:
> 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 again. My problems are partly
> because I am using MAMP and for the life of me can't work out how to give
> myself full privileges when using mysqladmin.. another part is because it is
> quite easy to get in a muddle because I do it so often.
>
> You could say, "well, design your databases first", but I just don't work
> like that...
>
> Most of the time I just need to add an extra field (which shouldn't be too
> complicated should it?)
>
> Sometimes I'd like to change something about the field (adding an index to
> it for example) which I almost could do "under" the django models without it
> knowing about.
>
> Are there any approaches or tools I should know about when dealing with what
> is a common problem for me of regularly evolving models.py and lots of data?
>
> thanks
>
> tom
>
>
>
>
>
>  >
>


-- 
Clint Ecker | STONE WARD
440 N. Wells, Suite 750, Chicago, IL 60610
Boston | [ Chicago ] | Little Rock
www.stoneward.com

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



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 again. My problems are partly because I am using MAMP and for the life of me can't work out how to give myself full privileges when using mysqladmin.. another part is because it is quite easy to get in a muddle because I do it so often.You could say, "well, design your databases first", but I just don't work like that...Most of the time I just need to add an extra field (which shouldn't be too complicated should it?)Sometimes I'd like to change something about the field (adding an index to it for example) which I almost could do "under" the django models without it knowing about.Are there any approaches or tools I should know about when dealing with what is a common problem for me of regularly evolving models.py and lots of data?thankstom 
--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---



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 Django use mysql Views? If so, how would I access them?
2. Are mysql Views what I think they are... are they a "live" take  
on the data or just dumped into a table once?

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



Re: import opml file

2006-09-23 Thread Jon Atkinson

Upload to where? For what? There isn't really enough information in
this and the previous posts in this thread to get any sensible answer
:-)

--Jon

On 9/23/06, a <[EMAIL PROTECTED]> wrote:
> is there an easy way to upload opml files
> thanks
> Jon Atkinson wrote:
> > I've found that using XMLObject
> > (http://www.freenet.org.nz/python/xmlobject/) is a simple way to get
> > the feed information from an OPML feed, then you can read the feed
> > however you like (e.g. with Feedparser (www.feedparser.org)).
> > Something like this should get you started:
> >
> > from xmlobject import XMLFile
> >
> > opml = XMLFile(path="/path/to/file.opml")
> >
> > for person in x.root.body.outline:
> >   print "Name: " + str(person.text)
> >   print "Feed: " + str(person.xmlUrl)
> >
> > --Jon
> >
> > On 26/08/06, a <[EMAIL PROTECTED]> wrote:
> > >
> > > feedjack is a lot of stuff, it exports opml but it doesnt import opml
> > > any ideas for importing opml
> > > > > you might want to check out FeedJack http://www.feedjack.org/
> > > > > it's done a lot of stuff in that area.
> > > > >
> > > > > regards
> > > > > Ian
> > > > >
> > > > > On 24/08/2006, at 5:42 PM, a wrote:
> > > > >
> > > > > >
> > > > > > hi guys how do i import opml file in django
> > > > > > using syndication
> > > > > >
> > > > > > i m tryin to build an rss reader
> > > > > > thanks
> > > > > >
> > > > >
> > > > > --
> > > > > Ian Holsman
> > > > > [EMAIL PROTECTED]
> > > > > http://personalinjuryfocus.com/
> > >
> > >
> > > >
> > >
>
>

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



Re: seeking clarification: custom manipulator foreign key / many-to-many

2006-09-23 Thread patrickk

still learning ...
btw, it works fine now.

thanks,
patrick

Am 23.09.2006 um 12:45 schrieb Ivan Sagalaev:

>
> patrickk wrote:
>> thanks, I think I´ve got it now.
>>
>> the documentation of custom manipulators really lacks advanced  
>> examples.
>> I don´t know how one should find out what you explained in the last
>> few mails by reading the documentation.
>> e.g., I´m quite sure that there´s no explanation of "_meta" in the
>> documentation
>
> Indeed. But you should never underestimate value of reading code in
> Python :-). Docs are good but they never cover everything...
>
> >


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



Re: seeking clarification: custom manipulator foreign key / many-to-many

2006-09-23 Thread Ivan Sagalaev

patrickk wrote:
> thanks, I think I´ve got it now.
> 
> the documentation of custom manipulators really lacks advanced examples.
> I don´t know how one should find out what you explained in the last  
> few mails by reading the documentation.
> e.g., I´m quite sure that there´s no explanation of "_meta" in the  
> documentation

Indeed. But you should never underestimate value of reading code in 
Python :-). Docs are good but they never cover everything...

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



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//
http://pythonmac.org/packages/py24-fat/index.html

Then to client to MySQL I use Cocoa MySQL SBG http:// 
www.theonline.org/cocoamysql/ which I can also connect over shh to  
remote databases.

And although these MySQL Tools get a few bad comments on  
VersionTracker, so far I think they are fab...
http://www.versiontracker.com/dyn/moreinfo/macosx/26085

To edit the Python and HTML I use TextMate ...
http://macromates.com/
Because I can create a project file and have numerous settings.py,  
results.html files open in one window.



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



Re: date filter behaviour

2006-09-23 Thread Malcolm Tredinnick

On Sat, 2006-09-23 at 01:52 -0700, Rudolph wrote:
> Hi,
> 
> When I have datetime field with the value "1000-1-1 00:00:00" and I
> have a template which has:
> {{ datetime_field|date:"j F Y" }}
> I get a ValueError: year out of range. But when I do:
> {{ datetime_field.date|date:"j F Y" }}
> it works okay (except that I lost the time values if I wanted to use
> them).

You've found a way to work around ticket #1443. I'm not really sure what
the true solution is there, but at some point I'd like to fix things so
that we can use dates prior to 1900, so I'm keeping a small eye on that
bug.

Regards,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



date filter behaviour

2006-09-23 Thread Rudolph

Hi,

When I have datetime field with the value "1000-1-1 00:00:00" and I
have a template which has:
{{ datetime_field|date:"j F Y" }}
I get a ValueError: year out of range. But when I do:
{{ datetime_field.date|date:"j F Y" }}
it works okay (except that I lost the time values if I wanted to use
them).

Anyone any idea?

Rudolph


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



Re: How to test Validatidators

2006-09-23 Thread Malcolm Tredinnick

On Fri, 2006-09-22 at 23:46 -0700, Maximillian Dornseif wrote:
> I'm struggeling to build tests for (custom) validators - see
> http://www.djangoproject.com/documentation/forms/#validators for the
> basics.
> 
> To my understanding there  are two kinds of validators:
> 
> a) Validators inherent  to a Field type, e.g. isValidEmail for
> EmailField
> b) custom validators set via validator_list
> 
> Every model has a function validate() which calls the type a)
> validators for all fields in the model.

This function exists, but it isn't actually called in normal processing.
This was an early attempt to fix up model-aware validation and try to
eliminate some of the manipulator stuff. It is still very ongoing work,
so ignore the validate() method for now.

>  But how do I get a model to
> call all of it's type b) validators?

In order to test your validator, you really just need to create the
'data' string and all_data dictionary that a validator normally would
receive and call it. That would be the most basic unittest for a
validator I can think of: you pass controlled data to it and test that
it raises exceptions at the right point.

If you want to test it as though it were part of a form validation --
and validators are all tied up with form validation, not with models;
the fact that you get some default form fields as part of the models
default manipulator is just a shortcut -- it might help to understand a
little about how a call to manipulator.get_validation_errors() works:

All validators are treated the same, whether you write them yourself or
they are "defaults" for the form field. The default validators are just
inserted in the __init__ method of the relevant form field classes (have
a look, for example, in django//forms/__init__.py at the __init__ method
for the EmailField.

At the end of the chain of events kicked off by a call to
Manipulator.get_validation_errors() -- which is how you end up running
your validators against the form fields -- each validator from the
fields validator_list attribute is passed, in turn, to
field.run_validator(), along with the data to be evaluated. This call is
made by the get_validation_errors() method on the *field* (not the form;
the form calls each field's method).

So, given a FormField sub-class, you create your form data (which can
include data not relevant to this particular field) and then call
field.get_validation_errors(data).

Hope this gives you some ideas about the testing possibilities you have
available here. Again, all validators are really the same. You can call
them just as functions, although some of them are class methods, so you
would need to call those ones on an instance.

Regards,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: One-To-Many doesn't return a list.

2006-09-23 Thread Malcolm Tredinnick

Nothing jumps out at me, but here are a few ideas about how to debug
this...

On Fri, 2006-09-22 at 22:44 -0700, Tyson Tate wrote:
> I've got the following model:
> 
> http://paste.e-scribe.com/1666/

What happens when you reduce the example to something smaller? Does it
go away? What is the last thing you change before it goes away? If the
problem never goes away, you should end up with a two line example you
can paste in an email that we can turn into a test case, but I suspect
it won't get that far.

> And I'm trying to run the following in the Event object's  
> object_detail generic view template:
> 
> {% for slot in object.signupslot_set.all %}

So what does {{ object.signupslot_set.all }} display in the template
(you may need to "view source" to see the output precisely, since if it
contains angle brackets it will be interpreted as some invalid HTML
tag)? Do you get any different behaviour if you pass in a context
variable containing the value of objects.signupslot_set.all() that you
computed in your view?

These would all help you get a bit closer to working out what is going .

Regards,
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---