Re: [mezzanine-users] Foreign Key to Page Object - Controlling the dropdown text in Admin

2015-02-04 Thread Josh Cartmell
Hey Graham, could you go into a bit more detail.  Where is the dropdown?
What do the models look like?

On Wed, Feb 4, 2015 at 3:23 AM, Graham Oliver greenbay.gra...@gmail.com
wrote:

 Hi there
 I have a foreign key to a Page Object. I want to be able to control the
 text that appears on the drop down in the Admin.
 I am guessing that I need to override ModelChoiceField like here
 http://stackoverflow.com/questions/6836740/django-admin-change-foreignkey-display-text
 However, I am a bit stuck on how to do this with Mezzanine
 Would anyone be able to help me?

 TIA
 Graham

 --
 You received this message because you are subscribed to the Google Groups
 Mezzanine Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to mezzanine-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Foreign Key to Page Object - Controlling the dropdown text in Admin

2015-02-04 Thread Graham Oliver
Hi there
I have a foreign key to a Page Object. I want to be able to control the 
text that appears on the drop down in the Admin.
I am guessing that I need to override ModelChoiceField like here 
http://stackoverflow.com/questions/6836740/django-admin-change-foreignkey-display-text
However, I am a bit stuck on how to do this with Mezzanine
Would anyone be able to help me?

TIA
Graham

-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Foreign Key to Page Object - Controlling the dropdown text in Admin

2015-02-04 Thread Graham

Hi Josh
Here are the 2 models (simplified to focus on issue)

class SoulPractitioner(Page, RichText):
pass

class SoulClass(Displayable):
practitioner = models.ForeignKey(SoulPractitioner)

When I 'Add soul class' in the admin I get the option to select a 
foreign key to 'Soul Practitioner' as expected.


The text that displays for each SoulPractitioner is what I want to 
change (I want it to be only the 'Page title' rather than what I get 
which in this case is

'Grandparent page title' / 'Parent Page title' / 'Page title')

Regards
Graham


On 05/02/15 06:36, Josh Cartmell wrote:
Hey Graham, could you go into a bit more detail. Where is the 
dropdown?  What do the models look like?


On Wed, Feb 4, 2015 at 3:23 AM, Graham Oliver 
greenbay.gra...@gmail.com mailto:greenbay.gra...@gmail.com wrote:


Hi there
I have a foreign key to a Page Object. I want to be able to
control the text that appears on the drop down in the Admin.
I am guessing that I need to override ModelChoiceField like here

http://stackoverflow.com/questions/6836740/django-admin-change-foreignkey-display-text
However, I am a bit stuck on how to do this with Mezzanine
Would anyone be able to help me?

TIA
Graham
-- 
You received this message because you are subscribed to the Google

Groups Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it,
send an email to mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the 
Google Groups Mezzanine Users group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/mezzanine-users/xe7MPAnpeUU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
mezzanine-users+unsubscr...@googlegroups.com 
mailto:mezzanine-users+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups Mezzanine 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Foreign Key to Page Object - Controlling the dropdown text in Admin

2015-02-04 Thread Josh Cartmell
You need to override the __str__ method on SoulPractictioner.  Right now it
is being inherited from Page, you can see that here,
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/models.py#L54

On Wed, Feb 4, 2015 at 2:31 PM, Graham greenbay.gra...@gmail.com wrote:

  Hi Josh
 Here are the 2 models (simplified to focus on issue)

 class SoulPractitioner(Page, RichText):
 pass

 class SoulClass(Displayable):
 practitioner = models.ForeignKey(SoulPractitioner)

 When I 'Add soul class' in the admin I get the option to select a foreign
 key to 'Soul Practitioner' as expected.

 The text that displays for each SoulPractitioner is what I want to change
 (I want it to be only the 'Page title' rather than what I get which in this
 case is
 'Grandparent page title' / 'Parent Page title' / 'Page title')

 Regards
 Graham



 On 05/02/15 06:36, Josh Cartmell wrote:

 Hey Graham, could you go into a bit more detail.  Where is the dropdown?
 What do the models look like?

 On Wed, Feb 4, 2015 at 3:23 AM, Graham Oliver greenbay.gra...@gmail.com
 wrote:

 Hi there
 I have a foreign key to a Page Object. I want to be able to control the
 text that appears on the drop down in the Admin.
 I am guessing that I need to override ModelChoiceField like here
 http://stackoverflow.com/questions/6836740/django-admin-change-foreignkey-display-text
 However, I am a bit stuck on how to do this with Mezzanine
 Would anyone be able to help me?

 TIA
 Graham
  --
 You received this message because you are subscribed to the Google Groups
 Mezzanine Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to mezzanine-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to a topic in the
 Google Groups Mezzanine Users group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/mezzanine-users/xe7MPAnpeUU/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 mezzanine-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


  --
 You received this message because you are subscribed to the Google Groups
 Mezzanine Users group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to mezzanine-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Foreign Key to Page Object - Controlling the dropdown text in Admin

2015-02-04 Thread Graham

Thanks Josh
I think that I am missing something...
I have put this code in the SoulClass

def __str__(self):
print this should appear in the terminal if this method is 
being called

return self.title

But nothing appears in the terminal and the behaviour I am trying to 
change persists.
It would seem that this method is being ignored, which suggests to me 
that the syntax is wrong.


G


On 05/02/15 09:15, Josh Cartmell wrote:
You need to override the __str__ method on SoulPractictioner.  Right 
now it is being inherited from Page, you can see that here, 
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/models.py#L54


On Wed, Feb 4, 2015 at 2:31 PM, Graham greenbay.gra...@gmail.com 
mailto:greenbay.gra...@gmail.com wrote:


Hi Josh
Here are the 2 models (simplified to focus on issue)

class SoulPractitioner(Page, RichText):
pass

class SoulClass(Displayable):
practitioner = models.ForeignKey(SoulPractitioner)

When I 'Add soul class' in the admin I get the option to select a
foreign key to 'Soul Practitioner' as expected.

The text that displays for each SoulPractitioner is what I want to
change (I want it to be only the 'Page title' rather than what I
get which in this case is
'Grandparent page title' / 'Parent Page title' / 'Page title')

Regards
Graham



On 05/02/15 06:36, Josh Cartmell wrote:

Hey Graham, could you go into a bit more detail.  Where is the
dropdown?  What do the models look like?

On Wed, Feb 4, 2015 at 3:23 AM, Graham Oliver
greenbay.gra...@gmail.com mailto:greenbay.gra...@gmail.com wrote:

Hi there
I have a foreign key to a Page Object. I want to be able to
control the text that appears on the drop down in the Admin.
I am guessing that I need to override ModelChoiceField like
here

http://stackoverflow.com/questions/6836740/django-admin-change-foreignkey-display-text
However, I am a bit stuck on how to do this with Mezzanine
Would anyone be able to help me?

TIA
Graham
-- 
You received this message because you are subscribed to the

Google Groups Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from
it, send an email to
mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to a topic

in the Google Groups Mezzanine Users group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/mezzanine-users/xe7MPAnpeUU/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google

Groups Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it,
send an email to mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the 
Google Groups Mezzanine Users group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/mezzanine-users/xe7MPAnpeUU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
mezzanine-users+unsubscr...@googlegroups.com 
mailto:mezzanine-users+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups Mezzanine 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Fwd: Re: [mezzanine-users] Foreign Key to Page Object - Controlling the dropdown text in Admin

2015-02-04 Thread Graham

Hi Josh
I tried something based on this
https://docs.djangoproject.com/en/1.6/ref/models/instances/ and it worked!

Namely I changed __str__ to __unicode__

Not entirely sure why this worked but happy enough at this stage...

Thanks for your help
G


 Forwarded Message 
Subject: 	Re: [mezzanine-users] Foreign Key to Page Object - Controlling 
the dropdown text in Admin

Date:   Thu, 05 Feb 2015 11:20:07 +1300
From:   Graham greenbay.gra...@gmail.com
To: mezzanine-users@googlegroups.com



Thanks Josh
I think that I am missing something...
I have put this code in the SoulClass

def __str__(self):
print this should appear in the terminal if this method is 
being called

return self.title

But nothing appears in the terminal and the behaviour I am trying to 
change persists.
It would seem that this method is being ignored, which suggests to me 
that the syntax is wrong.


G


On 05/02/15 09:15, Josh Cartmell wrote:
You need to override the __str__ method on SoulPractictioner.  Right 
now it is being inherited from Page, you can see that here, 
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/models.py#L54


On Wed, Feb 4, 2015 at 2:31 PM, Graham greenbay.gra...@gmail.com 
mailto:greenbay.gra...@gmail.com wrote:


Hi Josh
Here are the 2 models (simplified to focus on issue)

class SoulPractitioner(Page, RichText):
pass

class SoulClass(Displayable):
practitioner = models.ForeignKey(SoulPractitioner)

When I 'Add soul class' in the admin I get the option to select a
foreign key to 'Soul Practitioner' as expected.

The text that displays for each SoulPractitioner is what I want to
change (I want it to be only the 'Page title' rather than what I
get which in this case is
'Grandparent page title' / 'Parent Page title' / 'Page title')

Regards
Graham



On 05/02/15 06:36, Josh Cartmell wrote:

Hey Graham, could you go into a bit more detail.  Where is the
dropdown?  What do the models look like?

On Wed, Feb 4, 2015 at 3:23 AM, Graham Oliver
greenbay.gra...@gmail.com mailto:greenbay.gra...@gmail.com wrote:

Hi there
I have a foreign key to a Page Object. I want to be able to
control the text that appears on the drop down in the Admin.
I am guessing that I need to override ModelChoiceField like
here

http://stackoverflow.com/questions/6836740/django-admin-change-foreignkey-display-text
However, I am a bit stuck on how to do this with Mezzanine
Would anyone be able to help me?

TIA
Graham
-- 
You received this message because you are subscribed to the

Google Groups Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from
it, send an email to
mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to a topic

in the Google Groups Mezzanine Users group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/mezzanine-users/xe7MPAnpeUU/unsubscribe.
To unsubscribe from this group and all its topics, send an email
to mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google

Groups Mezzanine Users group.
To unsubscribe from this group and stop receiving emails from it,
send an email to mezzanine-users+unsubscr...@googlegroups.com
mailto:mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to a topic in the 
Google Groups Mezzanine Users group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/mezzanine-users/xe7MPAnpeUU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
mezzanine-users+unsubscr...@googlegroups.com 
mailto:mezzanine-users+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.




--
You received this message because you are subscribed to the Google Groups Mezzanine 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.