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

  • Home
  • SEARCH
  • 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 3481672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:28:24+00:00 2026-05-18T10:28:24+00:00

while creating a blog i am using the following model class and form .but

  • 0

while creating a blog i am using the following model class and form .but since i don’t want the user to add the url(slugified field) himself i am stuck how can i add the slugified url before saving the model,should it be done in the view if i am correct.
PS: i am using app engine where i heard that the slug fields aren’t available.

  class Post(db.Model):
          title=db.StringProperty(required=True)
            url=db.StringProperty(required=True)
            content_html=db.TextProperty(required=True)
            dateTime=db.DateTimeProperty(auto_now_add=True,required=True)
            tags=db.StringListProperty()


class PostForm(djangoforms.ModelForm): 
 class Meta:
  model=Post
  exclude=['url']
  • 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-05-18T10:28:24+00:00Added an answer on May 18, 2026 at 10:28 am

    You could either do this in your view or override your form’s save method. If you do it in your view it will look something like this:

    #views.py
    from django.template.defaultfilters import slugify
    
    def post_create(request, ...):
        ...
        if request.method == 'POST':
            form = PostForm(request.POST)
            if form.is_valid():
                post = form.save(commit=False)
                title = form.cleaned_data['title']
                slugified_title = str(slugify(title))
                post.url = [modify the slugified_title however you want...]
                post.save()
        ...
    

    Alternatively, you can override your form’s save method which would look something like:

    #forms.py
    class PostForm(django.forms.ModelForm):
        class Meta:
            model=Post
            exclude=['url']
        def save(self, commit=True, force_insert=False, force_update=False):
            post = super(PostForm, self).save(commit=False)
            slugified_title = str(slugify(post.title))
            post.url = [modify the slugfield_title however you want...]
            post.save()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want a quick way (and preferably not using a while loop)of createing
Using MEF I want to do the following. I have a WPF Shell. To
I created a report using wizard and while creating I selected 4 columns for
While creating new records. I need to create more records for the same model.
While creating a new object i am getting ActiveRecord::RecordNotSaved error on before_save. But i
While creating a netlink socket using netlink_kernel_create() a function pointer is passed as argument
In my web app while creating a particular item users can browse and add
While creating a file synchronization program in C# I tried to make a method
While creating classes in Java I often find myself creating instance-level collections that I
I just noticed while creating a RESTful WCF service that the Method parameter on

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.