Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Chris Cogdon
Well, I did all that (and I learned a few things in the process that will 
be useful for my own project... thank you!)

I never got the warnings you got, but I got three errors along the lines of:

==
ERROR: test_mismatched_agents1 
(valuenetwork.valueaccounting.tests.CompensationTest)
--
Traceback (most recent call last):
  File 
"/Users/ccogdon/dev/valuenetwork/valuenetwork/valuenetwork/valueaccounting/tests.py",
 
line 30, in setUp
self.agent_A.save()
  File 
"/Users/ccogdon/dev/valuenetwork/valuenetwork/valuenetwork/valueaccounting/models.py",
 
line 196, in save
super(EconomicAgent, self).save(*args, **kwargs)
  File 
"/Users/ccogdon/dev/valuenetwork/lib/python2.7/site-packages/django/db/models/base.py",
 
line 463, in save
self.save_base(using=using, force_insert=force_insert, 
force_update=force_update)
  File 
"/Users/ccogdon/dev/valuenetwork/lib/python2.7/site-packages/django/db/models/base.py",
 
line 551, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, 
using=using, raw=raw)
  File 
"/Users/ccogdon/dev/valuenetwork/lib/python2.7/site-packages/django/db/models/manager.py",
 
line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
  File 
"/Users/ccogdon/dev/valuenetwork/lib/python2.7/site-packages/django/db/models/query.py",
 
line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
  File 
"/Users/ccogdon/dev/valuenetwork/lib/python2.7/site-packages/django/db/models/sql/compiler.py",
 
line 910, in execute_sql
cursor.execute(sql, params)
  File 
"/Users/ccogdon/dev/valuenetwork/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",
 
line 337, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: valueaccounting_economicagent.created_date may not be NULL


Want me to grab a different revision from git ?

On Friday, December 14, 2012 5:27:04 PM UTC-8, bobhaugen wrote:
>
> Also, I recognize this is way beyond the call of duty, but if you 
> really want to reproduce the problem, you might need to follow: 
> https://github.com/valnet/valuenetwork/blob/master/docs/install.txt 
>
> On Fri, Dec 14, 2012 at 7:06 PM, Chris Cogdon  
> wrote: 
> > Checked out the code and attempted to run "manage.py test", but clearly 
> I 
> > don't have all the required modules installed. Sure is a lot of them! 
>

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



Re: Local thread variable (attempting to create a connection pool)

2012-12-14 Thread Russell Keith-Magee
Can a thread local work? Yes.

Are they a good idea? IMHO - Generally speaking, no.

>From a purely architectural point of view, it doesn't matter what you call
them -- you're talking about a global variable. Any argument that holds for
why global variables are bad also holds for thread locals. They make
everything harder to test. They make problems harder to isolate. If you can
avoid using them, you should.

The other big problem is that you need to be *really* careful. In the
context of a web server, a thread can last for multiple requests. This
means you need to be absolutely certainly that you're not leaking *any*
state between requests -- especially user state. If you leak *any* state
between requests, you run the risk of introducing a security problem,
because a request made by one user can leak sensitive information (account
session IDs, credentials, and so on) to another user. Of course, what gets
leaked depends entirely on what you're putting in the thread local -- but
if you don't put it in a thread local in the first place, it can't leak :-)

Making matters worse, the problems won't generally reveal themselves during
development; it's only when you have high volume of requests and a number
of different threads being reused extensively that you start to see any
problems with leaking state.

So - can they be used? Yes. Django uses thread locals in a couple of
places. If we had our time over (and none of the architectural
constraints), would we avoid using them? Absolutely.

Yours,
Russ Magee %-)

On Sat, Dec 15, 2012 at 11:27 AM, Rafael Almeida wrote:

> I'm not sure it's really a singleton that I need because I need a
> different value for each thread. I'm using threading.local for it, so far I
> haven't run into any issues, but I'd like to hear the opinion of a more
> experienced django developer.
>
> I save in cache the possible IPs of the backend system and I open
> connections to it when needed inside a threading.local subclass. I use an
> object from such class in order to retrieve a connection.
>
> The threading.local subclass is instantiated in a module variable, I could
> use the singleton class you pointed out as well. But I don't see the need
> for it in my case.
>
>
> On Friday, December 14, 2012 5:38:59 PM UTC-2, Chris Cogdon wrote:
>>
>> What you essentially want is a common pattern called a "singleton":
>> something that there is only one of, like "None" and "Elipsis". You can do
>> something workable, but ugly, using module-level variables, but there are
>> known patterns for creating singletons
>>
>> Here's some starters:
>>
>> http://stackoverflow.com/**questions/42558/python-and-**
>> the-singleton-pattern
>>
>>
>>
>>
>> On Friday, December 14, 2012 9:33:19 AM UTC-8, Rafael Almeida wrote:
>>>
>>> Hello,
>>>
>>> I have a django application which needs to connect to some backend
>>> services. Problem is I don't want to create a new connection everytime, but
>>> to use a connection pool. One connection per thread would be fine, but I
>>> don't know how to use django in order to achive that. I'd like to perhaps
>>> save those connections on cache subsystem, but I don't know how to create
>>> one key per thread, per worker.
>>>
>>> Thank you for your help,
>>> Rafael
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/hsdCWcl-2owJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Local thread variable (attempting to create a connection pool)

2012-12-14 Thread Rafael Almeida
I'm not sure it's really a singleton that I need because I need a different 
value for each thread. I'm using threading.local for it, so far I haven't 
run into any issues, but I'd like to hear the opinion of a more experienced 
django developer.

I save in cache the possible IPs of the backend system and I open 
connections to it when needed inside a threading.local subclass. I use an 
object from such class in order to retrieve a connection.

The threading.local subclass is instantiated in a module variable, I could 
use the singleton class you pointed out as well. But I don't see the need 
for it in my case.

On Friday, December 14, 2012 5:38:59 PM UTC-2, Chris Cogdon wrote:
>
> What you essentially want is a common pattern called a "singleton": 
> something that there is only one of, like "None" and "Elipsis". You can do 
> something workable, but ugly, using module-level variables, but there are 
> known patterns for creating singletons
>
> Here's some starters:
>
> http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern
>
>
>
>
> On Friday, December 14, 2012 9:33:19 AM UTC-8, Rafael Almeida wrote:
>>
>> Hello,
>>
>> I have a django application which needs to connect to some backend 
>> services. Problem is I don't want to create a new connection everytime, but 
>> to use a connection pool. One connection per thread would be fine, but I 
>> don't know how to use django in order to achive that. I'd like to perhaps 
>> save those connections on cache subsystem, but I don't know how to create 
>> one key per thread, per worker.
>>
>> Thank you for your help,
>> Rafael
>>
>

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Bob Haugen
Also, I recognize this is way beyond the call of duty, but if you
really want to reproduce the problem, you might need to follow:
https://github.com/valnet/valuenetwork/blob/master/docs/install.txt

On Fri, Dec 14, 2012 at 7:06 PM, Chris Cogdon  wrote:
> Checked out the code and attempted to run "manage.py test", but clearly I
> don't have all the required modules installed. Sure is a lot of them!

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Bob Haugen
I'm running ./manage.py test valueaccounting

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Chris Cogdon
Checked out the code and attempted to run "manage.py test", but clearly I 
don't have all the required modules installed. Sure is a lot of them!

Are you running tests using "manage.py test" ??  If so, have you considered 
that its not _your_ code that is showing up those errors, but that of one 
of the other modules? Take your module out of INSTALLED_APPS and re-run 
test. Still happening? Then it ain't you! :)


On Friday, December 14, 2012 4:09:25 PM UTC-8, bobhaugen wrote:
>
> On Fri, Dec 14, 2012 at 6:07 PM, Chris Cogdon  
> wrote: 
> > Throw the code up somewhere I can see the results for myself? 
>
>
> https://github.com/valnet/valuenetwork/blob/master/valuenetwork/valueaccounting/tests.py
>  
>

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



Re: Model's optional __unicode__() return values?

2012-12-14 Thread Micky Hulse
Hi Chris! Thanks so much for your quick reply, I really appreciate it.

On Fri, Dec 14, 2012 at 3:41 PM, Chris Cogdon  wrote:
> oops... that should be "if x is not None", not "where x is not None"...
> Clearly I am still half in SQL mode :)

Sweet!!! Works perfectly:

return ' | '.join ([unicode(x) for x in (self.target, getattr(self,
'page_type', None)) if x is not None])

Much appreciated. :)

Have a nice holiday.

Cheers,
Micky

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Bob Haugen
On Fri, Dec 14, 2012 at 6:07 PM, Chris Cogdon  wrote:
> Throw the code up somewhere I can see the results for myself?

https://github.com/valnet/valuenetwork/blob/master/valuenetwork/valueaccounting/tests.py

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Chris Cogdon
Throw the code up somewhere I can see the results for myself?

On Friday, December 14, 2012 3:52:11 PM UTC-8, bobhaugen wrote:
>
> But sincerely, Chris, thanks for hanging in there on this.  I baffled. 
>
> On Fri, Dec 14, 2012 at 5:51 PM, Bob Haugen  
> wrote: 
> > On Fri, Dec 14, 2012 at 5:42 PM, Chris Cogdon 
> >  
> wrote: 
> >> Okay, so when you create your datetimes, are you defining them with a 
> >> timezone ? 
> > 
> > I tried that; did not make any difference.  The error messages came up 
> > before any of the test setup code ran.  (I put a pdb trace in at the 
> > start; the error messages had already happened.) 
> > 
> > I did not create any datetimes.  I did create dates, but they did not 
> > cause any errors. The errors had already arisen way before then. 
>

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



Re: Modelform and Ajax (Select a valid choice..... Error)

2012-12-14 Thread Chris Cogdon
Good... but we'd all appreciate knowing what was wrong, so we can guide 
others :)

On Thursday, December 13, 2012 9:05:44 PM UTC-8, siddharth56660 wrote:
>
> Hey Chris 
>
> Thanks for the replybut i figured it out what was wrong. 
> :) 
> -Siddharth 
> On Thu, Dec 13, 2012 at 6:09 PM, Chris Cogdon  
> wrote: 
> > How are you populating the choices in the ChoiceField? Remember, you 
> need to 
> > do this on BOTH the POST AND the non-POST versions of creating the form. 
> > 
> > But ChoiceField is a Form field, not a Model field... so its not 
> perfectly 
> > clear what you're asking. 
> > 
> > 
> > On Tuesday, December 11, 2012 3:39:48 AM UTC-8, siddharth56660 wrote: 
> >> 
> >> Hi, 
> >> 
> >> I am facing problem in handling modelform and ajax together. 
> >> The situation is:- 
> >> I am using modelform to get display the form as ul in the template. 
> >> I have 3 ChoiceFields (country, state,city). On select of a country 
> >> from the dropdown, the valid states dropdown gets populated and on 
> >> select of a state the respective city dropdown gets populated. 
> >> For achieving the above functionality I am calling an ajax function 
> >> which returns me the available data of the other dropdown in Json Form 
> >> {stat_id, stat_name} 
> >> I am able to populate the data in next dropdown i.e state and city, 
> >> but when i click submit form it shows "Select a valid choice. 8 is not 
> >> one of the available choices" 
> >> 8 happens to be the stat_id in this case. 
> >> I have gone through google but dint find anything useful. Help is 
> >> really appreciated. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/NEBq73A9EyEJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Bob Haugen
But sincerely, Chris, thanks for hanging in there on this.  I baffled.

On Fri, Dec 14, 2012 at 5:51 PM, Bob Haugen  wrote:
> On Fri, Dec 14, 2012 at 5:42 PM, Chris Cogdon  wrote:
>> Okay, so when you create your datetimes, are you defining them with a
>> timezone ?
>
> I tried that; did not make any difference.  The error messages came up
> before any of the test setup code ran.  (I put a pdb trace in at the
> start; the error messages had already happened.)
>
> I did not create any datetimes.  I did create dates, but they did not
> cause any errors. The errors had already arisen way before then.

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



Re: Helptext forms forms

2012-12-14 Thread Chris Cogdon
"Support": sure! I won't "do the work" for you though :)

Okay, Just reading through the django code, and I'm seeing that the 
help_text is _not_ emitted in the field's widget, but in the _html_output 
method of BaseForm In other words, you don't need to update the widget. 
Useless doing so.

So, to ask about the options above, do you want to override the behaviour 
of the admin, or your own code?

Do you use this often enough that you'll want to change the behaviour of 
as_p, as_table or as_ul, or are you happy to just take control of things on 
that side, yourself?

The standard behaviour is to put the help text into xxx ... its perfectly possible to use jQuery to 
replace all of those instances with whatever HTML you want.


So... which route is going to get you what you need ?


On Friday, December 14, 2012 12:52:23 PM UTC-8, 4 The good Life we work 
wrote:
>
> Hallo Chris, 
>
> thank you for the good explanation. 
> I'm then afread that I have to create my own widget for this. Can you 
> support me on this? 
>
> Thanks, 
> Tony Michael 
>
> On Fri 14 Dec 2012 08:45:40 PM CET, Chris Cogdon wrote: 
> > If you're designing your own HTML (eg: this is not in the admin) then 
> > there's nothing stopping you rendering the help text any way you want. 
> Eg: 
> > 
> > 
> > {{ form.field1 }} > onclick="showpopuphelp('{{ form.field1.help_text }}');return false;" /> 
> > 
> > (that might not exactly work as written, but using it to give you the 
> > gist of things... my preference would be to put the text into a  > class="fieldhelp> and use jQuery magic to wrap it up) 
> > 
> > If you were doing this a lot, and would prefer to stick with using {{ 
> > form.as_table }} (for example) and rely on the default HTML generators 
> > for each field, then you'll need to create your own widgets, probably 
> > inheriting from the standard widgets, and override the html generators. 
> > 
> > 
> > If you wanted to change how the fields were being displayed in the 
> > ADMIN, then that will require overriding the field widgets in the 
> > ModelAdmin's with your own widgets created the same way above. 
> > 
> > 
> > 
> > On Friday, December 14, 2012 5:16:49 AM UTC-8, 4 The good Life we work 
> > wrote: 
> > 
> > Hallo, 
> > I'm wondering if there is a better way to have helptext informs than 
> > help_text which is displayed under the form. 
> > Something like FIEDL ? while ? is a button I can click on and it 
> > displays the helptext. 
> > 
> > I'll welcome an example. 
> > 
> > Thanks, 
> > Tony 
> > 
>

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Bob Haugen
On Fri, Dec 14, 2012 at 5:42 PM, Chris Cogdon  wrote:
> Okay, so when you create your datetimes, are you defining them with a
> timezone ?

I tried that; did not make any difference.  The error messages came up
before any of the test setup code ran.  (I put a pdb trace in at the
start; the error messages had already happened.)

I did not create any datetimes.  I did create dates, but they did not
cause any errors. The errors had already arisen way before then.

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Chris Cogdon
Okay, so when you create your datetimes, are you defining them with a 
timezone ?

On Friday, December 14, 2012 1:05:19 PM UTC-8, bobhaugen wrote:
>
> On Fri, Dec 14, 2012 at 3:02 PM, Chris Cogdon  
> wrote: 
> > Nothing definitive, but from checking the location of the code that is 
> > raising the warning, I suspect one of the following: 
> > 
> > 1. USE_TZ is not set in your production code, but _is_ set in your 
> settings 
> > file for your tests. Of course, your code should work either way for the 
> > most flexibility. 
>
> USE_TZ is set in settings.py (in production code) 
> > 
> > 2. The test database you are using (ie, from fixtures or otherwise) has 
> > non-timezone dates and times, and USE_TZ is set in your testing settings 
> > files. In these cases your test data and the USE_TZ setting should be 
> > matching. 
>
> No fixtures. Creating test objects in the test setup code. 
>

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



Re: Model's optional __unicode__() return values?

2012-12-14 Thread Chris Cogdon
oops... that should be "if x is not None", not "where x is not None"... 
Clearly I am still half in SQL mode :)

On Friday, December 14, 2012 3:41:01 PM UTC-8, Chris Cogdon wrote:
>
> The pattern I use is ", ".join ( [ unicode(x) for x in ( thing_a, thing_b, 
> getattr(obj,"optional_attribute",None ), ...etc... ) where x is not None ] )
>
>
> On Friday, December 14, 2012 2:49:16 PM UTC-8, mhulse wrote:
>>
>> Hello, 
>>
>> This is probably a dumb question, but... 
>>
>> What's the best way to handle optional __unicode__() return values? 
>>
>> In this situation, I'm wanting to return the __unicode__ values from 
>> other models. 
>>
>> I've found myself doing a lot of this: 
>>
>> def __unicode__(self): 
>> return _(u'%s%s%s') % (self.target, (' | ' if self.page_type else 
>> ''), (self.page_type if self.page_type else '')) 
>>
>> Which works, but seems clunky. 
>>
>> I've tried: 
>>
>> return _(u'%s') % ' | '.join(filter(None, (self.target, getattr(self, 
>> 'page_type', None 
>>
>> But that gives me: 
>>
>> Caught TypeError while rendering: sequence item 0: expected string, 
>> Target found 
>>
>> Tips would be appreciated. :) 
>>
>> Thank you! 
>>
>> Cheers, 
>> M 
>>
>

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



Re: Model's optional __unicode__() return values?

2012-12-14 Thread Chris Cogdon
The pattern I use is ", ".join ( [ unicode(x) for x in ( thing_a, thing_b, 
getattr(obj,"optional_attribute",None ), ...etc... ) where x is not None ] )


On Friday, December 14, 2012 2:49:16 PM UTC-8, mhulse wrote:
>
> Hello, 
>
> This is probably a dumb question, but... 
>
> What's the best way to handle optional __unicode__() return values? 
>
> In this situation, I'm wanting to return the __unicode__ values from 
> other models. 
>
> I've found myself doing a lot of this: 
>
> def __unicode__(self): 
> return _(u'%s%s%s') % (self.target, (' | ' if self.page_type else 
> ''), (self.page_type if self.page_type else '')) 
>
> Which works, but seems clunky. 
>
> I've tried: 
>
> return _(u'%s') % ' | '.join(filter(None, (self.target, getattr(self, 
> 'page_type', None 
>
> But that gives me: 
>
> Caught TypeError while rendering: sequence item 0: expected string, Target 
> found 
>
> Tips would be appreciated. :) 
>
> Thank you! 
>
> Cheers, 
> M 
>

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



Model's optional __unicode__() return values?

2012-12-14 Thread Micky Hulse
Hello,

This is probably a dumb question, but...

What's the best way to handle optional __unicode__() return values?

In this situation, I'm wanting to return the __unicode__ values from
other models.

I've found myself doing a lot of this:

def __unicode__(self):
return _(u'%s%s%s') % (self.target, (' | ' if self.page_type else
''), (self.page_type if self.page_type else ''))

Which works, but seems clunky.

I've tried:

return _(u'%s') % ' | '.join(filter(None, (self.target, getattr(self,
'page_type', None

But that gives me:

Caught TypeError while rendering: sequence item 0: expected string, Target found

Tips would be appreciated. :)

Thank you!

Cheers,
M

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Bob Haugen
On Fri, Dec 14, 2012 at 3:02 PM, Chris Cogdon  wrote:
> Nothing definitive, but from checking the location of the code that is
> raising the warning, I suspect one of the following:
>
> 1. USE_TZ is not set in your production code, but _is_ set in your settings
> file for your tests. Of course, your code should work either way for the
> most flexibility.

USE_TZ is set in settings.py (in production code)
>
> 2. The test database you are using (ie, from fixtures or otherwise) has
> non-timezone dates and times, and USE_TZ is set in your testing settings
> files. In these cases your test data and the USE_TZ setting should be
> matching.

No fixtures. Creating test objects in the test setup code.

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Chris Cogdon
Nothing definitive, but from checking the location of the code that is 
raising the warning, I suspect one of the following:

1. USE_TZ is not set in your production code, but _is_ set in your settings 
file for your tests. Of course, your code should work either way for the 
most flexibility.

2. The test database you are using (ie, from fixtures or otherwise) has 
non-timezone dates and times, and USE_TZ is set in your testing settings 
files. In these cases your test data and the USE_TZ setting should be 
matching.

On Friday, December 14, 2012 11:43:09 AM UTC-8, bobhaugen wrote:
>
> Thanks for the reply.
>
> On Friday, December 14, 2012 1:27:03 PM UTC-6, Chris Cogdon wrote:
>>
>> Would be nice to know what function's raising that error, and where the 
>> value came from. Requesting traceback, database type (tried it with more 
>> than one database type), and other information.
>>
>> It's in a test.   No real traceback, just a bunch of the same error 
> messages:
>
> ./manage.py test valueaccounting
> Creating test database for alias 'default'...
> /home/bob/.virtualenvs/vn2/lib/python2.6/site-packages/django/db/models/fields/__init__.py:808:
>  
> RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
> 19:41:27.469600) while time zone support is active.
>   RuntimeWarning)
> /home/bob/.virtualenvs/vn2/lib/python2.6/site-packages/django/db/models/fields/__init__.py:808:
>  
> RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
> 19:41:27.507916) while time zone support is active.
>   RuntimeWarning)
>
> Database is sqlite. 
>

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



Re: Helptext forms forms

2012-12-14 Thread 4 The good Life we work
Hallo Chris,

thank you for the good explanation.
I'm then afread that I have to create my own widget for this. Can you 
support me on this?

Thanks,
Tony Michael

On Fri 14 Dec 2012 08:45:40 PM CET, Chris Cogdon wrote:
> If you're designing your own HTML (eg: this is not in the admin) then
> there's nothing stopping you rendering the help text any way you want. Eg:
>
>
> {{ form.field1 }} onclick="showpopuphelp('{{ form.field1.help_text }}');return false;" />
>
> (that might not exactly work as written, but using it to give you the
> gist of things... my preference would be to put the text into a  class="fieldhelp> and use jQuery magic to wrap it up)
>
> If you were doing this a lot, and would prefer to stick with using {{
> form.as_table }} (for example) and rely on the default HTML generators
> for each field, then you'll need to create your own widgets, probably
> inheriting from the standard widgets, and override the html generators.
>
>
> If you wanted to change how the fields were being displayed in the
> ADMIN, then that will require overriding the field widgets in the
> ModelAdmin's with your own widgets created the same way above.
>
>
>
> On Friday, December 14, 2012 5:16:49 AM UTC-8, 4 The good Life we work
> wrote:
>
> Hallo,
> I'm wondering if there is a better way to have helptext informs than
> help_text which is displayed under the form.
> Something like FIEDL ? while ? is a button I can click on and it
> displays the helptext.
>
> I'll welcome an example.
>
> Thanks,
> Tony
>

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



Re: Send out E-mail at given time

2012-12-14 Thread 4 The good Life we work
Hi William,

thanks :). I'll look at celery.

Thanks,
Michael
On 12/14/2012 04:08 PM, william ratcliff wrote:
> Welcome aboard!   Please check out django-celery.   I believe it will
> solve your problem for doing an activity at a specified time.
>
> Good luck!
>
>
> On Fri, Dec 14, 2012 at 8:37 AM, 4 The good Life we work
> <4thegdl...@googlemail.com > wrote:
>
> Hallo,
>
> I'm building my first Django 1.4.2 Application with stores
> contract data.
> I would like to get a reminder E-mail when the set remainder date
> in the
> DB is reached.
>
> Let's say I've choosen the 15th Dez 2012 as reminder date.
> Then by 1AM the system should send out an E-mail to the user.
> E-mail is
> saved under user-data.
>
> Thx for any support,
> Tony
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Send out E-mail at given time

2012-12-14 Thread 4 The good Life we work
Hallo Javier,

this sound good. I'll try this.

Thank you,
Michael

On Fri 14 Dec 2012 07:58:26 PM CET, Javier Guerra Giraldez wrote:
> On Fri, Dec 14, 2012 at 8:37 AM, 4 The good Life we work
> <4thegdl...@googlemail.com> wrote:
>> Let's say I've choosen the 15th Dez 2012 as reminder date.
>> Then by 1AM the system should send out an E-mail to the user. E-mail is
>> saved under user-data.
>
> - create a 'custom management command'
> (https://docs.djangoproject.com/en/1.4/howto/custom-management-commands/).
>  something like "manage.py send-emails" that checks the database and
> sends any programmed email.
>
> - add a cron job that periodically calls that command.  (typically
> once an hour or a couple of times a day)
>
> --
> Javier
>

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



Re: validation error in Django Admin

2012-12-14 Thread Chris Cogdon
Thanks for the follow up!

On Wednesday, December 12, 2012 4:21:59 PM UTC-8, Mike Dewhirst wrote:
>
> I'm getting an unexpected validation error in Admin which baffles me. 
> Any hints appreciated ... here is the traceback 
>
> http://dpaste.com/844972/ 
>
> At the bottom of the traceback where the error is raised, the local vars 
> are ... 
>
> self  
> value u'33' 
> key 'pk' 
>
> When I save the item, it auto-generates many-to-many connections to a 
> few standard images in the database via a through table. However there 
> is a rule which says "if ever these two images are connected to an item, 
> only keep this one and drop that one." 
>
> I use a post-save signal to "drop that one" using ... 
>
>Item_Pictogram.objects.filter(item=instance, pictogram=pic, 
> via='auto').delete() 
>
> The local var value above being u'33' happens to be the exact pk of the 
> Item_Pictogram record I want to delete - I checked in Postgres. 
>
> The pk should be an integer but I suppose that's nothing. 
>
> Thanks for any help 
>
> Mike 
>

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



Re: Helptext forms forms

2012-12-14 Thread Chris Cogdon
If you're designing your own HTML (eg: this is not in the admin) then 
there's nothing stopping you rendering the help text any way you want. Eg:


{{ form.field1 }}

(that might not exactly work as written, but using it to give you the gist 
of things... my preference would be to put the text into a https://groups.google.com/d/msg/django-users/-/ebt7rZSPRHQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread bobhaugen
Oh, and Django 1.4.1...sorry.

On Friday, December 14, 2012 1:43:09 PM UTC-6, bobhaugen wrote:
>
> Thanks for the reply.
>
> On Friday, December 14, 2012 1:27:03 PM UTC-6, Chris Cogdon wrote:
>>
>> Would be nice to know what function's raising that error, and where the 
>> value came from. Requesting traceback, database type (tried it with more 
>> than one database type), and other information.
>>
>> It's in a test.   No real traceback, just a bunch of the same error 
> messages:
>
> ./manage.py test valueaccounting
> Creating test database for alias 'default'...
> /home/bob/.virtualenvs/vn2/lib/python2.6/site-packages/django/db/models/fields/__init__.py:808:
>  
> RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
> 19:41:27.469600) while time zone support is active.
>   RuntimeWarning)
> /home/bob/.virtualenvs/vn2/lib/python2.6/site-packages/django/db/models/fields/__init__.py:808:
>  
> RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
> 19:41:27.507916) while time zone support is active.
>   RuntimeWarning)
>
> Database is sqlite. 
>

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread bobhaugen
Thanks for the reply.

On Friday, December 14, 2012 1:27:03 PM UTC-6, Chris Cogdon wrote:
>
> Would be nice to know what function's raising that error, and where the 
> value came from. Requesting traceback, database type (tried it with more 
> than one database type), and other information.
>
> It's in a test.   No real traceback, just a bunch of the same error 
messages:

./manage.py test valueaccounting
Creating test database for alias 'default'...
/home/bob/.virtualenvs/vn2/lib/python2.6/site-packages/django/db/models/fields/__init__.py:808:
 
RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
19:41:27.469600) while time zone support is active.
  RuntimeWarning)
/home/bob/.virtualenvs/vn2/lib/python2.6/site-packages/django/db/models/fields/__init__.py:808:
 
RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
19:41:27.507916) while time zone support is active.
  RuntimeWarning)

Database is sqlite. 

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



Re: Local thread variable (attempting to create a connection pool)

2012-12-14 Thread Chris Cogdon
What you essentially want is a common pattern called a "singleton": 
something that there is only one of, like "None" and "Elipsis". You can do 
something workable, but ugly, using module-level variables, but there are 
known patterns for creating singletons

Here's some starters:

http://stackoverflow.com/questions/42558/python-and-the-singleton-pattern




On Friday, December 14, 2012 9:33:19 AM UTC-8, Rafael Almeida wrote:
>
> Hello,
>
> I have a django application which needs to connect to some backend 
> services. Problem is I don't want to create a new connection everytime, but 
> to use a connection pool. One connection per thread would be fine, but I 
> don't know how to use django in order to achive that. I'd like to perhaps 
> save those connections on cache subsystem, but I don't know how to create 
> one key per thread, per worker.
>
> Thank you for your help,
> Rafael
>

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



Re: GeoDjango annotate distance

2012-12-14 Thread Chris Cogdon
Just did a cursory read of the geodjango documentation for the first 
time...the querysets being returned from "all()" (or really, just objects) 
need to be GeoQuerySets which have a default "position" as part of their 
specification (I think), also such modules need to inherit from the geo 
version of model.Model AND use a special GeoManager. So, once you use that 
special manager, there is a point, boundary or area tat all the geo 
functions refer to.

On Wednesday, December 12, 2012 1:15:44 PM UTC-8, mikegolf wrote:
>
> Hi,
> I've recently started learning GeoDjango and I'm a bit confused. 
> There's a GeoQuerySet method "distance" which annotates each object with 
> the distance to the given point, like that:
>
> pnt = 'POINT(coords... coords ...)'
> MyModel.objects.all().distance(pnt)
>
> but what field of the object does it take to calculate the distance?
> I'd like to do "classic" annotation, like that:
>
> MyModel.objects.all().annotate(distance_to_pnt = 
> Distance('location_attribute_of_MyModel', pnt))
>
> any tips?
> thanks
> mg
>

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



Re: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread Chris Cogdon
Would be nice to know what function's raising that error, and where the 
value came from. Requesting traceback, database type (tried it with more 
than one database type), and other information.


On Friday, December 14, 2012 9:46:33 AM UTC-8, bobhaugen wrote:
>
> RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
> 17:39:38.878379) while time zone support is active.
>
> This is happening in my tests, but not in normal code.
>
> From dropping a trace in, it looks like it is happening before the test 
> setup even runs.
>
> I double-checked my models,  not a DateTimeField in the lot. Nor anywhere 
> else in my code except for South migrations, where it is found in 
> models['auth.user']. (But I'm not creating any Users in my test code, 
> either...)
>
> The tests run ok, but the error messages will be disconcerting to people 
> who install my open-source project code.
>
> Any clues?
>
> Thanks.
>
>

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



Re: Send out E-mail at given time

2012-12-14 Thread Javier Guerra Giraldez
On Fri, Dec 14, 2012 at 8:37 AM, 4 The good Life we work
<4thegdl...@googlemail.com> wrote:
> Let's say I've choosen the 15th Dez 2012 as reminder date.
> Then by 1AM the system should send out an E-mail to the user. E-mail is
> saved under user-data.

- create a 'custom management command'
(https://docs.djangoproject.com/en/1.4/howto/custom-management-commands/).
 something like "manage.py send-emails" that checks the database and
sends any programmed email.

- add a cron job that periodically calls that command.  (typically
once an hour or a couple of times a day)

--
Javier

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



Re: How Alter Table to add foreign key to Django Models

2012-12-14 Thread Javier Guerra Giraldez
On Thu, Dec 13, 2012 at 7:53 AM, laxglx  wrote:
> Can anybody plz tell me how to add a foreign key an existing table using SQL
> Queries?
>>> I got the command, nut can't understand
>
> ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address)
> REFERENCES addresses (address) MATCH FULL;


as Chris has noted, this question as stated doesn't have anything to
do with Django.

what i'm guessing here is that you got that command from your database
docs and want to know how to apply that to modify your tables. right?

in principle, you shouldn't have to need that.  Django lets you define
the relationships in the model declaration, including foreign keys
constraints and indexes.

but if you have just added the foreign key, Django won't alter an
existing table.  (the syncdb command never modifies an existing table,
it only creates new tables when not found on the database)

if that's the case, you have three options:

- delete the table and redo the syncdb.  Django will create the table
with the current definition in the models.  pro: works every time.
con: you lose all existing data on that table.

- analyze the current table structure, what the new model represents
and manually issue the needed ALTER TABLEs.  pro: won't lose data if
done correctly.  con: not easy to do it right.

- use South.  it handles all the data structure migrations for you.
pro: very reliable, very easy, very maintanable. con: you have to
learn to use it (but it's not hard, and the docs are very good)


>
> What's  "distfk" here if it is key name what is (address) ? and what is
> addresses(address)?

"distfk" is the name of the constraint.  i don't think it's used
anywhere except an identifier.
the first "address" is the name of your referring field ("source
field") the second "address" (in fact "addresses(address)") is the
referred field ("target field").  typically it's more like
"address_id" for the first and "address(id)" for the second, since in
the vast majority of cases it's preferable that foreign key fields use
the id field for reference.

> And What does mean Match Full

that seems specific to your RDBMS.  i'll guess that it means use the
whole field to match.  typically on very long text fields wouldn't be
practical to copy the whole content to an index and to the referring
key, so it can use a length limited prefix.  Match Full sounds like
not to use any prefix, but the full field.


--
Javier

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



Re: Django Celery FIFO ORDER

2012-12-14 Thread Nikolas Stevenson-Molnar
Ok, how about this: instead of sending the POST data as part of your
Celery task, serialize the data to your DB with an auto-increment id
(which is default for Django model ids), then have he celery task grab
the data from the database, sorted by asc id. Then you'll always be
processing the data the order it was received.

_Nik

On 12/14/2012 2:05 AM, psychok7 wrote:
> Ok i am going to detail what i want to do a little further:
>
> So i have this django app, and when i press submit after i fill in the
> form my celery worker wakes up and takes care of taking that submitted
> data and posting to a remote server. This i can do without problems.
>
> Now, imagine that my internet goes down at that exact time, my celery
> worker keeps retrying to send until it is successful  But imagine i do
> another submit before my previous data is submitted, my data wont be
> consistent on the other remote server.
>
> Now that is my problem. I am not able to make this requests FIFO with
> the retry option given by celery so i that's were i need some help
> figuring that out.
>
>
> On Monday, December 10, 2012 4:20:52 PM UTC, psychok7 wrote:
>
> So I have this 2 applications connected with a REST API (json
> messages). One written in Django and the other in Php. I have an
> exact database replica on both sides (using mysql).
>
> When i press "submit" on one of them, i want that data to be saved
> on the current app database, and start a cron job with
> celery/redis to update the remote database for the other app using
> rest.
>
> /*My question is, how do i attribute the same worker to my tasks
> in order to keep a FIFO order?*/
>
> I need my data to be consistent and FIFO is really important.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/9uZtJG0v85UJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Local thread variable (attempting to create a connection pool)

2012-12-14 Thread Rafael Almeida
Hello,

I have a django application which needs to connect to some backend 
services. Problem is I don't want to create a new connection everytime, but 
to use a connection pool. One connection per thread would be fine, but I 
don't know how to use django in order to achive that. I'd like to perhaps 
save those connections on cache subsystem, but I don't know how to create 
one key per thread, per worker.

Thank you for your help,
Rafael

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



getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-14 Thread bobhaugen
RuntimeWarning: DateTimeField received a naive datetime (2012-12-14 
17:39:38.878379) while time zone support is active.

This is happening in my tests, but not in normal code.

>From dropping a trace in, it looks like it is happening before the test 
setup even runs.

I double-checked my models,  not a DateTimeField in the lot. Nor anywhere 
else in my code except for South migrations, where it is found in 
models['auth.user']. (But I'm not creating any Users in my test code, 
either...)

The tests run ok, but the error messages will be disconcerting to people 
who install my open-source project code.

Any clues?

Thanks.

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



Re: Weird problem in common_settings include

2012-12-14 Thread Bill Freeman
On Fri, Dec 14, 2012 at 8:39 AM, florian  wrote:

>
>
> On Friday, December 14, 2012 11:17:07 AM UTC+1, ke1g wrote:
>>
>>
>> How are you combining INSTALLED_APPS from the two files?  Note that
>> simply "setting" it to what you want to add in the file that includes the
>> other *replaces* the value you have imported from the other.  Be sure to
>> use += instead of = .
>>
>
> INSTALLED_APPS = COMMON_INSTALLED_APPS + SPECIFIC_INSTALLED_APPS
>
> in each specific settings file
>

This should work fine.  The only caveat is that in some corner cases the
order of things in INSTALLED_APPS matters.


>
>> Also, if you run "python manage.py shell" you can "from django.conf
>> import settings" and poke around at the values that you are actually
>> setting, which may give a clue.
>>
>
>
> From the shell, INSTALLED_APPS value is as expected
>

So "django.contrib.contenttypes", the app it's complaining about, is there,
and spelled correctly?  What happens when you try to import it directly
from the shell?


>
>
>> Finally, you can put "import pdb; pdb.set_trace()" at/near the top of one
>> or the other file and single step your way along to explore how execution
>> differs from your plan.
>>
>
> I'll try this
>
> thanks
>
>
> Bill

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



Re: [ANNOUNCE] Security releases (Django 1.3.5, Django 1.4.3, Django 1.5 beta 2)

2012-12-14 Thread victoria
On Mon, Dec 10, 2012 at 11:38 PM, James Bennett  wrote:
> Django 1.3.5, Django 1.4.3 and Django 1.5 beta 2 have just been issued
> in response to security issues.
>
> Details are available here:
>
> https://www.djangoproject.com/weblog/2012/dec/10/security/
>

It has taken a bit for us (BitNami) but we have now updated the three
versions of BitNami Django Stack to include these latest Django
versions with the security fixes. You can get them from
http://bitnami.org/stack/djangostack.

Best regards,

Victoria.

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

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



Re: Question on Multiple Database Connections

2012-12-14 Thread Matt Woodward
On Thursday, December 13, 2012 8:01:13 AM UTC-8, ke1g wrote:
>
>
> Just a shot in the dark: Maybe if, since you're not using the ORM on the 
> 'other' database, you shouldn't use django-pyodbc, but rather just pyobdc.
>

I should have said this earlier but I had the same thought and tried doing 
it directly with pyodbc, opening and closing the connection myself, and 
oddly enough the behavior is the same.

Thanks for the idea though! I'll keep digging and report back if I figure 
anything out. I have some alternative ways to handle this situation anyway 
but I'm curious to get to the bottom of the behavior for my own knowledge 
if nothing else.

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



Re: AttributeError on _strptime_time

2012-12-14 Thread code2live
http://bugs.python.org/issue7980
http://bugs.python.org/issue11108

On Tuesday, September 25, 2012 1:39:53 PM UTC-4, Victor wrote:

> MadeR did you ever get to the bottom of this error? I am using 
> python2.6.5, django1.3.1, and tastypie0.9.7 with a mysql5.1 back end. Its a 
> real doozy, I have never seen it when developing locally, but once a week 
> or so I'll get an email from my production django server that has something 
> like this in it:
> Traceback (most recent call last):
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/tastypie/resources.py",
>  
> line 175, in wrapper
> response = callback(request, *args, **kwargs)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/tastypie/resources.py",
>  
> line 334, in dispatch_list
> return self.dispatch('list', request, **kwargs)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/tastypie/resources.py",
>  
> line 364, in dispatch
> response = method(request, **kwargs)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/tastypie/resources.py",
>  
> line 934, in get_list
> objects = self.obj_get_list(request=request, 
> **self.remove_api_resource_names(kwargs))
>
>   File 
> "/var/www/TorrentGuru/releases/current/TorrentGuru/apache/../runrecognition/api.py",
>  
> line 178, in obj_get_list
> return self.get_object_list(request)
>
>   File 
> "/var/www/TorrentGuru/releases/current/TorrentGuru/apache/../runrecognition/api.py",
>  
> line 339, in get_object_list
> return get_weekly_winner_row_list(min_date=min_date, max_date=max_date)
>
>   File 
> "/var/www/TorrentGuru/releases/current/TorrentGuru/apache/../runrecognition/leaderboard_builder.py",
>  
> line 145, in get_weekly_winner_row_list
> weeks = _build_query(weeks, min_date, max_date)
>
>   File 
> "/var/www/TorrentGuru/releases/current/TorrentGuru/apache/../runrecognition/leaderboard_builder.py",
>  
> line 135, in _build_query
> initial_objects = initial_objects.filter(victory_date__gte=min_date)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/manager.py",
>  
> line 141, in filter
> return self.get_query_set().filter(*args, **kwargs)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/query.py",
>  
> line 550, in filter
> return self._filter_or_exclude(False, *args, **kwargs)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/query.py",
>  
> line 568, in _filter_or_exclude
> clone.query.add_q(Q(*args, **kwargs))
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/sql/query.py",
>  
> line 1172, in add_q
> can_reuse=used_aliases, force_having=force_having)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/sql/query.py",
>  
> line 1107, in add_filter
> connector)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/sql/where.py",
>  
> line 67, in add
> value = obj.prepare(lookup_type, value)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/sql/where.py",
>  
> line 316, in prepare
> return self.field.get_prep_lookup(lookup_type, value)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/fields/__init__.py",
>  
> line 644, in get_prep_lookup
> return super(DateField, self).get_prep_lookup(lookup_type, value)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/fields/__init__.py",
>  
> line 292, in get_prep_lookup
> return self.get_prep_value(value)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/fields/__init__.py",
>  
> line 721, in get_prep_value
> return self.to_python(value)
>
>   File 
> "/var/www/TorrentGuru/local-python/lib/python2.6/site-packages/django/db/models/fields/__init__.py",
>  
> line 698, in to_python
> return datetime.datetime(*time.strptime(value, '%Y-%m-%d 
> %H:%M:%S')[:6],
>
> AttributeError: _strptime_time
>
> Any pointers you might have for me would be greatly appreciated.
>
> On Thursday, March 10, 2011 12:03:31 PM UTC-5, MadeR wrote: 
>>
>> The error  was trapped by django-sentry and does *not* occur in python
>> interpreter, thus I can't understand it!
>> Please can anybody enlighten me? 
>>
>> Here the details:
>>
>> Exception Type: AttributeError
>> Exception Value: _strptime_time
>>
>> The error is raised by line #698 in
>>
>> /usr/local/lib/python2.6/dist-packages/Django-1.2.5-py2.6.egg/django/db/models/fields/__init__.py
>> in to_python using django 1.2.5:
>>
>>  698. return datetime.datetime(*time.strptime(value, '%Y-%m-%d
>> %H:%M:%S')[:6],
>>  699. **kwargs)
>>
>> With local variables:
>>
>> kwargs = {'microsecond': 0}
>> self = u''
>> 

Re: Implementing a monitoring system with django.

2012-12-14 Thread Marc Aymerich
On Wed, Dec 12, 2012 at 12:23 PM, Tom Evans  wrote:
> On Mon, Dec 10, 2012 at 7:41 PM, Marc Aymerich  wrote:
>> Hi,
>> I'm considering to implement a simple monitorization system that
>> basically gathers some data from a set of nodes (<1000 nodes). The
>> gathered data should be stored in order to let users perform some
>> queries and maybe also generate some graphs.
>>
>> I'm looking for advice in what components are best suited for each of
>> the following parts:
>>
>> 1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
>> 2) Data gathering: celery periodic tasks?
>> 3) Graphs: rrd? or some java script framework for graphing?
>>
>> thanks for your comments!!
>
> Any reason not to use something like Nagios or Cacti? We use Nagios at
> $JOB, it's great.
>

Hi Tom,
We already have developed a web interface for controlling those nodes
in Django, so I think that it would be easy to run our own monitoring
system than integrate Nagios into our existing interface.


-- 
Marc

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



Best way to distribute a "standalone django application" ?

2012-12-14 Thread Chris Cogdon
I've been developing an art show management application (in both the 
general and Django senses) for the past few years, and have had it up on 
sourceforge and github for a while. It's very close to being "complete" and 
I'd like to make sure its as useful as possible to as wide an audience.

However, i'd like to distribute it in a form that is useful to both parties 
that want a "drop in and go" installation, and others that might use it as 
an app in a larger Django site. However, the two seem at loggerheads:

The first suggests I should have a single check out or download that 
includes the artshow app, the project, settings files (with instructions to 
modify certain parts). While the second suggests I should have a python 
module usable as a Django app, and include instructions on the required 
additions to middleware, context processors, and app-specific settings, and 
ensure it's installable from PyPI.

Catering for the one makes it harder for the other. Does anyone have 
suggestions on the "better" solution, or even some combination that caters 
to both well?

Project is currently here: http://github.com/chmarr/artshow-jockey/

Its currently in the former state, but with some "replaceable" components 
split out as a separate app. This was done mostly to demonstrate how to 
create a replaceable "Person" model, and did it in a way that shows that 
it's already effectively replaced. As is, the installation instructions for 
the django-noob are very simple, and I'd like to keep that attribute. Also, 
I'm considering rolling "peeps" "tinyreg" and the other "replaceable" 
modules back into the "artshow" module regardless... if anything to just 
make it look cleaner.

One idea that came to mind is to have the github repository show as a 
"stand alone application", just as it is now, but have the PyPI package 
only download the "artshow" component. Anyone that wants to both use 
artshow in their own Django site, but use the git checkout for the module, 
can simply check artshow-jockey out somewhere and put that into the python 
path. Does that seem feasible?

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



Re: How Alter Table to add foreign key to Django Models

2012-12-14 Thread Chris Cogdon
It doesn't look like you're using Django at all. I suggest taking your 
question to the support community for the database you're using.



On Thursday, December 13, 2012 4:53:25 AM UTC-8, laxglx wrote:
>
> Can anybody plz tell me how to add a foreign key an existing table using 
> SQL Queries?
> >> I got the command, nut can't understand 
>
> ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) 
> REFERENCES addresses (address) MATCH FULL;
>
>
> What's  "distfk" here if it is key name what is (address) ? and what is 
> addresses(address)?
> And What does mean Match Full
>
>
> Thanks in advance 
> laxglx
>

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



Send out E-mail at given time

2012-12-14 Thread 4 The good Life we work
Hallo,

I'm building my first Django 1.4.2 Application with stores contract data.
I would like to get a reminder E-mail when the set remainder date in the
DB is reached.

Let's say I've choosen the 15th Dez 2012 as reminder date.
Then by 1AM the system should send out an E-mail to the user. E-mail is
saved under user-data.

Thx for any support,
Tony

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



Re: How Alter Table to add foreign key to Django Models

2012-12-14 Thread Chris Cogdon
Are you sure you're using Django? This SQL statement does not look like 
something django would have emitted. Perhaps your query is best taken to 
the support community for the database you're using. Our advice here may 
not be relevant to you.

The issue you're having is what the South package is designed to solve. 
South will want to see your model before you added the foreign key, but 
once you initialise it in that state, it will handle that for you.

To answer the specific questions (because I'm nice):

'distfk' is just a name for the constraint. It can be anything, really. The 
first 'address' is the column in the distributors table. The 
'addresses(address)' refers to the address column in the 'addresses' table. 
'MATCH FULL' is the type of uniqueness constraint you're putting in place. 
You should check the manual for the database for details. (looks like 
MySQL?)



On Thursday, December 13, 2012 4:53:25 AM UTC-8, laxglx wrote:
>
> Can anybody plz tell me how to add a foreign key an existing table using 
> SQL Queries?
> >> I got the command, nut can't understand 
>
> ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) 
> REFERENCES addresses (address) MATCH FULL;
>
>
> What's  "distfk" here if it is key name what is (address) ? and what is 
> addresses(address)?
> And What does mean Match Full
>
>
> Thanks in advance 
> laxglx
>

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



Re: Weird problem in common_settings include

2012-12-14 Thread florian


On Friday, December 14, 2012 11:17:07 AM UTC+1, ke1g wrote:
>
>
> How are you combining INSTALLED_APPS from the two files?  Note that simply 
> "setting" it to what you want to add in the file that includes the other 
> *replaces* the value you have imported from the other.  Be sure to use += 
> instead of = .
>

INSTALLED_APPS = COMMON_INSTALLED_APPS + SPECIFIC_INSTALLED_APPS

in each specific settings file
 

> Also, if you run "python manage.py shell" you can "from django.conf import 
> settings" and poke around at the values that you are actually setting, 
> which may give a clue.
>


>From the shell, INSTALLED_APPS value is as expected

 

> Finally, you can put "import pdb; pdb.set_trace()" at/near the top of one 
> or the other file and single step your way along to explore how execution 
> differs from your plan.
>

I'll try this

thanks
 

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



Helptext forms forms

2012-12-14 Thread 4 The good Life we work
Hallo,
I'm wondering if there is a better way to have helptext informs than
help_text which is displayed under the form.
Something like FIEDL ? while ? is a button I can click on and it
displays the helptext.

I'll welcome an example.

Thanks,
Tony

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



Re: django-registration customization

2012-12-14 Thread sri
Hi Karen,

Thanks very much for your help. It's working now after i used the 
registrationfrom in the template.

Thanks

On Friday, 14 December 2012 02:34:24 UTC, Karen Tracey wrote:
>
> On Wed, Dec 12, 2012 at 3:36 PM, sri  >wrote:
>
>> Now, when i click on the register button on the page, the form validation 
>> does not work.
>> Let's say if i enter the username that already exists on the database, it 
>> is not reporting any errors. It is just displaying the form without any 
>> error messages.
>> Can anyone help with what i am missing?
>>
>
> Sounds like the form validation is working, since you are not getting 
> redirected to next page but rather the registration page is being 
> re-displayed. The form created in the view is where the validation errors 
> have been stored, and that form thus needs to be used by the template for 
> rendering the errors. However, the template you show is not using the 
> registerform that is being passed in the context from the view, it just has 
> all the fields hard-coded. You'll need to use the registerform to render 
> the form validation errors, since that is where they've been stored. See:
>
>
> https://docs.djangoproject.com/en/1.4/topics/forms/#displaying-a-form-using-a-template
>
> Karen
> -- 
> http://tracey.org/kmt/
>
>

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



Re: Error with unit testing with Raven.

2012-12-14 Thread xina towner
I've found the solution. The problem was that I was using the
'raven.contrib.django.middleware.Sentry404CatchMiddleware' so the
Middleware was getting the 404 signals. I think that because of that the
test were not receiving the signals so when in the test we were checking
for 404 codes the tests were failing.

Thanks,

Ruben.

On 13 December 2012 20:22, xina towner  wrote:

> Hi, I'm trying to use Raven in order to send messages to my CI server.
>
> I had some tests that pass but suddenly they are failing. Does anyone
> knows why is that?
>
> Output:
>
> ==
> ERROR: test_not_individual (quests.tests.views.TaskDoTest)
> --
> Traceback (most recent call last):
>   File "/var/lib/jenkins/jobs/Newin/workspace/quests/tests/views.py", line 
> 632, in test_not_individual
> resp=self.client.get(reverse('task_do', args=[self.qu_t.id]))
>   File 
> "/var/lib/jenkins/jobs/Newin/workspace/.env/local/lib/python2.7/site-packages/django/test/client.py",
>  line 439, in get
> response = super(Client, self).get(path, data=data, **extra)
>   File 
> "/var/lib/jenkins/jobs/Newin/workspace/.env/local/lib/python2.7/site-packages/django/test/client.py",
>  line 244, in get
> return self.request(**r)
>   File 
> "/var/lib/jenkins/jobs/Newin/workspace/.env/local/lib/python2.7/site-packages/django/core/handlers/base.py",
>  line 188, in get_response
> response = middleware_method(request, response)
>   File 
> "/var/lib/jenkins/jobs/Newin/workspace/.env/local/lib/python2.7/site-packages/raven/contrib/django/middleware/__init__.py",
>  line 29, in process_response
> 'id': client.get_ident(result),
>   File 
> "/var/lib/jenkins/jobs/Newin/workspace/.env/local/lib/python2.7/site-packages/raven/base.py",
>  line 222, in get_ident
> return '$'.join(result)
> TypeError
>
> --
>
> I checked in the link :
>
>
> http://raven.readthedocs.org/en/latest/config/django.html#error-handling-middleware
>
> But I don't think that's the reason.
>
> --
> Thanks,
>
> Rubén
>
>


-- 
Gràcies,

Rubén

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



Re: Weird problem in common_settings include

2012-12-14 Thread Bill Freeman
On Thu, Dec 13, 2012 at 7:47 AM, florian iragne  wrote:

> Ok, i've get rid of my "special" mobile_manage.py and pass the --settings
> option when i start the fcgi process (i use nginx+fcgi, no mod_wsgi).
>
> Using manage.py, with each settings file, i can verify that the
> INSTALLED_APPS is correct and complete. However, i still get the error
>
> any idea?
>
> thanks
>
> Florian
>

How are you combining INSTALLED_APPS from the two files?  Note that simply
"setting" it to what you want to add in the file that includes the other
*replaces* the value you have imported from the other.  Be sure to use +=
instead of = .

Also, if you run "python manage.py shell" you can "from django.conf import
settings" and poke around at the values that you are actually setting,
which may give a clue.

Finally, you can put "import pdb; pdb.set_trace()" at/near the top of one
or the other file and single step your way along to explore how execution
differs from your plan.

Bill

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



Re: Django Celery FIFO ORDER

2012-12-14 Thread psychok7
Ok i am going to detail what i want to do a little further:

So i have this django app, and when i press submit after i fill in the form 
my celery worker wakes up and takes care of taking that submitted data and 
posting to a remote server. This i can do without problems.

Now, imagine that my internet goes down at that exact time, my celery 
worker keeps retrying to send until it is successful  But imagine i do 
another submit before my previous data is submitted, my data wont be 
consistent on the other remote server.

Now that is my problem. I am not able to make this requests FIFO with the 
retry option given by celery so i that's were i need some help figuring 
that out.


On Monday, December 10, 2012 4:20:52 PM UTC, psychok7 wrote:
>
> So I have this 2 applications connected with a REST API (json messages). 
> One written in Django and the other in Php. I have an exact database 
> replica on both sides (using mysql).
>
> When i press "submit" on one of them, i want that data to be saved on the 
> current app database, and start a cron job with celery/redis to update the 
> remote database for the other app using rest.
>
> *My question is, how do i attribute the same worker to my tasks in order 
> to keep a FIFO order?*
>
> I need my data to be consistent and FIFO is really important.
>

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