I've an existing project on Django 3.1 and I upgraded my project to Django 
3.2. I created an app called payment on my project. But When I make 
migrations. It trow an error 
```AttributeError: 'TextField' object has no attribute 'db_collation'```
```
from django.db import models
from django.conf import settings
from django.utils.translation import gettext_lazy as _
# Create your models here.
from simple_history.models import HistoricalRecords


class TransactionType(models.TextChoices):
    CASH_IN = 'IN', _('Cash In')
    CASH_OUT = 'OUT', _('Cash Out')


class TransactionMethod(models.TextChoices):
    STUDENT_TR = 'STT', _('Student Transaction')
    BANK_TR = 'BKT', _('Bank Transaction')
    SCHOOL_TR = 'SLT', _('School Transaction')
    Teacher_TR = 'TRT', _('Teacher Transaction')
    DONATE_TR = 'DET', _('Donate Transaction')


class Payment(models.Model):
    id = models.AutoField(primary_key=True)
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   on_delete=models.PROTECT,
                                   related_name="created_by")
    updated_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   on_delete=models.PROTECT,
                                   related_name="updated_by")
    transaction_amount = models.FloatField("Transaction amount")
    transaction_type = models.CharField(max_length=3, 
choices=TransactionType.choices, default=TransactionType.CASH_IN,)
    transaction_method = models.CharField(max_length=3, 
choices=TransactionMethod.choices, default=TransactionMethod.STUDENT_TR,)
    transaction_note = models.CharField(null=True, blank=True, 
max_length=200)
    is_approved = models.BooleanField(default=False)
    is_approved_by_user = models.ForeignKey(settings.AUTH_USER_MODEL,
                                            on_delete=models.PROTECT,
                                            related_name="approved_by",
                                            null=True,
                                            blank=True)
    created_at = models.DateTimeField(auto_now=True, blank=True, null=True)
    updated_at = models.DateTimeField(auto_now_add=True, blank=True, 
null=True)
    history = HistoricalRecords()


```

Full error message 
```Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 419, in execute_from_command_line
    utility.execute()
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/__init__.py",
 
line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 398, in execute
    output = self.handle(*args, **options)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/base.py",
 
line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py",
 
line 150, in handle
    ProjectState.from_apps(apps),
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/migrations/state.py",
 
line 220, in from_apps
    model_state = ModelState.from_model(model)
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/migrations/state.py",
 
line 407, in from_model
    fields.append((name, field.clone()))
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
 
line 512, in clone
    name, path, args, kwargs = self.deconstruct()
  File 
"/home/asad/PycharmProjects/amarschool/venv/lib/python3.6/site-packages/django/db/models/fields/__init__.py",
 
line 2173, in deconstruct
    if self.db_collation:
AttributeError: 'TextField' object has no attribute 'db_collation'
```
stackoverflowlink: 
https://stackoverflow.com/questions/66981658/django-3-2-attributeerror-textfield-object-has-no-attribute-db-collation

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1c70a09d-e14f-4a38-bcf5-90dd4ac327fen%40googlegroups.com.

Reply via email to