I think this is not how it works. The snippet is a form field, not a model
field. Basically I think you should use an IntegerField (you just want to
store a year, right?). Then somehow you need to override the widget or so
and make sure that in the admin that form will be used for that
IntegerField. This form field basically just makes sure, that people don't
enter anything stupid, but what is being saved will just be a normal
integer, I guess.

Sorry, don't have enough time to give a better hint.

Best regards,
Martin

On Sat, Jun 11, 2011 at 9:53 AM, mhulse <rgmi...@gmail.com> wrote:

> I feel like this should be simple...
>
> I would like to replace this model field:
>
> date = models.DateField(_(u'Year'), unique=True)
>
> ...with this snippet:
>
> http://djangosnippets.org/snippets/508/
>
> I have spent the last couple hours banging my head on my keyboard...
>
> During the course of my tests, at one point, I was getting an error that
> said something like "__init__() got an unexpected keyword argument 'unique'"
> (I think I was trying to extend IntegerField).
>
> Any tips on how to convert that snippet so I can do:
>
> from app.fields import YearField
> ...
> year = YearField(_(u'Year'), unique=True)
> ...
>
> Normally I wouldn't ask, but I am ready to give up... At this point, I am
> just curious to see how it's done for the sake of learning something new.
>
> Thanks so much!
>
> Cheers,
> Micky
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Ov8sCyIqUUIJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to