Jay,
Yep, that worked.  Thanks for the help!

On May 6, 12:16 pm, "Jay Parlar" <[EMAIL PROTECTED]> wrote:
> On 5/6/07, gsmith <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
> > Jay,
> > I've already added my SlugField.  Here is a look at the table I
> > created
>
> > class news(models.Model):
> >     title = models.CharField(maxlength=200)
> >     theslug = models.SlugField(prepopulate_from=("title"))
> >     body = models.TextField(maxlength=2000)
>
> >     def __str__(self,):
> >         return self.title
>
> >     class Admin:
>
> > However, when i login to my admin and type something into my title
> > field nothing appears in the SlugField.  I'm assuming that I need to
> > import some JavaScript file so that my SlugField gets auto-populated
> > when I enter text into the text field.
>
> Nope, no need to import anything manually. You've been bitten by a
> "quirk" of Python. Notice that you have this:
>
> prepopulate_from=("title")
>
> That's *almost* right. In the documentation, they show a two element
> tuple, ("pre_name", "name"). You only have a one element tuple.
> However, you did it wrong. A one element tuple in Python *has* to have
> a trailing comma, so it should be
>
> prepopulate_from=("title",)
>
> Alternatively, you can use a list instead of a tuple, then you don't
> need the comma
>
> prepopulate_from=["title"]
>
> The trailing comma in a tuple is required so Python knows whether or
> not you are creating a tuple, or just simply putting brackets around
> an expression.
>
> Hope that helps,
> Jay P.- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to