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. Dynamic Models Revisited by Ben 4 years, 4 months ago
  2. Save a model using an arbitrary db connection by weswinham 2 years, 5 months ago
  3. Database migration and dump/load script by akaihola 4 years, 10 months ago
  4. ModelForm-based create_update generic views by carljm 3 years, 6 months ago
  5. Little middleware that create a facebook user by marinho 4 years, 1 month ago

Comments

(Forgotten your password?)