From looking around at the code and at some other modules/answers on this site, I attempted to use the following in a module models.py class. Node.add_to_class('test', models.IntegerField(default=0))

I used this methodology to add to the Action model and it was successful, but when I try it with the Node class I get the error below when trying to add a question. I checked and this did create the field correctly in the database

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/questions/ask/
Django Version: 1.2.1
Python Version: 2.7.0

Traceback:
File "C:\\Python27\\lib\\site-packages\\django-1.2.1-py2.7.egg\\django\\core\\handlers\\base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "C:\\dev\\epon\\forum\\modules\\decorators.py" in __call__
  52.         res = self._callable(*args, **kwargs)
File "C:\\dev\\epon\\forum\\modules\\decorators.py" in <lambda>
  30.                 self._callable = lambda *args, **kwargs: fn(origin, *args, **kwargs)
File "C:\\dev\\epon\\forum_modules\\akismet\\startup.py" in wrapper
  53.         return origin(request, *args, **kwargs)
File "C:\\dev\\epon\\forum\\views\\writers.py" in ask
  80.                     ask_action = AskAction(user=request.user, ip=request.META['REMOTE_ADDR']).save(data=form.cleaned_data)
File "C:\\dev\\epon\\forum\\models\\action.py" in save
  128.             self.process_data(**data)
File "C:\\dev\\epon\\forum\\actions\\node.py" in process_data
  23.         question.save()
File "C:\\dev\\epon\\forum\\models\\node.py" in save
  378.             super(BaseModel, self).save(*args, **kwargs)
File "C:\\Python27\\lib\\site-packages\\django-1.2.1-py2.7.egg\\django\\db\\models\\base.py" in save
  435.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "C:\\Python27\\lib\\site-packages\\django-1.2.1-py2.7.egg\\django\\db\\models\\base.py" in save_base
  479.                 self.save_base(cls=parent, origin=org, using=using)
File "C:\\Python27\\lib\\site-packages\\django-1.2.1-py2.7.egg\\django\\db\\models\\base.py" in save_base
  518.                         for f in meta.local_fields if not isinstance(f, AutoField)]
File "C:\\Python27\\lib\\site-packages\\django-1.2.1-py2.7.egg\\django\\db\\models\\fields\\__init__.py" in pre_save
  257.         return getattr(model_instance, self.attname)

Exception Type: AttributeError at /questions/ask/
Exception Value: 'Question' object has no attribute 'test'

asked 04 Aug '10, 23:26

andy's gravatar image

andy
6126
accept rate: 0%

andy, where is Node.add_to_class call in your module?

(29 Sep '10, 18:01) Hernani Cerq... ♦♦

in the models.py file

(29 Sep '10, 19:14) andy
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×44
×24
×6

Asked: 04 Aug '10, 23:26

Seen: 332 times

Last updated: 29 Sep '10, 19:14

powered by OSQA