UUIDField oriented django User

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from django.db import models
from django.db.models.fields import AutoField
from django.contrib.auth.models import User
from fields import UUIDField

if type(User._meta.pk) != type(UUIDField()):
    for f in User._meta.local_fields:
        if f.name == 'email':
            f.null = False
            f.blank = False
        if f.name == 'id':
            User._meta.local_fields.remove(f)
    User._meta.pk = None
    uuidfield = UUIDField(primary_key=True)
    User.add_to_class("id", uuidfield)
    temp = User._meta.local_fields.pop()
    User._meta.local_fields = [temp] + User._meta.local_fields

More like this

  1. UUIDField by bwhittington 4 years, 1 month ago
  2. safe(r) monkeypatching scheme for django testing by showell 3 years, 6 months ago
  3. duplicate model object merging script by nstrite 5 years, 10 months ago
  4. Decorator to modify reverse() to render SSL urls by AndrewIngram 4 years, 1 month ago
  5. Arbitrary auto-generated primary keys by gsakkis 2 years, 11 months ago

Comments

(Forgotten your password?)