Django: How to customize the admin form for specific model

2015-01-24 Thread Shoaib Ijaz


First of all I apologize the question title can be unrelated to my query. I 
am also confused what I want to do because I am less familiar with django.

I want to create simple comment system. The requirement is clear that user 
can post comment with multiple images.Every comment should have reply. so I 
created following models.

#comment table class Comments(models.Model):
parent = models.ForeignKey('self',null=True) // for comment reply
description = models.TextField(max_length=1000, blank=False, null=False)

class Meta:
db_table = u'comments'

#images tableclass CommentImages(models.Model):
comment = models.ForeignKey(Comments)
image = models.CharField(max_length=250, blank=False, null=False)

class Meta:
db_table = u'comments_images'

I have query about admin side how can i manage these things?

I want to show images list when admin view the specific comment.

Admin can view replies of specific comment.

Here i draw the example. [image: enter image description here]

So I dont want to ask about coding. I want to know what techniques will be 
used to change the admin view. I am using admin panel for others models too 
so I want to change the specific model view.

How can I get these things? Thank you

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0fb17b82-042a-4d45-a8dd-bb842d94923c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django REST Framework: How to add prefix in URL for versioning

2014-11-05 Thread Shoaib Ijaz


I am trying to create version for REST application. Here is my URL Examle

www.myapi.com/foo [default version]
www.myapi.com/v1/foo [version one]

This is the project structure

├── __init__.py├── settings.py├── urls.py├── default_app│ ├── __init__.py│ ├── 
serializer.py│ ├── models.py│ ├── views.py│ ├── urls.py│ └── v1_app├── 
__init__.py├── serializer.py├── models.py├── views.py├── urls.py

*default_app urls.py*

from django.conf.urls import *from default_app import views as df_viewsfrom 
rest_framework import routers

router = routers.DefaultRouter()
router.register(r'foo', df_views.viewname, "foo")
urlpatterns = router.urls

*v1_app urls.py*

from django.conf.urls import *from v1_app import views as ver_viewsfrom 
rest_framework import routers

router = routers.DefaultRouter()
router.register(r'foo', ver_views.viewname, "foo")
urlpatterns = router.urls

*main file for urls.py*

from django.conf.urls import patterns, include, urlfrom defualt_app import urls 
as default_urlsfrom v1_app import urls as v1_urlsfrom 
django.contrib.staticfiles.urls import staticfiles_urlpatterns



urlpatterns += patterns('',
url(r'^', include(default_urls, namespace="default")),
url(r'^v1/', include(v1_urls, namespace="v1")))

urlpatterns += staticfiles_urlpatterns()

My issue is, when i using simple url without any prefix then it is working

www.myapi.com/foo

and when i used version prefix v1 or v2 then it throws error [Page not 
found (404)]

www.myapi.com/v1/foo

I got this idea from this link http://stackoverflow.com/a/21839842/1558544

If I don't use middleware class then is this possible to get same result?

Thank you

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42d759fb-19f2-483f-a979-1b61cce51d57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django: How to apply filter on geometry type using GeoDjango QuerySet

2014-10-14 Thread Shoaib Ijaz
Yeah, Now I am using .extra() function

My Implementation 
<http://stackoverflow.com/questions/26353830/django-how-to-apply-filter-on-geometry-type-using-geodjango-queryset/26356034#26356034>

On Tuesday, 14 October 2014 12:22:44 UTC+5, Jani Tiainen wrote:
>
> On Mon, 13 Oct 2014 23:34:04 -0700 (PDT) 
> Shoaib Ijaz <shoaib...@gmail.com > wrote: 
>
> > 
> > 
> > I am trying to convert a SQL into Django Query: 
> > 
> > SELECT * from tbl_name where geometrytype(geometry) LIKE 'POINT'; 
> > 
> > I have searched on it but cannot find any geometry type function. 
> > 
>
> You can't, at least not with current Django versions. Geodjango assumes 
> that geometry column contains just one type of a geometries. 
>
> But you should be able to use .raw() query to get what you want to. 
>
> -- 
>
> Jani Tiainen 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/952713cb-106c-4089-9b10-acbc02b90191%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django: How to apply filter on geometry type using GeoDjango QuerySet

2014-10-14 Thread Shoaib Ijaz


I am trying to convert a SQL into Django Query:

SELECT * from tbl_name where geometrytype(geometry) LIKE 'POINT';

I have searched on it but cannot find any geometry type function.

Any Help? Thank you

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d373701c-1f91-418a-8108-4b854692d39a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django - How to fix “the procedure entry point sqlite3_rtree_geometry_callback could not be located in the dynamic link library sqlite3.dll”

2014-08-20 Thread Shoaib Ijaz


I have problem with django project. I am facing error when i am trying to 
execute project in browser.

"the procedure entry point sqlite3_rtree_geometry_callback could not be 
located in the dynamic link library sqlite3.dll"

I have no idea where is the issue.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4d3473cc-f795-4ea6-959a-89c6d014ffdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to use Database Views in Django Rest Framework

2014-04-18 Thread Shoaib Ijaz


I am using Django Rest Framework for serialize data. I came across a 
scenario where I have to use Database Views as Model.

*My Model*

class A(models.Model):
name = models.CharField(max_length=240, blank=True)
value = models.CharField(max_length=240, blank=True)

class Meta:
db_table = 'tbl_a'
class B(models.Model):
   name = models.CharField(max_length=240, blank=True)
   value = models.CharField(max_length=240, blank=True)

class Meta:
db_table = 'tbl_b'

*Database View Query*

CREATE OR REPLACE VIEW ab_view AS
SELECT id,name,value FROM tabl_a WHERE name='foo' UNION (SELECT 
b.id,b.name,b.value FROM tabl_b b WHERE b.name='foo')

*Model For Database View*

class ABView(models.Model):
id = models.IntegerField(primary_key=True)
name = models.CharField(max_length=240, blank=True)
value = models.CharField(max_length=240, blank=True)

class Meta:
db_table = u'ab_view'
managed = False

*Print Text Query*

query = ABView.objects.all()print query.count() #output (1000)

When I used ABView as Model in serializer class in it shows me error

TypeError at /ViewName/ 'source' is an invalid keyword argument for this 
function

class ABViewSerializer(rest_serializer.Serializer):

class Meta:
model = AbView
fields = ('name', 'value')

*View*

class ABViewSet(viewsets.ModelViewSet):
serializer_class = ABSerializer
queryset = ABView.objects.all()

Is there anything missing in this code?

Can I use Database View in Django REST Framework?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5baa757f-f5af-4581-a8fd-9e054184d792%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Union in Django queryset

2014-04-17 Thread Shoaib Ijaz
I don't want use SQL query in django

On Thursday, 17 April 2014 04:39:09 UTC+5, Russell Keith-Magee wrote:
>
> On Wed, Apr 16, 2014 at 9:30 PM, Shoaib Ijaz 
> <shoaib...@gmail.com> 
> wrote: 
> > Sorry for duplicate post How to create Union 
> > 
> > I am using Django REST Framework in project and I want to create union 
> two 
> > different Models. 
> > 
> > My Models 
> > 
> > class A(models.Model): 
> > name = models.CharField(max_length=240, blank=True) 
> > geometry = models.GeometryField(blank=True, null=True) 
> > abwrapper= models.ForeignKey(ABWrapper) 
> > 
> > class Meta: 
> > db_table = 'tbl_a' 
> > 
> > class B(models.Model): 
> > name = models.CharField(max_length=240, blank=True) 
> > link = models.IntegerField(blank=True, null=True) 
> > geometry = models.GeometryField(blank=True, null=True) 
> > abwrapper= models.ForeignKey(ABWrapper) 
> > 
> > class Meta: 
> > db_table = 'tbl_b' 
> > 
> > I am trying to create this query 
> > 
> > SELECT id,name FROM tbl_a UNION (SELECT b.id,b.name From tbl_b b) 
> > 
> > My attempt for union 
> > 
> > a = A.objects.values_list('id') 
> > b = B.objects.values_list('id') 
> > queryset = a | b 
> > 
> > Error: 
> > AssertionError: Cannot combine queries on two different base models. 
> > 
> > Now i tried with parent Model in this way 
> > 
> > class ABWrapper(models.Model): 
> > objects = models.GeoManager() 
> > class Meta: 
> > db_table = u'ab_wrapper' 
> > 
> > Added this model as ForeignKey above both Models 
> > 
> > a = ABWrapper.objects.filter(a__isnull=False).values('a__id') 
> > b = ABWrapper.objects.filter(b__isnull=False).values('b__id') 
> > queryset = a | b 
> > 
> > Error: 
> > TypeError: Merging 'GeoValuesQuerySet' classes must involve the same 
> values 
> > in each case. 
> > 
> > Another attempt by making alias 
> > 
> > a = 
> > 
> ABWrapper.objects.filter(a__isnull=False).extra(select={'tempID':'a__id'}).values_list('tempID')
>  
>
> > b = 
> > 
> ABWrapper.objects.filter(b__isnull=False).extra(select={'tempID':'b__id'}).values_list('tempID')
>  
>
> > queryset = a | b 
> > 
> > Error: 
> > ValueError: When merging querysets using 'or', you cannot have 
> > extra(select=...) on both sides. 
> > 
> > I have searched on it, mostly answered this issue as using list for both 
> > models. But I don't want to use list as I am using Django Rest Framework 
> so 
> > I need QuerySet. So my question if I use list for union can I convert 
> > resulting list into QuerySet. 
> > 
> > Note: I don't want to use SQL Query in Django 
>
> Why not? That would seem to be the exact answer you need. 
>
> You appear to have a very specific idea of the SQL query you want to 
> issue, including UNION clauses (an operator that Django's ORM doesn't 
> support) and "extra" columns (which means the data you want is outside 
> your regular Django model). Getting this query in 100% native Django 
> query sets is going to be somewhere between difficult and impossible. 
>
> However, you don't have to drop right back to SQL cursors - Django has 
> raw query sets for exactly this purpose: 
>
> ABWrapper.objects.raw("SELECT …. FROM … WHERE") 
>
> This will return ABWrapper objects contained in a query set object 
> that should be compatible with Django REST Framework, but you get 
> those objects by providing the exact SQL you want to execute. 
>
> See: 
>
> https://docs.djangoproject.com/en/dev/topics/db/sql/ 
>
> for more details 
>
> Yours, 
> Russ Magee %-) 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3cd4534c-aee8-4d94-9efa-5500ded935f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create Union in Django queryset

2014-04-16 Thread Shoaib Ijaz
Sorry for duplicate post How to create 
Union

I am using Django REST Framework in project and I want to create union two 
different Models.

*My Models*

class A(models.Model):
name = models.CharField(max_length=240, blank=True)
geometry = models.GeometryField(blank=True, null=True)
abwrapper= models.ForeignKey(ABWrapper)

class Meta:
db_table = 'tbl_a'
class B(models.Model):
name = models.CharField(max_length=240, blank=True)
link = models.IntegerField(blank=True, null=True)
geometry = models.GeometryField(blank=True, null=True)
abwrapper= models.ForeignKey(ABWrapper)

class Meta:
db_table = 'tbl_b'

I am trying to create this query

SELECT id,name FROM tbl_a UNION (SELECT b.id,b.name From tbl_b b)

*My attempt for union*

a = A.objects.values_list('id')
b = B.objects.values_list('id')
queryset = a | b
Error:AssertionError: Cannot combine queries on two different base models.

*Now i tried with parent Model in this way*

class ABWrapper(models.Model):
objects = models.GeoManager()
class Meta:
db_table = u'ab_wrapper'

Added this model as ForeignKey above both Models

a = ABWrapper.objects.filter(a__isnull=False).values('a__id')
b = ABWrapper.objects.filter(b__isnull=False).values('b__id')
queryset = a | b
Error:TypeError: Merging 'GeoValuesQuerySet' classes must involve the same 
values in each case.

*Another attempt by making alias*

a = 
ABWrapper.objects.filter(a__isnull=False).extra(select={'tempID':'a__id'}).values_list('tempID')
b = 
ABWrapper.objects.filter(b__isnull=False).extra(select={'tempID':'b__id'}).values_list('tempID')
queryset = a | b
Error:ValueError: When merging querysets using 'or', you cannot have 
extra(select=...) on both sides.

I have searched on it, mostly answered this issue as using list for both 
models. But I don't want to use list as I am using Django Rest Framework so 
I need QuerySet. So my question if I use list for union can I convert 
resulting list into QuerySet.

*Note:* I don't want to use SQL Query in Django

Is there any other way to do this task?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f4182754-b952-41a9-8c4c-90e32a287e06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Relation in Django REST Framework?

2014-04-08 Thread Shoaib Ijaz


I am using serializers.GeoFeatureModelSerializer to serialize Model. I have 
a queryset

that is creating Left Outer Join. I want to serialize related Model fields

Here is my Model

class LookupTiming(models.Model):
day = models.CharField(max_length=7)
time_1 = models.TimeField()
time_2 = models.TimeField()

class Meta:
db_table = u'lookup_timing'
class Streets(models.Model):
name = models.CharField(max_length=50)
geometry = models.GeometryField(null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'streets'

def __unicode__(self):
return '%s' % self.name

class StreetTimings(models.Model):
street= models.ForeignKey(Streets)
lookuptiming = models.ForeignKey(LookupTiming)
class Meta:
db_table = u'street_timings'

queryset = Streets.objects.filter(streettimings_*lookuptiming*_isnull=True)

Serializer Class

class StreetSerializer(gis_serializer.GeoFeatureModelSerializer):

class Meta:
model = Streets
geo_field = "geometry"
id_field = False
fields = ('id', 'streettimings__lookuptiming__day', other fields)

I want to show following fields

street_*id, LookupTiming*_day, LookupTiming__time_1 , LookupTiming__time_2

How can i do this?

Thank you

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e1b1c3e1-f6c1-4046-9404-67b30a8fdb93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create complex Left JOIN in Django

2014-04-07 Thread Shoaib Ijaz


I am trying to create multi Model Left join using django

Here is my model

class LookupTiming(models.Model):
day = models.CharField(max_length=7)
time_1 = models.TimeField()
time_2 = models.TimeField()

class Meta:
db_table = u'lookup_timing'
class Streets(models.Model):
name = models.CharField(max_length=50)
point = models.GeometryField(null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'streets'

def __unicode__(self):
return '%s' % self.name

class StreetTimings(models.Model):
street= models.ForeignKey(Streets)
lookuptiming = models.ForeignKey(LookupTiming)
class Meta:
db_table = u'street_timings'

This is query that i have created

Streets.objects.filter(streettimings_*isnull=True).filter(streettimings*
_lookuptiming__isnull=True).values('id')

This is sql output of above query

SELECT "streets"."id" FROM "streets"
LEFT OUTER JOIN "street_timings" ON ( "streets"."id" = 
"street_timings"."street_id" ) 
LEFT OUTER JOIN "street_timings" T3 ON ( "streets"."id" = T3."street_id" )
WHERE ("street_timings"."id" IS NULL AND T3."lookuptiming" IS NULL)

But i want following query

select st.id from streets st
LEFT JOIN street_timings timing on timing.street_id = st.id 
LEFT JOIN lookup_timing lt on lt.id = timing.lookuptiming_id 

So problem is that, the django query total ignore *lookuptiming* Model. I 
want to create following joins

Streets(id) = StreetTimings (street_id)

LookupTiming (id) = StreetTimings (lookuptiming_id)

How can i create left join for multiple models?

Thank you

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/50df8abf-f539-4c08-8211-d40a35e43cc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to use inspectdb command for postgres table in Django

2014-04-03 Thread Shoaib Ijaz


I am trying to generate Model class from postgres table, this table contain 
some geometry type column.

I am using following command for Model creation

python manage.py inspectdb

But facing this error

Exception: Could not find a geometry or geography column for 
"accommodation"."geometry"

this error generating from following file

File 
"C:\Python27\lib\site-packages\django\contrib\gis\db\backends\postgis\introspection.py",
 
line 88, in get_geometry_type

But i don't know why this exception is throwing, i have checked geometry 
type column exists in table.

Can anyone help me to fix this issue?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2ffafc29-b227-4cad-bf4d-282b66ba52a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How transform specific geometry column using Django GIS GeoQuerySet

2014-03-28 Thread Shoaib Ijaz

>
> Can you elaborate following statement, i am at beginner level in django 
> what why i cannot understand your reply


*   One option would be to return the data and then transform it once you 
 have the spatial objects into python variables.  *

   Thank you

>  

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc978288-2005-4dcc-a56d-383a21e7744c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How transform geometry column using GeoDjango

2014-03-27 Thread Shoaib Ijaz


I am trying to transform geometry column in django, here is my model

class Network(models.Model):
name = models.CharField(max_length=50, blank=True)
alias = models.CharField(max_length=100, blank=True)
geometry = models.GeometryField(srid=3857, null=True, blank=True)
bbox = models.GeometryField(srid=3857, null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'tbl_network'

def __unicode__(self):
return '%s' % self.name

I am trying to transform *bbox* column but GeoQuerySet automatically 
tranform *geometry* column

Network.objects.transform(srid=3857).values('geometry','bbox')

*SQL query output of above django query*

  SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
FROM "tbl_network"

So i tried it different way, now i exclude *geometry* column

 Network.objects.transform(srid=3857).values('bbox')

*SQL query output of above django query*

 SELECT "tbl_network"."bbox" FROM "tbl_network"

Now GeoQuerySet totally ignore transform function.

So my questions is,

How can i transform specific column of model?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e99f8f98-b9b3-48fa-8eb2-699da60bb97d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How transform specific geometry column using Django GIS GeoQuerySet

2014-03-27 Thread Shoaib Ijaz
*(*)* I am not doing sql queries in django

On Thursday, 27 March 2014 16:53:30 UTC+5, Shoaib Ijaz wrote:
>
> I am doing sql queries in django, the queries that i mentioned above are 
>> print queries of django
>
>
>   Network.objects.transform(srid=3857).values('geometry', 'bbox')
>
>  *This is printed SQL query output of above django query *
>
>  SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
> FROM "tbl_network"
>
>  Network.objects.transform(srid=3857).values('bbox')
>
> *This is printed SQL query output of above django query *
>
>  SELECT "tbl_network"."bbox" FROM "tbl_network" 
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/521bc234-0a25-461d-94fa-062e5cb199fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How transform specific geometry column using Django GIS GeoQuerySet

2014-03-27 Thread Shoaib Ijaz

>
> I am doing sql queries in django, the queries that i mentioned above are 
> print queries of django


  Network.objects.transform(srid=3857).values('geometry', 'bbox')

 *This is printed SQL query output of above django query *

 SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" FROM 
"tbl_network"

 Network.objects.transform(srid=3857).values('bbox')

*This is printed SQL query output of above django query *

 SELECT "tbl_network"."bbox" FROM "tbl_network" 


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f95b90d3-4d95-4aba-9bc6-73935ceb1a33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How transform specific geometry column using Django GIS GeoQuerySet

2014-03-26 Thread Shoaib Ijaz
Sorry i mistype queries

  Network.objects.transform(srid=3857).values('geometry', 'bbox')
>
>   SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
> FROM "tbl_network"
>
>  Network.objects.transform(srid=3857).values('bbox')
>
>  SELECT "tbl_network"."bbox" FROM "tbl_network"
>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d0e3b6fd-1b5e-4959-ab1c-713add6d9c8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How transform specific geometry column using Django GIS GeoQuerySet

2014-03-26 Thread Shoaib Ijaz


I am trying to transform geometry column type in django, here is my model

class Network(models.Model):
name = models.CharField(max_length=50, blank=True)
alias = models.CharField(max_length=100, blank=True)
geometry = models.GeometryField(srid=3857, null=True, blank=True)
bbox = models.GeometryField(srid=3857, null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'tbl_network'

def __unicode__(self):
return '%s' % self.name

Problem is that when i tried to transform bbox it does not transform it

  Network(srid=3857).values('geometry','bbox')

  SELECT ST_Transform("tbl_network"."geometry", 3857), "tbl_network"."bbox" 
FROM "tbl_network"

Above query automaticly tranform geomtery field and igonre bbox field

So i tried it different different way

 Network(srid=3857).values('bbox')

 SELECT "tbl_network"."bbox" FROM "tbl_network"

Now this query totally ignored transform function.

So my questions is,

How can i transform specific column of model?

thank you

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c95708f5-e6d7-4a80-a929-74e451f33047%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to convert SQL Complex QUERY to django QUERY

2014-03-18 Thread Shoaib Ijaz


I am trying to convert sql query to django query but failed to do this, can 
anyone help me

select id,name,round(value::numeric,2) as value, st_transform(geometry, 3857) 
as geometry
from net_rest
where state_id in (1,2) and name = 'height'
union
(select d.id,d.restriction,d.value, st_transform(d.geometry, 3857) as 
geometry from display_rest d
where d.restriction='height' and condition_id not in (select 
condition_id 
from net_rest_conditions where version_id = 2)

OR This

select id,name,value as value, geometry
from net_rest
where state_id in (1,2) and name = 'height'
union
(select d.id,d.restriction,d.value,geometry from display_rest d
where d.restriction='height' and condition_id not in (select 
condition_id 
from net_rest_conditions where version_id = 2)

*Updated the question fro here*

I am using django django rest framework serialize *net_rest* Model, 
basically i am working on project related to GIS where i have to make rest 
api to expose data

Here is some of my models

class net_rest(models.Model):
name = models.CharField(max_length=50, blank=True)
value = models.FloatField()
state_id = models.IntegerField(null=True, blank=True)
geometry = models.GeometryField(null=True, blank=True)
objects = models.GeoManager()

class Meta:
db_table = u'tbl_net_rest'

def __unicode__(self):
return '%s' % self.name


class display_rest(models.Model):
restriction = models.CharField(max_length=45, blank=True)
link_id = models.IntegerField(blank=True, null=True)
condition_id = models.IntegerField(blank=True, null=True)
value = models.FloatField(blank=True, null=True)
geometry = models.GeometryField(blank=True, null=True)
class Meta:
db_table = u'tbl_display_rest'


class net_rest_conditions(models.Model):
condition_id = models.IntegerField()
version_id =  models.IntegerField(blank=True, null=True)
class Meta:
db_table = u'tbl_net_rest_conditions'
class networkSerializer(serializers.GeoModelSerializer):
class Meta:
model = net_rest
fields = ('id', 'name', 'value', 'geometry')

Here is view

class networkSerializerViewSet(viewsets.ModelViewSet):

q1 = display_rest.objects.values_list('id', 'name', 'value', 
'geometry').filter(restriction='height')\

.exclude(condition_id__in=net_rest_conditions.objects.filter(version_id=2).values_list('condition_id',flat=True))

q2 = net_rest.objects.all().filter(Q(name="height"), Q(state_id=1) | 
Q(state_id=2)).values_list('id', 'value', 'geometry')

queryset = q1 | q2

serializer_class = networkSerializer

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e137e70-e88d-49bb-b000-e6174aae3837%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Python-Django : ImportError at / : No module named urls

2013-12-11 Thread shoaib ijaz


I have created Djnago project in eclipse. Unfortunately, i am facing issue 
when i run the project

ImportError at / No module named urls

Here Error Page http://dpaste.com/1499981/

Eclipse Project 
http://i1008.photobucket.com/albums/af204/shoaibshah01/Untitled_zps84f95b4f.jpg

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b05a6745-d150-4b1a-bd2a-297d665da1f7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.