Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:14:35+00:00 2026-06-06T08:14:35+00:00

So I am trying to create a unique permalink each time that a person

  • 0

So I am trying to create a unique permalink each time that a person posts on my webpage and I want it to be relatively search engine friendly so I have made a little code to change the title to a good search engine title and it is working but then my handler cannot accept it. At least that is what I think is happening because the webpage just gives me a 404 error. The HTML works fine because when I redirect to a static page it all goes through. Here is the applicable code:

def post(self):
    subject = self.request.get('subject')
    content = self.request.get('content')

    if subject and content:
        p = Post(parent = blog_key(), subject = subject, content = content)
        p.put()

        id=str(p.key().id())

        subject = str(subject)
        subject = subject.replace(' ', '25fdsa67ggggsd5')
        subject = ''.join(e for e in subject if e.isalnum())
        subject = subject.replace('25fdsa67ggggsd5', '-')
        subject = subject.lower()

        url = '/blog/%s/%s' % (id, subject)
        self.redirect('/blog/%s/%s' % (id, subject))

class PostPage(BlogHandler):
    def get(self, post_id):
       key = db.Key.from_path('PersonalPost', int(post_id), parent=blog_key())
       post = db.get(key)

       if not post:
          self.error(404)
          return

       self.render("permalink.html", post = post)

class PersonalPost(db.Model):
    subject = db.StringProperty(required = True)
    content = db.TextProperty(required = True)
    created = db.DateTimeProperty(auto_now_add = True)
    last_modified = db.DateTimeProperty(auto_now = True)
    user_id = db.StringProperty(required = True)

    def render(self):
        self._render_text = self.content.replace('\n', '<br>')
        return render_str("post.html", p = self)

def blog_key(name = 'default'):
    return db.Key.from_path('blogs', name)

app = webapp2.WSGIApplication([('/blog/([0-9]+)/([.*]+)', PostPage)]

And again it works when I just have it redirect to the main page and list them but not when I try to direct to the new SEO page.

UPDATE:

The test url I am using is setting

subject = "test-url"
id = "1234"

The app then directs me to http://www.url.com/blog/1234/test-url but it gives me a 404 error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:14:38+00:00Added an answer on June 6, 2026 at 8:14 am

    You define two groups in ('/blog/([0-9]+)/([.*]+) but your PostPage.get() only takes one.
    Change it to def get(self, post_id, subject) or remove the second group ('/blog/([0-9]+)/[.*]+

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a unique id that's random. This solution was suggested, but
I'm trying to create a custom way of computing and passing unique id's that
I'm trying to create a trigger that will associate an unique random string to
I am trying to create a unique taskID list based on the selections. Each
I am trying to create a unique slug in Django so that I can
Trying to create a variable with unique name for each $item . To prevent
I'm trying to create a rather unique effect. It's actually not that complicated, what
I'm trying to create an unique array regardless of its original order and using
I am trying to create a unique constraint on two fields in a table.
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.