The first argument to Constraint.construct() is a URL helper object which 
allows you to set the scheme, host, path, querystring and fragment 
separately. So reversing a domain constraint is as simple as this:

class DomainConstraint(Constraint):
    def construct(self, url_object, *args, **kwargs): = self.domain
        return url_object, args, kwargs

On Thursday, January 7, 2016 at 2:07:03 PM UTC+1, Florian Apolloner wrote:
> On Monday, December 28, 2015 at 5:23:19 PM UTC+1, Marten Kenbeek wrote:
>> One can for example implement a DomainConstraint or MethodConstraint to 
>> match a domain name or request method in the URL, or implement a set of 
>> constraints based on the parse library for better performance than the 
>> built-in regex-based constraints.
> A method constraint seems simple enough, how would the domain constraint 
> work with regards to reversing -- do you have an example for that?
> Cheers,
> Florian

You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

Reply via email to