Re: Cannot access imported functions in django shell by pipeline command

2017-08-25 Thread James Schneider
On Aug 24, 2017 10:33 PM, "Cheng-Hung Hsueh"  wrote:

It is a python script `tshi3.py` :


在此輸入代碼...

import csv
def li2ho2():
print(csv)
li2ho2()


I copied this code and pasted it in `python manage.py shell`. It works.

But I ran `python manage.py shell < tshi3.py`. Got `NameError: name 'csv'
is not defined.`

Why?


I don't know if the 'manage.py shell' command supports what you are doing.
I would instead write a management command to run arbitrary code from the
command line.

https://docs.djangoproject.com/en/1.11/howto/custom-management-commands/

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUYgjGm5%2BNGByT2O9PjJvzGefuCEi0rYJf5AMPDiP%2Bj2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Upsert Transaction

2017-08-25 Thread Mike Morris

what's the point of doing this


I assume it is "atomicity" -- making sure the  update/insert pair is 
indivisible and that it is impossible to do one without the other. 
Depending on application, that could be catastrophic...





On 08/25/2017 04:39 AM, Fendy Purnomo wrote:

Hi,

I'm relatively new to Django and have use it in past few months.

Recently I stumbled upon a SQL deadlock. After digging deeper it was 
caused by SQL gap lock when inserting.


Then I found that Django upsert is actually putting update/insert 
inside one transaction. I might be missing what's the point of doing 
this but why don't we put it in different transaction?


I am really new to DBA stuffs and a bit lost where to start. Really 
glad for any kind of help! Thanks in advance :D


Regards,
Fendy
--
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/a9d77d3b-c538-4912-ad7b-b4ce2ea06b55%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/21e272fc-531c-21ca-5101-f19605285a96%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot access imported functions in django shell by pipeline command

2017-08-25 Thread Mike Morris

Wild guess: Different default directory.

Try setting PYTHONPATH, or add "os.chdir('some/dir')" to top of script...




On 08/24/2017 10:33 PM, Cheng-Hung Hsueh wrote:


It is a python script `|tshi3.py|` :


|
在此輸入代碼...
|importcsv defli2ho2():print(csv)li2ho2()|
|

I copied this code and pasted it in |`python manage.py shell|`. It works.

But I ran `|python manage.py shell < tshi3.py|`. Got |`NameError: name 
'csv' is not defined|.`


Why?


Enviroment:

|
在此輸入代碼...
|LinuxMint18.1Python3.4.1(default,Sep32014,08:45:22)Django==1.11.4|
|

--
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/7466c326-0f03-4299-9239-1126daf24aaf%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/b1944651-6a10-cfcc-f555-9ba7e5460797%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: include template in a page

2017-08-25 Thread Mike Morris
I may be alone in this, but perhaps it will help piceofkayk2718 to know 
that I completely ignore his (?) posts because there is never any 
context




On 08/23/2017 12:01 PM, pieceofkayk2...@gmail.com wrote:

Do you have an action on your register form?  Like 
--
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/ce2a92c4-270a-46c9-9b49-06a2d72cf72b%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/f3c8d7c5-5efb-98ca-51e9-674325e4b88e%40musicplace.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to implement a more complex user registration/auth flow?

2017-08-25 Thread Alexander Joseph
Thanks Eduardo, I actually extended the User model by making an 
AbstractBaseUser sub-class. I'm using is_active also but I guess I'm not 
sure how to implement my flow for registering new users. I suppose I need 
to extend the classes or models in django.contrib.auth.

I was also just looking at allauth which looks like its probably the way to 
go, and it looks like its got a lot of awesome functionality related to 
security too



On Friday, August 25, 2017 at 5:35:13 PM UTC-6, Eduardo Balbinot wrote:
>
> You probably need extra attributes in your User class, which means you 
> could extend the User class like explained here: 
> https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#extending-the-existing-user-model
> Don't forget you could also work with the *is_active *attribute to 
> control whether the administrator has / hasn't flagged the account as 
> active.
>
> Hope my answer helps you.
>
> Em sexta-feira, 25 de agosto de 2017 15:31:43 UTC-3, Alexander Joseph 
> escreveu:
>>
>> I'm currently using django.contrib.auth for my user authentication which 
>> works well for simple authentication/authorization but I'd like to expand 
>> the registration/auth flow a little. 
>>
>> Right now with the default flow users go to the signup page, signup, then 
>> are redirected to the login page and can immediately sign in. Id like to 
>> have it so that once the new user signs up they are sent an email 
>> confirmation. Once they confirm their email their account is flagged 
>> inactive so they cant login until a site administrator, who receives a 
>> notification email once they confirm, flags their account as active. Once 
>> the administrator flags their account as active the user gets another email 
>> saying their account is approved and they can login.
>>
>> Is there a library out there that can help me build this so that I dont 
>> have to build everything myself ontop of the django auth? 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/001d2616-b667-48de-ab09-b00030fc2d1a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to implement a more complex user registration/auth flow?

2017-08-25 Thread Eduardo Balbinot
You probably need extra attributes in your User class, which means you 
could extend the User class like explained here: 
https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#extending-the-existing-user-model
Don't forget you could also work with the *is_active *attribute to control 
whether the administrator has / hasn't flagged the account as active.

Hope my answer helps you.

Em sexta-feira, 25 de agosto de 2017 15:31:43 UTC-3, Alexander Joseph 
escreveu:
>
> I'm currently using django.contrib.auth for my user authentication which 
> works well for simple authentication/authorization but I'd like to expand 
> the registration/auth flow a little. 
>
> Right now with the default flow users go to the signup page, signup, then 
> are redirected to the login page and can immediately sign in. Id like to 
> have it so that once the new user signs up they are sent an email 
> confirmation. Once they confirm their email their account is flagged 
> inactive so they cant login until a site administrator, who receives a 
> notification email once they confirm, flags their account as active. Once 
> the administrator flags their account as active the user gets another email 
> saying their account is approved and they can login.
>
> Is there a library out there that can help me build this so that I dont 
> have to build everything myself ontop of the django auth? 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/4a2c8f9f-1436-4a37-8dd7-559ee6becd8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do you interact with the Django test database outside of tests?

2017-08-25 Thread Kurt Wheeler
I am attempting to write end-to-end tests for my system. To do this I am 
running one container called "workers" as it would normally be run during 
development, i.e. not via a test runner. I have another container called 
"foreman" that is run via a test runner which sets up the tests, sends work 
to the "workers" container, and then make assertions about the work that 
has been done. These two containers coordinate/communicate via a messaging 
system (Celery) and the database (postgres). Therefore I am running the 
"foreman" tests with the `--keepdb` option so the test database doesn't get 
destroyed, then changing the settings for the "workers" container to use 
"test_" .

According to the docs 
:
 The 
default test database names are created by prepending test_ to the value of 
each NAME in DATABASES. Therefore I think that my "workers" container 
should be using the same database as the "foreman", even though it is being 
run by a test runner. However my issue is that the "workers" can't find any 
of the database records inserted by the "foreman".

I've tried to debug this by using the postgresql CLI to connect to the test 
database, but even when I insert a record from the tests, enter an infinite 
loop (so no cleanup code whatsoever will be run), and then check the tables 
in the test database I do not see any records there.

Does anyone know why I cannot seem to find any evidence of the test 
database records from any interface other than an actively running test?

Thanks in advance. I'm happy to share more details if needed, my project is 
even open source so I can link the source code if someone wants to dig that 
deep.

-- 
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/514c8e50-b89c-4939-afa7-c737bbb5604f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Best way to implement a more complex user registration/auth flow?

2017-08-25 Thread Alexander Joseph
I'm currently using django.contrib.auth for my user authentication which 
works well for simple authentication/authorization but I'd like to expand 
the registration/auth flow a little. 

Right now with the default flow users go to the signup page, signup, then 
are redirected to the login page and can immediately sign in. Id like to 
have it so that once the new user signs up they are sent an email 
confirmation. Once they confirm their email their account is flagged 
inactive so they cant login until a site administrator, who receives a 
notification email once they confirm, flags their account as active. Once 
the administrator flags their account as active the user gets another email 
saying their account is approved and they can login.

Is there a library out there that can help me build this so that I dont 
have to build everything myself ontop of the django auth? 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/0a9f7baa-b343-479e-84ca-699972a8060e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying Django Tutorials or Guides - mod_wsgi, Apache, Linux

2017-08-25 Thread Mike Gering
After a lot of trouble, I got my django apps running on an apache server in 
CentOS/cPanel. I documented the apache config file in the readme for the 
project . And the website is 
https://quotes.klezy.xyzhttps://quote.klezy.xyz


>

-- 
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/9626ed35-f351-48d6-b014-3d0ae93cdc77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: A lot of Problems with Migrating (conceptual)

2017-08-25 Thread Alexander Joseph
Awesome, thanks James, thats exactly what I'm looking for. I'll try layout 
1 first as you suggest



On Wednesday, August 23, 2017 at 7:49:05 PM UTC-6, James Schneider wrote:
>
>
>
> On Wed, Aug 23, 2017 at 4:40 PM, Alexander Joseph  > wrote:
>
>> One more question - is there a way to put apps in folders/sub-folders 
>> instead of creating sub-apps/modules? I just want to keep things easier to 
>> navigate on the development side. I will eventually have about 20 sub-apps 
>> in the 'Engineering' app alone.
>>
>> Even if I could just group all the engineering sub-apps i have now under 
>> an engineering folder without any further hierarchy that would help as 
>> there will also be HR, financial apps, administration apps, etc.
>>
>> Thanks again
>>
>
> Technically you can go as deep as you'd like. You can use the module 
> strategy to emulate a Django 'app' without all the registration fuss. A 
> couple abbreviated examples:
>
>
> # 1. Group resources and references by object type
> project/
> engineering/
> __init__.py
> models/
> __init__.py
>  widgets.py
>  gadgets.py
>  product1.py
>  product2.py
> views/
> __init__.py
> product1.py
> product2.py
>  # etc.
>
> All of the models for engineering would be grouped in a single 'models' 
> module. Imports would look like 'from engineering.models.widgets import 
> WonderWidget'
>
> The engineering/models/__init__.py file would contain lines like 'from 
> .widgets import *' for all of your files that contain models.
>
>
> # 2. Group by business segment or workflow
> project/
> engineering/
> __init__.py
> models.py
> product1/
> __init__.py
> models.py
> views.py
> urls.py
> product2/
> __init__.py
> models.py
> views.py
> urls.py
>  # etc.
> 
> In this case, you're replicating the structure of an 'app' without 
> creating one by Django's definition. The engineering/models.py file would 
> then contain imports like 'from .product1.models import *' in order to get 
> the model auto-discovery to work correctly. 
>
> I'm under the impression that most developers use layout #1, but a large 
> project might work better with #2 if there aren't a lot of 
> cross-dependencies. 
>
> Note that using Python modules rather than real Django apps will also keep 
> your settings.INSTALLED_APPS list minimized. With as many 'apps' as you 
> were originally talking about, that list could be dozens or hundreds of 
> items long.
>
> IMHO I would start with #1 and see how it works for you. It could be the 
> generalized term 'product' that you're using, but to me, a product would 
> not trigger a new 'app' for me, just extra model/view/url/etc. files, 
> especially given how often products change or are added/removed. In that 
> case, #2 might work better since all of the related code is within a single 
> sub-folder (but all the references to that code aren't, so there is still 
> work to be done). YMMV
>
> -James
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/73339417-ce65-4ab1-8836-d521b39c62c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How rewrite query in Django ORM?

2017-08-25 Thread Daniel Hepper
You have to assign the left side of the comparison to a field name with 
annotate. At least I'm not aware of another way, except falling back to raw 
SQL.

Assuming VALUE in your example is just a variable:

T.objects.annotate(field_replaced=F('field'), Value('-'), Value(' '), 
function='replace')).filter(field_replaced=Func(Value('my_value'), 
Value('-'), Value(' '), function='replace'))

This results in a query like this:

SELECT "T"."id", "T"."field", replace("T"."field", '-', ' ') AS 
"field_replaced" FROM "T" WHERE replace("T"."field", '-', ' ') = 
(replace('my_value', '-', ' '))

Hope that helps!

Daniel

On Thursday, August 24, 2017 at 10:44:40 PM UTC+2, Николай Инкогнито wrote:
>
> SELECT * FROM T WHERE REPLACE(T.field, '-', ' ') = REPLACE(VALUE,'-', ' ')
>
>

-- 
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/82fde496-2523-4c03-bfa3-5771cb410485%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Upsert Transaction

2017-08-25 Thread Fendy Purnomo
Hi,

I'm relatively new to Django and have use it in past few months.

Recently I stumbled upon a SQL deadlock. After digging deeper it was caused 
by SQL gap lock when inserting.

Then I found that Django upsert is actually putting update/insert inside 
one transaction. I might be missing what's the point of doing this but why 
don't we put it in different transaction?

I am really new to DBA stuffs and a bit lost where to start. Really glad 
for any kind of help! Thanks in advance :D

Regards,
Fendy

-- 
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/a9d77d3b-c538-4912-ad7b-b4ce2ea06b55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django hosting / Email Account

2017-08-25 Thread ADEWALE ADISA
Thanks all. Am able to create 5 mail account after buying hosting service
despite the fact that i don't want to host my application with them because
they don't provide python hosting unless i purchase VPS. so i will be using
their mail and domain, then host my app on pythonanywhere.com.


On Fri, Aug 25, 2017 at 3:23 AM, wang sheng  wrote:

> I recommend to use  some "email cloud service " such as "mailgun" or "
> sendcloude.com "
>
> 2017-08-25 4:24 GMT+08:00 ADEWALE ADISA :
>
>> thanks Guerrero,
>> i too taught so, i have sent mail to my registrar but they have not
>> reply. before when am hosting php site, i use to host the site with the
>> registrar, so the will give me link to cpanel where i can create email
>> account.
>> but now this registrar the not give me link to cpanel, that what is not
>> clear to me
>> On Aug 24, 2017 5:23 PM, "Gerardo Palazuelos Guerrero" <
>> gerardo.palazue...@gmail.com> wrote:
>>
>>> hi,
>>> For sure not from pythonanywhere.com
>>>
>>> Your domain registrar may have some free emails accounts (like godaddy
>>> which allows you to create email accounts for your domain purchased with
>>> them).
>>>
>>> Otherwise, you will have to buy the service (like in gmail for business
>>> or in fastmail.com)
>>>
>>>
>>>
>>> --
>>> Gerardo Palazuelos Guerrero
>>>
>>>
>>> On Thu, Aug 24, 2017 at 10:12 AM, ADEWALE ADISA 
>>> wrote:
>>>
 Good day friends;
 Please help me to clarify this issue:

 I just purchase a domain name , let say abc.com.
 I want to host my django application on pythonanywhere.com using my
 domain name abc.com.
 Now i want to create up to three email accout for my clients using my
 domain name e.g 1...@abc.com, 4...@abc.com.
 Please where would i create this mail account ? Is it from my domain
 registrant  where i purchase abc.com or pythonanywhere.com ?

 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/ms
 gid/django-users/CAMGzuy-m%3DH5evUgvzDKRoX2mOOik82TOsUNU8_%2
 BZ1xpbX1PKog%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/ms
>>> gid/django-users/CAJ8iCyMM%3DdS%3DwwpWjvmG7f7Yp6EQ_tv4o_w9dj
>>> c8Ec3O1FA5Jg%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/ms
>> gid/django-users/CAMGzuy-Lw%3DtumtdFaRwnbpAeVrLg0X9%2Bp1KG%
>> 2B5zJhEveGNJhiQ%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/CA%2BmnDnqn_zTWNxM2Cyw8pZ-
> 1UVRQeXXuC0fjKyx%3D0UmHmOxmeA%40mail.gmail.com
> 
> .
>

Re: GeoDjango: strip z dimension; force 2D

2017-08-25 Thread Rukaya Johaadien
I did the following: 

from django.contrib.gis.geos import GEOSGeometry, WKTWriter
wkt_w = WKTWriter()
wkt_w.outdim = 2 # This sets the writer to output 2D WKT
polygon = GEOSGeometry(json.dumps(item['geometry'])) # The 3D geometry
temp = wkt_w.write(polygon)
polygon = GEOSGeometry(temp) # The 3D geometry

Here it is in the 
docs: 
https://docs.djangoproject.com/en/1.11/ref/contrib/gis/geos/#django.contrib.gis.geos.WKBWriter.outdim


On Monday, 7 March 2016 20:43:05 UTC+2, Jônatas Castro wrote:
>
> In my project I need to import *shapefiles* and same some geometry.
>
> Some of these are *MULTIPOLYGON Z* type, but all Z coordinates are 
> 0-value.
>
> When I try to save the geometry, I get the error: *"Geometry has Z 
> dimension but column does not".*
>
> *What is the best way to strip the Z dimension?*
>
>
>
> My code:
>
>
>
> *ds = DataSource(file_path, encoding='ISO-8859-1')layers = ds[0]*
>
> *#need something HERE to coerce geometry to 2D*
>
>
> *obj=MyModel(geometry=GEOSGeometry(layers[0].geom.hex))*
> *obj.save()*
>
>

-- 
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/377d3f34-c092-46dd-92f1-5d9e806c6f59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.