Re: "... is an invalid model parameter" -- huh?

2006-02-09 Thread Tobias

Thanks for answering so fast.

I didn't see this anywhere, but I didn't understand how it is supposed
to work after reading
http://www.djangoproject.com/documentation/db_api/#many-to-one-relations
(just behind the one-to-one part, but obviously not working in a
similar way), and I don't understand yet the name mangling, the
assumptions about fields etc. which Django does; being a Django newbie
(with some Python programming experience), this still looks like Voodoo
to me.

Tobias



Re: "... is an invalid model parameter" -- huh?

2006-02-09 Thread Adrian Holovaty

On 2/9/06, Tobias <[EMAIL PROTECTED]> wrote:
> class KeyData(meta.Model):
> orga_id = meta.ForeignKey(Unternehmen, db_column='id')
> keyd_year = meta.IntegerField()
> # ...
> id = meta.IntegerField(primary_key=1)
> # this causes the error:
> the_unternehmen = meta.ManyToOne(unternehmens.Unternehmen, 'id')

You want this instead:

the_unternehmen = meta.ForeignKey(unternehmens.Unternehmen)

You're never supposed to use meta.ManyToOne directly -- if you let me
know where you saw that, I will correct the documentation.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


"... is an invalid model parameter" -- huh?

2006-02-09 Thread Tobias

Hi,

I get a very strange (and not very helpful, at least to a Django
newbie) error message when trying to establish a ManytoOne-relation.

This is what I have:


class Unternehmen(meta.Model):
id = meta.IntegerField(primary_key=1)
# ...

class KeyData(meta.Model):
orga_id = meta.ForeignKey(Unternehmen, db_column='id')
keyd_year = meta.IntegerField()
# ...
id = meta.IntegerField(primary_key=1)
# this causes the error:
the_unternehmen = meta.ManyToOne(unternehmens.Unternehmen, 'id')


This causes the following error (Traceback):


Unhandled exception in thread started by 
Traceback (most recent call last):
  File
"c:\programme\python\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\management.py",
line 757, in inner_run
validate()
  File
"c:\programme\python\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\management.py",
line 741, in validate
num_errors = get_validation_errors(outfile)
  File
"c:\programme\python\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\management.py",
line 634, in get_validation_errors
import django.models
  File
"c:\programme\python\python24\lib\site-packages\django-0.91-py2.4.egg\django\models\__init__.py",
line 13, in ?
modules = meta.get_installed_model_modules(__all__)
  File
"c:\programme\python\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py",
line 111, in get_installed_model_modules
mod = __import__('django.models.%s' % submodule, '', '', [''])
  File
"D:\vdb-Ostendorf\Django\prod\..\prod\wwe_evus\models\wwe_evus.py",
line
144, in ?
class KeyData(meta.Model):
  File
"c:\programme\python\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\meta\__init__.py",
line 699, in __new__
assert callable(v), "%r is an invalid model parameter." % k
AssertionError: 'the_unternehmen' is an invalid model parameter.


The ModelBase __new__ method seems to complain that "the_unternehmen"
is not callable -- but I'm just about to create it... To me, this error
is not understandable at all.

Can please somebody help me? Thanks!

Tobias