I realized after I posted this that I did not explain it well, so here
goes try number two.
The editable=false affects the admin interface and I believe the
newforms module and perhaps the old manipulator framework. You can
simply create your own form, particularly with a model this simple,
and do your own validation (see the docs for how to do this) for the
form after checking to see that the user is a super user. Also after
re-reading your post my question is whether or not what you are really
trying to accomplish would require the user field to be editable=false
as well. This would ensure that the email address could not be
changed, and that the user associated with the email address could not
be changed without using a custom view that was limited to the super
user.
hth,
-r
On Aug 10, 9:48 pm, r_f_d <[EMAIL PROTECTED]> wrote:
> If I am not mistaken, editable=False is only applicable to the admin-
> forms. Simply create a view that checks to see if the user is a
> superuser and then give them a form to add an email address.
>
> peace,
> -r
>
> On Aug 10, 7:59 pm, Russell Blau <[EMAIL PROTECTED]> wrote:
>
> > I am working on an application that includes the following in
> > models.py:
>
> > class UserEmail(models.Model):
> > email = models.EmailField("email address", unique=True,
> > editable=False)
> > user = models.ForeignKey(UserRegistration)
>
> > # an email address can only be associated with one user, and can
> > never
> > # be deleted
> > # once assigned to a user, it can be shifted to another user only
> > by
> > # manual intervention by an administrator
>
> > def delete(self):
> > "Deletion of email addresses is not permitted"
> > warnings.warn("Attempt to delete registered email %s
> > rejected."
> > % self.email)
>
> > def __str__(self):
> > return self.email
>
> > class Admin:
> > pass
>
> > Basically, I want to keep track of every email address that has ever
> > been registered with my app, to prevent duplication. By overriding
> > delete(), I prevent any address from being removed from the database,
> > but I also have to prevent editing the address once it has been
> > registered. The problem is that "editable=False" works too well -- it
> > prevents an admin from editing an existing address, but also prevents
> > them from adding new ones. Is there a way to set up my model so that
> > the administrator can enter new email addresses for a user, but cannot
> > change the existing ones?
>
> > Russ
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---