I response in the other mail, but I am curious
changing TextField for. CharField with max_length has big impact in the
database performance.

I saw you have a lot of TextFields so are you sure that you need all those
TextFields ? Or y
could you change those TextFields for CharFields with a small max_length ?

#    id = models.TextField(primary_key=True)

    id = models.CharField(primary_key=True, max_length = 32)




El viernes, 19 de febrero de 2016, Mike Dewhirst <mi...@dewhirst.com.au>
escribió:
> On 20/02/2016 6:26 AM, Sammi Singh wrote:
>>
>> Hi,
>>
>> I'm new to Django and facing this error
>> "*/django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'id' used
>> in key specification without a key length")/*"
>>
>> Here is my code:
>>
>> class Steps(models.Model):
>>
>> Â  Â  author = models.ForeignKey(User)
>>
>> #Â  Â  id = models.TextField(primary_key=True)
>
> I don't think it makes sense to use a text field as a primary key. If you
don't want to use the default primary key (and you need a strong case to
want something else) and you really want a string as a primary key use
models.CharField(max_length=99, primary_key=True)
>
>
>>
>> Â  Â  id = models.CharField(primary_key=True, max_length = 32)
>>
>> Â  Â  text = models.TextField()
>>
>> Â  Â  status = models.TextField()
>>
>> Â  Â  step_id = models.TextField(null=True)
>>
>> Â  Â  release_id = models.TextField(null=True)
>>
>> Â  Â  region = models.TextField(null=True)
>>
>> Â  Â  # Time is a rhinocerous
>>
>> Â  Â  updated = models.DateTimeField(auto_now=True)
>>
>> Â  Â  created = models.DateTimeField(auto_now_add=True)
>>
>>
>> class UserConfig(models.Model):
>>
>> Â  Â  author = models.ForeignKey(User)
>>
>> #Â  Â  id = models.TextField(primary_key=True)
>>
>> Â  Â  id = models.CharField(primary_key=True, max_length = 32)
>>
>> Â  Â  co_range = models.TextField()
>>
>> Â  Â  tu_range = models.TextField()
>>
>> Â  Â  st_range = models.TextField()
>>
>> Â  Â  de_host = models.TextField()
>>
>> Â  Â  in_host1 = models.TextField()
>>
>> Â  Â  in_host2 = models.TextField()
>>
>> Â  Â  in_host3 = models.TextField()
>>
>> Â  Â  co_host = models.TextField()
>>
>> Â  Â  vp_name = models.TextField()
>>
>>
>> Â  Â  # Time is a rhinocerous
>>
>> Â  Â  updated = models.DateTimeField(auto_now=True)
>>
>> Â  Â Â created = models.DateTimeField(auto_now_add=True)
>>
>>
>> Any help would be appreciated......
>>
>>
>> Regards
>>
>> Sammi
>>
>> --
>> 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 django-users+unsubscr...@googlegroups.com
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>>
https://groups.google.com/d/msgid/django-users/5100d863-f887-4b97-9ea4-95227ab99bdf%40googlegroups.com
>> <
https://groups.google.com/d/msgid/django-users/5100d863-f887-4b97-9ea4-95227ab99bdf%40googlegroups.com?utm_medium=email&utm_source=footer
>.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/56C7A494.4060103%40dewhirst.com.au
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyPLG2Tnyqxz_6yHWDX_qHgjgRL2%2B-5wOHCa3b0GQYeiAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to