|
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'
|
andy, where is Node.add_to_class call in your module?
in the models.py file