Django: How to use UUIDField from django-extensions

How to use UUIDField in my model?

If i do

somefield = UUIDField 

I get:

  UUIDField is not defined. 

I am importing uuid on top of my model file.

And I have django_extensions in installed applications ...

+6
source share
1 answer

A good place to see how to use the features of a Django application are application tests.

Here are a few examples from the django-extension UUIDField tests that demonstrate how to use this field:

 from django.db import models from django_extensions.db.fields import UUIDField class TestModel_field(models.Model): a = models.IntegerField() uuid_field = UUIDField() class TestModel_pk(models.Model): uuid_field = UUIDField(primary_key=True) 

Without seeing the whole file, it's hard to say what is happening. Make sure you import the UUIDField from django_extensions.db.fields (as in the example above), and not into the uuid Python module.

+22
source

Source: https://habr.com/ru/post/905420/


All Articles