Hello,

I'm new to Django and wonder how to solve this problem. I am trying to
add some additional data to the User standard model.

I follow the instructions here:
http://digitaldreamer.net/blog/2010/12/8/custom-user-profile-and-extend-user-admin-django/
That I believe they're pretty the same as in Django docs (but in more
detail).

My models.py:
...
# Class for the client data:
class client(models.Model):
    user = models.OneToOneField(User)
    name = models.CharField(max_length=100)
    description = models.CharField(max_length=250)
    # Now some standard methods overriden:
    def __unicode__():
        return self.name
# This is to link the client (user profile) to the user standard
saving.
def create_client(sender, instance, created, **kwargs):
    """ Create a new client when a User is saved."""
    if created:
        myClient = client() # This creates the client object.
        myClient.user = instance # This updates the user with the
newly created instance
        myClient.save() # This saves the model.
# And this connects to the saving user signal the creation of the
client:
post_save.connect(create_client,sender=User)
...
And my admin.py:
...
# This class allows to link the client with the user admin interface:
class ClientInline(admin.StackedInline):
    model = client
    fk_name = 'user'
    max_num = 1

class ClientUserAdmin(UserAdmin):
    inlines = [ClientInline,]

admin.site.unregister(User)
admin.site.register(User,ClientUserAdmin)
...
But the server raises an error:
DatabaseError at /admin/auth/user/3/
no such column: d2w3_client.user_id
Request Method: GET
Request URL:    http://localhost:8000/admin/auth/user/3/
Django Version: 1.2.3
Exception Type: DatabaseError
Exception Value:
no such column: d2w3_client.user_id
Exception Location:     /usr/lib/pymodules/python2.6/django/db/backends/
sqlite3/base.py in execute, line 200
Python Executable:      /usr/bin/python
Python Version: 2.6.6

Apparently Django is trying to access to user_id field (from user, but
related to client by OneToOneField relation), and it's not found.
Where's the error.
Thanks in advance,
Daniel.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to