[Django] #27562: Django using uuid as primary key, receive AttributeError during createsuperuser

52 views
Skip to first unread message

Django

unread,
Dec 1, 2016, 9:48:05 PM12/1/16
to django-...@googlegroups.com
#27562: Django using uuid as primary key, receive AttributeError during
createsuperuser
-----------------------------------------+------------------------
Reporter: diansheng | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
I am using uuid as the primary key for my CustomerUser model which is to
override the default django user. I got an AttributeError when trying to
run `./manage.py createsuperuser`

Here is my model.
`
class CustomUser(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
user_type = models.CharField(max_length=1, choices=TYPE_USER,
default='U')
is_deleted = models.BooleanField(_('deleted'), default=False)
`
Software version: django version 1.10.2 and python version 2.7.10

And this is the exception

`
value = uuid.UUID(value)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py",
line 131, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'long' object has no attribute 'replace'
`

--
Ticket URL: <https://code.djangoproject.com/ticket/27562>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 1, 2016, 9:50:08 PM12/1/16
to django-...@googlegroups.com
#27562: Django using uuid as primary key, receive AttributeError during
createsuperuser
-------------------------------------+-------------------------------------
Reporter: Sean, Liu Diansheng | Owner: nobody

Type: Bug | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Sean, Liu Diansheng:

Old description:

> I am using uuid as the primary key for my CustomerUser model which is to
> override the default django user. I got an AttributeError when trying to
> run `./manage.py createsuperuser`
>
> Here is my model.
> `
> class CustomUser(AbstractUser):
> id = models.UUIDField(primary_key=True, default=uuid.uuid4,
> editable=False)
> user_type = models.CharField(max_length=1, choices=TYPE_USER,
> default='U')
> is_deleted = models.BooleanField(_('deleted'), default=False)
> `
> Software version: django version 1.10.2 and python version 2.7.10
>
> And this is the exception
>
> `
> value = uuid.UUID(value)
> File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py",
> line 131, in __init__
> hex = hex.replace('urn:', '').replace('uuid:', '')
> AttributeError: 'long' object has no attribute 'replace'
> `

New description:

I am using '''uuid as the primary key''' for my ''CustomerUser model''
which is to override the default django user. I got an AttributeError when
trying to run `./manage.py createsuperuser`

Here is my model.
{{{
class CustomUser(AbstractUser):
id = models.UUIDField(primary_key=True, default=uuid.uuid4,
editable=False)
user_type = models.CharField(max_length=1, choices=TYPE_USER,
default='U')
is_deleted = models.BooleanField(_('deleted'), default=False)
}}}
Software version: django version 1.10.2 and python version 2.7.10

And this is the exception

{{{
value = uuid.UUID(value)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/uuid.py",
line 131, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'long' object has no attribute 'replace'
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27562#comment:1>

Django

unread,
Dec 1, 2016, 10:17:04 PM12/1/16
to django-...@googlegroups.com
#27562: Django using uuid as primary key, receive AttributeError during
createsuperuser(NOT AN ISSUE)

-------------------------------------+-------------------------------------
Reporter: Sean, Liu Diansheng | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sean, Liu Diansheng):

* status: new => closed
* resolution: => invalid
* type: Bug => Uncategorized


Comment:

I restarted mysql, delete all migrations and databases, the issue is gone.
It is not a bug.

--
Ticket URL: <https://code.djangoproject.com/ticket/27562#comment:2>

Reply all
Reply to author
Forward
0 new messages