Skip to content

Commit

Permalink
Merge pull request #41 from caktus/31-flexible-object-id
Browse files Browse the repository at this point in the history
Change object_id to a CharField to allow linking to UUID PKs
  • Loading branch information
vkurup committed Oct 1, 2015
2 parents e79e3ce + c67510c commit 932dfa9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
19 changes: 19 additions & 0 deletions treenav/migrations/0002_auto_20151001_1646.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('treenav', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='menuitem',
name='object_id',
field=models.CharField(default=b'', max_length=36, db_index=True, blank=True),
),
]
7 changes: 5 additions & 2 deletions treenav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ class MenuItem(MPTTModel):
null=True,
blank=True,
)
object_id = models.PositiveIntegerField(
null=True,
object_id = models.CharField(
# use a CharField to be able to point to tables with UUID pks
max_length=36,
blank=True,
db_index=True,
default=''
)
content_object = fields.GenericForeignKey('content_type', 'object_id')
href = models.CharField(_('href'), editable=False, max_length=255)
Expand Down

0 comments on commit 932dfa9

Please sign in to comment.