Ask Your Question

How to add fields to user profile in an askbot-based site?

asked 2013-04-05 11:57:43 -0500

hammergun's avatar

updated 2013-04-05 19:48:20 -0500

Evgeny's avatar

I read the guide but is there anyway that I can make the askbot as a base for my portal and add features to the user model? Is this possible and could any one guide me on this?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2013-04-05 19:47:11 -0500

Evgeny's avatar

In Askbot we extend the auth_user table, but for your site - feel free to do it any way you find best.

There doesn't seem to be a nice general solution IMO when several applications at the same time need custom fields associated with the user account.

One way is to have separate user profiles for each app, but then you might (but of course you might as well be lucky and not have this issue) run into a situation when you have say "user_birth_date" saved separately in two places and likely under different names - then you have to deal with keeping data in both places in sync.

Another way is to maintain common user model, which will require patching a single database table to satisfy both applications.

We chose to patch auth_user table which brings own advantages and disadvantages.

Django 1.5 allows to use custom user model, but IMO it is not really helping. You still have to decide to either have per-app user profiles or maintain one table for all user data.

edit flag offensive delete link more


But if I have seperate user models for each app wouldn't there be issues in logging in and logging out. Actually the Q&A is just one of the features in my portal. I have messaages(for which I'm using django postman), File uploading and deletion(django-filer). So if I can have a simple way to make a single user model which would work with all these components I would be really happy. And what is your opinion in modifying the askbot user model. Also can I use the askbot as a project rather than a plugin(i.e which resides in the lib folder of python). I really like the login system of askbot and that is the main reason why I chose to keep askbot as the base to my project.

hammergun's avatar hammergun  ( 2013-04-06 00:10:17 -0500 )edit

Askbot uses auth_user - the django's user table, it is not Askbot's own user table. Please modify it as you like. It is a little tricky to create south migrations for a third party user model, but possible. I usually create a dummy model where I add a field I need, then produce the new migration file, which I later manually edit so that it is applied to the auth_user model. If you do those changes rarely - you can just use SQL scripts adding columns. For an example of a migration patching the foreign app's table - take a look at askbot/migrations/0126... (there is a long file name, which is truncated). With some understanding of South it is possible to make those migration files manually.

Evgeny's avatar Evgeny  ( 2013-04-06 00:17:46 -0500 )edit

Could you give a code snippet(an example) regarding this.. I'm actually a newbie to django.

hammergun's avatar hammergun  ( 2013-04-06 00:21:31 -0500 )edit

Please find it in the askbot repository on github, it's easy to find. The path to the file is relative to the askbot repo.

Evgeny's avatar Evgeny  ( 2013-04-06 00:24:56 -0500 )edit

answered 2014-05-03 16:22:30 -0500

SocialQA's avatar

In django world its advise not to actually modify auth_user table but askbot does modification, In my application I created a new table with relationship of auth_user table and added the fields that I need in user profile to be in that table. Then I modified the view to pickup that I field when I render the user profile.

edit flag offensive delete link more


Have you had an actual problem due to this modification? Meaning - something did not work that was expected to work?

Evgeny's avatar Evgeny  ( 2014-05-03 16:32:30 -0500 )edit

answered 2014-05-14 05:29:00 -0500

I am not sure thes question.So sorry to these.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-04-05 11:57:43 -0500

Seen: 2,476 times

Last updated: May 14 '14