#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Argentina
    Posts
    2
    Rep Power
    0

    What is the best way to encode a title for url structure ?


    Hi, what is the best way to encode a title for url structure in Django ?

    I think that i have this alternatives:

    1) I can save the encoded url in my model (database) and then use it on the template.

    2) I can make a method in the model and call it every time i access a content that use the encoded url string.

    3) I can make it on urls.py maybe ???

    And the other question, how can i make the encoding ?

    Iam noob on python, iam starting ! thanks alot !
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,894
    Rep Power
    481
    Use a unicode string.

    Seriously, beats the heck out of me. Call me a curmudgeon, I say read the python tutorial, practice with some small programs, learn something about programming, python, and the standard modules before you try to program the fanciest web page.

    Comments on this post

    • codergeek42 agrees
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Location
    Argentina
    Posts
    2
    Rep Power
    0
    You dident understand my question.

    I was asking for a method, i found it => slugify

    And i was asking for the fastest arquitecture way to do it in this language, seems that saving the slug it is gonna be the best option.

    Comments on this post

    • b49P23TIvg agrees : Correct! I did not understand your question.

IMN logo majestic logo threadwatch logo seochat tools logo