First time here? Check out the FAQ!

Revision history  [back]

It's achieved via "related name". Django adds one automatically for each relational field of the models.

In this case one could do:

u = User.objects.get(id=1)
shib_profile = u.shibuser_set.all()[0]
shib_profile.shib_user_role = 'captain'
shib_profile.save()

or:

u.shibuser_set.all().update(shib_user_role='captain')

If you don't like name shibuser_set, create your own with the related_name parameter in the model field definition (see django docs for that).

Most importantly I would recommend you to define that extra model in a separate app. If it's inside askbot code base, it may be harder down the road to keep the code in sync. It will be also more difficult this way to identify bugs as you will be reporting bugs against your custom code base and we may not be able to verify and help you.

It's not a good idea at all to modify askbot/forms.py, much easier to create an app say askbot_shib and define a separate form there.

Then - if adding that form to askbot is not yet available by configuration, we can build such capability. It's already possible to define custom "ask" and "answer" forms and we can have more.

It's achieved via "related name". Django adds one automatically for each relational field of the models.

In this case one could do:

u = User.objects.get(id=1)
shib_profile = u.shibuser_set.all()[0]
shib_profile.shib_user_role = 'captain'
shib_profile.save()

or:

u.shibuser_set.all().update(shib_user_role='captain')

If you don't like name shibuser_set, create your own with the related_name parameter in the model field definition (see django docs for that).

Most importantly I would recommend you to define that extra model in a separate app. If it's inside askbot code base, it may be harder down the road to keep the code in sync. It will be also more difficult this way to identify bugs as you will be reporting bugs against your custom code base and we may not be able to verify and help you.

It's not a good idea at all to modify askbot/forms.py, much easier to create an app say askbot_shib and define a separate form there.

Then - if adding that form to askbot is not yet available by configuration, we can build such capability. It's already possible to define custom "ask" and "answer" forms and we can have more.

capability.

It's achieved via "related name". Django adds one automatically for each relational field of the models.

In this case one could do:

u = User.objects.get(id=1)
shib_profile = u.shibuser_set.all()[0]
shib_profile.shib_user_role = 'captain'
shib_profile.save()

or:

u.shibuser_set.all().update(shib_user_role='captain')

If you don't like name shibuser_set, create your own with the related_name parameter in the model field definition (see django docs for that).

Most importantly importantly I would recommend you to define that extra model in a separate app. If it's inside askbot code base, it may be harder down the road to keep the code in sync. It will be also more difficult this way to identify bugs as you will be reporting bugs against your custom code base and we may not be able to verify and help you.sync.

It's not a good idea at all to modify askbot/forms.py, much easier to create an app say askbot_shib and define a separate form there.

Then - if adding that form to askbot is not yet available by configuration, we can build such capability.