adding a new text field to question

I am planning to add a new (optional) text field (with a single line textbox and at most 200 characters) to "the question" in askbot code. Please point me to files that need to be changed and other required steps (like database migration etc.,).

1 Answer

To make things simpler, create a model related to thread via foreign key and maintain it in the separate app, and have migrations for that app separately. That way it will be much easier to maintain your version and avoid clashes in the migrations.

The question model is askbot.models.Thread. There is also model askbot.model.Post, which contains all comment, answer and question bodies. Thread holds the question title, tags and some more things.

That could work, but it would mean a many-to-one relationship in the wrong direction. I could potentially create a m2m relationship but that's not ideal. I'm adding locations as a form of required tag and anticipated this would need a new model attached to threads, I might look into seeing if I can work this feature into tags itself.

You can add one-to-one if you want or add a unique together constraint on ids or use ManyToMany. However I would not recommend M2M unless you really need it as database lookups will be less efficient. You could also just fork the code and add your field or add a field with migration from the additional app. If you just need one field, adding it directly will be the most efficient, but requires changes in the base schema.