Re: html templates and dynamic loading

2013-08-23 Thread Mantas Zilinskis
this might help you

http://stackoverflow.com/questions/1879872/django-update-div-with-ajax

let me know if you need more help


On Fri, Aug 23, 2013 at 10:51 AM, Bastien Amiel  wrote:

>  Le 23/08/2013 17:01, Mantas Zilinskis a écrit :
>
>  can you post all of chat.html
>
>
>
> On Fri, Aug 23, 2013 at 7:04 AM, Bastien Amiel  wrote:
>
>>  Le 23/08/2013 11:26, Huu Da Tran a écrit :
>>
>> On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:
>>
>>
>>> I need to update the chat when an event come but :
>>>
>>> 1.
>>> If I update my chat sub page, inputs are reset (seems logic since html
>>> is recreated).
>>>
>>
>>  You can always have some field that keep when the chat was started (in
>> the session), and redisplay everything since that time.
>>
>>
>>> Then what would be the good / best method to update only the chat
>>> content ?
>>> (I have 2 ideas but they don't seems very Django'ic)
>>>
>>> 2.
>>> For now, I update the content every XX ms with a periodic request client
>>> side.
>>> Would it be possible / preferable to have a push from server when new
>>> data comes or is there a better way to update this kind of content ?
>>
>>
>>  Trying to hack django to get server push would be hell (look into
>> tornado). If you really need server push, you may need to look into other
>> technologies, like nodejs.
>>
>>  Using the periodic request client-side is what is mostly done.
>>
>>
>>  Hope this helps.
>>
>>  HD.
>>
>>
>> 1.
>> My question was not clear enough,
>> Let's admit i have this template page :
>>
>> *{% for elem in data %}**
>> ****
>> **{{ elem.datetime }}**
>> **{{ elem.name }} :**
>> **{{ elem.text }}**
>> ****
>> **{% endfor %}**
>> **Text : *
>>
>> and this view.py :
>>
>> *def getchat(request):**
>> **template = loader.get_template('chat.html')**
>> **context  = RequestContext(request, { 'data': lines })** # lines is
>> an array with lines
>> **response = {'html' : template.render(context)}**
>> **return HttpResponse(json.dumps(response),
>> mimetype='application/json')*
>>
>> and this javascript :
>>
>> *function getchat()**
>> **{**
>> **$.post('/getchat')**.done(function(data, textStatus, jqXHR) **
>> **{**
>> **$("#chat").html(data["html"])**
>> **})**
>> **}
>>
>> *Then whenever I call getchat() in javascript, the chat is reloaded with
>> all the old lines, this point is ok, but
>>  field is reseted too, which mean that if user was typing, the
>> content is erased.
>> I would say the solution is to create a second function in view *
>> getchatcontent* that will send only the content so I do not
>> update the whole thing. Do you think it is the right way ?
>>
>>
>> 2.
>> lets use periodic request client-side.
>>
>>
>>
>> Thank you for your answer
>>
>>
> There is nothing more in chat.html
> there is a base.html template that contains
>
> ***
> **{% load staticfiles %}**
> 
> **
> **
> 
> 
> 
> 
> **post**
> ***
>
>
> appchat.js
>
>
> *$(document).ready(function()**
> **{**
> **$("#addline").click(function()**
> **{**
> **addline($("#chatname")[0].value, $("#chatinput")[0].value);*
> *
> **$("#chatinput")[0].value = "" **
> **})**
> **setInterval(function() { getchat() }, 1000);**
> **})**
> **
> **function addline(name, text)**
> **{**
> **$.post('/addline', {"name":name, "text":text})**
> **.done(function() ** {** })**
> **}**
> **
> **function getchat()**
> **{**
> **   $.post('/getchat')*
> *
> **.done(function(data, textStatus, jqXHR) **
> **{**
> **   **$("#chat").html(data["html"])**
> **})**
> **}*
>
>
> Now you have everything, does this seems the right way to do what I want
> to achieve with django or is there a better way ?
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Why cannot template tags be used for password reset email notification template file?

2013-08-23 Thread nobody
Hi,

I have customized template string tags such as {{ org_name }} and {{ 
account_email }} which work fine for most of email template files and html 
files, but the tags {{ org_name }} and {{ account_email }} could not work 
with password reset email template. The django/contrib/auth/forms.py 
defined several arguments for password reset, such as domain, site_name, 
user and email. I can override the domain by "domain_override", but I 
cannot add the tags to it. How can I make the {{ org_name }} and {{ 
account_email }} tags working with my password reset email template file 
password_reset_email.html?

Thank you.

jupiter

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: recaptcha options... which one to choose

2013-08-23 Thread Tom Lockhart

On 2013-08-23, at 11:19 AM, TinyJaguar  wrote:

> I'm about to implement recaptcha in my feedbackform but I'm a bit confused by 
> all the possibilities.
> Should I use:   
> recaptcha-client 1.0.6 or recaptcha 1.0rc1. 
> django-recaptcha or django-recaptcha-works
> other options? what would be your sane choice?

fwiw I stuffed recaptcha-client into one of my forms as a one-liner and It Just 
Worked.

- Tom

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-23 Thread Mark Furbee
I see. I don't understand how this works: {{
itens.instance.idproduto.codigobarra
}} when this doesn't: {{ itens.instance.idproduto.idmercadoria.referencia }}

Can you post your template code?




On Fri, Aug 23, 2013 at 10:13 AM, Fellipe Henrique wrote:

> form.instance is "Pedido"  model, not "ItensPedido".
>
> My "ItensPedido" has "idproduto" not my "Pedido". and all idproduto has
> idmercadoria, it a required field, never, never go null`s this field.
>
> Cheers,
>
> Em sexta-feira, 23 de agosto de 2013 12h15min15s UTC-3, Mark escreveu:
>>
>> Are you sure the idmercadoria is not None on that idproduto record?
>>
>> {{ form.instance.idproduto.**idmerc**adoria }} Does this display
>> anything?
>> How about {{ form.instance.idproduto }}?
>>
>> If these don't display, verify the records in your database. In Django
>> templates, if something is None or does not exist, it will not raise an
>> exception, it just ignores it and remains blank. Also verify the referencia
>> field is not empty. If the field is 'NOT NULL' then it will be an empty
>> string if it is blank.
>>
>>
>>
>> On Thu, Aug 22, 2013 at 12:58 PM, Fellipe Henrique wrote:
>>
>>> No, nothing displayed..
>>>
>>> Em quinta-feira, 22 de agosto de 2013 13h38min04s UTC-3, Mark escreveu:

 Try dropping the .value from referencia. Like {{
 form.instance.idproduto.**idmerc**adoria.referencia }}. Does this work?


 On Thu, Aug 22, 2013 at 9:35 AM, Fellipe Henrique wrote:

> I tried again.. and work if I have just 1 FK, if I have more then one,
> doesn't work, like this:
>
> I have this models:
> Itens -> produto -> mercadoria
>
> itens:
>   idproduto = FK (produto)
> produto:
>   idmercadoria = FK(mercadoria)
> mercadoria:
>   referencia = Char
>
> I try to get "referencia" field, as you told:
>
> {{ form.instance.idproduto.**idmerc**adoria.referencia.value }}
>
> doesn't work.. what I miss?
>
> Here is my complete models, forms and view: http://pastebin.com/**w2Tm
> **yLzt 
>
>  Cheers,
>
>
> Em quinta-feira, 22 de agosto de 2013 13h24min31s UTC-3, Fellipe
> Henrique escreveu:
>
>> Ok, I read that, but the problem persist.. I try to use as you told,
>> but nothing show... and no errors appears..
>>
>> Sorry about my first line.. I just stop here, simple problem, in more
>> then 1 day, and I don't find any solution, anything on internet to...
>>
>> Cheers
>> Fellipe
>>
>>
>>>  --
> 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
> .
> For more options, visit 
> https://groups.google.com/**grou**ps/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...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users
>>> .
>>> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Advice on deploying multiple Django instances to single Apache server

2013-08-23 Thread TinyJaguar
Just go with mod_wsgi and virtual hosts for each application.
PHP and mod_wsgi may clash given the two modus operandi for Apache. MPM or 
prefork
Alternatively you could use NGINX with gunicorn




On Friday, August 23, 2013 6:50:49 PM UTC+2, Jon Dufresne wrote:
>
> Hi,
>
> I am getting ready to deploy my Django application. This application must 
> serve several independent parties. In the past, I've done this with 
> multiple instances of a PHP application on the server. Is this the right 
> approach in the Django world?
>
> My server is running Apache and MySQL. Each instance of the application 
> will have its own configuration and database. These instances will not 
> communicate with each other in any way. These instances are all (possibly) 
> different versions of the same application running in their own virtualenv.
>
> My instinct is to go with the Apache mod_wsgi approach. As Apache is 
> already running successfully on the server serving PHP an static files.
>
> Any advice or good resources on how to accomplish what I am doing? All the 
> documentation seems to be targeted at one server with one Django 
> application.
>
> Thanks,
> Jon
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


recaptcha options... which one to choose

2013-08-23 Thread TinyJaguar
I'm about to implement recaptcha in my feedbackform but I'm a bit confused 
by all the possibilities.
Should I use:   
recaptcha-client 1.0.6 or 
recaptcha 1.0rc1 . 
django-recaptcha or django-recaptcha-works
other options? what would be your sane choice?


-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Merge a wiki app with static files

2013-08-23 Thread Skip Montanaro
I've horsed around with Django a bit, but it's been awhile since I worked 
my way through the tutorial literature.  I now have a concrete application, 
my existing personal website.  It's currently a site full of static files 
and a separate wiki.  I want to get away from the wiki (PmWiki) and the 
hosting service (GoDaddy).  I'm thinking it should be fairly 
straightforward to do this with Django, pushing my site up to Heroku or 
other cloud-based hosting service. I'm having trouble figuring out how this 
would look structurally (partly because it's been several months since I 
last picked up any Django stuff), and I'm not having any luck finding 
anything useful, likely because I am probably using the wrong terms in my 
searches.

If you assume /cr is the URL root of the wiki and any other URL is a static 
file (including /), how do I structure this? This seems like it should 
almost be like plugging two smaller apps together.

Pointers gratefully appreciated,

Skip Montanaro

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


django template loop collections.defaultdict(lambda: collections.defaultdict(list))

2013-08-23 Thread Daviddd
Dear All,

In my view I create the following dictionary of lists from a queryset

#view.py
queryset = MyModel.objects.filter(owner=user, 
dashboard=tab).order_by('position')
my_dict = collections.defaultdict(lambda: collections.defaultdict(list))for 
obj in queryset:

my_dict[int(obj.position.split('-')[0])][int(obj.position.split('-')[2])].append(obj)return
 Response({'queryset': dict(my_dict)}, template_name='dashboard/_maps_tab.html')


Position field is a charFiled following the format: X-X-X-X used the create 
the my_dict

my_dict is

--[1] #group[1] #col 1-- object1.1.1 #group.col.pk-- 
object1.1.2-- object1.1.3[2] #col 2-- object1.2.4[3] 
#col3-- object1.3.5-- object1.3.6
--[2] #group[1] #col 1--object2.1.7 #group.col.pk
--[3] #group[1] #col1-- object3.1.8 #group.col.pk[2] 
#col2--object3.2.9--object3.2.10


In my template I tried:

{% for key, groups in queryset.iteritems %}
groups = {{ groups }} 
{% for group_key, cols in groups.iteritems %}
  cols = {{ group_key }} 
  {% for objs in cols %}
  {# rest of the code #}  


But only the first loop is evaluated

groups = (1, defaultdict(, {1: [, , ], 2: [], 3: [, , ]}))
groups = (2, defaultdict(, {1: []}))
groups = (3, defaultdict(, {1: []}))


(Linked question: 
http://stackoverflow.com/questions/18406126/django-template-loop-collections-defaultdictlambda-collections-defaultdictlis
)

I'm not able to spot the error.

Thanks

D




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-23 Thread Fellipe Henrique
form.instance is "Pedido"  model, not "ItensPedido".

My "ItensPedido" has "idproduto" not my "Pedido". and all idproduto has 
idmercadoria, it a required field, never, never go null`s this field.

Cheers,

Em sexta-feira, 23 de agosto de 2013 12h15min15s UTC-3, Mark escreveu:
>
> Are you sure the idmercadoria is not None on that idproduto record?
>
> {{ form.instance.idproduto.**idmercadoria }} Does this display anything?
> How about {{ form.instance.idproduto }}?
>
> If these don't display, verify the records in your database. In Django 
> templates, if something is None or does not exist, it will not raise an 
> exception, it just ignores it and remains blank. Also verify the referencia 
> field is not empty. If the field is 'NOT NULL' then it will be an empty 
> string if it is blank.
>
>
>
> On Thu, Aug 22, 2013 at 12:58 PM, Fellipe Henrique 
>  > wrote:
>
>> No, nothing displayed..
>>
>> Em quinta-feira, 22 de agosto de 2013 13h38min04s UTC-3, Mark escreveu:
>>>
>>> Try dropping the .value from referencia. Like {{ form.instance.idproduto.
>>> **idmercadoria.referencia }}. Does this work?
>>>
>>>
>>> On Thu, Aug 22, 2013 at 9:35 AM, Fellipe Henrique wrote:
>>>
 I tried again.. and work if I have just 1 FK, if I have more then one, 
 doesn't work, like this:

 I have this models:
 Itens -> produto -> mercadoria

 itens:
   idproduto = FK (produto)
 produto:
   idmercadoria = FK(mercadoria)
 mercadoria:
   referencia = Char

 I try to get "referencia" field, as you told:

 {{ form.instance.idproduto.**idmercadoria.referencia.value }}

 doesn't work.. what I miss?

 Here is my complete models, forms and view: http://pastebin.com/**
 w2TmyLzt 

  Cheers,


 Em quinta-feira, 22 de agosto de 2013 13h24min31s UTC-3, Fellipe 
 Henrique escreveu:

> Ok, I read that, but the problem persist.. I try to use as you told, 
> but nothing show... and no errors appears..
>
> Sorry about my first line.. I just stop here, simple problem, in more 
> then 1 day, and I don't find any solution, anything on internet to...
>
> Cheers
> Fellipe
>
>
>>  -- 
 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
 .
 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Advice on deploying multiple Django instances to single Apache server

2013-08-23 Thread Jon Dufresne
Hi,

I am getting ready to deploy my Django application. This application must
serve several independent parties. In the past, I've done this with
multiple instances of a PHP application on the server. Is this the right
approach in the Django world?

My server is running Apache and MySQL. Each instance of the application
will have its own configuration and database. These instances will not
communicate with each other in any way. These instances are all (possibly)
different versions of the same application running in their own virtualenv.

My instinct is to go with the Apache mod_wsgi approach. As Apache is
already running successfully on the server serving PHP an static files.

Any advice or good resources on how to accomplish what I am doing? All the
documentation seems to be targeted at one server with one Django
application.

Thanks,
Jon

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html templates and dynamic loading

2013-08-23 Thread Bastien Amiel

Le 23/08/2013 17:01, Mantas Zilinskis a écrit :

can you post all of chat.html



On Fri, Aug 23, 2013 at 7:04 AM, Bastien Amiel > wrote:


Le 23/08/2013 11:26, Huu Da Tran a écrit :

On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:

I need to update the chat when an event come but :

1.
If I update my chat sub page, inputs are reset (seems logic
since html
is recreated).


You can always have some field that keep when the chat was
started (in the session), and redisplay everything since that time.

Then what would be the good / best method to update only the
chat content ?
(I have 2 ideas but they don't seems very Django'ic)

2.
For now, I update the content every XX ms with a periodic
request client
side.
Would it be possible / preferable to have a push from server
when new
data comes or is there a better way to update this kind of
content ?


Trying to hack django to get server push would be hell (look into
tornado). If you really need server push, you may need to look
into other technologies, like nodejs.

Using the periodic request client-side is what is mostly done.


Hope this helps.

HD.


1.
My question was not clear enough,
Let's admit i have this template page :

/{% for elem in data %}//
////
//{{ elem.datetime }}//
//{{ elem.name  }}
://
//{{ elem.text }}//
////
//{% endfor %}//
//Text : /

and this view.py :

/def getchat(request)://
//template = loader.get_template('chat.html')//
//context  = RequestContext(request, { 'data': lines })//#
lines is an array with lines
//response = {'html' : template.render(context)}//
//return HttpResponse(json.dumps(response),
mimetype='application/json')/

and this javascript :

/function getchat()//
//{ //
//$.post('/getchat')//.done(function(data, textStatus, jqXHR) //
//{//
//$("#chat").html(data["html"])//
//})//
//}

/Then whenever I call getchat() in javascript, the chat is
reloaded with all the old lines, this point is ok, but
 field is reseted too, which mean that if user was typing,
the content is erased.
I would say the solution is to create a second function in view
/getchatcontent/ that will send only the content so I do not
update the whole thing. Do you think it is the right way ?


2.
lets use periodic request client-side.



Thank you for your answer



There is nothing more in chat.html
there is a base.html template that contains

///
//{% load staticfiles %}//







//post//
///


appchat.js


/$(document).ready(function()//
//{//
//$("#addline").click(function()//
//{//
//addline($("#chatname")[0].value, $("#chatinput")[0].value);//
//$("#chatinput")[0].value = "" //
//})//
//setInterval(function() { getchat() }, 1000);//
//})//
//
//function addline(name, text)//
//{//
//$.post('/addline', {"name":name, "text":text})//
//.done(function() //{//})//
//}//
//
//function getchat()//
//{ //
//   $.post('/getchat')//
//.done(function(data, textStatus, jqXHR) //
//{//
   $("#chat").html(data["html"])//
//})//
//}/


Now you have everything, does this seems the right way to do what I want 
to achieve with django or is there a better way ?


--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html templates and dynamic loading

2013-08-23 Thread Mantas Zilinskis
can you post all of chat.html






On Fri, Aug 23, 2013 at 7:04 AM, Bastien Amiel  wrote:

>  Le 23/08/2013 11:26, Huu Da Tran a écrit :
>
> On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:
>
>
>> I need to update the chat when an event come but :
>>
>> 1.
>> If I update my chat sub page, inputs are reset (seems logic since html
>> is recreated).
>>
>
>  You can always have some field that keep when the chat was started (in
> the session), and redisplay everything since that time.
>
>
>> Then what would be the good / best method to update only the chat content
>> ?
>> (I have 2 ideas but they don't seems very Django'ic)
>>
>> 2.
>> For now, I update the content every XX ms with a periodic request client
>> side.
>> Would it be possible / preferable to have a push from server when new
>> data comes or is there a better way to update this kind of content ?
>
>
>  Trying to hack django to get server push would be hell (look into
> tornado). If you really need server push, you may need to look into other
> technologies, like nodejs.
>
>  Using the periodic request client-side is what is mostly done.
>
>
>  Hope this helps.
>
>  HD.
>
>
> 1.
> My question was not clear enough,
> Let's admit i have this template page :
>
> *{% for elem in data %}**
> ****
> **{{ elem.datetime }}**
> **{{ elem.name }} :**
> **{{ elem.text }}**
> ****
> **{% endfor %}**
> **Text : *
>
> and this view.py :
>
> *def getchat(request):**
> **template = loader.get_template('chat.html')**
> **context  = RequestContext(request, { 'data': lines })** # lines is
> an array with lines
> **response = {'html' : template.render(context)}**
> **return HttpResponse(json.dumps(response),
> mimetype='application/json')*
>
> and this javascript :
>
> *function getchat()**
> **{**
> **$.post('/getchat')**.done(function(data, textStatus, jqXHR) **
> **{**
> **$("#chat").html(data["html"])**
> **})**
> **}
>
> *Then whenever I call getchat() in javascript, the chat is reloaded with
> all the old lines, this point is ok, but
>  field is reseted too, which mean that if user was typing, the
> content is erased.
> I would say the solution is to create a second function in view *
> getchatcontent* that will send only the content so I do not
> update the whole thing. Do you think it is the right way ?
>
>
> 2.
> lets use periodic request client-side.
>
>
>
> Thank you for your answer
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I really about to give up Django

2013-08-23 Thread Mark Furbee
Are you sure the idmercadoria is not None on that idproduto record?

{{ form.instance.idproduto.**idmercadoria }} Does this display anything?
How about {{ form.instance.idproduto }}?

If these don't display, verify the records in your database. In Django
templates, if something is None or does not exist, it will not raise an
exception, it just ignores it and remains blank. Also verify the referencia
field is not empty. If the field is 'NOT NULL' then it will be an empty
string if it is blank.



On Thu, Aug 22, 2013 at 12:58 PM, Fellipe Henrique wrote:

> No, nothing displayed..
>
> Em quinta-feira, 22 de agosto de 2013 13h38min04s UTC-3, Mark escreveu:
>>
>> Try dropping the .value from referencia. Like {{ form.instance.idproduto.
>> **idmercadoria.referencia }}. Does this work?
>>
>>
>> On Thu, Aug 22, 2013 at 9:35 AM, Fellipe Henrique wrote:
>>
>>> I tried again.. and work if I have just 1 FK, if I have more then one,
>>> doesn't work, like this:
>>>
>>> I have this models:
>>> Itens -> produto -> mercadoria
>>>
>>> itens:
>>>   idproduto = FK (produto)
>>> produto:
>>>   idmercadoria = FK(mercadoria)
>>> mercadoria:
>>>   referencia = Char
>>>
>>> I try to get "referencia" field, as you told:
>>>
>>> {{ form.instance.idproduto.**idmercadoria.referencia.value }}
>>>
>>> doesn't work.. what I miss?
>>>
>>> Here is my complete models, forms and view: http://pastebin.com/**
>>> w2TmyLzt 
>>>
>>>  Cheers,
>>>
>>>
>>> Em quinta-feira, 22 de agosto de 2013 13h24min31s UTC-3, Fellipe
>>> Henrique escreveu:
>>>
 Ok, I read that, but the problem persist.. I try to use as you told,
 but nothing show... and no errors appears..

 Sorry about my first line.. I just stop here, simple problem, in more
 then 1 day, and I don't find any solution, anything on internet to...

 Cheers
 Fellipe


>  --
>>> 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
>>> .
>>> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django1.5 - url resolver vs i18n_patterns : wrong behaviour

2013-08-23 Thread uniqe . klmov . anton
For those who also suffers: yes its a bug.
https://code.djangoproject.com/ticket/17734
it was fixed in 1.6b2

вторник, 4 июня 2013 г., 13:23:23 UTC+4 пользователь Ivan Tatarchuk написал:
>
> When I using i18n_patterns in my project urls.py I have strange behaviour 
> of url resolver:
>   expected behaviour: 
>  - if pattern defined in django.conf.urls.patterns, url resolver 
> doesn't add language prefix
> - ip pattern defined in django.conf.urls.i18n.i18n_patterns, url 
> resolver adds language prefix at the begining of url
>  
>   actual behaviour
>   if NO patterns defined in i18n_patterns, all work fine
>   but if some pattern defined in  i18n_patterns, url resolver add 
> language prefix to ALL urls resoved by url resolver regardless of place of 
> pattern defenition (django.conf.urls.patterns or 
> django.conf.urls.i18n.i18n_patterns)
>
> Example:
>
> * urls.py *
> from django.conf.urls import patterns, include, url
> from django.conf.urls.i18n import i18n_patterns
>
> urlpatterns = patterns('',
> url(r'^admin/', include(admin.site.urls)),
> )
>
> urlpatterns += i18n_patterns('',
> #   url(r'^other/', include('apps.other.urls')),
> }
>
> now {% url 'admin:password_change' %} resolved as 'admin/password_change' 
> (normal behaviour)
> but if we uncomment line in i18n_patterns it will be resolved  as 
> 'curr_lang/admin/password_change'
>
> Can somebody explaine my why?
> Thanks
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Getting 500 server error when debug=False

2013-08-23 Thread Jonathan Roberts
Nevermind. Solved it (I was setting it ALLOWED_HOSTS twice -  removed the 
duplicate and it all worked fine). Nothing to see 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.
For more options, visit https://groups.google.com/groups/opt_out.


Getting 500 server error when debug=False

2013-08-23 Thread Jonathan Roberts
I'm changing my development server over to production, and I'm getting a 
500 error page as soon as I set DEBUG=False in the settings.

I've been googling around, and have already checked 
here: 
http://stackoverflow.com/questions/15128135/django-setting-debug-false-causes-500-error

I have set ALLOWED_HOSTS = [], and also tried ALLOWED_HOSTS = [*] but 
neither solves the 500 server errors.

I have a custom 500 and 404 template written. The error log isn't showing 
anything on the server. I'm tearing my hair out a little on this one. Are 
there any other settings that could be triggering a problem when I switch 
off debug mode?

Thanks in advance!

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Get a list into request.POST

2013-08-23 Thread Nick Jiang
hi,

you should consider of using JSON.stringify() function to convert 
javascript object to json data.

*>>* *
JSON.stringify({'array':[{'que':1,'ans':3},{'que':1,'ans':2},{'que':4,'ans':5},{'que':2,'ans':4}]})
*
**This is example build from jsfiddle
*>> alert example 
*

**hope this can help

On Friday, August 23, 2013 7:30:45 PM UTC+8, Sarfraz Ahmad wrote:
>
> Hello guys, i am working on a view where i m needed to pass an array of 
> objects into a ajax request.
> the array of java script objects is like this
>   
>  [{'que':1,'ans':3},{'que':1,'ans':2},{'que':4,'ans':5},{'que':2,'ans':4}]
> i posted is in ajax request like
>
>   $.ajax({
>   url:'/someurl/',
>   type:'POST',
>   data:{'array':[{'que':1,'ans':3},{'que':1,'ans':2},
> {'que':4,'ans':5},{'que':2,'ans':4}]},
>   success:function(data){},
>   error:function(data){}
> })
>
> but when i recieve it in view using
> 
>  request.POST.get('array') or
> 
> request.POST.getlist('array') 
> or 
>
> request.POST.getlist('array[]') 
>   It gives me a blank list not the data i have sent with the request.
>
>
> tell me how can i get this data in django view.
> any help would be appreciable 
>
>
>
>
>
>
>
>  
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Get a list into request.POST

2013-08-23 Thread Laurent Meunier

On 23/08/2013 13:30, Sarfraz Ahmad wrote:

Hello guys, i am working on a view where i m needed to pass an array of
objects into a ajax request.
the array of java script objects is like this

  [{'que':1,'ans':3},{'que':1,'ans':2},{'que':4,'ans':5},{'que':2,'ans':4}]
i posted is in ajax request like

   $.ajax({
   url:'/someurl/',
   type:'POST',

data:{'array':[{'que':1,'ans':3},{'que':1,'ans':2},{'que':4,'ans':5},{'que':2,'ans':4}]},
   success:function(data){},
   error:function(data){}
})

but when i recieve it in view using

  request.POST.get('array') or
request.POST.getlist('array') or
request.POST.getlist('array[]')
   It gives me a blank list not the data i have sent with the request.


tell me how can i get this data in django view.
any help would be appreciable


Hi,

You can serialize your javascript object in JSON and POST the resulting 
string to Django. Then in your view, decode the json POSTed string to a 
list of dict.



Javascript:

var s = 
JSON.stringify([{'que':1,'ans':3},{'que':1,'ans':2},{'que':4,'ans':5},{'que':2,'ans':4}]);


$.ajax({
  url:'/someurl/',
  type:'POST',
  data:{'s': s},
  success:function(data){},
});


Django view:

s = request.POST['s']
o = json.loads(s)

--
Laurent Meunier 

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to add a code table to this group?

2013-08-23 Thread Mário Neto
Paste your code in http://dpaste.com and share the link in this group
Em 22/08/2013 12:42, "Gerd Koetje"  escreveu:

> In many posts i submit django code.
> I tried to use the < c o d e >  < / c o d e >  tag but it doesnt format it
> very nicely
> Is there a other tags to use?
>
> --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html templates and dynamic loading

2013-08-23 Thread Bastien Amiel

Le 23/08/2013 11:26, Huu Da Tran a écrit :

On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:

I need to update the chat when an event come but :

1.
If I update my chat sub page, inputs are reset (seems logic since
html
is recreated).


You can always have some field that keep when the chat was started (in 
the session), and redisplay everything since that time.


Then what would be the good / best method to update only the chat
content ?
(I have 2 ideas but they don't seems very Django'ic)

2.
For now, I update the content every XX ms with a periodic request
client
side.
Would it be possible / preferable to have a push from server when new
data comes or is there a better way to update this kind of content ?


Trying to hack django to get server push would be hell (look into 
tornado). If you really need server push, you may need to look into 
other technologies, like nodejs.


Using the periodic request client-side is what is mostly done.


Hope this helps.

HD.


1.
My question was not clear enough,
Let's admit i have this template page :

/{% for elem in data %}//
////
//{{ elem.datetime }}//
//{{ elem.name }} ://
//{{ elem.text }}//
////
//{% endfor %}//
//Text : /

and this view.py :

/def getchat(request)://
//template = loader.get_template('chat.html')//
//context  = RequestContext(request, { 'data': lines })//# lines is 
an array with lines

//response = {'html' : template.render(context)}//
//return HttpResponse(json.dumps(response), 
mimetype='application/json')/


and this javascript :

/function getchat()//
//{ //
//$.post('/getchat')//.done(function(data, textStatus, jqXHR) //
//{//
//$("#chat").html(data["html"])//
//})//
//}

/Then whenever I call getchat() in javascript, the chat is reloaded with 
all the old lines, this point is ok, but
 field is reseted too, which mean that if user was typing, the 
content is erased.
I would say the solution is to create a second function in view 
/getchatcontent/ that will send only the content so I do not

update the whole thing. Do you think it is the right way ?


2.
lets use periodic request client-side.



Thank you for your answer

--
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.
For more options, visit https://groups.google.com/groups/opt_out.


Get a list into request.POST

2013-08-23 Thread Sarfraz Ahmad
Hello guys, i am working on a view where i m needed to pass an array of 
objects into a ajax request.
the array of java script objects is like this
  
 [{'que':1,'ans':3},{'que':1,'ans':2},{'que':4,'ans':5},{'que':2,'ans':4}]
i posted is in ajax request like

  $.ajax({
  url:'/someurl/',
  type:'POST',
  data:{'array':[{'que':1,'ans':3},{'que':1,'ans':2},
{'que':4,'ans':5},{'que':2,'ans':4}]},
  success:function(data){},
  error:function(data){}
})

but when i recieve it in view using

 request.POST.get('array') or

request.POST.getlist('array') 
or 
   
request.POST.getlist('array[]') 
  It gives me a blank list not the data i have sent with the request.


tell me how can i get this data in django view.
any help would be appreciable 







 

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: hello everyone error in python

2013-08-23 Thread abhijeet shete
Hi,

Please provide more details about the error.
Like what you are trying to do or which part of your code is raising
this error ?


On Fri, Aug 23, 2013 at 3:24 PM, Shru  wrote:

> error :'str' object is not callable
>
> error location :C:\Python27\lib\site-packages\django\core\handlers\base.py
> in get_response, line 115
> so help me to fix 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


hello everyone error in python

2013-08-23 Thread Shru


error :'str' object is not callable

error location :C:\Python27\lib\site-packages\django\core\handlers\base.py 
in get_response, line 115
so help me to fix 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.
For more options, visit https://groups.google.com/groups/opt_out.


how can I use django model with range like this?

2013-08-23 Thread jinge
Hi, everyone!

We use django for processing our logs. We build our model like this

class URL(models.Model):
  url = models.TextField(unique=True)

class cachelogtype1(models.Model):
url = models.ForeignKey(URL)
datetime = models.DateTimeField()

Our tables in DB like this.

  id | url
  1 | 
http://218.76.137.52/videos2/tv/20130819/c71a206fc558cb36aa8c3c354f69f910.f4v
  2 | http://1.kuai8.com/pc/00043_dafuweng8.gmz
  3 | http://fsigns.duba.net/df/libs/180
  4 | 
http://7529f396.f.1xiazai.net/520f45bb/70fb23ba775f6/zmp3/2012lDec/13W/13SI/02.wma
 
 id | url_id |datetime
++
  1 |  1 | 2013-05-05 08:23:44+08
  2 |  2 | 2013-05-05 09:28:29+08
  3 |  1 | 2013-05-05 12:34:48+08
  4 |  3 | 2013-05-05 09:34:55+08
  5 |  1 | 2013-05-05 08:34:56+08
  6 |  3 | 2013-05-05 08:34:58+08
  7 |  2 | 2013-05-05 12:35:06+08
  8 |  3 | 2013-05-05 10:35:08+08
  9 |  1 | 2013-05-05 09:35:13+08


And We want to get count of url in time ranges and the start time and end time 
in the ranges like
ranges is 2013-05-05 08:00:00+08 to  2013-05-05 10:00:00+08

 starttime | endtime | url | count
++
2013-05-05 08:23:44+08|2013-05-05 09:35:13+08 
|http://218.76.137.52/videos2/tv/20130819/c71a206fc558cb36aa8c3c354f69f910.f4v 
|4|
  2013-05-05 08:34:58+08|2013-05-05 09:34:55+08 
|http://fsigns.duba.net/df/libs/180 |2|
  2013-05-05 09:28:29+0|2013-05-05 
09:28:29+0|http://1.kuai8.com/pc/00043_dafuweng8.gmz|1|

And is there any one can help how we use django model to release like this? 
Thank you very much!


Regards
Jinge



-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Need Advise on the best way to track how much time a user is logged in.....

2013-08-23 Thread Huu Da Tran
On Thursday, August 22, 2013 3:09:45 PM UTC-4, 7equiv...@gmail.com wrote:

> My users will not be able to logout by closing a browser because they have 
> no such interaction with the system. They will be passing an RFID tag over 
> a reader to unlock the door and clock in and a python script will handle 
> the loging in and out. So if I can get the logout to time stamp a database 
> entry I'll be good.
>

Am I just missing your point or you are actually defining a website with a 
login function and a logout function? If so, in the view for login, just 
call

user.userlogin_set.create(timestamp=datetime.datetime.utcnow())

and in the logout view, just call

user.userlogout_set.create(timestamp=datetime.datetime.utcnow())


-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: html templates and dynamic loading

2013-08-23 Thread Huu Da Tran
On Thursday, August 22, 2013 8:42:04 AM UTC-4, Bastien Amiel wrote:
 

> I need to update the chat when an event come but : 
>
> 1. 
> If I update my chat sub page, inputs are reset (seems logic since html 
> is recreated). 
>

You can always have some field that keep when the chat was started (in the 
session), and redisplay everything since that time.
 

> Then what would be the good / best method to update only the chat content 
> ? 
> (I have 2 ideas but they don't seems very Django'ic) 
>
> 2. 
> For now, I update the content every XX ms with a periodic request client 
> side. 
> Would it be possible / preferable to have a push from server when new 
> data comes or is there a better way to update this kind of content ?


Trying to hack django to get server push would be hell (look into tornado). 
If you really need server push, you may need to look into other 
technologies, like nodejs.

Using the periodic request client-side is what is mostly done.

 
Hope this helps.

HD.

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.