I'm creating an application for a client in which the Admin has a
"customer" model. The admin area was easy to set up, and everything's
working just swell under Apache 2.

The challenge I'm facing, however, is that when the Admin (admin here
meaning a person using the Admin interface) creates a Customer (model),
I want to automatically create a User (model) and assign permissions
accordingly. I've read through the documentation, and I couldn't quite
manage it.

I tried what I thought was a bit clever, by using the User API on the
Customer model, like so:

# import User, etc.

class Customer(models.Model):
    # model.FieldsAndWhatnot
    username = models.CharField(maxlength=50)
    password = models.CharField(maxlength=50)
    ...

    user = User.objects.create_user(username, email, password)

As sometimes is the case with clever solutions, this didn't work.

Does anyone know how I can go about this? I don't want to do it via a
view, and I don't want the Admins to have to manually create a User
each time they add a Customer.

The reason for all this is that I need to authenticate a Customer so
they can see their Order (another model), but they should, somewhat
obviously, not be able to see someone else's order.

Have I explained this well? Does this make sense? Does anyone have any
ideas?

Big fan of Django, so far. Everything has been relatively easy to
manage. This is the first honest challenge I've come across.

Thanks,
Dave Worley


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to