2
1

I have been making modifications to the "Ask a Question" form source file (root/forum/forms/qanda.py), however if there is an update all those modifications will be lost. Is there a way to make a module that can modify the contents of the ask a question form.

The main thing I want to do is change the tags field from a CharField to a ChoiceField (basically limit tag creation into set parameters).

Is this possible and if so, what would be the best way to go about achieving this?

asked 02 Sep '10, 02:38

Dos's gravatar image

Dos
111458
accept rate: 0%


In the AskForm the tags field is initialized in the init method, so you have to replace the entire method, and you can use our decoration set. Create the module folder and empty init.py file, and in the startup.py file:

from forum.modules import decorate
from forum import forms as osqa_forms

@decorate(osqa_forms.AskForm.__init__, needs_origin=False)
def replacement_init(self, *args, **kwargs):
    pass

This will safely replace the init method in the AskForm by your own method. Hope it helps.

link

answered 02 Sep '10, 07:24

Hernani%20Cerqueira's gravatar image

Hernani Cerq... ♦♦
16.8k65975
accept rate: 52%

Silly question, but I'm successfully replacing the the AskForm method with the technique above, but where should I place my alternate AskForm method?

(07 Sep '10, 21:02) Dos

@Dos, just create a folder with an alphanumerical name under forum_modules, create the files:

__init__.py
startup.pt

Put it in the startup file. The other one stays empty.

(08 Sep '10, 06:00) Hernani Cerq... ♦♦
Your answer
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
×17
×9

Asked: 02 Sep '10, 02:38

Seen: 755 times

Last updated: 08 Sep '10, 06:00

powered by OSQA