[Ncr-Python.in] [ilugd] Django mptt help

Gora Mohanty gora at mimirtech.com
Fri Jun 14 11:39:43 CEST 2013


On 14 June 2013 12:35, Raakesh kumar <kumar3180 at gmail.com> wrote:
[...]
> Ok,
> Let me put it in this way:
> 1 - My table "works" has a column "invities", and this column stores
> user_id1,user_id2 type of data. Which means these users are the member for
> this particular row data.
> 2 -  And following code is used to view the tree::
> def view(request, id):
>     try:
>         ideas = Works.objects.filter(tree_id=id).filter(is_deleted=False)
>         # Following Code is to fetch user details and replace their ids with
> name
>         for i in range(len(ideas)):
>             invities = ''
>             members = ideas[i].invities
>             members = members.split(',')
>             for member in members:
>                 try:
>                     member_detail = User.objects.get(email = member)
>                     member_name = member_detail.full_name
>                 except User.DoesNotExist:
>                     member_name = member

I do not see how this can possibly be working for you,
Presumably User is the django.contrib.auth User model,
in which case it has no attribute full_name (you probably
meant get_full_name()). Thus, an AttributeError should
be raised, and your program should crash.

I suspect that you have not shown us the real code, and
you are instead catching all exceptions, which would
explain the behaviour that you are seeing, as your exception
handling code then simply replaces the original value.

Regards,
Gora


More information about the Ncr-Python.in mailing list