Created
July 5, 2010 21:33
-
-
Save jjdelc/464710 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -crB django_extensions/db/fields/__init__.py /home/jj/programas/django/extras/django-extensions/django_extensions/db/fields/__init__.py | |
*** django_extensions/db/fields/__init__.py 2010-07-05 16:15:30.000000000 -0500 | |
--- /home/jj/programas/django/extras/django-extensions/django_extensions/db/fields/__init__.py 2010-07-05 16:23:38.000000000 -0500 | |
*************** | |
*** 67,91 **** | |
self._populate_from = (self._populate_from, ) | |
slug_field = model_instance._meta.get_field(self.attname) | |
- slug_for_field = lambda field: self.slugify_func(getattr(model_instance, field)) | |
if add or self.overwrite: | |
# slugify the original field content and set next step to 2 | |
slug = self.separator.join(map(slug_for_field, self._populate_from)) | |
next = 2 | |
else: | |
# get slug from the current model instance and calculate next | |
# step from its number, clean-up | |
slug = self._slug_strip(getattr(model_instance, self.attname)) | |
! generated_slug = self.separator.join(map(slug_for_field, self._populate_from)) | |
! # Make sure we're not confusing "articles-2010" where 2010 is | |
! # the year generated from the slug and not the next added to | |
! # avoid dups | |
! if slug.startswith(generated_slug): | |
! rest_of_slug = slug[len(generated_slug):] | |
! next = rest_of_slug.split(self.separator)[-1] | |
! else: | |
! next = '' | |
! | |
if next.isdigit(): | |
slug = self.separator.join(slug.split(self.separator)[:-1]) | |
next = int(next) | |
--- 67,82 ---- | |
self._populate_from = (self._populate_from, ) | |
slug_field = model_instance._meta.get_field(self.attname) | |
if add or self.overwrite: | |
# slugify the original field content and set next step to 2 | |
+ slug_for_field = lambda field: self.slugify_func(getattr(model_instance, field)) | |
slug = self.separator.join(map(slug_for_field, self._populate_from)) | |
next = 2 | |
else: | |
# get slug from the current model instance and calculate next | |
# step from its number, clean-up | |
slug = self._slug_strip(getattr(model_instance, self.attname)) | |
! next = slug.split(self.separator)[-1] | |
if next.isdigit(): | |
slug = self.separator.join(slug.split(self.separator)[:-1]) | |
next = int(next) | |
*************** | |
*** 253,256 **** | |
field_class = "django.db.models.fields.CharField" | |
args, kwargs = introspector(self) | |
# That's our definition! | |
! return (field_class, args, kwargs) | |
--- 244,247 ---- | |
field_class = "django.db.models.fields.CharField" | |
args, kwargs = introspector(self) | |
# That's our definition! | |
! return (field_class, args, kwargs) | |
\ No newline at end of file | |
Only in django_extensions/db/fields: __init__.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment