Re: button not responding when click but when press return key than works

2018-06-13 Thread Fidel Leon
If I remember correctly, the correct tag for a button is [obviously]
, no  (please see the missing T).

El jue., 14 jun. 2018 a las 0:14, Asif Khan () escribió:

> No I am not using JS capturing for any kind of actions. where as my other
> form button are working.
>
> On Thursday, June 14, 2018 at 2:14:48 AM UTC+5, Asif Khan wrote:
>>
>> I am having amazing problem in my django template. Button does not
>> respond on pressing click on it. It works when I press return key. code is
>> following.
>> {% extends 'vtapp/baseapp_layout.html' %}
>>
>> {% block head %}
>> Vehicle Vegilince - Customer Search
>> {% endblock %}
>>
>> {% block content %}
>> Enter Customer information
>> 
>> {% csrf_token %}
>> 
>> 
>> 
>> 
>> 
>> Search
>> 
>> 
>> 
>>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5f518cba-fcdc-4b2a-9f75-fad87b0e3cd0%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Fidel Leon
fi...@flm.cat
Phone: +34 622 26 44 92

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHXg%3DN10d1-vfh38-DoEpQrp8Xegv70%3DZh25E%2BbtHQTP253xBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server-Sent Events for Django

2018-06-13 Thread Justin Karneges
Thanks for the tips.

I didn't think about referencing a CDN, but I suppose that's a better
default, and if people want local copies then they can make their own.

Json2 probably shouldn't be in there. I've been dragging that file around
for years without really thinking about it. If anyone really needs to
support old IE they should know to include it themselves.

Justin

On Wed, Jun 13, 2018 at 7:45 PM, Jason  wrote:

> ooh, nice!  missed that part.
>
> Did you consider having that pull from a CDN rather than locally?  Reason
> being, any updates to said polyfills will require you to deploy an update.
> Whereas if you have a template tag to pull from a CDN, you can have your
> users specify the version if necessary and pull the latest by default.
> Would be one less thing you have to worry about maintaining.
>
> https://cdnjs.com/libraries/event-source-polyfill
> https://www.jsdelivr.com/package/npm/reconnecting-eventsource
>
> Also, what's the reason for having json2 in the static files?
> https://github.com/douglascrockford/JSON-js even states
>
> On current browsers, this file does nothing, preferring the built-in JSON 
> object. There is no reason to use this file unless fate compels you to 
> support IE8, which is something that no one should ever have to do again.
>>
>>
> Other than that, the lib looks pretty good to me.  
>
> On Wednesday, June 13, 2018 at 9:20:44 PM UTC-4, Justin Karneges wrote:
>>
>> Thanks Jason! The library comes with Yaffle's polyfill for IE/Edge
>> support, that can be included with a template tag.
>>
>> https://github.com/fanout/django-eventstream#receiving-in-the-browser
>>
>> On Wed, Jun 13, 2018 at 5:20 PM, Jason  wrote:
>>
>>> Nice library!  good work :-)
>>>
>>> I would suggest you update your readme to reflect that SSE is not
>>> supported by any MS browser (IE or Edge) as shown by
>>> https://caniuse.com/#feat=eventsource.
>>>
>>>
>>> On Wednesday, June 13, 2018 at 7:34:21 PM UTC-4, Justin Karneges wrote:

 Hi folks,

 I'm pleased to announce an SSE library for Django:
 https://github.com/fanout/django-eventstream

 The library makes pushing data from the server really easy. It uses
 Channels under the hood, although you don't have to write any async code.
 Simply declare endpoints in routing.py and call send_event() from anywhere.

 I hope others find it useful.

 Justin

>>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOTs0uCjsCAd_PzKFcF8WLHitWYmHHnd6TeigU8Mf9pcPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server-Sent Events for Django

2018-06-13 Thread Jason
ooh, nice!  missed that part.

Did you consider having that pull from a CDN rather than locally?  Reason 
being, any updates to said polyfills will require you to deploy an update.  
Whereas if you have a template tag to pull from a CDN, you can have your 
users specify the version if necessary and pull the latest by default.  
Would be one less thing you have to worry about maintaining.  

https://cdnjs.com/libraries/event-source-polyfill
https://www.jsdelivr.com/package/npm/reconnecting-eventsource

Also, what's the reason for having json2 in the static files?  
https://github.com/douglascrockford/JSON-js even states

On current browsers, this file does nothing, preferring the built-in JSON 
object. There is no reason to use this file unless fate compels you to support 
IE8, which is something that no one should ever have to do again.
>
>
Other than that, the lib looks pretty good to me.  
 
On Wednesday, June 13, 2018 at 9:20:44 PM UTC-4, Justin Karneges wrote:
>
> Thanks Jason! The library comes with Yaffle's polyfill for IE/Edge 
> support, that can be included with a template tag.
>
> https://github.com/fanout/django-eventstream#receiving-in-the-browser
>
> On Wed, Jun 13, 2018 at 5:20 PM, Jason > 
> wrote:
>
>> Nice library!  good work :-)
>>
>> I would suggest you update your readme to reflect that SSE is not 
>> supported by any MS browser (IE or Edge) as shown by 
>> https://caniuse.com/#feat=eventsource.  
>>
>>
>> On Wednesday, June 13, 2018 at 7:34:21 PM UTC-4, Justin Karneges wrote:
>>>
>>> Hi folks,
>>>
>>> I'm pleased to announce an SSE library for Django:
>>> https://github.com/fanout/django-eventstream
>>>
>>> The library makes pushing data from the server really easy. It uses 
>>> Channels under the hood, although you don't have to write any async code. 
>>> Simply declare endpoints in routing.py and call send_event() from anywhere.
>>>
>>> I hope others find it useful.
>>>
>>> Justin
>>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dfe6f4ad-006d-422f-8911-1cbab60f038e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server-Sent Events for Django

2018-06-13 Thread Justin Karneges
Thanks Jason! The library comes with Yaffle's polyfill for IE/Edge support,
that can be included with a template tag.

https://github.com/fanout/django-eventstream#receiving-in-the-browser

On Wed, Jun 13, 2018 at 5:20 PM, Jason  wrote:

> Nice library!  good work :-)
>
> I would suggest you update your readme to reflect that SSE is not
> supported by any MS browser (IE or Edge) as shown by
> https://caniuse.com/#feat=eventsource.
>
>
> On Wednesday, June 13, 2018 at 7:34:21 PM UTC-4, Justin Karneges wrote:
>>
>> Hi folks,
>>
>> I'm pleased to announce an SSE library for Django:
>> https://github.com/fanout/django-eventstream
>>
>> The library makes pushing data from the server really easy. It uses
>> Channels under the hood, although you don't have to write any async code.
>> Simply declare endpoints in routing.py and call send_event() from anywhere.
>>
>> I hope others find it useful.
>>
>> Justin
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOQbaWJ_NbNYRzWAryN3pwZqmmr8Z16R24eqRjsWUsasHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Server-Sent Events for Django

2018-06-13 Thread Jason
Nice library!  good work :-)

I would suggest you update your readme to reflect that SSE is not supported 
by any MS browser (IE or Edge) as shown by 
https://caniuse.com/#feat=eventsource.  

On Wednesday, June 13, 2018 at 7:34:21 PM UTC-4, Justin Karneges wrote:
>
> Hi folks,
>
> I'm pleased to announce an SSE library for Django:
> https://github.com/fanout/django-eventstream
>
> The library makes pushing data from the server really easy. It uses 
> Channels under the hood, although you don't have to write any async code. 
> Simply declare endpoints in routing.py and call send_event() from anywhere.
>
> I hope others find it useful.
>
> Justin
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4663cbf8-ff53-4fef-973b-ba26f09acd42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Server-Sent Events for Django

2018-06-13 Thread Justin Karneges
Hi folks,

I'm pleased to announce an SSE library for Django:
https://github.com/fanout/django-eventstream

The library makes pushing data from the server really easy. It uses
Channels under the hood, although you don't have to write any async code.
Simply declare endpoints in routing.py and call send_event() from anywhere.

I hope others find it useful.

Justin

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKFnGOQ4-s6xOSWfthEiddpKRYgMYs4y15V_XRn1SOBvz_SZqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Nested for loops in templates

2018-06-13 Thread Matthew Pava
field is a string – a name of a field, field is not actually an attribute of 
row.  You’ll need a template tag to get the attribute named field from row.
This StackOverflow question may help you:
https://stackoverflow.com/questions/844746/performing-a-getattr-style-lookup-in-a-django-template?utm_medium=organic_source=google_rich_qa_campaign=google_rich_qa


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Mikkel Kromann
Sent: Wednesday, June 13, 2018 3:54 PM
To: Django users
Subject: Nested for loops in templates

Dear Django users.

Thanks to the good advice of many people on this list, I've managed to create 
some nice generic class based views that work simultaneously with many models.
The models may differ from each other with regards to the number of columns in 
their data tables as well as the naming of the columns.
In order to use the same ListView template for many models, I will need to 
iterate not only over the rows of the queries, but also the columns.

I managed to pass a field_list into the context_data - it works as it shows 
nicely in the table headers.
However, when I iterate over the rows of the query result table, I'm not able 
to pinpoint the fields of the data row using the field iterator.

My template.html is:


{% for fields in field_list %}
{{field}}
{% endfor %}
{% for row in row_list %}

{% for field in field_list %}
{{row.field}}
{% endfor %}
{% endfor %}


Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as well 
as {{ row.{{field}} }} (yeah, long shot ...)

Any ideas, or should I try to create an entirely different data structure in my 
view, which can be parsed more easily by Django templates?


cheers + thanks, Mikkel
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0c30ad68ef05474da124726df608820b%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Nested for loops in templates

2018-06-13 Thread Vijay Khemlani
As far as I know you can't do it directly in the templating system

Yo could write a template tag as described here

https://stackoverflow.com/questions/2894365/use-variable-as-dictionary-key-in-django-template/10700142#10700142

or use a different data structure, for example each row as a list of the
values in the order that they should appear

On Wed, Jun 13, 2018 at 4:54 PM Mikkel Kromann 
wrote:

> Dear Django users.
>
> Thanks to the good advice of many people on this list, I've managed to
> create some nice generic class based views that work simultaneously with
> many models.
> The models may differ from each other with regards to the number of
> columns in their data tables as well as the naming of the columns.
> In order to use the same ListView template for many models, I will need to
> iterate not only over the rows of the queries, but also the columns.
>
> I managed to pass a field_list into the context_data - it works as it
> shows nicely in the table headers.
> However, when I iterate over the rows of the query result table, I'm not
> able to pinpoint the fields of the data row using the field iterator.
>
> My template.html is:
> 
> 
> {% for fields in field_list %}
> {{field}}
> {% endfor %}
> {% for row in row_list %}
> 
> {% for field in field_list %}
> {{row.field}}
> {% endfor %}
> {% endfor %}
> 
>
>
> Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as
> well as {{ row.{{field}} }} (yeah, long shot ...)
>
> Any ideas, or should I try to create an entirely different data structure
> in my view, which can be parsed more easily by Django templates?
>
>
> cheers + thanks, Mikkel
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2wQ4h-WFRy%3Dv_xqa6Bxi_Y_k8Z8qDvZpu3X2arh2ndQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: button not responding when click but when press return key than works

2018-06-13 Thread Asif Khan
No I am not using JS capturing for any kind of actions. where as my other 
form button are working.

On Thursday, June 14, 2018 at 2:14:48 AM UTC+5, Asif Khan wrote:
>
> I am having amazing problem in my django template. Button does not respond 
> on pressing click on it. It works when I press return key. code is 
> following. 
> {% extends 'vtapp/baseapp_layout.html' %}
>
> {% block head %}
> Vehicle Vegilince - Customer Search
> {% endblock %}
>
> {% block content %}
> Enter Customer information
> 
> {% csrf_token %}
> 
> 
> 
>  
> 
> Search
> 
> 
> 
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5f518cba-fcdc-4b2a-9f75-fad87b0e3cd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: button not responding when click but when press return key than works

2018-06-13 Thread Julio Biason
Hi Asif,

Are you sure you don't have any JS capturing the submit press and doing
`preventDefault()`? That would prevent the button from sending the form.

On Firefox, if you inspect the button, if it shows an "EV" near it, it
means there is something capturing the button events -- and `click` could
be one of those events, with the preventDefault().

On Wed, Jun 13, 2018 at 6:14 PM, Asif Khan  wrote:

> I am having amazing problem in my django template. Button does not respond
> on pressing click on it. It works when I press return key. code is
> following.
> {% extends 'vtapp/baseapp_layout.html' %}
>
> {% block head %}
> Vehicle Vegilince - Customer Search
> {% endblock %}
>
> {% block content %}
> Enter Customer information
> 
> {% csrf_token %}
> 
> 
> 
> 
> 
> Search
> 
> 
> 
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ea697019-42b8-4f66-8658-36f26ba3493a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Julio Biason*, Sofware Engineer
*AZION*  |  Deliver. Accelerate. Protect.
Office: +55 51 3083 8101   |  Mobile: +55 51
*99907 0554*

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEM7gE2nBPU4C34996RBrPAmOYvjkEC-8RhL4GeJWX5p%2Bq1G3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


button not responding when click but when press return key than works

2018-06-13 Thread Asif Khan
I am having amazing problem in my django template. Button does not respond 
on pressing click on it. It works when I press return key. code is 
following. 
{% extends 'vtapp/baseapp_layout.html' %}

{% block head %}
Vehicle Vegilince - Customer Search
{% endblock %}

{% block content %}
Enter Customer information

{% csrf_token %}



 

Search




-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea697019-42b8-4f66-8658-36f26ba3493a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Nested for loops in templates

2018-06-13 Thread Mikkel Kromann
Dear Django users.

Thanks to the good advice of many people on this list, I've managed to 
create some nice generic class based views that work simultaneously with 
many models.
The models may differ from each other with regards to the number of columns 
in their data tables as well as the naming of the columns.
In order to use the same ListView template for many models, I will need to 
iterate not only over the rows of the queries, but also the columns.

I managed to pass a field_list into the context_data - it works as it shows 
nicely in the table headers.
However, when I iterate over the rows of the query result table, I'm not 
able to pinpoint the fields of the data row using the field iterator. 

My template.html is:


{% for fields in field_list %}
{{field}}
{% endfor %}
{% for row in row_list %}

{% for field in field_list %}
{{row.field}}
{% endfor %}
{% endfor %}



Besides trying with {{row.field}}, I've tried with {{row}}.{{field}}, as 
well as {{ row.{{field}} }} (yeah, long shot ...)

Any ideas, or should I try to create an entirely different data structure 
in my view, which can be parsed more easily by Django templates?


cheers + thanks, Mikkel

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c9e29d66-f93c-4fc4-ae9f-dbeae93a2e45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jani Tiainen
Hi.

I usually do data cleanups with QGIS tool which has excellent tools to
manipulate data. And it's relatively fast.

Of course if you need to import data more regular basis QGIS might not be
an option.

ke 13. kesäk. 2018 klo 21.30 Jack  kirjoitti:

> See original question on Stack Overflow
> 
>  for
> better formating.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8b8f53c5-2e53-4ec8-b2e6-7c7ec18ed5fe%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeDgwMGQ8Q1E7fk5K9-Pw1k8vMjBfK9sisSY94Z1%3D-WbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jack
See original question on Stack Overflow 

 for 
better formating.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b8f53c5-2e53-4ec8-b2e6-7c7ec18ed5fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jack
I am trying to add a bunch of school boundary files into the database.  The 
boundary files are inconsistent.  They are processed by `DataSource` as 
either `Polygon`, `MultiPolygon`, or `GeometryCollection`.

Converting `Polygon` into `MultiPolygon` is fairly simple using this 
solution 
(https://gis.stackexchange.com/questions/13498),
 
but the conversion does not work for `GeometryCollection`.

class School(models.Model):
boundaries = models.MultiPolygonField()

---

from django.contrib.gis.geos import Polygon, MultiPolygon
from django.contrib.gis.geos.collections import GeometryCollection

ds = DataSource('school_boundaries.aspx')
feature = ds[0][0]
geom_geos = feature.geom.geos
if isinstance(geom_geos, Polygon):
geom_geos = MultiPolygon(geom_geos)
elif isinstance(geom_geos, GeometryCollection):
geom_geos = MultiPolygon(GeometryCollection)  #This does not work
school = School(boundaries = geom_geos)
school.save()

Is there some way to convert `GeometryField` to `MultiPolygon` in GeoDjango?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9fa3df23-bc41-4ea4-a766-d68525065766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How would I turn this function into a CBV?

2018-06-13 Thread Alexander Joseph
I found a tutorial for putting forms in modals that works but its not using 
CBVs and I'd rather use CBVs. Here is the function that works...

def gaas_create(request):
form = GaasWaferDesignForm()
context = {'form': form}
html_form = 
render_to_string('engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html',
context,
request=request,
)
return JsonResponse({'html_form': html_form})

so far this is what I've tried but it doesnt work...

class GaasWaferDesignCreateView(LoginRequiredMixin, CreateView):
fields = ("design_ui", "emitting", "contact_location", "optical_power", 
"design_date", "designer", "design_document", "designer_ui", "in_trash", 
"inactive_date", "notes")
model = GaasWaferDesign
template_name = 
'engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html'
form = GaasWaferDesignForm()
context = {'form': form}
html_form = 
render_to_string('engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html')

def options(self, request, *args, **kwargs):
response = JsonResponse({'html_form': html_form})
return response

def form_valid(self, form):
object = form.save(commit=False)
object.created_by = self.request.user
object.save()
return super(GaasWaferDesignCreateView, self).form_valid(form)


I'm just guessing but i think the part thats causing it not to work might 
be 

html_form = 
render_to_string('engineering/gaas_wafer_designs/gaas_wafer_design_form_inner.html',
context,
request=request,
)



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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fbe33122-a132-46a9-9281-1e02d52838af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: odd crash

2018-06-13 Thread Larry Martell
Update:

The django code clearly has a bug, and I fixed it on my system. That
allowed me to see the next higher up error, which was an error
importing one of my own context_processors. This is odd, as the file
and function are there, and are readable, and if they were not I would
always get this error, not just get it intermittently. I still think
there is another higher up error, and I tried to find it by setting a
breakpoint and running the devel server, but with that the error never
occurs.

On Fri, Jun 8, 2018 at 4:16 PM, Larry Martell  wrote:
> I have an app that uses 1.9. It will work fine for weeks and weeks,
> and then out of the blue a page that has just worked will crash with
> this:
>
> Request Method: GET
> Request URL:
>
> Django Version: 1.9
> Python Version: 2.7.5
> Installed Applications:
> ['django.contrib.admin',
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'core.data',
> 'core.alerts',
> 'core.reports',
> 'app.cdsem',
> 'app.semvision',
> 'app.developer',
> 'dispatch',
> 'ui',
> 'configuration']
> Installed Middleware:
> ['django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'middleware.LastSiteUrl']
>
> Traceback:
>
> File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>  174. response =
> self.process_exception_by_middleware(e, request)
> File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>  172. response = response.render()
> File "/usr/lib/python2.7/site-packages/django/template/response.py" in render
>  160. self.content = self.rendered_content
> File "/usr/lib/python2.7/site-packages/django/template/response.py" in
> rendered_content
>  137. content = template.render(context, self._request)
> File "/usr/lib/python2.7/site-packages/django/template/backends/django.py"
> in render
>  95. return self.template.render(context)
> File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
>  204. with context.bind_template(self):
> File "/usr/lib64/python2.7/contextlib.py" in __enter__
>  17. return self.gen.next()
>
> exceptions must be old-style classes or derived from BaseException, not str
>
> Request Method: GET
> Request URL:
> Django Version: 1.9
> Exception Type: TypeError
> Exception Value:
>
> exceptions must be old-style classes or derived from BaseException, not str
>
> Exception Location:
> /usr/lib/python2.7/site-packages/django/utils/module_loading.py in
> import_string, line 23
>
> If I go the exact same URL again it will work.
>
> Anyone have any idea what could be causing this or how I can debug it further?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5ao_A0pXKiFDZ8K_naRJdt1MkWuP6XW9ZmX457b2%2BSzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: saving django session data for anonymous user

2018-06-13 Thread Siddharth Srivastava
Thanks  Anthony for your prompt reply. current implementation is that i am
using django orm query to pull the user cart details and cart id(session
key) is the key so when user switch from anonymous
user to actual user then i loses the data came from the query.

so when user gets authenticated then it create new session id then previous
session data we lose. I am not finding much help in google:(.

Thanks,

Siddharth



On Tue, Jun 12, 2018 at 8:37 AM, Anthony Flury  wrote:

> The only way I can think of is when your user goes to log in - check if
> their session id is already recorded.
>
> When they login - I assume that they get an new Session Id - and remap the
> data from their old session id to their new session Id.
>
> Would that work ?
>
> On 12/06/18 11:01, Siddharth Srivastava wrote:
>
>> Hi ,
>>
>> i was writing small ecommerce application in django framework. so i was
>> trying to implement add to cart functionality like that if user is
>> anonymous user then selected products should be mapped to it's session id
>> which is act. cart id in models. so the scenario is that whenever anonymous
>> user check out and mapped data against that session id is purged. Is there
>> any mechanism to save anonymous user session data even after user logs in.
>> kindly provide easy possible solution as i am bit new to django:)
>>
>> Thanks,
>>
>> Siddharth
>>
>>
>> --
>> 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 > django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/d17bbc16-4c0b-4d06-bfa5-af814a20cbc6%40googlegroups.com
>> > b-4d06-bfa5-af814a20cbc6%40googlegroups.com?utm_medium=email
>> _source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> --
> Anthony Flury
> email : *anthony.fl...@btinternet.com*
> Twitter : *@TonyFlury *
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAENVTMq%3DUUZ%3D_o-GVpcT8LsgeLGTYEQpa2Urjv8h97jgLONMBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Admin verification

2018-06-13 Thread habib mobolaji
 

Please, I am currently working on a project for a modeling agency where the 
admin verifies the details of a new model after completing a registration 
form. The project is using python django framework.

This is the breakdown;

   - A new model fills a form.
   - The form is send to the administrator's email for notification and 
   confirmation of the data before being added to the database .
   - The new model is then added to the database .

I have little understanding about the above problem, I will be very 
grateful for any kind of help in this, 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f18776fd-8bac-4013-af82-75120e803a86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get the Parameter Value From URL

2018-06-13 Thread 赖信桃
Hi, Pravin

You don't need `get` method in template, just use dot, and if it doesn't
exist, Django template engine will set it to None automatically.

Both below works:

```
{{ request.GET.foo }}

{% if request.GET.my_var %}
  {{ request.GET.my_var }}
{% endif %}
```

Check Django template language:
https://docs.djangoproject.com/zh-hans/2.0/ref/templates/language/

Pravin Yadav 于2018年6月12日周二 下午8:49写道:

> Hello,
>
> I want to get the parameter value from url in djago template. i'm using
> the django 2.0.6 and python 3.6.1.
>
> *base.html:-  *
>
> {{ request.GET.get('videorandom_id') }}
>
> *My url: http://127.0.0.1:8000/watch/videos/4626634807531689
> *
>
>
> *Error Message:*
>
> TemplateSyntaxError at /watch/videos/4626634807531689
>
> Could not parse the remainder: '('videorandom_id')' from
> 'request.GET.get('videorandom_id')'
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/watch/videos/4626634807531689
> Django Version: 2.0.6
> Exception Type: TemplateSyntaxError
> Exception Value:
>
> Could not parse the remainder: '('videorandom_id')' from
> 'request.GET.get('videorandom_id')'
>
> Exception Location: 
> /usr/local/lib/python3.6/site-packages/django/template/base.py
> in __init__, line 668
> Python Executable: /usr/local/bin/python3
> Python Version: 3.6.1
> Python Path:
>
> ['/var/www/html/videowithfriends',
>  '/usr/local/lib/python36.zip',
>  '/usr/local/lib/python3.6',
>  '/usr/local/lib/python3.6/lib-dynload',
>  '/usr/local/lib/python3.6/site-packages']
>
> Server time: Tue, 12 Jun 2018 12:46:13 +
>
>
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEr6%3DdxutOMOROR_xjjA%3DYs%2BA2PHGA0KrbFeXxu%2BY-YVmeyc4w%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMv51WTsjk0JrCJnOUptVXqkXRHUhxSR1HkNMoGNGp2Ssok74A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Login with pre-set credentials.

2018-06-13 Thread 赖信桃
I believe the default django admin and default user system can meet you
need. Check the docs:
https://docs.djangoproject.com/zh-hans/2.0/ref/contrib/admin/

kimeualexis 于2018年6月12日周二 下午9:36写道:

> Hello, guys!
> Am working on a student's portal with users: Admin, Staff & Student. I
> want the admin to be able to register Students & Staff with a password.
> After being registered, the students will be able to login with the pre-set
> password and can later change it. How do I achieve this
> functionalitywhere the Admin registers a student and the student is
> able to login with the pre-set password? Kindly assist.
>
> Regards!
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/539e79df-ff06-40b0-93fc-2979a346eb47%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMv51WTosK6byptphCqtXfAgaJ-05tLxc-aWrjBgUzTMn4GP4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.