# Is there any parameter to textField in model to remove '\\r'

**URL:** <https://forum.djangoproject.com/t/is-there-any-parameter-to-textfield-in-model-to-remove-r/11523>\
**Category:** Django Internals\
**Created:** [January 12, 2022, 10:29am UTC](https://forum.djangoproject.com/t/is-there-any-parameter-to-textfield-in-model-to-remove-r/11523 "2022-01-12T10:29:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdacjitthu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/cdacjitthu/32/5946_2.png) [@cdacjitthu](https://forum.djangoproject.com/u/cdacjitthu)\
**Post date:** [January 12, 2022, 10:29am UTC](https://forum.djangoproject.com/t/is-there-any-parameter-to-textfield-in-model-to-remove-r/11523/1 "2022-01-12T10:29:12Z")

</div>

Hi,  
In model, one of the column in postgres is text area. Do this

```auto
class Car(models.Model):
    car_id = models.PositiveBigIntegerField("Car Number", primary_key=True)
    car_description = models.TextField("Describe")

```

registered the model in admin. started creating records in admin page and it was observed that it was appended with ‘\r’ when i press enter in the text area.

postgres=# select \* from car\_model;  
-[RECORD 1]—±-------------------  
car\_id | 1234  
car\_description | This is old car.\r +  
| Car number is 1234.  
Is there any way not append ‘\r’ when press enter in the text area?

---

<div class="post-metadata">

**Author:** ![bmispelon](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/bmispelon/32/38_2.png) [@bmispelon](https://forum.djangoproject.com/u/bmispelon)\
**Post date:** [January 12, 2022, 11:26am UTC](https://forum.djangoproject.com/t/is-there-any-parameter-to-textfield-in-model-to-remove-r/11523/2 "2022-01-12T11:26:20Z")

</div>

Hi,

`\r` is also called “carriage return” (CR) and is how new lines are represented in some operating systems (macOS typically). Other OSes can use `\n` (“line feed”) or even the combination of both `\r\n`.

Unfortunately there’s nothing in Django to normalize which character is used to represent a new line, so if that’s important for you you have to handle it yourself (using custom validation on the form for example).

It was proposed to add something at one point (9 years ago), but the idea was rejected: [#19251 (Normalize newlines from Textarea widgets) – Django](https://code.djangoproject.com/ticket/19251)  
Since then, Django did add the `strip` option (defaulting to `True`) that was also mentioned in this ticket, so maybe the idea of normalizing new lines would be received more positively today.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 12, 2022, 12:30pm UTC](https://forum.djangoproject.com/t/is-there-any-parameter-to-textfield-in-model-to-remove-r/11523/3 "2022-01-12T12:30:03Z")

</div>

Also note that this is normally an invisible character. You’re only seeing it because of how you’re looking at the data.

If that data gets reloaded into the text area, you won’t see it, nor will you see it if you render that field as text within a page.

---

<div class="post-metadata">

**Author:** ![cdacjitthu](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/cdacjitthu/32/5946_2.png) [@cdacjitthu](https://forum.djangoproject.com/u/cdacjitthu)\
**Post date:** [January 13, 2022, 4:55pm UTC](https://forum.djangoproject.com/t/is-there-any-parameter-to-textfield-in-model-to-remove-r/11523/4 "2022-01-13T16:55:22Z")

</div>

Thank you for quick for response.  
To remove “\r” from the TextField, i used clean validator of the model.

```auto
def clean(self):
    self.car_description = self.car_description.replace("\r", "\n")

```

in database, it is saved as  
postgres=# select \* from car\_model; -[RECORD 1]—±-------------------  
car\_id | 1234  
car\_description | This is old car. +  
| +  
| Car number is 1234.  
I want user readability. Therefore, i overwritten “\r” with “\n”. The side-effect is, introducing a new line in the database.  
Is there any better approach to resolve this (user readability is the priority)?  
Note: In actual use-case, i provide, SQL DDL statements. Here, i need user readability because of DDL statement after rendering from database to UI, i can not replace “\r” with " ".
