Hi, im using django 1.0+mysql
I get an unexpected error:
"'event' is an invalid keyword argument for this function"
I get using a django view which used to work for moving data into the
mysql db by saving a foreign key
instance of 'Event' in 'Category'.
1. The model is:
class Event (models.Model):
added = models.DateTimeField()
addedBy = models.IntegerField()
contact = models.CharField(max_length=100)
email = models.CharField(max_length=100)
phoneBH = models.CharField(max_length=30)
phoneAH = models.CharField(max_length=30)
phoneFax = models.CharField(max_length=30)
phoneM = models.CharField(max_length=30)
url = models.CharField(max_length=100)
title = models.CharField(max_length=100)
description = models.TextField()
def __unicode__(self):
return u"%s %s %s %s %s %s %s %s %s %s %s %s"%(self.added,
self.addedBy, self.contact, self.email, self.phoneBH, self.phoneAH,
self.phoneFax, self.phoneM, self.url, self.title, self.cost,
self.description)
class Category (models.Model):
event = models.ForeignKey(Event)
name = models.CharField(max_length=40)
def __unicode__(self):
return u"%s"%(self.name)
2. The piece of code which produces the error in the view:
>> events_category = Category(name=new_event_tag, event=events_event)
events_category.save()
#note events_event is just a saved instance of Event()
3. The behaviour of the error is such that if i rename the 'Category'
model to something else eg: 'Category2', drop the table and then
syncdb and run it again then i dont get the error. However if it is
called 'Category' then for some reason it does not work. Of course the
downside here is id have to go through and rename all usage of the
Category model in my views to the new class which with my project will
take a long time.
4. here is the error, its the usual sort of thing you get trying to
insert the wrong variable name into the model only it is the correct
name. I am familiar with what django docs say about the error and it
should be recognising the Foreign key 'event' being in Category but it
doesnt! I just hope im forgetting something easy
---------------------------------------------------------------------------------------------
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/eventmigrate/
Exception Type: TypeError
Exception Value:
'event' is an invalid keyword argument for this function
Exception Location:
/var/lib/python-support/python2.5/django/db/models/base.py in
__init__, line 265
Python Executable: /usr/bin/python
Python Version: 2.5.2
---------------------------------------------------------------------------------------------
5. I have a feeling something is wrong with mysql or django manage.py
is not building the table properly... any troubleshooting advice would
go a long way to helping me :)
In addition here is what "python manage.py inspectdb" says about Category:
---------------------------------------------------------------------------------------------
class EventsCategory(models.Model):
id = models.IntegerField(primary_key=True)
event_id = models.IntegerField()
name = models.CharField(max_length=120)
class Meta:
db_table = u'events_category'
cheers
---sam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---