Thank you for that, I will have to study that because it is a lot cleaner than what I did.
I added the following to my City model below Class Meta: def save(self): slug_parts = self.slug.split('-') num_slugs = len(slug_parts) state_position = (num_slugs - 1) state = State.objects.get(id=slug_parts[state_position]) state_slug = state.state.lower() city_slug = '' for i in range (0, (state_position)): city_slug += slug_parts[i] + '-' self.slug = "%s%s" % ( city_slug, state_slug ) super(City, self).save() I know it's hack a job. On Apr 17, 7:36 pm, "James Punteney" <[EMAIL PROTECTED]> wrote: > The javascript is part of the Simple pages app I've been working on so you > can view the code > here:http://code.google.com/p/django-simplepages/source/browse/trunk/simpl... > > It's a little different than what you are doing as I'm not pulling the > display value of the select box, I'm actually getting another value from the > foreign key object. I had to do the extra step of using django to print out > a javascript hash with the id's of the SiteSections as the key and the url > that I'm using to prepopulate text box (hence the reason this is a django > template file and not a plain javascript file). > > Overall it's pretty close to what you are wanting to do though. > > Hope that helps, > --James > > On Thu, Apr 17, 2008 at 4:53 PM, Merrick <[EMAIL PROTECTED]> wrote: > > > Hi James, > > > thank you for responding, can you point me in the right direction with > > the javascript. > > > --Merrick > > > On Apr 17, 1:25 pm, "James Punteney" <[EMAIL PROTECTED]> wrote: > > > I ran into this issue the other day wanting to use a foreign key value > > to > > > prepopulate a slugfield and just getting the id (if anything). > > According to > > > the documentation[1] prepopulate doesn't support foreign keys, so I > > ended up > > > going the custom javascript route in order to get it working. > > > > --James > > > > [1]http://www.djangoproject.com/documentation/model-api/#slugfield --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---