Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with manage.py #164

Open
callo94 opened this issue Jan 20, 2025 · 9 comments
Open

Problem with manage.py #164

callo94 opened this issue Jan 20, 2025 · 9 comments

Comments

@callo94
Copy link

callo94 commented Jan 20, 2025

hi!
i've a problem with manage.py when i try to start the script i've a this problem
python manage.py migrate
Traceback (most recent call last):
File "/home/imagiro/badgr/edubadges-server/manage.py", line 17, in
execute_from_command_line(sys.argv)
File "/home/imagiro/badgr/edubadges-server/.venv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line
utility.execute()
File "/home/imagiro/badgr/edubadges-server/.venv/lib/python3.9/site-packages/django/core/management/init.py", line 363, in execute
settings.INSTALLED_APPS
File "/home/imagiro/badgr/edubadges-server/.venv/lib/python3.9/site-packages/django/conf/_init.py", line 82, in _getattr
self._setup(name)
File "/home/imagiro/badgr/edubadges-server/.venv/lib/python3.9/site-packages/django/conf/init.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/home/imagiro/badgr/edubadges-server/.venv/lib/python3.9/site-packages/django/conf/_init.py", line 170, in _init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 850, in exec_module
File "", line 228, in _call_with_frames_removed
File "/home/imagiro/badgr/edubadges-server/apps/mainsite/settings.py", line 149, in
DOMAIN = os.environ['DOMAIN']
File "/usr/lib/python3.9/os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'DOMAIN'

@Iso5786
Copy link
Contributor

Iso5786 commented Jan 21, 2025

hi callo94,
you need to load the environment variables before running manage.py:
https://github.com/edubadges/edubadges-server?tab=readme-ov-file#customize-local-settings-to-your-environment

@callo94
Copy link
Author

callo94 commented Jan 22, 2025

Thank you!
I have resolved this problem, but now I cannot navigate the platform. I only see the API page. When I try to navigate to another page, I encounter this issue. What could be the problem?

Image

@Iso5786
Copy link
Contributor

Iso5786 commented Jan 23, 2025

Hi,
did you configure the database and connection to the db correctly?
See also https://github.com/edubadges/edubadges-server?tab=readme-ov-file#create-database and adjust your env vars accordingly,

Best regards, Daniel Ostkamp

@callo94
Copy link
Author

callo94 commented Jan 24, 2025

Hi! Thank you for your response.
I think the problem occurs during the seeding of the database because when I run the command ./migrate seed -c, this is the result:
Seeding 01_setup... 2025-01-24 10:16:17,402 DEBUG utils (0.001) SELECT mainsite_badgrapp.id, mainsite_badgrapp.created_by_id, mainsite_badgrapp.updated_by_id, mainsite_badgrapp.created_at, mainsite_badgrapp.updated_at, mainsite_badgrapp.is_active, mainsite_badgrapp.name, mainsite_badgrapp.cors, mainsite_badgrapp.email_confirmation_redirect, mainsite_badgrapp.signup_redirect, mainsite_badgrapp.forgot_password_redirect, mainsite_badgrapp.ui_login_redirect, mainsite_badgrapp.ui_signup_success_redirect, mainsite_badgrapp.ui_connect_success_redirect, mainsite_badgrapp.public_pages_redirect, mainsite_badgrapp.oauth_authorization_redirect, mainsite_badgrapp.use_auth_code_exchange, mainsite_badgrapp.is_demo_environment, mainsite_badgrapp.oauth_application_id FROM mainsite_badgrapp WHERE (mainsite_badgrapp.cors = 'http://localhost:4000' AND mainsite_badgrapp.email_confirmation_redirect = 'http://localhost:4000/login/' AND mainsite_badgrapp.forgot_password_redirect = 'http://localhost:4000/change-password/' AND mainsite_badgrapp.is_active AND mainsite_badgrapp.is_demo_environment AND mainsite_badgrapp.oauth_authorization_redirect = 'http://localhost:4000/oauth/' AND mainsite_badgrapp.public_pages_redirect = 'http://localhost:4000/public/' AND mainsite_badgrapp.signup_redirect = 'http://localhost:4000/signup/' AND mainsite_badgrapp.ui_connect_success_redirect = 'http://localhost:4000/profile/' AND mainsite_badgrapp.ui_login_redirect = 'http://localhost:4000/auth/login/' AND mainsite_badgrapp.ui_signup_success_redirect = 'http://localhost:4000/signup/success/' AND NOT mainsite_badgrapp.use_auth_code_exchange) LIMIT 21; args=('http://localhost:4000', 'http://localhost:4000/login/', 'http://localhost:4000/change-password/', 'http://localhost:4000/oauth/', 'http://localhost:4000/public/', 'http://localhost:4000/signup/', 'http://localhost:4000/profile/', 'http://localhost:4000/auth/login/', 'http://localhost:4000/signup/success/')
2025-01-24 10:16:17,406 DEBUG utils (0.000) INSERT INTO mainsite_badgrapp (created_by_id, updated_by_id, created_at, updated_at, is_active, name, cors, email_confirmation_redirect, signup_redirect, forgot_password_redirect, ui_login_redirect, ui_signup_success_redirect, ui_connect_success_redirect, public_pages_redirect, oauth_authorization_redirect, use_auth_code_exchange, is_demo_environment, oauth_application_id) VALUES (NULL, NULL, '2025-01-24 09:16:17.405302', '2025-01-24 09:16:17.405390', 1, NULL, 'http://localhost:4000', 'http://localhost:4000/login/', 'http://localhost:4000/signup/', 'http://localhost:4000/change-password/', 'http://localhost:4000/auth/login/', 'http://localhost:4000/signup/success/', 'http://localhost:4000/profile/', 'http://localhost:4000/public/', 'http://localhost:4000/oauth/', 0, 1, NULL); args=[None, None, '2025-01-24 09:16:17.405302', '2025-01-24 09:16:17.405390', True, None, 'http://localhost:4000', 'http://localhost:4000/login/', 'http://localhost:4000/signup/', 'http://localhost:4000/change-password/', 'http://localhost:4000/auth/login/', 'http://localhost:4000/signup/success/', 'http://localhost:4000/profile/', 'http://localhost:4000/public/', 'http://localhost:4000/oauth/', False, True, None]
FAILED!
Traceback (most recent call last):
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 581, in get_or_create
return self.get(**kwargs), False
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
raise self.model.DoesNotExist(
mainsite.models.BadgrApp.DoesNotExist: BadgrApp matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/callo/edubadges/edubadges-server/apps/mainsite/management/commands/seed.py", line 65, in run_seeds
import("mainsite.seeds." + seed)
File "/home/callo/edubadges/edubadges-server/apps/mainsite/seeds/01_setup.py", line 18, in
main_badgr_app, _ = BadgrApp.objects.get_or_create(
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 588, in get_or_create
return self.create(**params), True
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/django/db/models/query.py", line 453, in create
obj.save(force_insert=True, using=self.db)
File "/home/callo/edubadges/edubadges-server/apps/cachemodel/models.py", line 42, in save
self.publish()
File "/home/callo/edubadges/edubadges-server/apps/cachemodel/models.py", line 50, in publish
self.publish_by('pk')
File "/home/callo/edubadges/edubadges-server/apps/cachemodel/models.py", line 72, in publish_by
cache.set(key, self, CACHE_FOREVER_TIMEOUT)
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/django/core/cache/backends/memcached.py", line 82, in set
if not self._cache.set(key, value, self.get_backend_timeout(timeout)):
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/pymemcache/client/hash.py", line 344, in set
return self._run_cmd("set", key, False, *args, **kwargs)
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/pymemcache/client/hash.py", line 322, in _run_cmd
return self._safely_run_func(client, func, default_val, *args, **kwargs)
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/pymemcache/client/hash.py", line 211, in _safely_run_func
result = func(*args, **kwargs)
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/pymemcache/client/base.py", line 475, in set
return self._store_cmd(b"set", {key: value}, expire, noreply, flags=flags)[key]
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/pymemcache/client/base.py", line 1228, in _store_cmd
self._connect()
File "/home/callo/edubadges/edubadges-server/.venv/lib/python3.9/site-packages/pymemcache/client/base.py", line 424, in _connect
sock.connect(sockaddr)
ConnectionRefusedError: [Errno 111] Connection refused

[Errno 111] Connection refused

How can i resolve?

@Iso5786
Copy link
Contributor

Iso5786 commented Jan 24, 2025

You need a memcached instance running for caching purposes.
I see that we should update our README to reflect this as there it is stated as optional.
If you would use the docker compose, a memcached and mailhog instance is spin up automatically.

@Iso5786
Copy link
Contributor

Iso5786 commented Jan 30, 2025

Hi @callo94 , coud you solve your issues?

@callo94
Copy link
Author

callo94 commented Jan 30, 2025

Hi!
not completely unfortunately, now I have the flu and I can't work on it.

@callo94
Copy link
Author

callo94 commented Feb 7, 2025

Ok, I solved this problem. Now I was wondering, how can I insert a badge and verify it?

I installed the UI version, and when I go to "Open the issuer portal," I get this error:
{
"timestamp": "2025-02-07T16:46:26.864+00:00",
"status": 401,
"error": "unauthorized",
"path": "/saml2/authenticate/oidcng",
"error_description": "ClientID test.edubadges.nl or secret is not correct",
"message": "ClientID test.edubadges.nl or secret is not correct"
}

@Iso5786
Copy link
Contributor

Iso5786 commented Feb 7, 2025

Hi,
you need to provide your own identity provider. Currently, we hardcoded SurfConext (https://www.surf.nl/en/services/surfconext) for which you would need the correct credentials to connect to. But you need to implement your own, preferably based on OIDC or SAML.
See files under apps/badgrsocialauth/providers/surf_conext , I think it is easy to adapt if you have your own OIDC based IdP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants