Saturday, December 26, 2015

Re: basic Django 10,000 foot view of users (associating Django User with model class)

Mike, thanks for the reply.  I will try and implement this...


On Friday, December 25, 2015 at 8:56:57 AM UTC-5, Mitchell McConnell wrote:
I am just getting started in Django, and probably need to slow down, but I am trying to work through
the documentation *and* work on a real app that I have created in the past as a Python desktop app
using WxPython.

The app manages widgets for employees, who belong to an Organization (part of my model).  My assumption is that
the Django web site will allow Django Users to log in, who must belong to an Organization.

Then, that User will only see the widgets and employees that belong to their own Organization.  Note that
the Employees being managed (again, part of my model) are *NOT* going to need to be Django users on
the website... only the Organizations widget administrator(s).

I assume that I need to 
1. Extend the Django User class to include which Organization they belong to.


But the example I have found so far shows adding a foreign key to the model table, e.g.


Clearly, my Organization entity can have multiple Django users, and every Django user of my app
must belong to one and only one of my Organizations.

When I added the code from the link above to try and do #1 above, but without adding the example's
one-to-one User field to the Organization, I get the error:

ERRORS:
<class 'certapp.admin.OrganizationInline'>: (admin.E202) 'certapp.Organization' has no ForeignKey to 'auth.User'.


This seems like a pretty common way to organize a traditional app... what am I missing, or can
someone point me to an example that does what I want?

Thanks,

Mitch

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e4df2a4d-1428-4f5e-999a-f0cae3370549%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment