two apps against one table (admin)

2014-02-06 Thread fborell
All,

I need to create a second application in the admin section that ports to 
the first applications model. The second application's admin.py would 
contain only 5 of the 15 fields and be set for read-only.
My goal was to allow certain users the ability to do a simple search and 
not see some of the other data that they weren't authorized for. 

Any thoughts on how to proceed?

Thank,

-f

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d1ed61d4-16d9-4a51-a537-d46a1f334d3a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: two apps against one table (admin)

2014-02-06 Thread fborell
Proxy models seem to do the trick ...

On Thursday, February 6, 2014 1:23:31 PM UTC-5, fborell wrote:
>
> All,
>
> I need to create a second application in the admin section that ports to 
> the first applications model. The second application's admin.py would 
> contain only 5 of the 15 fields and be set for read-only.
> My goal was to allow certain users the ability to do a simple search and 
> not see some of the other data that they weren't authorized for. 
>
> Any thoughts on how to proceed?
>
> Thank,
>
> -f
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de66dd27-9db4-4ccb-acc1-3a249d9ddd22%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: two apps against one table (admin)

2014-02-06 Thread Ariel E. Isidro
What if you define your views to use only the fields that you need?
On Feb 7, 2014 2:24 AM, "fborell"  wrote:

> All,
>
> I need to create a second application in the admin section that ports to
> the first applications model. The second application's admin.py would
> contain only 5 of the 15 fields and be set for read-only.
> My goal was to allow certain users the ability to do a simple search and
> not see some of the other data that they weren't authorized for.
>
> Any thoughts on how to proceed?
>
> Thank,
>
> -f
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d1ed61d4-16d9-4a51-a537-d46a1f334d3a%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAECOjia6C34LOi28TBK%2Bs_Fqpy_c0nXkpq8FOmpk71_-Hwaqdw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: two apps against one table (admin)

2014-02-06 Thread Drew Ferguson
Hi

This seems a very complicated solution to a fairly basic problem unless I
am missing something

> On Feb 7, 2014 2:24 AM, "fborell"  wrote:
> 
> > I need to create a second application in the admin section that ports
> > to the first applications model. The second application's admin.py
> > would contain only 5 of the 15 fields and be set for read-only.
> > My goal was to allow certain users the ability to do a simple search
> > and not see some of the other data that they weren't authorized for.
> >
> > Any thoughts on how to proceed?

Create a regular ListView only showing the fields you want and then add an
ordinary form field to the template to input your search term (I would
usually include it with pagination controls)

In your view you can then filter the queryset on the search term like this

#views.py
  def get_queryset(self):
qs = super(MyListView, self).get_queryset()
if 'SEARCH' in self.request.GET:
  search = self.request.GET['SEARCH']
  qs =
  qs.filter(Q(field1__icontains=search)|Q(field2__icontains=search)) 
return qs

There is more on "Complex lookups with Q objects" in

https://docs.djangoproject.com/en/1.6/topics/db/queries/

-- 
Drew

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20140207015103.6ba1b05b%40blacktav.fergiesontour.org.
For more options, visit https://groups.google.com/groups/opt_out.