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 52545

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:55:25+00:00 2026-05-10T16:55:25+00:00

Assume the following: models.py class Entry(models.Model): title = models.CharField(max_length=50) slug = models.CharField(max_length=50, unique=True) body

  • 0

Assume the following:

models.py

class Entry(models.Model):     title = models.CharField(max_length=50)     slug = models.CharField(max_length=50, unique=True)     body = models.CharField(max_length=200) 

admin.py

class EntryAdmin(admin.ModelAdmin):     prepopulated_fields = {'slug':('title',)} 

I want the slug to be pre-populated by the title, but I dont want the user to be able to edit it from the admin. I assumed that adding the fields=[] to the admin object and not including the slug would have worked, but it didnt. I also tried setting editable=False in the model, but that also didnt work (infact, stops the page from rendering).

Thoughts?

  • 0 0 Answers
  • 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. 2026-05-10T16:55:26+00:00Added an answer on May 10, 2026 at 4:55 pm

    For this particular case you can override your save method to slugify (it’s built-in method, look at django source) the title and store it in slug field. Also from there you can easily check if this slug is indeed unique and change it somehow if it’s not.

    Consider this example:

    def save(self):     from django.template.defaultfilters import slugify      if not self.slug:         self.slug = slugify(self.title)      super(Your_Model_Name,self).save() 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer from functools import wraps def intercept(target,**trigger): def decorator(func): names =… May 11, 2026 at 10:15 am
  • added an answer Well you can try this DirectoryInfo sourcedinfo = new DirectoryInfo(@'E:\source');… May 11, 2026 at 10:15 am
  • added an answer You could load/save to a MemoryStream to solve your issue… May 11, 2026 at 10:15 am

Related Questions

Assume the following: models.py class Entry(models.Model): title = models.CharField(max_length=50) slug = models.CharField(max_length=50, unique=True) body
Assume the following class: public class MyEnum: IEnumerator { private List<SomeObject> _myList = new
Assume the following code: using (SqlConnection conn = new SqlConnection(connectionString)) { ... using (SqlCommand
Assume the following type definitions: public interface IFoo<T> : IBar<T> {} public class Foo<T>
Assume a table with the following columns: pri_id , item_id , comment , date
Assume you are doing something like the following List<string> myitems = new List<string> {
Let's assume we've got the following Java code: public class Maintainer { private Map<Enum,
Assume your .NET-based development team is already using the following set of tools in
When writing GUIs, I've frequently come over the following problem: Assume you have a
This is an Eclipse question, and you can assume the Java package for all

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.