Jump to content

Help talk:Toolforge/My first Django OAuth tool

From Wikitech
Latest comment: 11 months ago by Zache-tool in topic Missing user groups field

Venv activate

@BryanDavis: Do you know how to correctly export the environment variables in venv/bin/activate? Locally I am using this service:

[Unit]
Description=uWSGI instance to serve myapp

[Service]
ExecStartPre=-/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown tobias:nginx /run/uwsgi'
ExecStart=/usr/bin/bash -c 'cd /home/tobias/git/my-first-django-oauth-app/src; source /home/tobias/git/venv-my-first-django-oauth-app/bin/activate; uwsgi --ini app.ini'

[Install]
WantedBy=multi-user.target

But on ToolLabs I am not sure how to go through the venv activate step that exports the variables. Currently I just have the keys in the settings.py, but that is not as nice for source control. --Tobias47n9e (talk) 15:44, 12 March 2017 (UTC)Reply

The webservice script will automatically activate a virtual environment by using the --venv argument to uwsgi when the $HOME/www/python/venv directory exists. When you are doing something outside of the webservice script, the easiest way to handle this is with a small shell script that sets up the environment and then uses exec to run the main python script. --BryanDavis (talk) 22:24, 12 March 2017 (UTC)Reply

Goal?

What is the use of Django OAuth tool? Avnerk (talk) 07:28, 27 April 2017 (UTC)Reply

@Avnerk: I think that is better explained at https://www.mediawiki.org/wiki/Help:OAuth - This page is just about one of many technical implementations for a tool that authenticates with Wikipedia (or for any Mediawiki with OAuth extension for that matter). Let me know if that answer was helpful! --Tobias47n9e (talk) 06:50, 15 August 2017 (UTC)Reply

MIDDLEWARE_CLASSES?

Under Adding OAuth, should MIDDLEWARE_CLASSES be changed to MIDDLEWARE? The later is what's used in modern django versions. RoySmith (talk) 01:36, 21 September 2019 (UTC)Reply

Database

A short chapter on how to link Database, I mean other than sqlite, would be nice, as one big advantage of Django is the database management. Psemdel (talk) 13:55, 8 September 2020 (UTC) edit: I gave it a try at user databases. Psemdel (talk) 14:06, 9 September 2020 (UTC)Reply

Uwsgi

In the text, it is written "In the uwsgi.ini file add the following:", but the previous part is for local use. When I look at the code on Github, it is completely different... I would suggest to write, "set the uwsgi.ini as following" and to write the correct one (which I don't know, otherwise I would so it myself). Psemdel (talk) 08:18, 30 September 2020 (UTC)Reply

Missing user groups field

There was the following error when I tried to run the code. It was because the code tried to store a list of user groups and the model didn't allow it.

Direct assignment to the forward side of a many-to-many set is prohibited. Use groups.set() instead.

I just workaround it by adding JSONField where to store the values. (diff) However, the proper place to fix would be to fix the upstream ( Django social auth app?) so if somebody will fix it there this change can be removed. -- Zache-tool (talk) 02:25, 20 October 2022 (UTC)Reply

I updated my workaround to be adding SOCIAL_AUTH_PROTECTED_USER_FIELDS = ['groups'] to settings.py per python-social-auth ticket (diff) -- Zache-tool (talk) 07:07, 17 December 2023 (UTC)Reply