Friday, July 1, 2011

Re: More than one project using the same database

Hi all and thanks for the feedback.

I'll elaborate on my situation. The sites have different uses but they
use exactly the same models. Infact the second site has no model.py of
its own. The second site's views simply import the required models
from the first site and, where possible, uses the same form classes
and functions.

Given the above, I hope that I shouldn't get any race issues.

However, if anyone knows of any documentation on recommended setup for
situations like these, it would be good to get a pointer. Secondly, on
how to detect if there is a risk of race conditions.

Cheers

ALJ

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Managing objects spred among several tables/databases.

I have a somewhat similar situation.

In my form, fields from various database tables are combined.
A user may add/edit/delete/doesn't change fields.
While saving the form, the logic should check--
1) which table(s) would require add SQL statement,
2) which table(s) require update stmt,
3) which one(s) require delete stmt.

At present, I am using some other web framework.
There, I need to do the circus of deriving the above statements.
Although one can write a class for the above, I would be happy if
something similar is already there in django.

In such a case, I may abandon my present framework & switch to this
web framework.

Does anybody know about such a facility here?
Any comments / response highly pappreciated.

On Jun 30, 9:23 am, qMax <qwigly...@gmail.com> wrote:
> Hello here.
>
> My application task is to integrate several applications, and it
> should manipulate objects, spread among several tables in several
> databases. Final object is constructed by 'joining' tables by single
> field (or derivatives).
> A user should see such objects as solid entities and manipulate them
> with basic CRUD operations (with search).
> Backend should synchronize all changes in all databases.
> And i wish i could use admin site for that.
>
> If i guess correctly, all required magic should go into custom
> QuerySet implementation to properly translate CRUD operations on
> models into various distributed requests on databases, like zigzag-
> joins, etc instead of usual sql.Queries.
>
> I wonder if QuerySet is the only consolidation of such interface.
> What else should i customize to make it work? (i see at least
> db.models.Manager should be customized to use another queryset impl)
> Also, how to figure out what subset of QuerySet interface is used in
> admin site?
>
> Maybe, someone already managed similar task and there are some recipes?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: OperationalError: no connection to the server using Django and gunicorn

I'm getting this error randomly
and it throws 500error to nginx (I'm using nginx+gunicorn)

and it appears really randomly ;)

On Jul 1, 10:16 am, Adrián Ribao Martínez <ari...@gmail.com> wrote:
> I think that the error comes only when starting the server.
>
> Reload the page about 10 times and check if you still get the error.
>
> Regards,
>
> Adrián
>
>
>
>
>
>
>
> > Hi Adrian,
>
> > Have you solved this weird issue?
>
> > if yes, please tell me how.
>
> > Best regards,
> > Andrey Makhnach
>
> > On May 27, 12:53 pm, Adrián Ribao <ari...@gmail.com> wrote:
> > > I'm doing it manually because I'm just testing:
>
> > > ./manage.py run_gunicorn -c gunicorn.conf.py
>
> > > where gunicorn.conf.py
>
> > > # -*- coding: utf-8 -*-
> > > import multiprocessing
>
> > > bind = "127.0.0.1:8000"
> > > workers = multiprocessing.cpu_count() * 2 + 1
> > > worker_class = 'gevent'
>
> > > On 27 mayo, 02:23, Shawn Milochik <sh...@milochik.com> wrote:
>
> > > > What's the command you're using to run it?
>
> > > > Are you in screen? Are you using supervisor or anything like that?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: E-store

On 2011-06-28 15:34:34 +0200, lillian cauldwell said:

> How does one set up an e-store on their d'jango website?

You can use several shop solutions:

http://djangopackages.com/grids/g/ecommerce/

You can read following book (I haven't read it) and build your own solution:

http://django-ecommerce.blogspot.com/

HTH
Kai


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

access fields in intermediate model

http://stackoverflow.com/questions/2005953/django-access-fields-in-intermediate-model

in this post, you can find how to access fields in intermediate model
like this 'my_group.membership_set.all()'

i use this in my own code, but it did not work. it get ' [] '

my models is very likely with the models in that post. And the code
"my_group.members.all()" is not ' [] '.

anyone know the reason?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Weird join conditions

On 1 июл, 01:35, Michal Petrucha <michal.petru...@ksp.sk> wrote:
> On Thu, Jun 30, 2011 at 02:13:05PM -0700, peroksid wrote:
> > Thank you, Michal,
>
> > Unfortunately, I need join condition, not a WHERE clause, which can be
> > easily extended with extra() method arguments.
> > It is not my bad mood, simply the same condition in WHERE and ON
> > produces different effect.
>
> Hmm, could you please provide an example? (-: Don't know whether it's
> the late night combined with lack of caffeine or something else but I
> can't figure out the difference at the moment...
>

Example, yes. As Haroon said, it is LEFT OUTER JOIN.

We have models reduced for convenience's sake here:

class Campaign(models.Model):
pass

class CampaignExtraStatus(models.Model):
campaign = models.ForeignKey(Campaign)
user = models.ForeignKey(User)

There is campaign with id = 34, user with id - 17, CampaignExtraStatus
for user_id = 17 does not exist:

select count(*) from campaign_campaign where campaign_campaign.id = 34

count
=====
1

select count(*) from auth_user where auth_user.id = 17

count
=====
1

select count(*) from campaign_campaignextrastatus where user_id = 17
and campaign_id = 34;

count
=====
0

Now, query of type "a" takes all campaigns and fills columns from
NULLs where no row in campaign_campaignextrastatus for join condition.
Besides user_id there are useful data in that table.

a) SELECT "campaign_campaign"."id",
"campaign_campaignextrastatus"."user_id" FROM "campaign_campaign" LEFT
OUTER JOIN "campaign_campaignextrastatus" ON ("campaign_campaign"."id"
= "campaign_campaignextrastatus"."campaign_id" AND
campaign_campaignextrastatus.user_id = 17) WHERE
"campaign_campaign"."id" = 34

id | user_id
============
34 | Null
============
1 row

b) SELECT "campaign_campaign"."id",
"campaign_campaignextrastatus"."user_id" FROM "campaign_campaign" LEFT
OUTER JOIN "campaign_campaignextrastatus" ON ("campaign_campaign"."id"
= "campaign_campaignextrastatus"."campaign_id") WHERE
("campaign_campaign"."id" = 34 AND
campaign_campaignextrastatus.user_id = 17)

id | user_id
============
============
0 rows

c) SELECT "campaign_campaign"."id",
"campaign_campaignextrastatus"."user_id" FROM "campaign_campaign" LEFT
OUTER JOIN "campaign_campaignextrastatus" ON ("campaign_campaign"."id"
= "campaign_campaignextrastatus"."campaign_id") WHERE
("campaign_campaign"."id" = 34 AND
(campaign_campaignextrastatus.user_id = 17 OR
campaign_campaignextrastatus.user_id IS NULL ))

id | user_id
============
============
0 rows

Queries "b" and "c" have the condition in WHERE, where it can not
produce required impact. It works in join condition clause, and only
there.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: OperationalError: no connection to the server using Django and gunicorn

I think that the error comes only when starting the server.

Reload the page about 10 times and check if you still get the error.

Regards,

Adrián

> Hi Adrian,
>
> Have you solved this weird issue?
>
> if yes, please tell me how.
>
> Best regards,
> Andrey Makhnach
>
> On May 27, 12:53 pm, Adrián Ribao <ari...@gmail.com> wrote:
> > I'm doing it manually because I'm just testing:
> >
> > ./manage.py run_gunicorn -c gunicorn.conf.py
> >
> > where gunicorn.conf.py
> >
> > # -*- coding: utf-8 -*-
> > import multiprocessing
> >
> > bind = "127.0.0.1:8000"
> > workers = multiprocessing.cpu_count() * 2 + 1
> > worker_class = 'gevent'
> >
> > On 27 mayo, 02:23, Shawn Milochik <sh...@milochik.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > What's the command you're using to run it?
> >
> > > Are you in screen? Are you using supervisor or anything like that?
>
>

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.