fork download
  1. # your code goes here
  2. from django.db import models
  3. from taggit.managers import TaggableManager
  4. from resize.fields import ResizedImageField
  5. from taggit.models import GenericTaggedItemBase, TagBase
  6. from taggit.managers import _TaggableManager
  7. from autoslug import AutoSlugField
  8.  
  9. # Create your models here.
  10.  
  11. class CategoriesTag(TagBase):
  12. pass
  13. class CategoriesTaggedItem(GenericTaggedItemBase):
  14. tag = models.ForeignKey(CategoriesTag)
  15.  
  16. class Article(models.Model):
  17. class Meta():
  18. db_table = 'article'
  19.  
  20. article_title = models.CharField(max_length=256, blank=True)
  21.  
  22. image = ResizedImageField(resolutions=('135x240', '207x368',
  23. '360x640', '640x1136',
  24. '640x960', '720x1280',
  25. '750x1334', '1080x1920',
  26. '1080x2160', '1440x2560'), upload_to='images', blank=True)
  27. tags = TaggableManager(blank=True)
  28.  
  29. categories = TaggableManager(verbose_name='Categories', through=CategoriesTaggedItem, blank=True)
  30.  
  31. slug = AutoSlugField(populate_from='article_title')
  32.  
  33. #Проблема здесь
  34. def save(self, *args, **kwargs):
  35. if not self.id:
  36. self.article_title = ' '.join(self.tags.names()) # self.tags.names() возвращает list со строками тэгов
  37. super(Article, self).save(*args, **kwargs)
  38.  
  39. def __str__(self):
  40. return self.article_title
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "/usr/lib/python3.4/py_compile.py", line 124, in compile
    _optimize=optimize)
  File "<frozen importlib._bootstrap>", line 1532, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "./prog.py", line 40
    return self.article_title
                            ^
TabError: inconsistent use of tabs and spaces in indentation

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.4/py_compile.py", line 128, in compile
    raise py_exc
py_compile.PyCompileError: Sorry: TabError: inconsistent use of tabs and spaces in indentation (prog.py, line 40)
stdout
Standard output is empty