Re: Problems creating model.

2006-04-19 Thread Michael Radziej

Russell Keith-Magee schrieb:
> Unfortunately, this isn't possible in 0.91/trunk. However, in the
> magic-removal stream, you can forward reference a model using the string
> version of the model name.

No, not really. The only string is "self" ;-)

I tried it a few weeks ago. But if you can correct me, I would be really 
happy. Since I have circular dependencies in an ugly old database, I'll 
probably start to work on a way to implement forward references, but 
this will need a few weeks before I can even start.

Michael

--~--~-~--~~~---~--~~
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: Accessing custom managers in O2M2O / using RelatedManager

2006-04-19 Thread Luke Plant


> Am I approaching the problem in the wrong way? how can i access custom
> manager functions for Bar, via baz? It throws an error complaining of
> RelatedManager...how can I write my own RelatedManager?

What error does it throw?

Luke


--~--~-~--~~~---~--~~
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 soon will a stable magic-removal version probably be released?

2006-04-19 Thread flyaflya

Several days? several weeks? several months? or several years?
If too far,I will use 0.91 version.

--
http://www.flyaflya.com powered by pygame+python

--~--~-~--~~~---~--~~
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 soon will a stable magic-removal version probably be released?

2006-04-19 Thread Russell Cloran

Hi,

Have a look at :
http://groups.google.com/group/django-developers/browse_thread/thread/ea36b87b30cc9e1/34d4734058c2285e

Russell

On Wed, 2006-04-19 at 17:17 +0800, flyaflya wrote:
> Several days? several weeks? several months? or several years?
> If too far,I will use 0.91 version.
> 
> --
> http://www.flyaflya.com powered by pygame+python
> 
> > 


--~--~-~--~~~---~--~~
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: Custom Manipulator

2006-04-19 Thread PythonistL

Ian,
Thanks for your reply.
I implemented custom manipulator for ADDing but do not know how to do
that for CHANGING.

class ProductManipulator(formfields.Manipulator):# ADD  manipulator
 def __init__(self):
 .
   
def save(self,data):
  
..
#
In my code I  call it like this

manipulator = ProductManipulator()

then later
  new_trade = manipulator.save(new_data)
where new_data are supplied by a user via a form.

As to CHANGE manipulator, I do not know how to fill in (prepopulate)the
form with the data, being changed, from the database. Any idea?

Thanks for reply and help
L.


--~--~-~--~~~---~--~~
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: Problems creating model.

2006-04-19 Thread Russell Keith-Magee

On 4/19/06, Michael Radziej <[EMAIL PROTECTED]> wrote:
>
> Russell Keith-Magee schrieb:
> > Unfortunately, this isn't possible in 0.91/trunk. However, in the
> > magic-removal stream, you can forward reference a model using the string
> > version of the model name.
>
> No, not really. The only string is "self" ;-)

To clarify my point:

0.91 - "self" is the only string
magic-removal: "self" and "model-name" are allowed

If you have a use case in magic-removal where "self" is the only
allowed string, then you have probably found a bug. Is this the case,
or have we got some wires crossed?

Russ Magee %-)

--~--~-~--~~~---~--~~
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: Problems creating model.

2006-04-19 Thread Michael Radziej

Russell Keith-Magee schrieb:
> On 4/19/06, Michael Radziej <[EMAIL PROTECTED]> wrote:
>>No, not really. The only string is "self" ;-)
> 
> 
> To clarify my point:
> 
> 0.91 - "self" is the only string
> magic-removal: "self" and "model-name" are allowed
> 
> If you have a use case in magic-removal where "self" is the only
> allowed string, then you have probably found a bug. Is this the case,
> or have we got some wires crossed?

I'm not sure I'm following your words correctly, being a non-native 
writer ...

Take this model (magic-removal)

---
class Wenga(models.Moldel):
...

class Benga(models.Model):
wenga = ForeignKey("Wenga")



is this supposed to work?
Or even:

---
class Benga(models.Model):
wenga=ForeignKey("Wenga")

class Wenga(models.Model):
...



Last time I checked, none of this worked. If you say this is a bug, I 
will check it again. But I'd be highly surprised, since I didn't find 
anything in the meta class that would be able to deal with forward 
references. But, hey, I really only poked around.

Michael

--~--~-~--~~~---~--~~
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: possible to filter ManyToMany results?

2006-04-19 Thread nkeric

Luke Plant wrote:
> As I understand it, Django should be able to do this query no problem.
> I think there may be a mistake in what you posted though - IIRC, I
> would have expected the method name to be 'get_articles_list' not
> 'get_article_list', since you defined it as 'articles =
> meta.ManyToManyField(Article)'.  If you post the entire code for your
> models we may be able to find the problem.  Magic-removal branch
> doesn't really change what is possible here, it just changes the
> syntax.
>

hi Luke, Ivan!

I've migrated my new app to the m-r branch, it's AWESOME!

it's really simple to get things done:

[code]
gamesku = GameSku.objects.get(pk=gamesku_id)
article_list =
gamesku.articles.filter(article_type__name__exact=article_type).order_by('-submit_date')
[/code]

that's what I want :D

and, here is my **old** models definition, I don't know if it's
possible to do so with django trunk:

class ArticleType(meta.Model):
name = meta.CharField(maxlength=128)
display_name = meta.CharField(maxlength=128)
display_order = meta.IntegerField(blank=False)
description = meta.CharField(maxlength=2048)

class Article(meta.Model):
user = meta.ForeignKey(auth.User)
article_type = meta.ForeignKey(ArticleType)
title = meta.CharField(_('title'), maxlength=255, blank=False)
description = meta.TextField(_('description'), maxlength=500)
content = meta.TextField(_('content'), maxlength=3000)
submit_date = meta.DateTimeField(_('date/time submitted'),
auto_now_add=True)

class GameSku(meta.Model):
game = meta.ForeignKey(Game)
platform = meta.ForeignKey(GamingPlatform)
developer = meta.ForeignKey(Company, verbose_name='Developer')
publisher = meta.ForeignKey(Company, verbose_name='Publiser')
name = meta.CharField(maxlength=128)
articles = meta.ManyToManyField(Article)

the sql I wrote to get what I want is:

sql = "select distinct articles.id as id from articles, article_type,
game_sku_articles, game_sku where article_type.name =
'%(article_type)s' and articles.article_type_id = article_type.id and
game_sku.id = '%(gamesku_id)d' and game_sku_articles.gamesku_id =
game_sku.id and game_sku_articles.article_id = articles.id" % locals()

I was wondering how to "get a spefic type of articles of a gamesku
while gamesku & articles' relationship is many-to-many" in django
trunk..

BiG thanks to all you guys!

I used to be someone who didn't like django's ORM stuff, however, in
the new m-r branch, with brand-new ORM support and transaction support,
I'm LOVING it! 

Django rocks! :)

- nkeric


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



mange.py sql weirdness in MR

2006-04-19 Thread njharman

[Sorry if this should be on django-developer instead]

r2714 of the magic-removal branch

I have models/* and not a models.py in my app directory.

#myapp/models/__init__.py
from adventure import Story
class Foo(models.Model):
pass

'manage.py sql' produces output for Foo model but not Story model.  If I
copy Story to __init__.py or move everything to models.py output is
produced correctly.

Is this intended?


btw my version, 5.0, of MySQL doesn't grok the update core database
tables to magic_removal sql found here
http://code.djangoproject.com/wiki/RemovingTheMagic#Newfunctionalityyoucanstartusing

  ALTER TABLE django_content_type rename package to app_label;
  ALTER TABLE django_content_type rename python_module_name to model;

change to something like:

  ALTER TABLE django_content_type change package app_label varchar(100)
not null;
  ALTER TABLE django_content_type change python_module_name model
varchar(100) not null;

-- 
norm
Happy Prickle-Prickle, 3172 Discord 36

--~--~-~--~~~---~--~~
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: Problems creating model.

2006-04-19 Thread njharman

Russell Keith-Magee wrote:
> If you have a use case in magic-removal where "self" is the only
> allowed string, then you have probably found a bug. Is this the case,

[Jumpin into youses conversation with just such a bug]

class Foo(models.Model):
myfield = models.OneToOneField('SomeModel', to_field='id')

Works.

class Foo(models.Model):
myfield = models.OneToOneField('SomeModel')

Fails because whatever "turns" 'SomeModel' from string into class object
hasn't happened when code in
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/fields/related.py
on line 510 tries to determine default to_field.

--
norm
"Zhuangzi dreamed he was a butterfly" -- Zhuangzi


--~--~-~--~~~---~--~~
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: Custom Manipulator

2006-04-19 Thread Ian Clelland

On 4/19/06, PythonistL <[EMAIL PROTECTED]> wrote:
> As to CHANGE manipulator, I do not know how to fill in (prepopulate)the
> form with the data, being changed, from the database. Any idea?

If you want to pre-populate the form data, you just need to be able to
set new_data to hold the data from the object being changed, for when
you create a FormWrapper.

The documentation examples just do this by setting
new_data=original.__dict__, to put all of the object's fields into
new_data.

The general flow for the view is just:

manipulator = CustomChangeManipulator(object_key)
original = manipulator.original
if request.POST:
# code here exactly like for AddManipulator
else:
errors = {}
new_data = original.__dict__
# generate and present form just like AddManipulator


Regards,
Ian Clelland
<[EMAIL PROTECTED]>

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



Foriegn Key data retrieval question...

2006-04-19 Thread Esteban

I am trying to do something pretty basic here -- I even worked out how
to do it earlier but now I have forgotten so I need a nudge in the
right direction.

I have a model set up where an item has an owner, simple foreign key
relationship.  I have checked everything I modeled works nicely in the
Admin and now I am moving to making my own views.

In my view I want to pull the owner name for a given article.  I
remember earlier this was pretty simple but in my haste to get the rest
of the data modeled I have forgotten the syntax.  Any pointers would be
gratefully received.


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



Field Description in FormWrappers

2006-04-19 Thread Fawad Halim

Hi,
Is it possible to retrieve the description of a field in a FormWrapper
in the template? I'm able to get the field name using {{
form.field.field_name }}, but I'd like the verbose name to appear on the
form.

Regards
-fawad

--~--~-~--~~~---~--~~
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: maxlength in the Admin site

2006-04-19 Thread argus

Is there any reason that there's not a way to specify/override the size
of the form field that gets used in templates (separately from what
gets used in the admin interface)?  I can't think of one, and it's been
something of a thorn in my side recently, so I figured I'd ask :)  I'm
reluctant to hack into the Django source for something so trivial, but
I'm getting closer to doing so..


--~--~-~--~~~---~--~~
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: maxlength in the Admin site

2006-04-19 Thread Joseph Kocherhans

On 4/19/06, argus <[EMAIL PROTECTED]> wrote:
>
> Is there any reason that there's not a way to specify/override the size
> of the form field that gets used in templates (separately from what
> gets used in the admin interface)?  I can't think of one, and it's been
> something of a thorn in my side recently, so I figured I'd ask :)  I'm
> reluctant to hack into the Django source for something so trivial, but
> I'm getting closer to doing so..

As lame as it sounds, you're right. There isn't a clean way to do it.
I know it was discussed on the list not too long ago (or maybe it was
django-dev), but I don't think much came out of it. Here's a link
anyhow:

http://groups.google.com/group/django-users/browse_frm/thread/4f6e2e0c936dcca5/7e7c0a7b2b168bd5?tvc=1&q=field+length#7e7c0a7b2b168bd5

That said, if you can come up with a nice way to do this, patches and
ideas are welcome.

Joseph

--~--~-~--~~~---~--~~
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: maxlength in the Admin site

2006-04-19 Thread Joseph Kocherhans

On 4/19/06, Joseph Kocherhans <[EMAIL PROTECTED]> wrote:
> On 4/19/06, argus <[EMAIL PROTECTED]> wrote:
> >
> > Is there any reason that there's not a way to specify/override the size
> > of the form field that gets used in templates (separately from what
> > gets used in the admin interface)?  I can't think of one, and it's been
> > something of a thorn in my side recently, so I figured I'd ask :)  I'm
> > reluctant to hack into the Django source for something so trivial, but
> > I'm getting closer to doing so..
>
> As lame as it sounds, you're right. There isn't a clean way to do it.
> I know it was discussed on the list not too long ago (or maybe it was
> django-dev), but I don't think much came out of it. Here's a link
> anyhow:
>
> http://groups.google.com/group/django-users/browse_frm/thread/4f6e2e0c936dcca5/7e7c0a7b2b168bd5?tvc=1&q=field+length#7e7c0a7b2b168bd5

Wow... that's this thread! (Time for me to sleep.)

> That said, if you can come up with a nice way to do this, patches and
> ideas are welcome.

This still applies :)

--~--~-~--~~~---~--~~
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: maxlength in the Admin site

2006-04-19 Thread argus

Actually, it was really easy.  As in "four lines" easy.  I haven't done
extensive testing with it, but a quick run through seems to demonstrate
that it does what I want it to do.

Best of all, you only have to modify one file -- core/meta/fields.py:
1) Add a new param "length=None" to the __init__ declaration for the
base Field class, around lines 105-111

2) in the __init__ method, add a line to use the new param:
"self.length = length" (I added this right after the line that grabs
the maxlength param, cause it made sense to me there)

3) tweak the get_manipulator_fields method around line 230 to make use
of the new "self.length" attribute.  Add the following lines (with
corrected indenting, of course):

if self.length:
params['length'] = self.length

You should end up with something like:

if self.maxlength and not self.choices:
params['maxlength'] = self.maxlength
if self.length:
params['length'] = self.length


That's it.  Now you can use a "length" param in your model
declarations, like:
class Poll(meta.Model):
question = meta.CharField(maxlength=200, length=4)

The result is what you'd expect: the resulting HTML form field used in
the admin interface has its "size" attribute set to "4".


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



Trac error on code.djangoproject.com

2006-04-19 Thread Nebojsa Djordjevic

http://code.djangoproject.com/

Oops...

Trac detected an internal error:

database is locked
Traceback (most recent call last):
  File "/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", line 
206, in handler
dispatch_request(mpr.path_info, mpr, env)
  File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 139, in 
dispatch_request
dispatcher.dispatch(req)
  File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 80, in dispatch
req.perm = PermissionCache(self.env, req.authname)
  File "/usr/lib/python2.3/site-packages/trac/perm.py", line 276, in __init__
self.perms = PermissionSystem(env).get_user_permissions(username)
  File "/usr/lib/python2.3/site-packages/trac/perm.py", line 132, in 
get_user_permissions
for perm in self.store.get_user_permissions(username):
  File "/usr/lib/python2.3/site-packages/trac/perm.py", line 213, in 
get_user_permissions
cursor.execute("SELECT username,action FROM permission")
  File "/usr/lib/python2.3/site-packages/trac/db.py", line 219, in execute
args or [])
  File "/usr/lib/python2.3/site-packages/trac/db.py", line 211, in 
_rollback_on_error
return function(self, *args, **kwargs)
OperationalError: database is locked


-- 
Nebojša Đorđević - nesh
Studio Quattro - Niš - SCG
http://studioquattro.biz/
http://djnesh.blogspot.com/  |  http://djnesh-django.blogspot.com/ |  
http://djangoutils.python-hosting.com/
Registered Linux User 282159 [http://counter.li.org]

--~--~-~--~~~---~--~~
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: Trac error on code.djangoproject.com

2006-04-19 Thread limodou

On 4/20/06, Nebojsa Djordjevic <[EMAIL PROTECTED]> wrote:
>
> http://code.djangoproject.com/
>
> Oops...
>
> Trac detected an internal error:
>
> database is locked
> Traceback (most recent call last):
>   File "/usr/lib/python2.3/site-packages/trac/web/modpython_frontend.py", 
> line 206, in handler
> dispatch_request(mpr.path_info, mpr, env)
>   File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 139, in 
> dispatch_request
> dispatcher.dispatch(req)
>   File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 80, in 
> dispatch
> req.perm = PermissionCache(self.env, req.authname)
>   File "/usr/lib/python2.3/site-packages/trac/perm.py", line 276, in __init__
> self.perms = PermissionSystem(env).get_user_permissions(username)
>   File "/usr/lib/python2.3/site-packages/trac/perm.py", line 132, in 
> get_user_permissions
> for perm in self.store.get_user_permissions(username):
>   File "/usr/lib/python2.3/site-packages/trac/perm.py", line 213, in 
> get_user_permissions
> cursor.execute("SELECT username,action FROM permission")
>   File "/usr/lib/python2.3/site-packages/trac/db.py", line 219, in execute
> args or [])
>   File "/usr/lib/python2.3/site-packages/trac/db.py", line 211, in 
> _rollback_on_error
> return function(self, *args, **kwargs)
> OperationalError: database is locked
>
>

Retry it. I think it'll be ok.


--
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

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