0👍
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
6👍
I’m pretty sure your database is probably using the latin1 encoding. Django supposes you have everything set as unicode (utf8).
To check this out, get into MySQL Shell and type:
mysql> show variables like 'char%';
If you see a bunch of latin1 (or any other encoding that isn’t utf8, except binary), you’ll have to do this:
Open up my.cnf and look for the [mysqld]
section.
Make sure after tmpdir = /tmp
, you have the following lines:
default-character-set=utf8
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-external-locking
skip-character-set-client-handshake
Restart the server.
You’ll have to recreate or manually edit the encoding of all databases and table you have, changing my.cnf only affects the databases that will be created.
Hope I’ve helped.
Edit: By the way, on which Django version are you on? Seems like this was a bug that was fixed on 1.1: http://code.djangoproject.com/ticket/10267
- [Django]-Edit the opposite side of a many to many relationship with django generic form
- [Django]-Calculating distance between two points using latitude longitude and altitude (elevation)
- [Django]-Overriding Django Admin's main page? – Django
- [Django]-Problem rendering a Django form field with different representation
- [Django]-Could not find a version that satisfies the requirement pywin32==227 heroku
3👍
This link saved my day
you have to add unicode support for your admin in your models.py:
class MyModel (models.Model):
some_field = models.CharField(max_length=1000)
def __unicode__(self):
return u'%s'%(self.some_field)
there might be other problems such as: your system encoding is not utf8, your database encoding is not utf8 and … which is mentioned in the link provided!
- [Django]-Django extends different base templates
- [Django]-What's gettext_lazy on django is for?
- [Django]-Django queryset specific order by based on values of foreign key
1👍
in your model, have you tried putting
class Model(models.Model):
def __unicode__(self):
return self.name ## having a model object named "name"
Not sure if this is the answer you are searhing for, but have you tried?
- [Django]-Django – Custom Template Tag passing keyword args
- [Django]-Add reply to address to django EmailMultiAlternatives
- [Django]-Django method to change User email not working
- [Django]-Django send_mail results in Error 60, Operation Timed Out on Mac OSX