That's okay my website has not moved that far into the distance yet it's 
still pretty elementary so all the data in my database has been put there 
by me anyways. I can set up a new database. I see here:

https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#ref-gis-install

that I should do:

$ POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-2.0# Creating the 
template spatial database.$ createdb -E UTF8 template_postgis$ createlang -d 
template_postgis plpgsql # Adding PLPGSQL language support.# Allows 
non-superusers the ability to create from this template$ psql -d postgres -c 
"UPDATE pg_database SET datistemplate='true' WHERE 
datname='template_postgis';"# Loading the PostGIS SQL routines$ psql -d 
template_postgis -f $POSTGIS_SQL_PATH/postgis.sql$ psql -d template_postgis -f 
$POSTGIS_SQL_PATH/spatial_ref_sys.sql# Enabling users to alter spatial tables.$ 
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"$ psql -d 
template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"$ psql -d 
template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"

to make a postgis spatial database template? Is that right?

Then it says to do:

hese commands may be placed in a shell script for later use; for 
convenience the following scripts are available:
PostGIS versionBash shell 
script1.3create_template_postgis-1.3.sh<https://docs.djangoproject.com/en/dev/_downloads/create_template_postgis-1.3.sh>
1.4create_template_postgis-1.4.sh<https://docs.djangoproject.com/en/dev/_downloads/create_template_postgis-1.4.sh>
1.5create_template_postgis-1.5.sh<https://docs.djangoproject.com/en/dev/_downloads/create_template_postgis-1.5.sh>
Debian/Ubuntucreate_template_postgis-debian.sh<https://docs.djangoproject.com/en/dev/_downloads/create_template_postgis-debian.sh>

Afterwards, you may create a spatial database by simply specifying 
template_postgis as the template to use (via the -T option):

$ createdb -T template_postgis <db name>

So I guess once I run this bash script from SSH I then create a new 
database from an SSH terminal? I'm on Webfaction.

** Okay so I'm trying to parse through what you posted because at this 
point in time I'm going to just trash my old database and 
not preserve anything.

Can you help me get GeoDjango set up from scratch? That's what I'm trying 
to do here. 

This is for moving my data only right:

>From your current project, dump all your data to a json file:
$ python manage.py dumpdata --all --natural > all.json

The `natural` flag helps preserve some things like contenttypes and 
permissions.

Then switch to your new postgis template in your settings file (along with 
the other necessary items you already mentioned, like changing your backend 
to postgis).

Next:

$ python manage.py syncdb
$ python manage.py migrate # if using south
$ python manage.py loaddata all.json

You might run into an issue between syncdb and loaddata, because syncdb 
loads initial data into your tables for apps with a 
fixtures/initial_data.json file (auth, for example).  If you can use the 
dev (1.5) code, use the --no-initial-data flag.  Otherwise, you may need to 
run something like the following on your Postgres db before loaddata:

=# delete from auth_group_permissions; delete from auth_permission; delete 
from django_admin_log; delete from django_content_type;



If it is not only for that just let me know but that's what it seemed like. 
If I'm starting fresh I want a postgis database right? How do I then 
utilize GDAL, PROJ.4, and GEOS if my database gets set up as postgis?

Thanks for sticking it out through all the questions. I'm really not sure 
how to do this and what's the best way.

Thanks!

JJ


On Tuesday, October 16, 2012 10:57:58 AM UTC-4, smcoll wrote:
>
> You can add GIS support to your existing project, but as you suspected, 
> your current db will not be sufficient.  Unless someone knows how to 
> convert an existing database, i believe you'll need to set up a new 
> database from the postgis template, and move all your data to it.  That 
> process might look something like this:
>
> From your current project, dump all your data to a json file:
> $ python manage.py dumpdata --all --natural > all.json
>
> The `natural` flag helps preserve some things like contenttypes and 
> permissions.
>
> Then switch to your new postgis template in your settings file (along with 
> the other necessary items you already mentioned, like changing your backend 
> to postgis).
>
> Next:
>
> $ python manage.py syncdb
> $ python manage.py migrate # if using south
> $ python manage.py loaddata all.json
>
> You might run into an issue between syncdb and loaddata, because syncdb 
> loads initial data into your tables for apps with a 
> fixtures/initial_data.json file (auth, for example).  If you can use the 
> dev (1.5) code, use the --no-initial-data flag.  Otherwise, you may need to 
> run something like the following on your Postgres db before loaddata:
>
> =# delete from auth_group_permissions; delete from auth_permission; delete 
> from django_admin_log; delete from django_content_type;
>
> Hope that helps.
>
>
> On Monday, October 15, 2012 11:04:02 PM UTC-5, JJ Zolper wrote:
>>
>> Hello everyone,
>>
>> So I've installed GDAL, PostGIS, PROJ.4, and GEOS. I have Postgres set up 
>> too.
>>
>> What I need help on is the logistics of getting the GeoDjango portion of 
>> my website up and running. I already have my website code I'm just trying 
>> to add in GeoDjango so I can handle geographic operations on the website.
>>
>> So I've been reading here:
>>
>>
>> https://docs.djangoproject.com/en/1.4/ref/contrib/gis/tutorial/#introduction
>>
>> I see:
>> Create GeoDjango 
>> Project<https://docs.djangoproject.com/en/1.4/ref/contrib/gis/tutorial/#create-geodjango-project>
>>
>> Use the django-admin.py script like normal to create a geodjango project:
>>
>> $ django-admin.py startproject geodjango
>>
>> With the project initialized, now create a world Django application 
>> within the geodjango project:
>>
>> $ cd geodjango$ python manage.py startapp world
>>
>> Configure 
>> settings.py<https://docs.djangoproject.com/en/1.4/ref/contrib/gis/tutorial/#configure-settings-py>
>>
>> The geodjango project settings are stored in the geodjango/settings.py file. 
>> Edit the database connection settings appropriately:
>>
>> DATABASES = {
>>     'default': {
>>          'ENGINE': 'django.contrib.gis.db.backends.postgis',
>>          'NAME': 'geodjango',
>>          'USER': 'geo',
>>      }}
>>
>> In addition, modify the 
>> INSTALLED_APPS<https://docs.djangoproject.com/en/1.4/ref/settings/#std:setting-INSTALLED_APPS>
>>  setting 
>> to include 
>> django.contrib.admin<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#module-django.contrib.admin>
>> , 
>> django.contrib.gis<https://docs.djangoproject.com/en/1.4/ref/contrib/gis/#module-django.contrib.gis>,
>>  
>> and world (our newly created application):
>>
>> INSTALLED_APPS = (
>>     'django.contrib.auth',
>>     'django.contrib.contenttypes',
>>     'django.contrib.sessions',
>>     'django.contrib.sites',
>>     'django.contrib.messages',
>>     'django.contrib.staticfiles',
>>     'django.contrib.admin',
>>     'django.contrib.gis',
>>     'world')
>>
>>
>>
>> My question is do I need to start a new project if I already have one 
>> project already? I already have my project "madtrak" which is the project 
>> that contains my entire website. Do I need a separate project just for 
>> GeoDjango? I thought that the start project command was only done once and 
>> for the website. Or do I need to run "django-admin.py startproject 
>> geodjango" ?
>>
>> If I find that I don't need to start a new project that would help a lot 
>> because then I would already have a settings.py file with my installed apps 
>> and an app that will have a model that connects up to the Geodjango 
>> database.
>>
>> One more thing on this topic I see:
>>
>>          'ENGINE': 'django.contrib.gis.db.backends.postgis',
>>
>>
>> Even if I don't need an entire separate project do I need to add this 
>> backend to my current django project? That way I can handle all the 
>> Geodjango necessities? 
>>
>> Because currently I have:
>>
>>         'ENGINE': 'django.db.backends.postgresql_psycopg2',
>>
>> and I would guess that is not sufficient. Any advice on handling my 
>> current settings file and interfacing that with the GeoDjango database 
>> would be great!
>>
>>
>>
>> Okay secondly I see this:
>> Create a Spatial 
>> Database<https://docs.djangoproject.com/en/1.4/ref/contrib/gis/tutorial/#create-a-spatial-database>
>>
>> Note
>>
>> MySQL and Oracle users can skip this section because spatial types are 
>> already built into the database.
>>
>> First, a spatial database needs to be created for our project. If using 
>> PostgreSQL and PostGIS, then the following commands will create the 
>> database from a spatial database 
>> template<https://docs.djangoproject.com/en/1.4/ref/contrib/gis/install/#spatialdb-template>
>> :
>>
>> $ createdb -T template_postgis geodjango
>>
>>
>> So it seems to me I need a new database because it will be a spatial 
>> database for GeoDjango? I would think my current database would not be 
>> sufficient because there is nothing special about it to hold the geometric 
>> data I will need to process with GeoDjango. So do I need to run this 
>> command and set up a new database and remove my old one? If I do this is 
>> the idea that I have those extra features that I need in my spatial 
>> database for GeoDjango and I then have the option on when to use that 
>> functionality within each django app I build?
>>
>>
>> Any advice regarding the integration of GeoDjango into a current django 
>> project environment would be really useful!
>>
>> Thanks so much for your time.
>>
>> JJ Zolper
>>
>>

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

Reply via email to