ulule / django-badgify Goto Github PK
View Code? Open in Web Editor NEWA reusable application to create your own badge engine using Django
License: MIT License
A reusable application to create your own badge engine using Django
License: MIT License
I'm having a few issues. The first is simple. in README.md it says
from badgify.models import base
class Badge(base.Badge):
However the full path is badgify.models.base.badge.Badge. it should probably be something like
from badgify.models.base.badge import Badge as BaseBadge
class Badge(BaseBadge):
Even so I get a mysterious stack trace when trying to create the migration. Do you have any fuller example of a custom model?
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 443, in execute
self.check()
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 481, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python3.4/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python3.4/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 1183, in check
errors.extend(cls._check_long_column_names())
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 1624, in _check_long_column_names
for m2m in f.rel.through._meta.local_fields:
AttributeError: 'str' object has no attribute '_meta'
If I try to define both badge and award I get instead
my_badges.Award.badge: (fields.E300) Field defines a relation with model 'badgify.Badge', which is either not installed, or is abstract.
my_badges.Award: (fields.E336) The model is used as an intermediate model by 'my_badges.Badge.users', but it does not have a foreign key to 'Badge' or 'User'.
I can't redefine the relations because Django won't allow that.
Hello!
This package is great! But I need some more functionality:
Maybe, I don`t understand fully some code, so perhaps there are some solutions of these issues?
Thank a lot!
Hello!
There is such issue here, but I want to tell about the bug, I think.
from badgify.models import base
and base.Badge
but there is no Badge class in base
module. And init is empty. So is it right?Next, when adding CustomModel to models.py and set CustomModel path in settings.py
:
from badgify.models.base.badge import Badge as BaseBadge
class GuidaBadge(BaseBadge):
class Meta(BaseBadge.Meta):
abstract = False
and after run manage.py shell (or runserver or makemigartion) Python will run code line by line:
so firstly from badgify.models.base.badge import Badge as BaseBadge
would be run. But there is
Badge = load_class(settings.BADGE_MODEL)
https://github.com/ulule/django-badgify/blob/master/badgify/models/__init__.py#L8
in init.py of models. So python will try to load my custom model while custom model is not run by python.
So it is impossible to create custom model.
Have you tried to make custom model?
Say
badgify.register(Badge1)
badgify.register(Badge2)
or
badgify.register([Badge1, Badge2])
only Badge2 gets registered.
Currently it says "QuerySet returning User IDs likely to be awarded."
"likely to be awarded" is vague and gives no indication of what this actually does. Perhaps something like
"Optional. If set, this QuerySet will be awarded the badge when the badgify_sync awards command is run"
It might be good to provide some ideas on how Awards are given - as I can tell manually or with badgify_sync awards.
Hello1
I want to make the code that will automatically track changes in db. For example, I want to award user, which posts have more than, for example 100 likes.
So I need to auto generating awards,
How can I do it?
The JavaLoverRecipe example in the README file is mixing up "JavaScript" and "Java" terms. I guess it should be removed or updated.
Here is it straight from the README:
class JavaLoverRecipe(BaseRecipe):
"""
People loving Java.
"""
name = 'JS Lover'
slug = 'js-lover'
description = 'People loving JS programming language'
@property
def image(self):
return staticfiles_storage.open('js-lover.png')
Other than that, django-badgify seems to be a very promising module ;)
There is not such poin in Readme. But urls are included in exaple project.
Thanks.
When I try to run ./manage.py migrate:
`@sparagus ~/Developer/hackerspace_online/src $ ./manage.py makemigrations
/home/couture/Developer/hackerspace_online/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
return f(_args, *_kwds)
Traceback (most recent call last):
File "./manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/core/management/init.py", line 338, in execute_from_command_line
utility.execute()
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/core/management/init.py", line 312, in execute
django.setup()
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/importlib/init.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2231, in _gcd_import
File "", line 2214, in _find_and_load
File "", line 2203, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1448, in exec_module
File "", line 321, in _call_with_frames_removed
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/badgify/models/init.py", line 5, in
from ..utils import load_class
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/badgify/utils.py", line 56
except ImportError, e:
(hackerspace_online)couture@sparagus ~/Developer/hackerspace_online/src $ ./manage.py makemigrations
/home/couture/Developer/hackerspace_online/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
return f(_args, *_kwds)
Traceback (most recent call last):
File "./manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/core/management/init.py", line 338, in execute_from_command_line
utility.execute()
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/core/management/init.py", line 312, in execute
django.setup()
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/init.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/home/couture/Developer/hackerspace_online/lib/python3.4/importlib/init.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 2231, in _gcd_import
File "", line 2214, in _find_and_load
File "", line 2203, in _find_and_load_unlocked
File "", line 1200, in _load_unlocked
File "", line 1129, in _exec
File "", line 1448, in exec_module
File "", line 321, in _call_with_frames_removed
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/badgify/models/init.py", line 5, in
from ..utils import load_class
File "/home/couture/Developer/hackerspace_online/lib/python3.4/site-packages/badgify/utils.py", line 56
except ImportError, e:`
^
SyntaxError: invalid syntax
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.