Skip to content

Instantly share code, notes, and snippets.

@aruseni
Created February 8, 2017 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aruseni/301b50bbc095a886eaa445252f812791 to your computer and use it in GitHub Desktop.
Save aruseni/301b50bbc095a886eaa445252f812791 to your computer and use it in GitHub Desktop.
This is a TextField-based field with TextInput widget. This can be used instead of a CharField whenever you do not want to restrict the length of the content at the DB level (see http://stackoverflow.com/questions/4848964/postgresql-difference-between-text-and-varchar-character-varying for more info).
from django.db import models
from django import forms
class TextInputTextField(models.TextField):
def formfield(self, **kwargs):
kwargs.update({
"widget": forms.TextInput
})
return super(TextInputTextField, self).formfield(**kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment