Hello everybody,

   I'm having some troubles making a custom Account Registration page.
I created a new model with a OneToOne relation to User, setup the
AUTH_PROFILE_MODULE on settings and everything else. But how do I make
my new field appear in the form ? I tried to override the
RegistrationForm form, but without success.
    I think this is a gap in the Satchmo Documentation. It's a common
task and are taking me a lot of time. After I discover how to do this
I intend to make a full doc explaining how to achieve it.

Regards,
Ricardo Silva.

On Aug 26, 2:56 pm, Seth <[email protected]> wrote:
> Thanks Carlos, that's exactly what I was looking for.
>
> I only have one last thing to figure out, but it's not even that
> important.
>
> In my admin.py I have
> class ContactProfile_Inline(admin.TabularInline):
>     model = ContactProfile
>
> class ContactProfileOptions(AutocompleteAdmin):
>     list_display = ('last_name', 'first_name', 'role')
>     list_filter = ['create_date', 'role'] #, 'industry']
>     ordering = ['last_name']
>     search_fields = ('first_name', 'last_name', 'email')
>     related_search_fields = {'user': ('username', 'first_name',
> 'last_name', 'email')}
>     related_string_functions = {'user': lambda u: u"%s (%s)" %
> (u.username, u.get_full_name())}
>     inlines = [PhoneNumber_Inline, AddressBook_Inline,
> ContactProfile_Inline]
>
> admin.site.unregister(Contact)
> admin.site.register(Contact, ContactProfileOptions)
>
> This works fine to show the industry on the Contact page, but I'd like
> to include industry in the list_display and list_filter.  I've tried
> using both 'industry' and 'contactprofile.industry'.  Do you have any
> ideas of how to do that?
>
> Thanks,
> Seth
>
> On Aug 26, 10:44 am, Carlos Perelló Marín <[email protected]> wrote:
>
> > What you did is correct, except that you should understand that your
> > myApp.myProfile exists in its own database table, so you cannot access
> > it directly asuser.get_profile().industry until you create its row in
> > the myProfile table.
>
> > This is the way I do it:
>
> > def tryton_contact_form_save(sender, object=None, formdata=None,
> > form=None,  **kwargs):
>
> >     if object is None:
> >         return
>
> >     try:
> >         local_contact = LocalContact.objects.get(contact=object)
> >     except LocalContact.DoesNotExist:
> >         local_contact = LocalContact(contact=object)
>
> >     local_contact.vat_number = formdata['vat_number']
> >     local_contact.save()
>
> >  From now, I'm able to do: contact.local_contact to access my extra
> > contact information. Just in case you wonder, that's a listener for the
> > form_save signal.
>
> > I'm not saying this is THE way to do it, given that I'm quite new to
> > Satchmo, but it's the way I fixed the problem you are getting.
>
> > Cheers.
>
> > Seth escribió:
>
> > >user.get_profile() does in fact return the custom profile object.
>
> > > The problem is that the custom profile object is either
> > > contact.Contact or myApp.myProfile.  Never are both accessible.
>
> > > The way I was most hopeful about was to extend the Contact model with
>
> > > class myProfile(models.Model):
> > >     contact = models.ForeignKey(User, unique=True)
> > >     otherInfo = models.CharField()
>
> > > AUTH_PROFILE_MODULE = "myApp.myProfile"
>
> > > But with that setup
> > >User.objects.get(pk=1).get_profile()
>
> > > errors out with "Cannot resolve keyword 'user' into field. Choices
> > > are: contact, id, otherInfo"
>
> > > And if I change to
> > > AUTH_PROFILE_MODULE = "contact.Contact"
>
> > >user.get_profile().industry
> > > errors out with "'Contact' object has no attribute 'industry'"
>
> > > and
> > >user.get_profile().myProfile
> > > errors out with "'Contact' object has no attribute 'myProfile'
>
> > > Am I wrong to think that it's possible to have contact.Contact and
> > > myapp.myProfile accessible throughuser.get_profile()?
>
> > > On Aug 26, 9:23 am, Bob Waycott <[email protected]> wrote:
>
> > >> This may be an oversight ... or something that's changed in Django 1.1 
> > >> ...
>
> > >> Shouldn't it be:
>
> > >>user.get_profile() = custom profile object?
>
> > >> As opposed to the getProfile() you just used in your post?
>
> > >> Seth Boyd wrote:
>
> > >>> Sorry for the long delay.  I got distracted from this project for a bit.
>
> > >>> I'm trying to use the default Django way to make a Profile described
> > >>> athttp://docs.djangoproject.com/en/dev/topics/auth/#auth-profilesbut
> > >>> I'm running into issues regarding the AUTH_PROFILE_MODULE.  In short,
> > >>> what do I do with it?
>
> > >>> I've tried associating my Profile with both theUsermodel and
> > >>> Satchmo's Contact model and switched the AUTH_PROFILE_MODULE from
> > >>> contact.Contact to myApp.myProfile to no avail.  With
> > >>> AUTH_PROFILE_MODULE = "contact.Contact"
> > >>>user.getProfile().myExtendedAttributes don't work.  And the whole
> > >>> store gets borked when AUTH_PROFILE_MODULE = "myApp.myModel" because
> > >>>user.getProfile().satchmosContactAttributes are broken.
>
> > >>> Thanks again for your help
>
> > >>> On Tue, Aug 11, 2009 at 10:52 AM, Nathan Ekstrom
> > >>> <[email protected] <mailto:[email protected]>> wrote:
>
> > >>>     I'd say it all depends on how you want to access the data.  Do you
> > >>>     want to go through the contact model or theusermodel?
> > >>>      Associating with theUsermodel should make it more portable
> > >>>     though, if you ever wanted to use code from it in a non Satchmo
> > >>>     environment.
>
> > >>>     On Tue, Aug 11, 2009 at 6:52 AM, Seth Boyd <[email protected]
> > >>>     <mailto:[email protected]>> wrote:
>
> > >>>         Thanks for your responses.  I have one last question.  Is
> > >>>         there any benefit to associating my custom information with
> > >>>         satchmo's contact model over django'susermodel or vice versa?
>
> > >>>         Thanks again,
> > >>>         Seth
>
> > >>>         On Tue, Aug 11, 2009 at 2:42 AM, Carlos Perelló Marín
> > >>>         <[email protected] <mailto:[email protected]>> wrote:
>
> > >>>             Nathan Ekstrom escribió:
> > >>>             > I believe he saidUsermodel not product model.  As to
> > >>>             extending the
> > >>>             >usermodel  I don't know that there is a preferred
> > >>>             method.  Probably
> > >>>             > the best way so as not to mess with Satchmo too much
> > >>>             would be to
> > >>>             > create a 1-to-1 field linking a new model to theuser
> > >>>             model.  Then
> > >>>             > when you need to access your custom fields you just need
> > >>>             to do
> > >>>             >user.<custom_model>.field
>
> > >>>             Which is exactly the method explained in the document
> > >>>             about extending
> > >>>             the product model...
>
> > >>>             Cheers.
>
> > >>>             > Nathan
>
> > >>>             > On Mon, Aug 10, 2009 at 2:18 AM, Juanjo
> > >>>             <[email protected] <mailto:[email protected]>
> > >>>             > <mailto:[email protected] <mailto:[email protected]>>>
> > >>>             wrote:
>
> > >>>             >     Follow the documentation:
>
> > >>>             >http://www.satchmoproject.com/docs/svn/custom-product.html
>
> > >>>             >     Then, if you want your extension class to show in
> > >>>             the admin with the
> > >>>             >     regular product admin interface, check this on my 
> > >>> site:
>
> > >>>            
> > >>> http://juanjoalvarez.net/es/detail/2009/jul/27/why-bad-idea-tm-overri...
>
> > >>>             >     On Aug 9, 11:50 pm, Seth <[email protected]
> > >>>             <mailto:[email protected]>
> > >>>             > <mailto:[email protected]
> > >>>             <mailto:[email protected]>>> wrote:
> > >>>             > > What is the preferred to extend theusermodel?  I
> > >>>             need to store
> > >>>             >     more
> > >>>             > > information about the customer than satchmo does by
> > >>>             default.
>
> > >>>             --
> > >>>             Carlos Perelló Marín
> > >>>             [P+] SERVICIOS PROFESIONALES
> > >>>            http://www.pemas.es
> > >>>             mailto:[email protected] <mailto:[email protected]> ||
> > >>>             mailto:[email protected] <mailto:[email protected]>
>
> > >>>             Este mensaje y los ficheros anexos son confidenciales. Los
> > >>>             mismos
> > >>>             contienen información reservada de la empresa que no puede 
> > >>> ser
> > >>>             difundida. Si usted ha recibido este correo por error,
> > >>>             tenga la
> > >>>             amabilidad de eliminarlo de su sistema y avisar al
> > >>>             remitente mediante
> > >>>             reenvío a su dirección electrónica; no deberá copiar el
> > >>>             mensaje ni
> > >>>             divulgar su contenido a ninguna persona.
>
> > >>>             Su dirección de correo electrónico junto a sus datos
> > >>>             personales forman
> > >>>             parte de un fichero titularidad de PEMAS Servicios
> > >>>             Profesionales, S.L.
> > >>>             cuya finalidad es la de mantener el contacto con Ud. De
> > >>>             acuerdo con la
> > >>>             Ley Orgánica 15/1999, usted puede ejercitar sus derechos
> > >>>             de acceso,
> > >>>             rectificación, cancelación y, en su caso, oposición
> > >>>             enviando una
> > >>>             solicitud por escrito, acompañada de una fotocopia de su
> > >>>             DNI dirigida a
> > >>>             PEMAS Servicios Profesionales, S.L. C/ Santos Justo y
> > >>>             Pastor, 72 - 5,
> > >>>             C.P. 46022 de Valencia (España).
>
> > --
> > Carlos Perelló Marín
> > [P+] SERVICIOS PROFESIONALEShttp://www.pemas.es
> > mailto:[email protected] || mailto:[email protected]
>
> > Este mensaje y los ficheros anexos son confidenciales. Los mismos
> > contienen información reservada de la empresa que no puede ser
> > difundida. Si usted ha recibido este correo por error, tenga la
> > amabilidad de eliminarlo de su sistema y avisar al
>
> ...
>
> read more »

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Satchmo 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/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to