Circular import problem

2014-04-16 Thread Daniel Oźminkowski
Hello,

I recently cut my models.py into separate files and now I try to fix all
the problems with imports that showed up. I hit the wall on this one though.

Purpose of the application is to process a text file with instructions and
fit them into hierarchical structure like this:

Program <- Node <- Commands

Program has many Nodes, Nodes has many commands.

One of the possible Commands is jumping into subprogram. I want to get url
of that subprogram, so I can show it in a template.

During analysis Program calls Node to create nodes. Node then calls Command
to create Commands.

Then later Command takes the id of the subprogram and call
Program.objects.get().get_absolute_url()

How can I break this import chain?

Best regards,
Daniel

-- 
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/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


second level nested inlines not showing in django-nested-inlines

2014-04-16 Thread Andreas Bloch


I'm trying to add a nested admin interface using 
https://github.com/s-block/django-nested-inline *but the 2nd level is not 
showing up in the admin*...

I have a foreign key relationship between three models:

ContractTemplate => ContractClause => ContractSubClauses

(i.e. a template can have many clauses and every clause can have many 
sub-clauses)

*models.py*

class ContractTemplate(models.Model):
name = models.CharField()
...
class ContractClause(models.Model):
contract_template = models.ForeignKey(ContractTemplate)
title = models.CharField()
...
class ContractSubClauses(models.Model):
contract_clause = models.ForeignKey(ContractClause)
text = models.TextField()
...

*admin.py*

from nested_inlines.admin import NestedModelAdmin, NestedStackedInline, 
NestedTabularInline

class ContractSubClauseInline(NestedTabularInline):
model = ContractSubClause
class ContractClauseInline(NestedStackedInline):
model = ContractClause
inlines = [ContractSubClauseInline]
class ContractTemplateAdmin(NestedModelAdmin):
inlines = [ContractClauseInline]

admin.site.register(ContractTemplate, ContractTemplateAdmin)

--


This is how the admin looks (first level - ContractClause - shows, but 
ContractSubClause(s) are not showing):



What is missing to show the ContractSubClause(s)?

-- 
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/27ac4b42-072c-4e6a-b15d-2d7ef5c3967f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Circular import problem

2014-04-16 Thread Johannes Schneider
You can use from foo import bar inside your method/class definitions or 
you can use import foo.bar.


bg,
Johannes

On 16.04.2014 11:37, Daniel Oźminkowski wrote:

Hello,

I recently cut my models.py into separate files and now I try to fix all
the problems with imports that showed up. I hit the wall on this one though.

Purpose of the application is to process a text file with instructions
and fit them into hierarchical structure like this:

Program <- Node <- Commands

Program has many Nodes, Nodes has many commands.

One of the possible Commands is jumping into subprogram. I want to get
url of that subprogram, so I can show it in a template.

During analysis Program calls Node to create nodes. Node then calls
Command to create Commands.

Then later Command takes the id of the subprogram and call
Program.objects.get().get_absolute_url()

How can I break this import chain?

Best regards,
Daniel


--
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/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.



--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

--
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/534E5E10.30103%40galileo-press.de.
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.


Upgrading from 1.4.3 to 1.4.10

2014-04-16 Thread nu . everest
How do I discover what changed between Django 1.4.3 and 1.4.10?

Will require changes to my code, or will it just work?

-- 
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/144f37dc-c60b-4ced-995e-a3b75d6d177f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from 1.4.3 to 1.4.10

2014-04-16 Thread Lucas Klassmann
Hi,

Check documentation: https://docs.djangoproject.com/en/dev/releases/1.4.3/

On the bottom you can navigate between releases.

Att.


On Wed, Apr 16, 2014 at 11:08 AM,  wrote:

> How do I discover what changed between Django 1.4.3 and 1.4.10?
>
> Will require changes to my code, or will it just work?
>
> --
> 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/144f37dc-c60b-4ced-995e-a3b75d6d177f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Lucas Klassmann
Desenvolvedor de Software

Email: lucasklassm...@gmail.com
Web site: http://www.lucasklassmann.com

-- 
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/CAOz50p%2BbtfeXqc2H0MwVzaDqkDaBmecbCOyjuFWSdyip75RrUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from 1.4.3 to 1.4.10

2014-04-16 Thread Lucas Klassmann
Hi, again!

Remember to check all releases between is your project version with target
version.
In your case, check changes in 1.4.2 also.

https://docs.djangoproject.com/en/dev/releases/1.4.2/

Cheers


On Wed, Apr 16, 2014 at 11:13 AM, Lucas Klassmann
wrote:

> Hi,
>
> Check documentation: https://docs.djangoproject.com/en/dev/releases/1.4.3/
>
> On the bottom you can navigate between releases.
>
> Att.
>
>
> On Wed, Apr 16, 2014 at 11:08 AM,  wrote:
>
>> How do I discover what changed between Django 1.4.3 and 1.4.10?
>>
>> Will require changes to my code, or will it just work?
>>
>> --
>> 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/144f37dc-c60b-4ced-995e-a3b75d6d177f%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Lucas Klassmann
> Desenvolvedor de Software
>
> Email: lucasklassm...@gmail.com
> Web site: http://www.lucasklassmann.com
>



-- 
Lucas Klassmann
Desenvolvedor de Software

Email: lucasklassm...@gmail.com
Web site: http://www.lucasklassmann.com

-- 
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/CAOz50pLyBjkyyeXnEmjPi3iP_X9CN%2Bzj00KFA942%3D5h-wqc%2BKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from 1.4.3 to 1.4.10

2014-04-16 Thread Tom Evans
On Wed, Apr 16, 2014 at 3:08 PM,   wrote:
> How do I discover what changed between Django 1.4.3 and 1.4.10?
>
> Will require changes to my code, or will it just work?

There should be no breaking changes for minor-minor* upgrades unless
required to fix a security issue. I'm not aware of any in 1.4.4-10.

Check these pages to be sure:

https://docs.djangoproject.com/en/dev/releases/1.4.4/
https://docs.djangoproject.com/en/dev/releases/1.4.5/
https://docs.djangoproject.com/en/dev/releases/1.4.6/
https://docs.djangoproject.com/en/dev/releases/1.4.7/
https://docs.djangoproject.com/en/dev/releases/1.4.8/
https://docs.djangoproject.com/en/dev/releases/1.4.9/
https://docs.djangoproject.com/en/dev/releases/1.4.10/

Cheers

Tom

* 1.4.3 has major version 1, minor version 4, minor-minor version 3

-- 
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/CAFHbX1KY8%3DQMidEMU%2BZxoZJu4S9uyMiXpf3gG%3DJR-4QueOp5OA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Missing ORDER BY in subselect?

2014-04-16 Thread Gregor Jerše
Hi!

I am experiencing a weird Queryset behavior. Let the variable treatments refer 
to an ordered (and sliced) queryset. The first query 

Service.objects.filter(treatment__in=treatments).distinct()

returns different objects than the second one

Service.objects.filter(treatment__in=list(treatments)).distinct()

, but I would expect both results to be the same. Service model declares 
treatment field as ForeignKey.

The results given by the first query are incorrect. Further SQL code 
inspection reveals that ORDER BY clause (from treatments QuerySet) is missing 
in subselect. 

The results of the second query are correct, since subquery is evaluated first 
(with ORDER BY clause included). 

It actually looks similar to an old bug #12328, which was marked as fixed long 
time ago and I am using Django 1.6. Am I missing something?

Many Thanks,
Gregor

-- 
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/4696202.A3ANhoRLR9%40gregor.
For more options, visit https://groups.google.com/d/optout.


Re: Missing ORDER BY in subselect?

2014-04-16 Thread Simon Charette
I pretty sure this is related to 
#22434
.

There's a patch on Github  I'm 
actually reviewing and it's looking pretty good.

If all goes well it should make it to Django 1.7.

Le mercredi 16 avril 2014 15:16:02 UTC-4, Gregor Jerše a écrit :
>
> Hi! 
>
> I am experiencing a weird Queryset behavior. Let the variable treatments 
> refer 
> to an ordered (and sliced) queryset. The first query 
>
> Service.objects.filter(treatment__in=treatments).distinct() 
>
> returns different objects than the second one 
>
> Service.objects.filter(treatment__in=list(treatments)).distinct() 
>
> , but I would expect both results to be the same. Service model declares 
> treatment field as ForeignKey. 
>
> The results given by the first query are incorrect. Further SQL code 
> inspection reveals that ORDER BY clause (from treatments QuerySet) is 
> missing 
> in subselect. 
>
> The results of the second query are correct, since subquery is evaluated 
> first 
> (with ORDER BY clause included). 
>
> It actually looks similar to an old bug #12328, which was marked as fixed 
> long 
> time ago and I am using Django 1.6. Am I missing something? 
>
> Many Thanks, 
> Gregor 
>

-- 
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/1565ddae-59a0-442f-987d-8d84b092d7a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pluggable crowdfunding django apps

2014-04-16 Thread Mike Dewhirst

Andres

What does the app do? More particularly, does it manage crowd funding 
for a particular project on your own website or perhaps it is more 
generic for others to launch various projects ...


Thanks

Mike

On 16/04/2014 7:37 AM, Andres Osinski wrote:

I have a small crowd funding app that I made bit too long ago, which is
useful by itself but could easily be modularized for more generic use
cases. Shoot me an email later to remind me to upload the code to GitHub.

El abr 2, 2014 6:51 PM, "Raymond Besiga" mailto:raybes...@gmail.com>> escribió:

Hello community,

Been browsing Github and the web for Django-based crowdfunding apps
that I can build on top of. So far, I have come across CrowdTilt and
Catarse but both are Ruby/Rails projects. The only Django app I
found was Zipfelchappe but it heavily uses FeinCMS which I am not an
avid user or fan of. Any other options out there that I have not
heard of? Cheers. Thanks

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/eb5259c6-6532-4045-bb22-4803e2d30aff%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CA%2BxF-PxS8Rt%3DJjHVVa%2BbQPBtOHjDdr%3D_ignGh1dD1F_b86daZw%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/534F0D67.8090503%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Union in Django queryset

2014-04-16 Thread Russell Keith-Magee
On Wed, Apr 16, 2014 at 9:30 PM, Shoaib Ijaz  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/CAJxq84-NS8Pj2oJiqzte%2BdWaGRNkseXKGhckOeNf%2BUCGYr%2B7Fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to store variable length list of dict-type objects with FKs in Django SQL DB

2014-04-16 Thread Kreychek
 

Let's say I'm getting some JSON in the format of...

"fellowPlayers": [
{
   "championId": 110,
   "teamId": 100,
   "summonerId": 34258805
},
{
   "championId": 9,
   "teamId": 100,
   "summonerId": 19923759
},
{
   "championId": 46,
   "teamId": 200,
   "summonerId": 2112359
},
...]

...that can have a variable # of entries (from 0-11, inclusive), but each 
entry has those 3 attributes, 2 of which should map to other tables 
(championId and summonerId).

*How would I want to define a table/model in Django to store the list of 
fellowPlayers (of unknown length)?*

If any more information is needed please comment.

If this can't be directly done, how would you suggest handling such a 
situation? My initial thought was to hardcore in a # of fields 
(fellow_player_1, fellow_player_2, etc) based on what I expect the maximum 
# of entries to be, but that approach seems like it could be improved on a 
lot, although 11 isn't too bad in terms of hardcoding.

-- 
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/1a3aea81-ca1b-43be-be77-21c262095038%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


what's the best admin skin (free)

2014-04-16 Thread Bobby Roberts
hey group.   I've been out of the loop for  a few years now.  What is the 
best skin for admin?  Is Grapelli still good?

-- 
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/e51e16a7-5e37-4ead-88f7-1b1092c6e161%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to store variable length list of dict-type objects with FKs in Django SQL DB

2014-04-16 Thread Kreychek
To clarify, I have a model, let's call it MatchHistory, that stores a fixed 
set of statistics about a match (ex. points, kills, etc).

Example JSON for the stats:

u'stats': {   u'assists': 2,
  u'championsKilled': 6,
  u'doubleKills': 1,
  u'goldEarned': 7613,
  u'goldSpent': 7330,
  u'killingSprees': 2,
  u'largestKillingSpree': 3,
  u'largestMultiKill': 2,
  u'level': 13,
  u'magicDamageDealtPlayer': 39300,
  u'magicDamageDealtToChampions': 13151,
  u'magicDamageTaken': 7341,
  u'minionsKilled': 95,
  ...
}

These will be singly present for each match.

However, for any given match, in addition to the above data, there is 
another JSON object that I receive, listing the # of "fellowPlayers" 
(teammates and/or opponents) which can vary from 0-11 inclusive. For every 
fellowPlayer, their championId and summonerId would be linked to the model. 
These are the character they controlled in that game, and the actual player 
controlling said character. teamId can only have 1 of 2 values (constants). 

On Wednesday, April 16, 2014 7:34:30 PM UTC-4, Kreychek wrote:
>
> Let's say I'm getting some JSON in the format of...
>
> "fellowPlayers": [
> {
>"championId": 110,
>"teamId": 100,
>"summonerId": 34258805
> },
> {
>"championId": 9,
>"teamId": 100,
>"summonerId": 19923759
> },
> {
>"championId": 46,
>"teamId": 200,
>"summonerId": 2112359
> },
> ...]
>
> ...that can have a variable # of entries (from 0-11, inclusive), but each 
> entry has those 3 attributes, 2 of which should map to other tables 
> (championId and summonerId).
>
> *How would I want to define a table/model in Django to store the list of 
> fellowPlayers (of unknown length)?*
>
> If any more information is needed please comment.
>
> If this can't be directly done, how would you suggest handling such a 
> situation? My initial thought was to hardcore in a # of fields 
> (fellow_player_1, fellow_player_2, etc) based on what I expect the maximum 
> # of entries to be, but that approach seems like it could be improved on a 
> lot, although 11 isn't too bad in terms of hardcoding.
>

-- 
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/965e674e-f289-447a-92cf-763d5a9d8f5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Including Page Fragments

2014-04-16 Thread Venkatraman S
Just saw a weird problem while including template fragments:

Works :
  {% include "page.html" with one_variable="1" %}

Does not because of the space during the variable assignment :
   {% include "page.html" with one_variable = "1" %}

Regards,
Venkat

-- 
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/CAN7tdFT-kAGYgw6nioN-JK4a8LSK1_jadx6u0J7fnSt7%2Bo6%3D5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upgrading from 1.4.3 to 1.4.10

2014-04-16 Thread nu . everest
Thanks those release notes were very helpful.



On Wednesday, April 16, 2014 7:08:22 AM UTC-7, nu.ev...@gmail.com wrote:
>
> How do I discover what changed between Django 1.4.3 and 1.4.10?
>
> Will require changes to my code, or will it just work?
>

-- 
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/d0386985-dba7-4a51-b32e-9e8604fa6764%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create Union in Django queryset

2014-04-16 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 
> > 
> 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.