Forums

Django-thumbs

Hi, I try to use "django-thumbs" from http://djangothumbnails.com/. I've done all from guide, but I get an answer: 'module' object has no attribute 'ImageWithThumbsField'. What do you think about it?

I don't know much about Django, but does the path to the module need to be added to INSTALLED_APPS in settings.py? Does the module have an __init__.py file to be recognised as a Python module? It sounds like it's not importing the module properly, essentially.

No, it doesn't need to be added ti INSTALLED_APPS, because it isn't application and doesn't have an init.py file. You can look at guide in site http://djangothumbnails.com. I've just dowlanded a file "thumbs.py" and import by string: from eties.nurdus_shop.thumbs import ImageWithThumbsField (also tried by string: from thumbs import ImageWithThumbsField)

It may be that you have a module called thumbs that's earlier on your python path than the thumbs.py from djangothumbnails. Try importing thumbs and look at its __file__ attribute.

I've tried, it shows me true path.

That sounds very odd. Where is the code that's doing the import? Do you mind if we log in and take a look at your source?

I don't mind, you can try to do it. There is importing in file /home/nurdus/eties/nurdus_shop/model.py (in a line 8). A problem become when I uncomment code in line 55 and do 'schemamigration' in bash console.

Thanks. In line 55, you're referring to models.ImageWithThumbsField -- I think that should just be ImageWithThumbsField, without the models..

Thank you very much. I see. I'm stupid :)

If every software engineer who didn't notice a simple mistake were branded stupid, I don't think there'd be a single clever person left in the industry. (^_^)

As an aside, if you use Vim then there's a plugin to integrate with pyflakes - among other things, it will highlight any cases where you've used a name which doesn't exist (e.g. if you misspell a module name). It also detects syntax errors and unused variables and modules. It's not as severe as pylint, but it's lightweight enough to run automatically in the background.

I gather all the cool kids use syntastic for their vim syntax-error / linting needs... includes pyflakes but also jslint and any others you may have installed...

@harry: Hm, that looks pretty handy, thanks. It's also conveniently on Github so I can simply add it as a subtree of my own dotfiles repository there.

Thanks your supporting, I'm going to think about using Vim.

@nurdus -- vim is a great editor, and I'm sure we'd all absolutely encourage you to learn it (join us, joooin us...). But if you're still a beginner, you should be warned that it takes a little while to learn and get comfortable with...

@Cartroo nice dotfiles. I'm stealing some bits of your bashrc. Here's mine. You may, in particular, enjoy the STATUS LINE OF DEATH, all credit due to @tartley...

@nurdus: Vim has a steep learning curve, but if you edit files a lot (especially software) then you'll start to appreciate its features.

@harry: Glad there was something there of use. If you're a tmux user, I've just pushed another change which (among other things) auto-attaches to any running tmux session on login. Currently it's conditional in having something set in the .localbashrc to enable it, but that's obviously trivial to change. Might be useful for long-term working on machines on the other end of a damp piece of string, although possibly mosh is a more elegant solution.

The STATUSLINE OF DEATH certainly looks like a grand edifice worthy of closer inspection - I'll probably end up stealing bits of it piecemeal. Ta!