Obviously i tried with
(r'^users/activate_user/(?P<code>)/', 'views.register'),
(r'^users/activate_user/(?P<code>[a-zA-Z0-9%\-]+=)/',
'views.register'),
but it doesn't work: Django always return 404.
Is it an encoding problem or something? Any idea on how should i do?
Cheers (and grateful thanks, this group is greatly useful)
> As i said, i need to pass in my URL a <code> variable, wich is the
> result of a md5 digest.
> (no private information... only a validation key).
>
> Obviously i tried with
> (r'^users/activate_user/(?P<code>)/', 'views.register'),
> (r'^users/activate_user/(?P<code>[a-zA-Z0-9%\-]+=)/',
> 'views.register'),
> but it doesn't work: Django always return 404.
It works for me if the code ends with a single equals sign.
e.g.
http://localhost/users/activate_user/abc123=/
If you're stuck, maybe you could post a couple of example urls that
give you 404 errors.
Scott
I post, maybe someone could find it useful.
In my view i used the base64 library.
import md5, base64
...
key = md5.new(string).digest()
key = base64.urlsafe_b64encode(key)
validation.md5_key = key
validation.save()
The URL is
(r'^users/activate_user/(?P<code>[a-zA-Z0-9%\-]+==)/',
'views.activate_user'),
the final '+==' make it works, as any key generated this way ends with
2 equal signs.
On 27 Feb, 17:11, "ScottB" <tepidr...@gmail.com> wrote:
> Hi Giuseppe.
>
> > As i said, i need to pass in my URL a <code> variable, wich is the
> > result of a md5 digest.
> > (no private information... only a validation key).
>
> > Obviously i tried with
> > (r'^users/activate_user/(?P<code>)/', 'views.register'),
> > (r'^users/activate_user/(?P<code>[a-zA-Z0-9%\-]+=)/',
> > 'views.register'),
> > but it doesn't work: Django always return 404.
>
> It works for me if the code ends with a single equals sign.
> e.g.http://localhost/users/activate_user/abc123=/
An md5 hex digest is always 32 characters long, containing digits and
letters A through F, so something like
[a-fA-F0-9]{32}
is about as exact a regex for matching it as you'll find.
SHA1 has the same character range -- [a-fA-F0-9] -- but is forty
characters long.
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
Look at this: http://code.google.com/p/django-registration/
and this: http://django-registration.googlecode.com/svn/trunk/urls.py
--
Mfg.
Jens Diemer
----
CMS in pure Python CGI: http://www.pylucid.org