First time here? Check out the FAQ!
2

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

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?

hammergun's avatar
1
hammergun
asked 2013-04-05 11:57:43 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2013-04-05 19:48:20 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

2

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.

Evgeny's avatar
13.2k
Evgeny
answered 2013-04-05 19:47:11 -0600
edit flag offensive 0 remove flag delete link

Comments

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 -0600) 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 -0600) 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 -0600) 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 -0600) edit
add a comment see more comments
0

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.

SocialQA's avatar
265
SocialQA
answered 2014-05-03 16:22:30 -0600
edit flag offensive 0 remove flag delete link

Comments

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 -0600) edit
add a comment see more comments
0

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

909552623's avatar
1
909552623
answered 2014-05-14 05:29:00 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments