Changes between Version 3 and Version 4 of SlugifyUniquely


Ignore:
Timestamp:
May 4, 2010, 9:05:13 AM (15 years ago)
Author:
copiesofcopies
Comment:

Removed resume spam

Legend:

Unmodified
Added
Removed
Modified
  • SlugifyUniquely

    v3 v4  
    1 It's common for me to want a unique slug based on a user supplied name of an object. Following the pattern outlined at [http://www.b-list.org/weblog/2006/11/02/django-tips-auto-populated-fields djang-tips-auto-populated-fields], it's easy to get the field populated without user intervention. However, by setting the slug field in the save() method the field isn't validated and thus unique=True restrictions aren't checked. I wrote the following code to attempt to pick slugs which are unique within a particular model, [http://bestresearchpapers.net research paper] or [http://www.exclusive-essays.com/exes/Custom-Essays custom essay]. It's certainly not ideal (it suffers from race condition as well as potential for pounding a database with lots of small queries until it finds a good slug field), but it works for my small/mid-sized apps.[http://www.resumesplanet.com resume writers]
    2 
    3 
     1It's common for me to want a unique slug based on a user supplied name of an object. Following the pattern outlined at [http://www.b-list.org/weblog/2006/11/02/django-tips-auto-populated-fields djang-tips-auto-populated-fields], it's easy to get the field populated without user intervention. However, by setting the slug field in the save() method the field isn't validated and thus unique=True restrictions aren't checked. I wrote the following code to attempt to pick slugs which are unique within a particular model. It's certainly not ideal (it suffers from race condition as well as potential for pounding a database with lots of small queries until it finds a good slug field), but it works for my small/mid-sized apps.
    42
    53Feel free to suggest improvements to 'wam-djangowiki spam@wamber.net' (remove the ' spam' from the address there).
Back to Top