I just saw this example:
http://django.readthedocs.org/en/1.4/topics/db/models.html#multi-table-inheritance

Since it is possible for me to have a few number of users (now called
departments), I can define a create a python file which subclasses all the
models and then run syncdb to update the database for creating the new
tables.
But what is different is I need to fetch the Place subclass (eg. Restaurant
or School page above) at runtime based on the logged in user. Assuming I
have a map from id to class name can I just load it dynamically?

Thanks
Rohit Banga
http://iamrohitbanga.com/


On Fri, Sep 21, 2012 at 3:26 PM, Rohit Banga <iamrohitba...@gmail.com>wrote:

> Thanks for your comments. I agree that technically it is feasible to
> achieve the same affect with row level permissions or filtering the rows by
> user.
> The requirement is to keep the data separate using different tables,
> databases while still using the same model. May be user is not the right
> metaphor to use here. Lets just "imagine" that we have the same schema to
> use for different departments in a college but one department does not want
> to house their data in the same tables as another department.
>
> I don't want to filter rows by "userid" since one place we forget the
> filter in the code and there is an unauthorized data access.
>
> I will look into dynamic models though I am not sure if it is well
> supported.
> What about routing to different databases based on user id?
>
> Thanks
> Rohit Banga
> http://iamrohitbanga.com/
>
>
>
> On Fri, Sep 21, 2012 at 2:34 PM, Joel Goldstick 
> <joel.goldst...@gmail.com>wrote:
>
>> On Fri, Sep 21, 2012 at 2:30 PM, Nikolas Stevenson-Molnar
>> <nik.mol...@consbio.org> wrote:
>> > If you absolutely have to use separate tables per user (again, I do not
>> > recommend this), then you'll need to implement some form of dynamic
>> models
>> > (models which can be constructed at run-time rather than needing to be
>> > defined in the application code) such as discussed here:
>> > https://code.djangoproject.com/wiki/DynamicModels (see link at the top
>> of
>> > the page for newer approaches and full implementations of dynamic
>> models).
>> >
>> >
>> > _Nik
>> >
>> > On 9/21/2012 11:07 AM, Rohit Banga wrote:
>> >
>> > Just HAVE to separate data - requirement.
>> >
>> > On Sep 21, 2012 1:59 PM, "Mayukh Mukherjee" <mayu...@gmail.com> wrote:
>> >>
>> >> As I understand it: (And im fairly new to django too)
>> >>
>> >> A model corresponds to a single table (not multiple).
>> >> The question to you is what is different between User1 and User2 that
>> you
>> >> need different tables?
>> >>
>> >>
>> >>
>> >> On Fri, Sep 21, 2012 at 1:35 PM, Rohit Banga <iamrohitba...@gmail.com>
>> >> wrote:
>> >>>
>> >>> Hi
>> >>>
>> >>> I am a django #n00b. I came across the django model documentation and
>> >>> found it pretty interesting.
>> >>> (https://docs.djangoproject.com/en/dev/topics/db/models/).
>> >>>
>> >>> Now my usecase requires I have a set of Models and each model has
>> >>> multiple tables corresponding to it.
>> >>> For example when user1 registers I can create a table user1_t1,
>> user1_t2,
>> >>> user1_t3.
>> >>> When user2 registers I can create a table user2_t1, user2_t2,
>> user2_t3.
>> >>>
>> >>> I really like the Model abstraction but can't find a way to create
>> these
>> >>> multiple tables conveniently without creating new models. I could not
>> find
>> >>> clear solutions to this on the internet.
>> >>> I just want clear separation between t1, t2, t3 for the all users.
>> >>> Depending on the logged in user, I want to use the relevant table.
>> What is
>> >>> the cleanest way to achieve this with Django?
>> >>>
>> >>> If it is not possible to do this with tables I can think about
>> different
>> >>> databases one for each user with the same set of tables. Is it
>> possible to
>> >>> do the same with multiple databases?
>> >>>
>> >>> Thanks
>> >>> Rohit Banga
>> >>> --
>>
>> Why not add a user as a field in your models.  Then, when the user
>> logs in, make sure the queries filter only that user's data
>>
>> --
>> Joel Goldstick
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to