Re: Fast and Easy way to check if an instance of an Model exists in the Database

2014-01-21 Thread Erik Cederstrand
Den 21/01/2014 kl. 08.58 skrev Johannes Schneider 
:

> maybe I I formulated it not precise enough.
> I need to check if some instance of a model comes from some database query 
> (e.g. via get(..)) or is instanciated 'by hand'. and not jet written to the 
> database.
> In this case I don't need to know, if there is an related object (e.g. with 
> the same pk or same values for its attributes) in the database.

Okay. Sounds like your best bet is to either roll your own, or use the 
undocumented API as suggested by Tom Evans.

Either way, make sure to write tests so this doesn’t break when you upgrade 
Django.

Erik

-- 
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/78B3DC94-CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Fast and Easy way to check if an instance of an Model exists in the Database

2014-01-21 Thread Avraham Serour
wouldn't checking for the presence of an id enough? as far as I know
instantiated objects don't have id's


On Tue, Jan 21, 2014 at 10:16 AM, Erik Cederstrand <
erik+li...@cederstrand.dk> wrote:

> Den 21/01/2014 kl. 08.58 skrev Johannes Schneider <
> johannes.schnei...@galileo-press.de>:
>
> > maybe I I formulated it not precise enough.
> > I need to check if some instance of a model comes from some database
> query (e.g. via get(..)) or is instanciated 'by hand'. and not jet written
> to the database.
> > In this case I don't need to know, if there is an related object (e.g.
> with the same pk or same values for its attributes) in the database.
>
> Okay. Sounds like your best bet is to either roll your own, or use the
> undocumented API as suggested by Tom Evans.
>
> Either way, make sure to write tests so this doesn’t break when you
> upgrade Django.
>
> Erik
>
> --
> 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/78B3DC94-CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk
> .
> 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/CAFWa6t%2Brm9REWaWUTqZHd4Wv3Pw212RLGSh89%2BWJwC7NFNM%3DqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to send a activation email when creating accounts in site?

2014-01-21 Thread Swastik Acharya
Its very difficult to read your project dude..either u wont had chinese 
languages in between comments and codes or you must have written everything 
in your language..

cheers,
swastik

On Saturday, 4 January 2014 14:17:20 UTC+5:30, 项楠 wrote:
>
> I use django 1.6.1 and python 3.3.3 in windows8. I want to build a app 
> named 'customauth' that supports email activation. I choose to create my 
> own user model from the django.contrib.auth.models.AbstractBaseUser , not a 
> profile model that holds a OneToOneField to django build-in User model.
>
> This model class is called 'MyUser'.Its features:
>
> 1. Only three fields : email, username and password are required when 
> creating an MyUser instance.
>
> 2. User logins my site via email and password.
>
> 3. When creating a user (not superuser), field 'is_active' is False, 
> 'activation_key' is set to a random key with username, then, djanog sends 
> an email with a activation_key link to him. If user clicks it in some days 
> (like 3), his 'is_active' turns True,  'activation_key' turns to be a 
> constant , so he can login.
>
> 4.When creating a superuser, its 'is_active' is True, 'activation_key' 
> is a constant directly and not invoking the process of sending activation 
> email.
>
> Up to now, what I have done looks like a weird combination of a custom 
> User model from Substituting a custom User model 
> and
>  
> the theory from 
> django-registration
> .
>
> Now my situation is weird:
>
> 1.Only when 'python manage.py syncdb' in cmd.exe, creating the superuser, 
> the whole process can work fine (i.e.,send a mail, then click it to 
> activate). However, this superuser can not login admin site despite its 
> 'is_admin' is True. It can only login user site.
> https://www.dropbox.com/s/1l8f78fgfj4696a/super.jpg
>
> 2.When you register a user in the normal way (you enter some required 
> infomation in the form), the user can be created, but django will not send 
> a email to this user.
>
> Now I donot know the reason, but as the email activation system works fine 
> when first creating the superuser, there must be a way to make it works in 
> user register.
>
> So, what should I do, Thanks.
>
> This is the project file 
> myauth.zip,
>  
> if needed.'customauth' is the app.
>

-- 
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/915403c5-8d2e-4071-a183-597a3d2e4795%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Fast and Easy way to check if an instance of an Model exists in the Database

2014-01-21 Thread Johannes Schneider

yes, but the problem is that we manually give them a pk.

Maye it's the best to reduce the question to the following:
Which (undocumented) field is better for this case?
* instance._state.db (checking if this is None)
* instance_state.adding (checking for True)

bg,
Johannes


On 21.01.2014 10:07, Avraham Serour wrote:

wouldn't checking for the presence of an id enough? as far as I know
instantiated objects don't have id's


On Tue, Jan 21, 2014 at 10:16 AM, Erik Cederstrand
mailto:erik+li...@cederstrand.dk>> wrote:

Den 21/01/2014 kl. 08.58 skrev Johannes Schneider
mailto:johannes.schnei...@galileo-press.de>>:

 > maybe I I formulated it not precise enough.
 > I need to check if some instance of a model comes from some
database query (e.g. via get(..)) or is instanciated 'by hand'. and
not jet written to the database.
 > In this case I don't need to know, if there is an related object
(e.g. with the same pk or same values for its attributes) in the
database.

Okay. Sounds like your best bet is to either roll your own, or use
the undocumented API as suggested by Tom Evans.

Either way, make sure to write tests so this doesn’t break when you
upgrade Django.

Erik

--
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/78B3DC94-CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk.
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/CAFWa6t%2Brm9REWaWUTqZHd4Wv3Pw212RLGSh89%2BWJwC7NFNM%3DqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
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/52DE442B.1010300%40galileo-press.de.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Survey App

2014-01-21 Thread Yazmin Lucy Cumberbirch
Hi!

Thanks for your suggestion!

I have tried to use it, I installed formly and added it to my 
INSTALLED_APPS and to the urls, but I cant manage to get it working. I also 
downloaded the pinax account project but can't run it.

Any change you can give me hand with it?

pinax account project wont run, gives a sintax error :S and formly when 
added to the urls is missing templates. I think they are in the pinax, but 
as i said, I cant get it working.

Thanks

On Monday, January 20, 2014 4:04:06 PM UTC+1, ovnicraft wrote:
>
>
>
>
> On Mon, Jan 20, 2014 at 6:41 AM, Yazmin Lucy Cumberbirch 
> 
> > wrote:
>
>> Hi!
>>
>> I am trying to find a survey app for my django project. I need it to be 
>> able to send personalized survey invitations, so I know who is answering 
>> them.
>>
>> This is similar to SurveyMonkey, but the API they provide doesn't include 
>> any methods to send the survey to the list of mails (or I can't find how to 
>> do it).
>>
>> Does anybody know of an app that does this? Or an external page that does 
>> so, and has an API so I can do it all automatically?
>>
>
> Hi i am using https://github.com/eldarion/formly is really great you need 
> to use it with pinax account project 
> https://github.com/pinax/pinax-project-account
>
> It allows you make all surveys as you want and its bootstrap based :-)
>
> Thanks to eldarion.
>
>
> Regards,
>  
>
>>
>> Thanks for any help!
>>
>> ylc
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/f853ede3-5b27-41bc-b8fc-d709efcc7215%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Cristian Salamea
> @ovnicraft 
>

-- 
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/8d174289-f382-47cc-b9de-2289ad14236a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: UUIDField from django-extensions is not available in Class Based Views

2014-01-21 Thread Timothy W. Cook
SOLVED:  (sort of)

I am not sure if this is the only or best way to solve the problem. But,
since I needed to use get_context_data() in the view anyway. I am now doing
this to get ct_id into the view template:

def get_context_data(self,**kwargs):
context = super(DvStringUpdateView, self).get_context_data(**kwargs)
semlinks = []
obj = get_object_or_404(DvString,pk=context['object'].id)
if obj.resource_uri:
urilist = obj.resource_uri.splitlines()
attrlist = obj.sem_attr.splitlines()
for n in range(0,len(urilist)):
semlinks.append(attrlist[n] + ' = ' + unquote(urilist[n]))

context['semlinks'] = semlinks
context['ct_id'] = obj.ct_id
return context



Is there a bug in the way the UUIDField is defined causing it to not be
available in CBVs? This is at least a workaround.


Cheers,
Tim




On Mon, Jan 20, 2014 at 7:55 PM, Timothy W. Cook  wrote:

> BTW:
>
> In the actual code the ct_id field is quaoted correctly.  It was just an
> error in my post here.
>
> fields =['published','prj_name','data_name','ct_id',]
>
>
>
> On Mon, Jan 20, 2014 at 7:03 PM, Timothy W. Cook  wrote:
>
>>
>> I have a web application where I use a couple of UUIDFields. In the Admin
>> UI, in function based views and other Python code, these fields work as
>> expected. However, when trying to list them in the 'fields' in a CBV, I get
>> the error:
>>
>> FieldError(message) django.core.exceptions.FieldError: Unknown field(s) 
>> (ct_id)
>>
>>  The subject field here is *ct_id*. But another one does the same.
>>
>> From models.py:
>>
>> ct_id = UUIDField(_("UUID"), version=4, help_text=_('A unique identifier for 
>> this PCT.'))
>>
>>  As mentioned above, they work in Admin lists:
>>
>> list_display = ('data_name','prj_name','published','ct_id')
>> admin.site.register(DvBoolean, DvBooleanAdmin)
>>
>>  In function based views to create JSON for DynaTree:
>>
>> pct_json['tooltip'] = 'ct-'+pct.ct_id + " : " +pct.description
>>
>>  But in a CBV, this raises the error:
>>
>> fields =['published','prj_name','data_name',ct_id,]
>>
>>  Any ideas on how to make this work? I only want to render them for
>> display, not for editing.
>>
>> Thanks,
>>
>> Tim
>>
>> PS. This question is also on StackOverflow at:   http://goo.gl/mA7I6V
>>
>> --
>> MLHIM VIP Signup: http://goo.gl/22B0U
>> 
>> Timothy Cook, MSc   +55 21 94711995
>> MLHIM http://www.mlhim.org
>> Like Us on FB: https://www.facebook.com/mlhim2
>> Circle us on G+: http://goo.gl/44EV5
>> Google Scholar: http://goo.gl/MMZ1o
>> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>>
>
>
>
> --
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
>



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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/CA%2B%3DOU3XsgqO%2BPCWtd6-XXRzov43vnxbShNk_J3eAaiFViM9oLA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Survey App

2014-01-21 Thread Yazmin Lucy Cumberbirch
Solved the problem :) Thanks for the help. Will see if it does all my boss 
wants ^^ 

On Tuesday, January 21, 2014 11:10:45 AM UTC+1, Yazmin Lucy Cumberbirch 
wrote:
>
> Hi!
>
> Thanks for your suggestion!
>
> I have tried to use it, I installed formly and added it to my 
> INSTALLED_APPS and to the urls, but I cant manage to get it working. I also 
> downloaded the pinax account project but can't run it.
>
> Any change you can give me hand with it?
>
> pinax account project wont run, gives a sintax error :S and formly when 
> added to the urls is missing templates. I think they are in the pinax, but 
> as i said, I cant get it working.
>
> Thanks
>
> On Monday, January 20, 2014 4:04:06 PM UTC+1, ovnicraft wrote:
>>
>>
>>
>>
>> On Mon, Jan 20, 2014 at 6:41 AM, Yazmin Lucy Cumberbirch 
>> wrote:
>>
>>> Hi!
>>>
>>> I am trying to find a survey app for my django project. I need it to be 
>>> able to send personalized survey invitations, so I know who is answering 
>>> them.
>>>
>>> This is similar to SurveyMonkey, but the API they provide doesn't 
>>> include any methods to send the survey to the list of mails (or I can't 
>>> find how to do it).
>>>
>>> Does anybody know of an app that does this? Or an external page that 
>>> does so, and has an API so I can do it all automatically?
>>>
>>
>> Hi i am using https://github.com/eldarion/formly is really great you 
>> need to use it with pinax account project 
>> https://github.com/pinax/pinax-project-account
>>
>> It allows you make all surveys as you want and its bootstrap based :-)
>>
>> Thanks to eldarion.
>>
>>
>> Regards,
>>  
>>
>>>
>>> Thanks for any help!
>>>
>>> ylc
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/f853ede3-5b27-41bc-b8fc-d709efcc7215%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> -- 
>> Cristian Salamea
>> @ovnicraft 
>>
>

-- 
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/ba699809-c4d4-4a65-b169-1af504360882%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Saving models with NOT NULL ForeignKeys referencing each other

2014-01-21 Thread antialiasis
Hi,

I just bumped into this issue. Say I have the following models:


class Foo(models.Model):
bar = models.ForeignKey('Bar', related_name='foos')

class Bar(models.Model):
default_foo = models.ForeignKey(Foo, related_name='+')


Basically, the idea is that each bar has many foos, but one of them is the 
bar's default foo. Every foo must have an associated bar, and each bar must 
have a default foo, so both of the ForeignKey fields are NOT NULL.

This was working great until I realized that now I can't actually create 
any Foo or Bar objects, because I can't save a Foo object without setting 
its bar_id, and I can't save a Bar object without setting its foo_id.

Does Django have any kind of way around this, or is the solution just to 
allow null for one of them (dangerous for data integrity)? Or should I 
perhaps just not use this kind of circular reference altogether and instead 
go with something like an is_default field on the Foo model?

-- 
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/ca21053a-ac47-4c07-96c1-93294de97cf8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Fast and Easy way to check if an instance of an Model exists in the Database

2014-01-21 Thread Avraham Serour
pk is not necessarily id, in any case if you are the one adding it then you
already know that the object didn't come from the db, in order to check
that later I would add an attribute to the object and check it's presence,
if not present it means it came from the db.


On Tue, Jan 21, 2014 at 11:55 AM, Johannes Schneider <
johannes.schnei...@galileo-press.de> wrote:

> yes, but the problem is that we manually give them a pk.
>
> Maye it's the best to reduce the question to the following:
> Which (undocumented) field is better for this case?
> * instance._state.db (checking if this is None)
> * instance_state.adding (checking for True)
>
> bg,
> Johannes
>
>
>
> On 21.01.2014 10:07, Avraham Serour wrote:
>
>> wouldn't checking for the presence of an id enough? as far as I know
>> instantiated objects don't have id's
>>
>>
>> On Tue, Jan 21, 2014 at 10:16 AM, Erik Cederstrand
>> mailto:erik+li...@cederstrand.dk>> wrote:
>>
>> Den 21/01/2014 kl. 08.58 skrev Johannes Schneider
>> > >:
>>
>>
>>  > maybe I I formulated it not precise enough.
>>  > I need to check if some instance of a model comes from some
>> database query (e.g. via get(..)) or is instanciated 'by hand'. and
>> not jet written to the database.
>>  > In this case I don't need to know, if there is an related object
>> (e.g. with the same pk or same values for its attributes) in the
>> database.
>>
>> Okay. Sounds like your best bet is to either roll your own, or use
>> the undocumented API as suggested by Tom Evans.
>>
>> Either way, make sure to write tests so this doesn’t break when you
>> upgrade Django.
>>
>> Erik
>>
>> --
>> 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/78B3DC94-
>> CBFC-4F38-A35C-73F54CAB572A%40cederstrand.dk.
>> 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/CAFWa6t%
>> 2Brm9REWaWUTqZHd4Wv3Pw212RLGSh89%2BWJwC7NFNM%3DqQ%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
> --
> Johannes Schneider
> Webentwicklung
> johannes.schnei...@galileo-press.de
> Tel.: +49.228.42150.xxx
>
> Galileo Press GmbH
> Rheinwerkallee 4 - 53227 Bonn - Germany
> Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
> http://www.galileo-press.de/
>
> Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
> HRB 8363 Amtsgericht Bonn
>
> --
> 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/52DE442B.1010300%40galileo-press.de.
>
> 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/CAFWa6t%2BNnHb94_vNdFoKv8bsv_cF3pzxt2MpuftKir5WcV67rA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Saving models with NOT NULL ForeignKeys referencing each other

2014-01-21 Thread Russell Keith-Magee
On Tue, Jan 21, 2014 at 6:54 PM, antialiasis  wrote:

> Hi,
>
> I just bumped into this issue. Say I have the following models:
>
>
> class Foo(models.Model):
> bar = models.ForeignKey('Bar', related_name='foos')
>
> class Bar(models.Model):
> default_foo = models.ForeignKey(Foo, related_name='+')
>
>
> Basically, the idea is that each bar has many foos, but one of them is the
> bar's default foo. Every foo must have an associated bar, and each bar must
> have a default foo, so both of the ForeignKey fields are NOT NULL.
>
> This was working great until I realized that now I can't actually create
> any Foo or Bar objects, because I can't save a Foo object without setting
> its bar_id, and I can't save a Bar object without setting its foo_id.
>
> Does Django have any kind of way around this, or is the solution just to
> allow null for one of them (dangerous for data integrity)? Or should I
> perhaps just not use this kind of circular reference altogether and instead
> go with something like an is_default field on the Foo model?
>

This is what database transactions are for. A transaction is a way to make
a series of individual changes as a single atomic change in the database.

In Django 1.6, the main way to implement transactional behaviour is to use
the atomic decorator:

https://docs.djangoproject.com/en/1.6/topics/db/transactions/#django.db.transaction.atomic

The only place this doesn't work is with MySQL, because it has a broken
implementation of referential integrity. If you're using PostgreSQL (which
implements referential integrity at the transaction boundary) or SQLite
(which doesn't have referential integrity), a transaction will do the job.

If you have to use MySQL (and personally, I'd really recommend you don't),
the approach you've described of making one of the fields nullable is what
you have to do.

Yours,
Russ Magee %-)

-- 
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/CAJxq849o%2B6s%2BALP7obU3o_sG1mk_J9J0th8DP5Wx9AFmDCp-Ag%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


displaying manytomany fields in template

2014-01-21 Thread splucena


Template:
   
 {% for per in person_list%}

{{ per }}
{% for spec in per.specialization_id.all %}
{{ spec }}
{% endfor %}

{% endfor %}

Here's my code in the template. I'ts not doing what I intend to see.

The table looks like this:

FullName | Programming | Web Design

How can I make it look like this instead

FullName | Programming, Web Design |

-- 
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/38b192a0-0c4e-40d0-812a-fc004be9ca50%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


AttributeError: 'TaggableManager' object has no attribute 'primary_key'

2014-01-21 Thread vinoth kumar renganathan
When i making new migration with this command "python manage.py 
schemamigration blogger --auto" it shows " You cannot use --auto on an app 
with no migrations. Try --initial."

so i try to run "python manage.py schemamigration blogger --initial" . And 
i got this in my terminal
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 399, in execute_from_command_line
utility.execute()
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 242, in run_from_argv
self.execute(*args, **options.__dict__)
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
line 285, in execute
output = self.handle(*args, **options)
  File 
"/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/management/commands/schemamigration.py",
 
line 151, in handle
for action_name, params in change_source.get_changes():
  File 
"/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/changes.py",
 
line 460, in get_changes
model_defs = freeze_apps([self.migrations.app_label()])
  File 
"/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py",
 
line 32, in freeze_apps
frozen_models.update(model_dependencies(model))
  File 
"/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py",
 
line 96, in model_dependencies
depends.update(field_dependencies(field, checked_models))
  File 
"/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py",
 
line 132, in field_dependencies
value = get_attribute(field, attrname)
  File 
"/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/utils/__init__.py",
 
line 38, in get_attribute
value = getattr(value, part)
AttributeError: 'TaggableManager' object has no attribute 'primary_key'

Herewith attached detail about my project.

urls.py   http://pastebin.com/Cibt5a9L
models.py  http://pastebin.com/prYeigN9 
views.pyhttp://pastebin.com/AJu2PXkJ
tagpage.html  http://pastebin.com/MBaj23cx

Also installed 'taggit'  in settings.py


 

-- 
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/83be8db0-9bb9-41cf-9eb7-087f87c3bafe%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Fast and Easy way to check if an instance of an Model exists in the Database

2014-01-21 Thread Erik Cederstrand
Den 21/01/2014 kl. 10.55 skrev Johannes Schneider 
:

> yes, but the problem is that we manually give them a pk.
> 
> Maye it's the best to reduce the question to the following:
> Which (undocumented) field is better for this case?
> * instance._state.db (checking if this is None)
> * instance_state.adding (checking for True)

Pick whichever works for you. But make sure to write tests for this, so it 
still works when you upgrade Django.

Erik

-- 
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/ADA379C6-E84C-492F-AFEE-7148CC9545A3%40cederstrand.dk.
For more options, visit https://groups.google.com/groups/opt_out.


Re: KeyError: u"Unknown language code 'en-us'."

2014-01-21 Thread Geotribu
Hi Jonathan,

Thanks to yhou I've found what was wrong in my configuration file !

Thanks again and I've a good day.

A.



Le lundi 20 janvier 2014 17:11:55 UTC-3:30, Jonathan Pentecost a écrit :
>
> There is no language code "en-us" in django. `from 
> django.conf.global_settings import LANGUAGES` to get a list of all 
> languages.
>
> On Monday, 20 January 2014 23:52:37 UTC+11, Geotribu wrote:
> Hi all,
>
>
> I've developed a multi-language application with Django.
> Everything works fine except I receive regularly this message by email:
>
> 8<--
>
> Traceback (most recent call last): File 
> "/home/users/avandecastee/osmq/lib/python2.6/site-packages/django/core/handlers/base.py",
>  
> line 140, in get_response response = response.render() File 
> "/home/users/avandecastee/osmq/lib/python2.6/site-packages/django/template/response.py",
>  
> line 105, in render self.content = self.rendered_content
> ..
>
>
> File 
> "/home/users/avandecastee/osmq/lib/python2.6/site-packages/django/utils/translation/__init__.py",
>  
> line 150, in get_language_info raise KeyError("Unknown language code %r." % 
> lang_code) KeyError: u"Unknown language code 'en-us'."
>
> -->8
>
>
>
> Could you tell me what I must change to avoid this message ?
>
>
> Thanks for your help
>
> Arnaud
>

-- 
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/c6981324-a3b6-4834-8b02-c7d15ab40fbe%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Fast and Easy way to check if an instance of an Model exists in the Database

2014-01-21 Thread Johannes Schneider

thnx guys for all that input.

On 21.01.2014 14:06, Erik Cederstrand wrote:

Den 21/01/2014 kl. 10.55 skrev Johannes Schneider 
:


yes, but the problem is that we manually give them a pk.

Maye it's the best to reduce the question to the following:
Which (undocumented) field is better for this case?
* instance._state.db (checking if this is None)
* instance_state.adding (checking for True)


Pick whichever works for you. But make sure to write tests for this, so it 
still works when you upgrade Django.

Erik




--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
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/52DE764A.5020609%40galileo-press.de.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Survey App

2014-01-21 Thread Ovnicraft
On Tue, Jan 21, 2014 at 5:14 AM, Yazmin Lucy Cumberbirch wrote:

> Solved the problem :) Thanks for the help. Will see if it does all my boss
> wants ^^
>
>
> On Tuesday, January 21, 2014 11:10:45 AM UTC+1, Yazmin Lucy Cumberbirch
> wrote:
>>
>> Hi!
>>
>> Thanks for your suggestion!
>>
>> I have tried to use it, I installed formly and added it to my
>> INSTALLED_APPS and to the urls, but I cant manage to get it working. I also
>> downloaded the pinax account project but can't run it.
>>
>> Any change you can give me hand with it?
>>
>> pinax account project wont run, gives a sintax error :S and formly when
>> added to the urls is missing templates. I think they are in the pinax, but
>> as i said, I cant get it working.
>>
>>
Can you provide more information, pastebin the log to read what is
happening.


Basically you need to:
 create a pinax project
 install formly
 syncdb
 runserver

You will need to add formly in urls too, then use it.

Regards,


> Thanks
>>
>> On Monday, January 20, 2014 4:04:06 PM UTC+1, ovnicraft wrote:
>>>
>>>
>>>
>>>
>>> On Mon, Jan 20, 2014 at 6:41 AM, Yazmin Lucy Cumberbirch 
>>> wrote:
>>>
 Hi!

 I am trying to find a survey app for my django project. I need it to be
 able to send personalized survey invitations, so I know who is answering
 them.

 This is similar to SurveyMonkey, but the API they provide doesn't
 include any methods to send the survey to the list of mails (or I can't
 find how to do it).

 Does anybody know of an app that does this? Or an external page that
 does so, and has an API so I can do it all automatically?

>>>
>>> Hi i am using https://github.com/eldarion/formly is really great you
>>> need to use it with pinax account project https://github.com/
>>> pinax/pinax-project-account
>>>
>>> It allows you make all surveys as you want and its bootstrap based :-)
>>>
>>> Thanks to eldarion.
>>>
>>>
>>> Regards,
>>>
>>>

 Thanks for any help!

 ylc

 --
 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...@googlegroups.com.
 To post to this group, send email to django...@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/f853ede3-5b27-41bc-b8fc-d709efcc7215%
 40googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>
>>>
>>> --
>>> Cristian Salamea
>>> @ovnicraft
>>>
>>  --
> 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/ba699809-c4d4-4a65-b169-1af504360882%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Cristian Salamea
@ovnicraft

-- 
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/CA%2B16coPE3cz666yrZFypKGmUwpMVo7f4aPJr-O5_oOPmKfx2vA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Adding an API to an existing Django app

2014-01-21 Thread Dennis Plöger
Hi!

You could use content negotiation to achieve what you want 
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html
>

No, that's not what I want. I'm actually looking for a way to lift my REST 
api to the same level as my Web UI.

I have a completely working Web UI, that uses models or querysets to 
create, update, delete and list objects. Now, for a REST api I would create 
a shadow structure where I release resources, that are based on the same 
models or querysets I use in the Web UI.

But I don't want to split these two. If I develop a new feature for the Web 
UI, it should be in the REST api as well. I want the REST api to be a first 
class citizen like the Web UI.

Is there a way for the Web UI (which uses generic class based views) to 
rely on the REST api instead of the ORM? Is this possible with tastypie or 
whatever?

Do you guys all separate the Web UI from the REST api? Or are you creating 
full Ajax-Web UIs, that are based on REST apis?

Kind regards
Dennis

-- 
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/8e58c872-875b-4e2a-bfd9-2ff226d4c3f3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Odd issue with 1.6.1 (as opposed to 1.5.5)

2014-01-21 Thread François Schiettecatte
Hi

I am wondering if there is something about CONN_MAX_AGE in 1.6.1 and accessing 
objects from a script (as opposed to as part of an HTTP request).

I have set CONN_MAX_AGE to 60 (seconds) but I don't see the connection closing 
after that interval. In fact I am seeing the connection idle for more than 60 
seconds (checking this in MySQL) and being reused by subsequent object accesses.


https://docs.djangoproject.com/en/1.6/ref/databases/#persistent-connections

https://docs.djangoproject.com/en/1.6/ref/settings/#std:setting-CONN_MAX_AGE

Am I missing something?

Cheers

François


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: rendering HTML as a select item

2014-01-21 Thread Bill Freeman
Have you confirmed that it isn't the browser doing this?

That is, with the mark safe in place, have you looked at the output with
curl?

Or have you made a static html page with the desired construct in it, and
viewed it in the browser?

It may bee that option elements can't contain block level elements.  You
could see what you can do with span instead of div.

Bill


On Sun, Jan 19, 2014 at 6:50 PM, Larry Martell wrote:

> I am trying to 'fake out' a model form and display data from 2 columns
> in one field. I can do this by returning the 2 columns in the model's
> __unicode__ method, but I want to apply styling to the data - I want
> one column's data left justified and the other column's data right
> justified. When I return this in the __unicode__ method:
>
> return mark_safe('%s%s' % (self.name, self.group_by))
>
> The HTML gets stripped out and I end up with just the data, e.g.:
>
> 12S target
>
> If I return the markup without the mark_safe, the HTML generated looks
> like this:
>
> 
12S
target
> > But what is displayed in the select box on the browser is: > > 12Starget > > Does anyone know how I can do this? > > -- > 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/CACwCsY7uh%2BWruXhaD5h8cxpfzHxGghEpFdxwyAahW%2Ba2qHEfjg%40mail.gmail.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/CAB%2BAj0s8mRHEnu5uv%3Dz21ErKeR2t3MaSk%2Bx08Mo%2BKz2yokcO0Q%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.

Insite help

2014-01-21 Thread Matthew Stroud
 I have been working on an application and it's working quite well. However 
I have been requested to have insite help integrated in to the site (e.g. a 
help button). Though I could just create static pages and serve them up, I 
would much rather have something that has a WYSIWYG editor that I can edit 
the pages on the fly. Any suggestions?

-- 
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/00a22c6b-45f2-48cc-b945-1247234c2674%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: rendering HTML as a select item

2014-01-21 Thread Larry Martell
On Tue, Jan 21, 2014 at 8:53 AM, Bill Freeman  wrote:
> Have you confirmed that it isn't the browser doing this?
>
> That is, with the mark safe in place, have you looked at the output with
> curl?
>
> Or have you made a static html page with the desired construct in it, and
> viewed it in the browser?
>
> It may bee that option elements can't contain block level elements.  You
> could see what you can do with span instead of div.

I discovered that  elements only allow "text with eventually
escaped characters (like é).", not general HTML -
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option.

> On Sun, Jan 19, 2014 at 6:50 PM, Larry Martell 
> wrote:
>>
>> I am trying to 'fake out' a model form and display data from 2 columns
>> in one field. I can do this by returning the 2 columns in the model's
>> __unicode__ method, but I want to apply styling to the data - I want
>> one column's data left justified and the other column's data right
>> justified. When I return this in the __unicode__ method:
>>
>> return mark_safe('%s%s' % (self.name, self.group_by))
>>
>> The HTML gets stripped out and I end up with just the data, e.g.:
>>
>> 12S target
>>
>> If I return the markup without the mark_safe, the HTML generated looks
>> like this:
>>
>> 
12S
target
>> >> But what is displayed in the select box on the browser is: >> >> 12Starget >> >> Does anyone know how I can do this? >> >> -- >> 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/CACwCsY7uh%2BWruXhaD5h8cxpfzHxGghEpFdxwyAahW%2Ba2qHEfjg%40mail.gmail.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/CAB%2BAj0s8mRHEnu5uv%3Dz21ErKeR2t3MaSk%2Bx08Mo%2BKz2yokcO0Q%40mail.gmail.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/CACwCsY71YUjJSr%3DDJsqZHpAXAQaaedOjhjmUOBrTq2HrdDSXSQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.

Re: Insite help

2014-01-21 Thread Avraham Serour
https://django-cms.org/


On Tue, Jan 21, 2014 at 5:55 PM, Matthew Stroud wrote:

>  I have been working on an application and it's working quite well.
> However I have been requested to have insite help integrated in to the site
> (e.g. a help button). Though I could just create static pages and serve
> them up, I would much rather have something that has a WYSIWYG editor that
> I can edit the pages on the fly. Any suggestions?
>
> --
> 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/00a22c6b-45f2-48cc-b945-1247234c2674%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/CAFWa6t%2BscLn4birkir8ZWyMwtg-wLbabg1j6C%2BkTpByf0R3C_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Flatpages - Django 1.5.1

2014-01-21 Thread James
Fixed. After some Google-fu I set SITE_ID = 2 and it worked.

On Monday, January 20, 2014 4:41:05 PM UTC-8, James wrote:
>
> I’m having trouble implementing flatpages in Django 1.5.1 - I’m new to 
> Django/Python (~3 months) so any insight is appreciated.
>
> I’ve added flatpages in APPS and MIDDLEWARE_CLASSES and ran a syncdb:
>
> INSTALLED_APPS = (
>
> 'django.contrib.auth',
>
> 'django.contrib.contenttypes',
>
> 'django.contrib.sessions',
>
> 'django.contrib.sites',
>
> 'django.contrib.messages',
>
> 'django.contrib.staticfiles',
>
> # Uncomment the next line to enable the admin:
>
> 'django.contrib.admin',
>
> # Uncomment the next line to enable admin documentation:
>
> 'django.contrib.admindocs',
>
> 'django.contrib.flatpages',
>
> 'blog',
>
> )
>
>
> MIDDLEWARE_CLASSES = (
>
> 'django.middleware.common.CommonMiddleware',
>
> 'django.contrib.sessions.middleware.SessionMiddleware',
>
> 'django.middleware.csrf.CsrfViewMiddleware',
>
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>
> 'django.contrib.messages.middleware.MessageMiddleware',
>
> 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
>
> )
>
> I logged into Django admin and created:
>
> URL: /about/
>
> Title: About
>
> Content: testing…
>
> Sites:  127.0.0.1:8000
>
> I clicked ‘view on site’ within the Django admin > flatpages > /about/ and 
> I get sent to http://localhost:8000/about/ which returns a 404.  I opened 
> up a SQLite browser and I can see that my page is in the db.  Am I missing 
> anything else?
>
> Thanks
>
> James
>

-- 
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/b15140af-244f-4fb1-8cae-82058849d0d8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Adding custom javascript to admin

2014-01-21 Thread Larry Martell
I have a model that I need to add some custom javascript processing to
its admin form, which is this:

class CategoryAdmin(admin.ModelAdmin):
radio_fields = {"data_path_ip": admin.HORIZONTAL}
list_display = ('name', 'event_path', 'data_path', 'file_spec',
'data_path_ip')
list_filter = ('name', 'event_path', 'data_path', 'file_spec',
'data_path_ip')
admin.site.register(Category, CategoryAdmin)

Where (i.e. in what template) would I put this js code in?

-- 
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/CACwCsY6s%3DsV0thFNHBCG%2BsUe87kX_K%3DyZJgYmYpOQr%2BRrm1krg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Adding custom javascript to admin

2014-01-21 Thread Larry Martell
On Tue, Jan 21, 2014 at 9:08 AM, Larry Martell  wrote:
> I have a model that I need to add some custom javascript processing to
> its admin form, which is this:
>
> class CategoryAdmin(admin.ModelAdmin):
> radio_fields = {"data_path_ip": admin.HORIZONTAL}
> list_display = ('name', 'event_path', 'data_path', 'file_spec',
> 'data_path_ip')
> list_filter = ('name', 'event_path', 'data_path', 'file_spec',
> 'data_path_ip')
> admin.site.register(Category, CategoryAdmin)
>
> Where (i.e. in what template) would I put this js code in?

I found this: 
https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#overriding-admin-templates
so I created my own change_form.html, and I overrode
object-tools-items and put my js in there, but I'm not seeing it when
I go to the change form. Then, just as a test, I put it directly into
the real django change_form.html, but still nothing. Then to see if
that template is being used, I changed it - added data, created syntax
errors, but still, it had no effect. So it seems like that template
isn't being used at all. But the HTML sure looks like it came from
that template. Can anyone give me some direction here please.

Thanks!
-larry

-- 
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/CACwCsY5hFfS%2BGJ928Edcr-LgGJyDqdVhjDRmc-br5pPdxpwLQA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Seperate fields for SelectDateWidget in template

2014-01-21 Thread ernando
Hi,

You have to look on MultiWidget and use it as base to create your own one.

- Dmitry


On Monday, January 6, 2014 7:22:07 PM UTC+3, Voyager wrote:
>
> I have Googled a lot but I can't find an answer. I want to use 
> SelectDateWidget in one of my forms but I want the select boxes in 
> separate divs so I can use them with Zurb Foundation. With all the other 
> widgets it is easy. For example I can do 
>
>  
>  {{ form.username.label_tag }}{{ form.username }}{{ 
> form.username.errors }} 
>   
>
> but with SelectDateWidget I want to do something like 
>
> {{ form.birth_date.label_tag }} 
>  
> {{ form.birth_date_month }} 
>  
>  
> {{ form.birth_date_day }} 
>  
>  
> {{ form.birth_date_year }} 
>  
>   {{ form.birth_date.errors }} 
>
> so I can use it with Foundation's grid system. I even looked at 
> SelectDateWidget source but I couldn't understand how to do it. 
>

-- 
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/561063e3-a03b-4cbb-9522-9a8d4a3e6811%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Insite help

2014-01-21 Thread Enyert Viñas
Right now you dont need WYSIWYG editors. Just learn Chrome
DevTools and
use a text editor. For example Vim, Sublime Text or Emacs. You can try an
IDE like eclipse or PyCharm too.

Regards.


2014/1/21 Matthew Stroud 

>  I have been working on an application and it's working quite well.
> However I have been requested to have insite help integrated in to the site
> (e.g. a help button). Though I could just create static pages and serve
> them up, I would much rather have something that has a WYSIWYG editor that
> I can edit the pages on the fly. Any suggestions?
>
> --
> 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/00a22c6b-45f2-48cc-b945-1247234c2674%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/CAPe5H6-yXy6m7owgJ_03BQsW8xG%3DHpGFwvpWuiqpQAhXjAz1Ww%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: displaying manytomany fields in template

2014-01-21 Thread Jonathan Pentecost
You will need to provide the Person model to decipher what is going on in 
your template. 

On Tuesday, 21 January 2014 17:34:00 UTC+11, splucena wrote:
>
>
>
> Template:
>
>  {% for per in person_list%}
> 
> {{ per }}
> {% for spec in per.specialization_id.all %}
> {{ spec }}
> {% endfor %}
> 
> {% endfor %}
>
> Here's my code in the template. I'ts not doing what I intend to see.
>
> The table looks like this:
>
> FullName | Programming | Web Design
>
> How can I make it look like this instead
>
> FullName | Programming, Web Design |
>

-- 
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/cae822f2-aa97-4999-9629-c6c345a3a6e3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: AttributeError: 'TaggableManager' object has no attribute 'primary_key'

2014-01-21 Thread Jonathan Pentecost
I think there is a problem with the taggit library, possibly similar to
 
https://github.com/alex/django-taggit/issues/186
?

On Tuesday, 21 January 2014 19:21:08 UTC+11, vinoth kumar renganathan wrote:
>
> When i making new migration with this command "python manage.py 
> schemamigration blogger --auto" it shows " You cannot use --auto on an 
> app with no migrations. Try --initial."
>
> so i try to run "python manage.py schemamigration blogger --initial" . And 
> i got this in my terminal
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 399, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", 
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 242, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", 
> line 285, in execute
> output = self.handle(*args, **options)
>   File 
> "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/management/commands/schemamigration.py",
>  
> line 151, in handle
> for action_name, params in change_source.get_changes():
>   File 
> "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/changes.py",
>  
> line 460, in get_changes
> model_defs = freeze_apps([self.migrations.app_label()])
>   File 
> "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py",
>  
> line 32, in freeze_apps
> frozen_models.update(model_dependencies(model))
>   File 
> "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py",
>  
> line 96, in model_dependencies
> depends.update(field_dependencies(field, checked_models))
>   File 
> "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py",
>  
> line 132, in field_dependencies
> value = get_attribute(field, attrname)
>   File 
> "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/utils/__init__.py",
>  
> line 38, in get_attribute
> value = getattr(value, part)
> AttributeError: 'TaggableManager' object has no attribute 'primary_key'
>
> Herewith attached detail about my project.
>
> urls.py   http://pastebin.com/Cibt5a9L
> models.py  http://pastebin.com/prYeigN9 
> views.pyhttp://pastebin.com/AJu2PXkJ
> tagpage.html  http://pastebin.com/MBaj23cx
>
> Also installed 'taggit'  in settings.py
>
>
>  
>

-- 
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/c7e13d54-9543-4e13-b6db-085384f749a6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Overriding admin sidebar

2014-01-21 Thread Jonathan Pentecost
Your not loading the "trans" tag, 
https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#internationalization-in-template-code
 

On Tuesday, 21 January 2014 12:32:56 UTC+11, larry@gmail.com wrote:
>
> I am trying to override the admin sidebar block. As a starting point I 
> just copied the entire block from the django index template into my 
> own index.html file. But I am getting: 
>
> Error during template rendering 
>
> In template /usr/local/motor/motor/ui/templates/admin/index.html, 
> error at line 6 
>
> This is the contents of my index.html file: 
>
> {% extends "admin/index.html" %} 
>
> {% block sidebar %} 
>  
>  
> {% trans 'Recent Actions' %} 
> {% trans 'My Actions' %} 
> {% load log %} 
> {% get_admin_log 10 as admin_log for_user user %} 
> {% if not admin_log %} 
> {% trans 'None available' %} 
> {% else %} 
>  
> {% for entry in admin_log %} 
>  
> {% if entry.is_deletion or not entry.get_admin_url %} 
> {{ entry.object_repr }} 
> {% else %} 
> {{ 
> entry.object_repr }} 
> {% endif %} 
>  
> {% if entry.content_type %} 
> {% filter capfirst %}{% 
> trans entry.content_type.name %}{% endfilter %} 
> {% else %} 
> {% trans 'Unknown 
> content' %} 
> {% endif %} 
>  
> {% endfor %} 
>  
> {% endif %} 
>  
>  
> {% endblock %} 
>
> What am I doing wrong here? 
>

-- 
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/5de5eed2-f498-4835-bec7-4241f29c3014%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Overriding admin sidebar

2014-01-21 Thread Larry Martell
Thanks!!

On Tue, Jan 21, 2014 at 1:43 PM, Jonathan Pentecost
 wrote:
> Your not loading the "trans" tag,
> https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#internationalization-in-template-code
>
>
> On Tuesday, 21 January 2014 12:32:56 UTC+11, larry@gmail.com wrote:
>>
>> I am trying to override the admin sidebar block. As a starting point I
>> just copied the entire block from the django index template into my
>> own index.html file. But I am getting:
>>
>> Error during template rendering
>>
>> In template /usr/local/motor/motor/ui/templates/admin/index.html,
>> error at line 6
>>
>> This is the contents of my index.html file:
>>
>> {% extends "admin/index.html" %}
>>
>> {% block sidebar %}
>> 
>> 
>> {% trans 'Recent Actions' %}
>> {% trans 'My Actions' %}
>> {% load log %}
>> {% get_admin_log 10 as admin_log for_user user %}
>> {% if not admin_log %}
>> {% trans 'None available' %}
>> {% else %}
>> 
>> {% for entry in admin_log %}
>> 
>> {% if entry.is_deletion or not entry.get_admin_url %}
>> {{ entry.object_repr }}
>> {% else %}
>> {{
>> entry.object_repr }}
>> {% endif %}
>> 
>> {% if entry.content_type %}
>> {% filter capfirst %}{%
>> trans entry.content_type.name %}{% endfilter %}
>> {% else %}
>> {% trans 'Unknown
>> content' %}
>> {% endif %}
>> 
>> {% endfor %}
>> 
>> {% endif %}
>> 
>> 
>> {% endblock %}
>>
>> What am I doing wrong here?
>
> --
> 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/5de5eed2-f498-4835-bec7-4241f29c3014%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/CACwCsY5vV_tSiPuZ4dWf1HdV3%3DU%3Dngudq8ybOTK9v201PgL2Qg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Question about django_session table.

2014-01-21 Thread Chen Xu
Hi  everyone,
I am wondering when I use db as my session backend, does django_session
table auto adds an entry to it when I call login?


Thanks in advance

-- 
⚡ Chen Xu ⚡

-- 
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/CACac-qYGc9xV5zM-o2x1JWELWdO0mdjBEme5AA-gFH9b6Na99g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Error in Django Admin When I try to add.

2014-01-21 Thread Dharwin Perez
I was trying to make a API Dispatcher, but when i try to add anything in 
Django Admin, run APIdispatcher and return Bad Request. I think that is 
some in the URL because when i comment those line, Django Admin works 
correctly.

urls.py

url(r'^(?P.*)/(?P.*)/(?P.*)/(?P.*)/$', 
'People.views.APIdispatcher', name='API_dispatcher')

views.py

@csrf_exempt
def APIdispatcher(request,version,table,secret_key,mac_address):
# Verificamos que sea una peticion POST
if request.method == 'POST':

if _version == 'V0.9' or _version == 'v0.9':
apiV09()
elif _version == 'V1.0' or _version == 'v1.0':
apiV10( )
return HttpResponse(status=200) 

else:
return HttpResponseBadRequest()
else:
return HttpResponseBadRequest()

admin.py

admin.site.register(Application)
>

models.py

class Application(models.Model):


> application_id = models.AutoField(

primary_key = True )


> name = models.CharField(

max_length = 200,

blank = False,

null = False,

unique  = True )


> secret_key = models.CharField(

max_length = 150,

blank = True,

null = True,

unique  = True )


>
> creation_date = models.DateField( auto_now_add = True )

creation_ts = models.DateTimeField( auto_now_add = True )

modification_date = models.DateField( auto_now = True )

modification_ts = models.DateTimeField( auto_now = True )

status  = models.CharField(

max_length  = 20,

choices = (

('1','ACTIVA'),

('2','SUSPENDIDA'),

('3','MANTENIMIENTO'),

('4','ELIMINADA')

),

default = '1'

) 

 

class Meta:

db_table = 'Applications'

verbose_name = 'Application'

verbose_name_plural = 'Applications'


> def __unicode__(self):

return self.name

 

-- 
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/316157cd-933a-49fe-98ee-697e49e57a2f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Opening up multiple database connections per request?

2014-01-21 Thread jeff do


Is it possible to open up multiple database connections inside of one 
request in Django? I am using Django 1.6 and Python3.3. 

In my use case, I have a web application that executes raw SQL against a 
data warehouse we have. For example, one page may require five different 
SQL queries to be executed to pull down all the datasets necessary to 
display as charts, tables, etc.

Using only one database connection and executing the SQL queries 
synchronously is too slow, so I am trying to use threads (specifically the 
concurrent.futures package in stdlib) to run my queries asynchronously. In 
particular, I have code that looks like:

 

from django.db import connection

from concurrent.futures import ThreadPoolExecutor, as_completed 

def execute_query(sql):

   cursor = connection.cursor()

   …

   rows = cursor.fetchall() 

return rows

def execute_queries_asynchronously(list_of_sql_queries):

datasets = []

with ThreadPoolExecutor(max_workers=3) as executor:

futures = [executor.submit(execute_query, query) for query in 
list_of_sql_queries]

for future in as_completed(futures):

datasets.append(future.result())

return datasets



When I run the above code in shell, total execution time improves 
noticeably which is expected (about 2x-3x faster). However, when I put this 
code in my web application, I get an almost negligible performance gain, if 
any. It doesn’t seem like Django is opening up more DB connections. I’d 
like Django to open up a new connection or pull from the connection pool 
for every worker thread. Does the Django connection handler limit the 
number of available DB connections to a request to only one?

-- 
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/cb7ebe95-1565-4f4b-84cd-e25a36a7497a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Opening up multiple database connections per request?

2014-01-21 Thread Russell Keith-Magee
Hi Jeff,

Correct - Django has one database connection per request.

If you want to open multiple connections, you're going to look into
Django's support for multiple databases. You're using django.db.connection;
this is really just shorthand for django.db.connections['default']. If you
define an 'other' database in your settings file, you can connect to
django.db.connections['other'] as well, using a separate connection.

Although this was developed with the intention of accessing multiple
*different* database sources (e.g., a database master and a slave, or a
sharded database), there's no reason you can't have multiple connections to
the same database (in fact, this can be a handy way to test logic around
master/slave configurations without needing to set up a master/slave
database configuration).

The simple approach to this requires pre-declaration of the number of
connections you want to have; if you're particularly ingenious, you might
be able to mess with the internals of the ConnectionManager object to
dynamically create extra connections at runtime based upon the definition
of your base database. However, this is undocumented API, so you're on your
own if you take this path.

Yours,
Russ Magee %-)


On Wed, Jan 22, 2014 at 7:40 AM, jeff do  wrote:

> Is it possible to open up multiple database connections inside of one
> request in Django? I am using Django 1.6 and Python3.3.
>
> In my use case, I have a web application that executes raw SQL against a
> data warehouse we have. For example, one page may require five different
> SQL queries to be executed to pull down all the datasets necessary to
> display as charts, tables, etc.
>
> Using only one database connection and executing the SQL queries
> synchronously is too slow, so I am trying to use threads (specifically the
> concurrent.futures package in stdlib) to run my queries asynchronously. In
> particular, I have code that looks like:
>
>
>
> from django.db import connection
>
> from concurrent.futures import ThreadPoolExecutor, as_completed
>
> def execute_query(sql):
>
>cursor = connection.cursor()
>
>…
>
>rows = cursor.fetchall()
>
> return rows
>
> def execute_queries_asynchronously(list_of_sql_queries):
>
> datasets = []
>
> with ThreadPoolExecutor(max_workers=3) as executor:
>
> futures = [executor.submit(execute_query, query) for query in
> list_of_sql_queries]
>
> for future in as_completed(futures):
>
> datasets.append(future.result())
>
> return datasets
>
>
>
> When I run the above code in shell, total execution time improves
> noticeably which is expected (about 2x-3x faster). However, when I put this
> code in my web application, I get an almost negligible performance gain, if
> any. It doesn’t seem like Django is opening up more DB connections. I’d
> like Django to open up a new connection or pull from the connection pool
> for every worker thread. Does the Django connection handler limit the
> number of available DB connections to a request to only one?
>
> --
> 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/cb7ebe95-1565-4f4b-84cd-e25a36a7497a%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/CAJxq849naMVqWGSh8bEX%3DAm5v4NX%3DORiO_B-iX9VfYpuu6mkBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


django with no relational db?

2014-01-21 Thread devash
 
 I am building an app with no relational DB. All data will be in flat files 
now and nosql dbs in future. 

 I plan to use django-tastypie for rest api and mostly pure python from 
rest api code to connect to file system and non relational backend python 
api. I do not plan to use Django ORM. 

 I will have web pages, d3.js, authenticated users and sessions. 

 1) Is it even possible to use Django without relational DB? 

 I noticed many of Django's core app like auth and session depend on having 
relational DB. Am i correct?

 2) Does it even make sense to use Django here? Is Django appropriate 
technology/framework to use here? or any other python alternatives I should 
look at?

-- 
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/4bafb35e-11fc-4268-b6bf-178df45ae921%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django with no relational db?

2014-01-21 Thread Alex Mandel
On 01/21/2014 06:56 PM, devash wrote:
>  
>  I am building an app with no relational DB. All data will be in flat files 
> now and nosql dbs in future. 
> 
>  I plan to use django-tastypie for rest api and mostly pure python from 
> rest api code to connect to file system and non relational backend python 
> api. I do not plan to use Django ORM. 
> 
>  I will have web pages, d3.js, authenticated users and sessions. 
> 
>  1) Is it even possible to use Django without relational DB? 
> 
>  I noticed many of Django's core app like auth and session depend on having 
> relational DB. Am i correct?
> 
>  2) Does it even make sense to use Django here? Is Django appropriate 
> technology/framework to use here? or any other python alternatives I should 
> look at?
> 

Just use sqlite, that gets rid of any complication/overhead of running a
service based db, and will cover auth stuff. Django really isn't meant
to run from flat files (there is a cheat using django flatpages) but
that's so you can edit through the web.

But yes this might be more than you need and you could look at
Pyramid/Pylons which less stuff to begin with.

Enjoy,
Alex

-- 
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/52DF5AFB.9090908%40wildintellect.com.
For more options, visit https://groups.google.com/groups/opt_out.


Cannot import name execute_manager

2014-01-21 Thread MAurice
Hello django users,
I have a problem when i try to sync my db or runserver on my ubuntu 13.10. 
of cant import name execute manger
Help me out thanks


File "manage.py", line 2, in 
from django.core.management import execute_manager
ImportError: cannot import name execute_manager

-- 
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/3dad08cb-842c-4f8b-bbf7-62d3ebcd3114%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Cannot import name execute_manager

2014-01-21 Thread Mike Dewhirst

On 22/01/2014 6:16pm, MAurice wrote:

Hello django users,
I have a problem when i try to sync my db or runserver on my ubuntu
13.10. of cant import name execute manger
Help me out thanks


You are probably running Django 1.6.x which doesn't have 
execute_manager. Here is the 1.5.x code which explains that it is a 
deprecated method ...


https://docs.djangoproject.com/en/dev/releases/1.4/#django-core-management-execute-manager

Little bit of work to do.

Hth

Mike




File "manage.py", line 2, in 
 from django.core.management import execute_manager
ImportError: cannot import name execute_manager

--
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/3dad08cb-842c-4f8b-bbf7-62d3ebcd3114%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/52DF74E3.2080008%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Cannot import name execute_manager

2014-01-21 Thread Mike Dewhirst

On 22/01/2014 6:36pm, Mike Dewhirst wrote:

On 22/01/2014 6:16pm, MAurice wrote:

Hello django users,
I have a problem when i try to sync my db or runserver on my ubuntu
13.10. of cant import name execute manger
Help me out thanks


You are probably running Django 1.6.x which doesn't have
execute_manager.Here is the


er ... link


which explains that it is a deprecated method ...

https://docs.djangoproject.com/en/dev/releases/1.4/#django-core-management-execute-manager


Little bit of work to do.

Hth

Mike




File "manage.py", line 2, in 
 from django.core.management import execute_manager
ImportError: cannot import name execute_manager

--
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/3dad08cb-842c-4f8b-bbf7-62d3ebcd3114%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.





--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9787 6598
M: 0411 704 143


--
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/52DF76E2.90108%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.