Anssi
Thanks for that - I'll do some testing.
I'm also thinking of middleware to look at the request and discover the
company on the way in so I can make it available to everything which
processes the request and produces a response.
Cheers
Mike
On 4/04/2012 5:55pm, akaariai wrote:
On Ap
On Apr 4, 3:15 am, Mike Dewhirst wrote:
> I have now discarded the idea :)
>
> I'm not very comfortable with thread locals. I need a bullet-proof
> approach which makes data from other companies invisible to members of
> this company. I suppose a view decorator is the way to go but I would
> have
On 3/04/2012 7:00pm, Tom Evans wrote:
On Tue, Apr 3, 2012 at 9:43 AM, Mike Dewhirst wrote:
I'm trying to make a custom manager for a few models. The objective is to
limit user access to information in the database belonging to the company of
which they are a member.
I think I want to say:
cla
On Tue, Apr 3, 2012 at 9:43 AM, Mike Dewhirst wrote:
> I'm trying to make a custom manager for a few models. The objective is to
> limit user access to information in the database belonging to the company of
> which they are a member.
>
> I think I want to say:
>
> class Something(models.Model):
>
Thanks a lot!
On Sat, Jul 23, 2011 at 5:08 AM, Matt M wrote:
> From The Definitive Guide to Django:
>
> "In short, a model’s manager is an object through which Django models
> perform database queries. Each Django model has at least one manager, and
> you can create custom managers to customize
>From The Definitive Guide to Django:
"In short, a model’s manager is an object through which Django models
perform database queries. Each Django model has at least one manager, and
you can create custom managers to customize database access. There are two
reasons you might want to create a custom
Managers operate on your model, so their methods usually call sgl
queries on a model's database.
As an example, assume a blog app with a Post model which, among other
things has a BooleanField called 'draft'.
You could then write a custom manager called PublishedManager that
subclasses the defaul
On 07/22/2011 10:30 AM, Eyad Al-Sibai wrote:
Hi!
I still do not get the meaning of Manager or Custom Manager in
Django... I am confused!
If you've used the '.objects' attribute of a model you've used a manager.
A custom manager would be a subclass of the standard manager. You can
then alt
I manage to do row delete operations.
Not very nice, since there's no delete-related, no signalst etc.
I don't think delete can be fixed for multiple databases without
modifying Django source or without duplicating code. Since
delete_objects function uses the global connection variable.
Would be
Just as a follow-up. I ended up switching to Elixir to handle
my multiple legacy databases, while keeping django to handle
the main system. The syntax is very similar, and it provides
some additional flexibility that allows me to deal with those
legacy DB's (like dealing with non-indexed tables).
Hello,
Anyone can give us a hint with this?
I have the same problem: with a custom manager (for a 2nd database)
SELETs and INSERTs are working, but not the DELETE operation.
Seems like DELETE references a global connection variable (to the main
database).
Thanks
michael wrote:
> Hi,
>
> [Sorry
H'ok, got this working. First off, I had a brain hiccup: my model was
one-to-many (the actual model is more complicated than my Book
example; I just used the Book to illustrate my point).
What I ended up doing was basically what you suggested to do using
Django's ORM: I ran two queries, one for B
On Sep 2, 2008, at 9:52 AM, MrJogo wrote:
>
> I read that post, and now have a general idea of what to do, but I'm
> still confused on the specifics. It doesn't help that my SQL is VERY
> rusty.
I'm really not the one to be walking you through this, since my own
success was a bit of a fluke,
I read that post, and now have a general idea of what to do, but I'm
still confused on the specifics. It doesn't help that my SQL is VERY
rusty.
Am I supposed to use cursor.execute() to do the INITIAL lookup? That
is, instead of calling a filter, or whatnot, on each book entry, I do
a cursor.exec
On Aug 26, 2008, at 5:00 PM, MrJogo wrote:
>
> I guess I saw it as operating on a group of objects: filtering the
> group of authors related to my_book by is_living. I also think I got
> RelatedManager confused with Manager.
Yaar, it can be a bit confusing. I guess what's important is to
reme
I guess I saw it as operating on a group of objects: filtering the
group of authors related to my_book by is_living. I also think I got
RelatedManager confused with Manager.
I think I can handle two db hits, although it's not optimal. I wish
there was a way to get a set of data filtered on many l
On Aug 25, 2008, at 3:11 PM, MrJogo wrote:
>
> How do I create a custom manager for many-to-many traversal? An
> example will illustrate what I want to do better. Suppose I have the
> following models.py:
>
> class Book(models.Model):
> title = models.CharField(max_length=100)
>
> class Author(
I could, but I need to do it in a template, and from what I
understand, passing variables to method calls in the template language
is a pain, or at least ugly. I think a custom manager is the elegant,
"proper" way to so it (someone can correct me if I'm wrong.
On Aug 25, 10:31 am, John M <[EMAIL
Since my_book.auther_set.all() returns a QS, can't you just say
something like ...all().filter(author__isalive=True) or something like
that? I've never tried, but I thought that django would figure it
out?
J
On Aug 25, 12:11 am, MrJogo <[EMAIL PROTECTED]> wrote:
> How do I create a custom manag
Hi Christopher,
> In the example
> http://www.djangoproject.com/documentation/model-api/#manager-names
> there custom method with_counts() returns a list
> How do i get it to return a queryset
See the entry_count example in the DB API in this section:
http://www.djangoproject.com/documentation
Hi, again
Found a solution which doesn't seem to be documented:
If you need a special manager for the admin interface, then you should
add this one to the Admin class of your model:
class Admin:
manager = MyManager()
Regards,
Laurent
On 12 avr, 15:39, "asrenzo" <[EMAIL PROTECTED]> wr
On Mon, 2006-10-02 at 02:10 -0700, Corey wrote:
> Never mind, I figured it out. I put the import inside the class instead
> of outside the class.
>
> I need more caffeine.
Wait a minute, here... I just wrote 400 words on where the problem is
going to be (assuming it was a Django bug) and how you
Hi Corey,
On Mon, 2006-10-02 at 02:06 -0700, Corey wrote:
> I have put a custom manager in a file called managers.py. When I import
> it in the model, and assign it to objects I get this strange error:
>
> unbound method contribute_to_class() must be called with AddressManager
> instance as firs
Never mind, I figured it out. I put the import inside the class instead
of outside the class.
I need more caffeine.
Corey
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group
Not that way anymore. I will just check (in the middleware) if the
requested entry's author is the logged in user (for edit action) if not
throw exception.
--
Adam Hoscilo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Gro
Just curious -- so now you're going to tie your middleware to the
model? ;-)
The MV(C|T) police will come after you!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, sen
You're right - my fault.
It just isn't the way I would like to handle this problem.
But I've forgotten about middleware and I think this will be the best
way to solve this _issue_ without breaking MVC(MVT) schema (just check
if the requested object was created by user).
--~--~-~--~~-
But Luke *is* proposing to do this in a manager. The middleware just
makes the current user available in the model/manager. (if you want it
to be)
Rather than a hack, the functionality that his middleware module
provides seems to me a missing part in a mostly very pragmatic
codebase, but I digres
But it's some kind of a hack that I don't want to have in my app.
It's easy to achieve this by get/filter in views - but manager would be
more secure(error-proof).
--
Adam Hoscilo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Go
On Saturday 17 June 2006 10:50, Adam Hoscilo wrote:
> I would like to filter entries from a logged in user and give him/her
> the ability to edit them - it would be nice to ensure that scope by
> manager.
> As far as I know Models don't have access to request and session data
> (and I realize it'
30 matches
Mail list logo