﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20448	Make Model.__repr__() safe	Patryk Zawadzki	nobody	"`__repr__` is mainly used in the debugging context and it calling `__unicode__` can yield unwanted consequences such as executing a database query. I also propose having it include the primary key of the object so it's easy to track the record in the database. `__unicode__` is not really suitable for lookup, even if it returns contents of an actual database field in most cases it will be an unindexed column.

Please note that while having a more verbose `__repr__` can be useful, you can always overload this method in your models.

There is a pull request on GitHub that implements `__repr__` the following way:

```
>>> Foo.objects.create()
Foo(id=1)
```

https://github.com/django/django/pull/1108"	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	wontfix			Unreviewed	1	0	0	0	0	0
