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 556411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:55:00+00:00 2026-05-13T11:55:00+00:00

In my django app, I have some objects that cause the corresponding URL in

  • 0

In my django app, I have some objects that cause the corresponding URL in the django admin to be non ascii. (for example: http://mysite/admin/myapp/myclass/Présentation/)

I can edit the object without any problem but when I save it I have the following error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 24: ordinal not in range(128), HTTP response headers must be in US-ASCII format

The strange thing is that the object is correctly saved into the database.

Does anybody know how the Django admin manages unicode? Any info, pointer or idea that can help to fix this problem would be appreciated.

Thanks in advance

Update: Here is the code of the Model

class Plugin(models.Model):
    """Some subcontent that can be added to a given page"""
    class Meta:
        ordering = ['ordering']

    name = models.CharField(max_length=32, primary_key=True)
    div_id = models.CharField(default='rightcol', max_length=32)
    published = models.BooleanField(default=True,
        help_text=_("If this is not checked, it is not displayed on the page."))
    ordering = models.IntegerField(default=1,
        help_text=_("plugins are sorted with this number in ascending order"))
    content = models.TextField(blank=True)
    registration_required = models.BooleanField(_('registration required'),
        help_text=_("If this is checked, only logged-in users will be able to view the page."))

    def __unicode__(self):
        return u"%s -- %s" % (self.name, self.div_id)

Update:
That’s clear that non-ascii character are not recommended in an URL. That’s the cause of my problem and I have changed that.

Does anybody know what is used by the Django admin to build the URL of an object. I guess that it is the primary key. Is it right? is there a way to force Django to use something else and to retrieve the object safely?

  • 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-13T11:55:00+00:00Added an answer on May 13, 2026 at 11:55 am

    I am now using the default id as primary key for every class of my model. As a consequence, I don’t have forbidden characters in the url when accessing objects from the admin site.

    I do recommend to keep the default id as primary key in most cases

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

Sidebar

Related Questions

I have a Django project that uses SQLAlchemy to use some legacy ORM objects.
I have a Django app which when presented with some user error (i.e URL
I have some external services. My Django app is built on top of my
I have been working on a django app on my local computer for some
I have a Django app that gets it's data completely from an external source
I have a Django app that use a django-tagging. I need to port this
I have a django app that I made and have implemented a plist into
I have a Django app with custom form fields, some of which have slow
I have a Django app that uses MySQL as a backend. I'm having difficulties
I have some django apps which are versioned by app name. appv1 appv2 The

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.