I have a model like this:
class CampaignPermittedURL(models.Model):
hostname = models.CharField(max_length=255)
path = models.CharField(max_length=255,blank=True)
Often, I will be given a URL that I can use to enter the host name and path. I would like the end user to be able to enter the host name (yahoo.com) and possibly the path (weddings).
I would like to find when the url does not match this host / path combination this way:
- success: www.yahoo.com/weddings/newyork
- success: yahoo.com/weddings
- failure: cnn.com
- crash: cnn.com/weddings
I think the best way to do this is:
url = urlsplit("http://www.yahoo.com/weddings/newyork")
matches = CampaignPermittedURL.objects.filter(hostname__regex=r'(com|yahoo.com|www.yahoo.com)'), \
path__regex=r'(weddings|weddings/newyork)')
- ? PostgreSQL Django Full , , , . , ?
, URL-, , CampaignPermittedURL . / , , .
back-end (Sphinx?), Django .