MAC Address-Field needed- Validate a Char-Field (RegEx) or create my own Field?

178 views
Skip to first unread message

ARie

unread,
Feb 6, 2009, 6:46:16 AM2/6/09
to Django users
Hi all,

i am just trying to create my first django application an ran into a
problem creating a field for a mac address.
I am looking for something similar as django's built in
IPAddressField.
As a special mac-field is missing, ithought i could simply use a char-
Field an validate it accordingly or i could use an RegExField, which
is mentioned in the documentation.
Unfortunately RexExFields don't seem to work within the admin form
(for now all the data will be entered via the admin interface). At
least i get the following error adding such a field:
"AttributeError: 'module' object has no attribute 'RegexField'"
I didn't just simply miss to import the right module, right?

If it isn't possible to create an RegExField, which other options to i
have to validate the user input in an admin form so that it sticks to
the pattern of a mac address?
I read some stuff about validators but as i learned, these are not
present anymore in django 1.x

Thanks for your help!
Andreas
Message has been deleted

Lee Braiden

unread,
Feb 6, 2009, 9:05:59 AM2/6/09
to django...@googlegroups.com
ARie,

Ideally, I think you'd want to create a mac field that works more like
a credit card validation field than a simple regex checker. I say
that because you could check the manufacturer prefix codes of the mac
addresses and verify that the suffixes match things they've produced,
and stuff like that. Maybe you couldn't do all of this yourself, but
if you get it started with a regex, and open source the code, others
would probably help.

I'm not sure if regexes are available in javascript, but I think you'd
want to validate this on the client side, or appear to, as well as
doing server-side validation.

2009/2/6 ARie <kap.tu...@googlemail.com>:


>
> Hi all,
>
> i am just trying to create my first django application an ran into a
> problem creating a field for a mac address.
> I am looking for something similar as django's built in
> IPAddressField.
> As a special mac-field is missing, ithought i could simply use a char-
> Field an validate it accordingly or i could use an RegExField, which
> is mentioned in the documentation.
> Unfortunately RexExFields don't seem to work within the admin form
> (for now all the data will be entered via the admin interface). At

--
Lee

Reply all
Reply to author
Forward
0 new messages