Django 1.10 full text search by UUIDField returns DataError
<p>I have the following model:</p>

<pre><code>class Show(models.Model):
    cid = models.UUIDField(
        default=uuid.uuid4,
        editable=False,
        verbose_name="Content ID",
        help_text="Unique Identifier"
    )
    title_short = models.CharField(
        max_length=60,
        blank=True,
        verbose_name="Short Title",
        help_text="Short title (60 chars)"
    )
</code></pre>

<p>I'm using the below snippet</p>

<pre><code>from django.contrib.postgres.search import SearchVector
Entry.objects.annotate(
    search=SearchVector('cid'),
).filter(search='wateva')
</code></pre>

<p>Returns:</p>

<pre><code>DataError at /meta/shows/

invalid input syntax for uuid: ""
LINE 1: ...unt", to_tsvector(COALESCE("entities_show"."cid", '')) AS    "s...
</code></pre>

<p>I tried with PostgreSQL 9.3.14 and PostgreSQL 9.5.3, Python 3.4.3</p>

<p>Has anyone encountered this issue ?</p>

<p>You may want to file a bug-report.</p>

<p>The Django code creates a COALESCE() statement, assuming that the final fallback value of an empty string (<code>''</code>) is acceptable for fields given.
I don't see a way to specify the fallback value through the official API, and since UUID fields are translated to Postgres Native <a href="https://www.postgresql.org/docs/9.4/static/datatype-uuid.html" rel="nofollow">UUID</a> fields, the empty string is an invalid value for that field.</p>

<p>If you decide to file a report, please add a comment here with the ticket ID, I might pitch in fixing it as I have a vested interest in this feature.</p>

python django postgresql full-text-search uuid