Is there a package that enables one Django project to authenticate via a second Django project?

2020-06-25 Thread Dave R
I keep running into this problem and started working on a custom 
solution... but before I spend hours on this, I want to confirm that such a 
package/solution doesn't already exist.

I was working on a large project last year that involved a single set of 
users and many small applications.  I made each application a Django app 
and had them all tied together in one database.  There was only one 
database dependency between the applications: the User table.

This became almost impossible to maintain for  multiple reasons:
* I had two apps that required different values in settings.py
* The test suite took forever to run
* One of the apps was developed originally using Postgres and I had to 
spend hours hacking through code getting it to work with MySQL
* I had to share my entire code base to employ freelancers
* I had to deprecate one of the apps and this became a project in itself 
(i.e., remove references in settings.py, dropping database tables, etc.)

Next time I'm in this situation, I'd like to develop each application as a 
separate Django project and have them authenticate (via OpenID Connect) to 
a project dedicated to this (e.g., accounts.mysite.com).

Has anyone seen an out-of-the-box solution for this?  The question is very 
open-ended.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0050a73c-fc46-449b-b087-a9f99508fadeo%40googlegroups.com.


Re: Is there a package that enables one Django project to authenticate via a second Django project?

2020-06-25 Thread Dave R
Is REMOTE_USER a technology that's still used?  Aside from the one page of 
documentation, I don't see a lot of other references to it on Stack 
Overflow, etc.

In my implementation, the client authenticates to the server, pulls the 
latest-and-greatest user data, then saves it on the client database.

Philosophically, I guess it's a personal preference.  But, as a startup 
person, I tend to build a lot of throwaway apps that I don't want 
cluttering up the core tried-and-tested apps.

On Thursday, June 25, 2020 at 3:55:40 PM UTC-4 andrea...@hypercode.se wrote:

> First of all - why separate the django apps into various projects? That 
> seems a bit strange because you are depending on one user account and one 
> database? There isn't really any benefit of doing it like that - why not 
> use a single django project?
>
> But on the other hand - if you want to continue doing it like that - what 
> I would do is setup a "user" project - that only handles the users. Then 
> you can use the remote user functionality of django in the other projects. 
> That way you have the user object centralized and all of the projects can 
> use the user interface from the remote user.
>
> https://docs.djangoproject.com/en/3.0/howto/auth-remote-user/
>
> The reason I wouldn't use open id connect is because you still need a 
> local user object for each project in that case. 
>
> Regards,
>
> Andréas
>
>
> Den tors 25 juni 2020 kl 21:26 skrev Dave R :
>
>> I keep running into this problem and started working on a custom 
>> solution... but before I spend hours on this, I want to confirm that such a 
>> package/solution doesn't already exist.
>>
>> I was working on a large project last year that involved a single set of 
>> users and many small applications.  I made each application a Django app 
>> and had them all tied together in one database.  There was only one 
>> database dependency between the applications: the User table.
>>
>> This became almost impossible to maintain for  multiple reasons:
>> * I had two apps that required different values in settings.py
>> * The test suite took forever to run
>> * One of the apps was developed originally using Postgres and I had to 
>> spend hours hacking through code getting it to work with MySQL
>> * I had to share my entire code base to employ freelancers
>> * I had to deprecate one of the apps and this became a project in itself 
>> (i.e., remove references in settings.py, dropping database tables, etc.)
>>
>> Next time I'm in this situation, I'd like to develop each application as 
>> a separate Django project and have them authenticate (via OpenID Connect) 
>> to a project dedicated to this (e.g., accounts.mysite.com).
>>
>> Has anyone seen an out-of-the-box solution for this?  The question is 
>> very open-ended.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0050a73c-fc46-449b-b087-a9f99508fadeo%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0050a73c-fc46-449b-b087-a9f99508fadeo%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/30afa521-a35d-4ea3-b8d8-ec8cc3f297acn%40googlegroups.com.


Django as an authentication server

2020-06-28 Thread Dave R
A few weeks ago on this group, I asked for suggestions on how to enable 
logging into one Django app from another Django app. I didn't love the 
answers I got, so I rolled out my own solution: 
https://github.com/pandichef/djangito 

I'd love to get some feedback on this and/or find contributors to help. 
Thanks!

In case you're wondering, it's ~1000 lines of code currently with ~80% test 
coverage.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f001d270-3af1-4b8a-a0cc-cec76e73f1cen%40googlegroups.com.


Django package auto-installation

2020-07-19 Thread Dave R
My new package:
https://github.com/pandichef/indjections

The basic idea: Installing third party Django packages should be one-line 
of code.

I'm looking for feedback and/or contributors.  Thanks!


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/89981aca-9610-40d6-9750-394012505241n%40googlegroups.com.


Question about django.utils.autoreload

2020-07-20 Thread Dave R
Hello, I'm trying to figure out how to rebuild my React.js project (with 
Django backend) and relaunch the Django dev server if a React.js file 
changes.  The code below works, but it rebuilds React even if the only code 
changes are in Django.  Can anyone suggest how to solve this problem?

import subprocess
from django.utils.autoreload import autoreload_started
from django.dispatch import receiver
@receiver(autoreload_started)
def rebuild_react_app(sender, **kwargs):
sender.watch_dir(os.path.join(BASE_DIR, 'reactapp', 'src'), '*')
subprocess.run(r'yarn --cwd ./reactapp build', shell=True)

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/13c40a08-6084-4609-8141-ddcf029c33a7n%40googlegroups.com.


"pytest --doctests-modules" AlreadyRegistered error

2020-07-31 Thread Dave R
I am using doctests via pytest with the command "pytest 
--doctest-modules".  Unfortunately, I keep getting the following error.  
I've already attached a screenshot.  Does anyone understand what's causing 
and how to address it?  Thanks!


== ERRORS 
===
__ ERROR collecting main/admin.py 
___
main\admin.py:25: in 
admin.site.register(PoolType, PoolTypeAdmin)
..\..\..\.virtualenvs\mysite\lib\site-packages\django\contrib\admin\sites.py:109:
 
in register
raise AlreadyRegistered('The model %s is already registered' % 
model.__name__)
E   django.contrib.admin.sites.AlreadyRegistered: The model PoolType is 
already registered
__ ERROR collecting main/models.py 
__
main\models.py:36: in 
class PoolType(models.Model):
..\..\..\.virtualenvs\mysite\lib\site-packages\django\db\models\base.py:111: 
in __new__
"INSTALLED_APPS." % (module, name)
E   RuntimeError: Model class mysite.main.models.PoolType doesn't declare 
an explicit app_label and isn't in an application in INSTALLED_APPS.
== short test summary info 
==
ERROR main/admin.py - django.contrib.admin.sites.AlreadyRegistered: The 
model PoolType is already r...
ERROR main/models.py - RuntimeError: Model class 
mysite.main.models.PoolType doesn't declare an ...
!! Interrupted: 2 errors during collection 
!!
= 2 errors in 0.62s 
=

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3acb7334-e158-4c83-af7c-35a55a2d9afan%40googlegroups.com.


Re: "pytest --doctests-modules" AlreadyRegistered error

2020-07-31 Thread Dave R
I figured this out.  I'm using Cookiecutter-Django, which puts a 
__init__.py for whatever reason in the root directory and this confuses 
pytest.  If you delete this __init__.py, everything works fine.


On Friday, July 31, 2020 at 8:53:39 PM UTC-4 Dave R wrote:

> I am using doctests via pytest with the command "pytest 
> --doctest-modules".  Unfortunately, I keep getting the following error.  
> I've already attached a screenshot.  Does anyone understand what's causing 
> and how to address it?  Thanks!
>
>
> == ERRORS 
> ===
> __ ERROR collecting main/admin.py 
> ___
> main\admin.py:25: in 
> admin.site.register(PoolType, PoolTypeAdmin)
> ..\..\..\.virtualenvs\mysite\lib\site-packages\django\contrib\admin\sites.py:109:
>  
> in register
> raise AlreadyRegistered('The model %s is already registered' % 
> model.__name__)
> E   django.contrib.admin.sites.AlreadyRegistered: The model PoolType is 
> already registered
> __ ERROR collecting main/models.py 
> __
> main\models.py:36: in 
> class PoolType(models.Model):
> ..\..\..\.virtualenvs\mysite\lib\site-packages\django\db\models\base.py:111: 
> in __new__
> "INSTALLED_APPS." % (module, name)
> E   RuntimeError: Model class mysite.main.models.PoolType doesn't declare 
> an explicit app_label and isn't in an application in INSTALLED_APPS.
> == short test summary info 
> ==
> ERROR main/admin.py - django.contrib.admin.sites.AlreadyRegistered: The 
> model PoolType is already r...
> ERROR main/models.py - RuntimeError: Model class 
> mysite.main.models.PoolType doesn't declare an ...
> !! Interrupted: 2 errors during collection 
> !!
> = 2 errors in 0.62s 
> =
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20130c53-87af-4561-8309-1f4b2bef7853n%40googlegroups.com.