![]() Strings_only parameter, if set to True, will result in Python When processing form input data, which might not be UTF-8 encoded.) The (For example, Django uses this internally smart_str(s, encoding='utf-8', strings_only=False, errors='strict')Ĭonverts its input to a string.The module contains a few functions that are handyįor converting back and forth between strings and bytestrings. In a bytestring, be prepared to receive a string back in the result. In most cases when Django is dealing with strings, it will convert them to Using your application – and if that person chooses a different setting, yourĬode must still continue to work. It’s under the control of the person installing and The reason for this is that theĭEFAULT_CHARSET setting is not actually under your control (if you are theĪpplication developer). Django will always assume UTF-8Įncoding for internal bytestrings. The result of template rendering (and email). To something other than 'utf-8' you can use that other encoding in yourīytestrings! DEFAULT_CHARSET only applies to the strings generated as Passing them around at will, because ASCII is a subset of UTF-8.ĭon’t be fooled into thinking that if your DEFAULT_CHARSET setting is set If your code only uses ASCII data, it’s safe to use your normal strings, Things will go wrong in interesting ways. If you pass a string to Django that has been encoded in some other format, To tell Django what encoding your database uses: that is handled transparently.įor more, see the section “The database API” below.Ī bytestring does not carry any information with it about its encoding.įor that reason, we have to make an assumption, and Django assumes that all They also automaticallyĬonvert strings retrieved from the database into strings. The appropriate encoding for talking to the database. ![]() SQLite always uses UTF-8Īll of Django’s database backends automatically convert strings into SQLite users, there is nothing you need to do.( section 2) or alter ( section 11) the database character set encoding. Oracle users, refer to the Oracle manual for details on how to set.PostgreSQL users, refer to the PostgreSQL manual for details on creating.MySQL users, refer to the MySQL manual for details on how to set or alter.If you useĪ more restrictive encoding – for example, latin1 (iso8859-1) – you won’t beĪble to store certain characters in the database, and information will be lost. Normally, this means giving it an encoding of UTF-8 or UTF-16. ![]() Make sure your database is configured to be able to store arbitrary stringĭata.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |