Re: Extension to QuerySet.values()

2013-10-09 Thread Russell Keith-Magee
Hi Arnaud,

I can see value in the feature you're describing here.

>From a design perspective, my question would be whether a whole new method
is needed, or whether it could be integrated into the existing values()
method. There will be some complications around the 'flat' key, but its
worth exploring the possibilities before we introduce a whole new API entry
point.

If you're interested in taking this to the next level, we'll need tests and
documentation for the new feature. If you want to discuss finer details of
the API, the django-developers mailing list is a better forum. Our
contribution process is also documented; if you want to get involved in
contributing to the internals of Django, it's worth giving this document a
read [1].

[1] https://docs.djangoproject.com/en/1.5/internals/contributing/

Yours,
Russ Magee %-)

On Wed, Oct 9, 2013 at 6:19 PM, Arnaud Delobelle  wrote:

> Hi there,
>
> I quite often find that when using queryset.values() I would like to be
> able to define myself the values of the keys, especially when they span
> models:
>
> e.g.
>
>my_query_set.values('foo__bar__baz', 'quux',
> 'another__long__field__name')
>
> Then I end up with dictionaries with unnecessarily long keys.  What I'd
> like to be able to do is something like:
>
> my_query_set.values('quux', baz='foo__bar__baz',
> name='another__long__field__name')
>
> Executing this would yield dictionaries of the type:
>
> {'quux': 2, 'baz': 'type 2', 'name': 'Frobulon'}
>
>
> I've had a quick look at the ValuesQuerySet class and there seems to be a
> simple enough way to get this feature.  I'm presenting it in the form of a
> new ValuesQuerySet subclass and a monkey patch to the parent QuerySet.
>  It's not unlikely that it will break some things as this is my first peek
> into the QuerySet class.  I'd like to know if this is something that other
> people feel the need for and if it is worth pushing for inclusion of such a
> feature into django.
>
> Cheers,
>
> Arnaud
>
> 
>
> from django.db.models.query import QuerySet, ValuesQuerySet
>
>
> class ValuesDictQuerySet(ValuesQuerySet):
>
> def iterator(self):
> # Purge any extra columns that haven't been explicitly asked for
> extra_names = list(self.query.extra_select)
> field_map = self.field_map
> field_names = [field_map.get(fname, fname) for fname in
> self.field_names]
> aggregate_names = list(self.query.aggregate_select)
>
> names = extra_names + field_names + aggregate_names
>
> for row in self.query.get_compiler(self.db).results_iter():
> yield dict(zip(names, row))
>
> def _clone(self, klass=None, setup=False, **kwargs):
> c = super(ValuesDictQuerySet, self)._clone(klass, **kwargs)
> c.field_map = self.field_map
> return c
>
>
> def QuerySet_values_dict(self, *field_list, **field_dict):
> fields = list(field_list)
> fields.extend(field_dict.values())
> field_map = dict(zip(field_dict.values(), field_dict.keys()))
> return self._clone(klass=ValuesDictQuerySet, setup=True,
> _fields=fields, field_map=field_map)
>
>
> # Now we monkey-patch QuerySet with the new method
> QuerySet.values_dict = QuerySet_values_dict
>
>  --
> 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/d4f8d6f0-3723-44d5-991a-9c6b3c13165d%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAJxq848VVVdKcAPRGnV5i7%2BfhLXvm28__De7ey91nYd-rXeZKA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Implementation of a Search Engine. How??

2013-10-09 Thread Kelvin Wong
Look up Solr because it does everything you want. You can crawl with Nutch. 
Django can be used as a front end to that.

http://en.wikipedia.org/wiki/Apache_Solr

K


On Wednesday, October 9, 2013 11:57:25 AM UTC-7, Mithil Bhoras wrote:
>
> Hello, I am a newbie in Django. I am required to do a project in Python 
> and I've chosen Django as the Web Framework. My project is a 'Smart' Search 
> Engine that retrieves results most relevant to user's query. This website 
> will:
>
>1. Index all the web pages available
>2. Use Page Ranking algorithm to update the database as the user uses 
>it
>3. Give suggestions for more appropriate queries based on the most 
>recent queries that other users world wide entered.
>4. Correct queries if user makes a spelling mistake.
>
>

-- 
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/3f55fdc5-ec38-4edd-861c-8cc5e1d16deb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Retrieving json stored in TextField as json

2013-10-09 Thread Rafael Durán Castañeda
I'm using django-json-field [1] for solving the same problem.

[1] https://github.com/derek-schaefer/django-json-field

HTH
El 09/10/2013, a las 16:01, Marc Aymerich  escribió:

> Hi,
> I'm storing large volumes of json data in a TextFields, Then I have a
> view that converts this text data into JSON, but this silly operation
> requires a considerable amount of resources for a large dataset.
> 
> It would be nice if I'm able to retrieve native JSON directly from the 
> database.
> 
> As you can see value is "almost" json, the only problem is that is
> wrapped around quotes :)
> 
 TimeSerie.objects.filter(type='cpu').values('value')
> [{'value': '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
> {'value': '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
> {'value': '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'},
> {'value': '{"scheduled":2,"total":814,"15min":0.3,"1min":0.2,"5min":0.25}'},
> {'value': '{"scheduled":2,"total":817,"15min":0.25,"1min":0.14,"5min":0.17}'},
> {'value': '{"scheduled":2,"total":815,"15min":0.22,"1min":0.18,"5min":0.14}'}]
> 
> Any suggestion in how I can speed this up by avoiding to convert each
> element to json by iterating on the query results?
> 
> I'm using psotgresql 9.3 with native json support, not sure if it is
> relevant or not :)
> 
> -- 
> Marc
> 
> -- 
> 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%2BDCN_vTbC0-yOt7cuToYLZSOD%2B%3DZCubLOjgkpu-MyB1VxbGMA%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/646FABCC-B4DB-4EE7-BC54-B0C5A2C7C25F%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Implementation of a Search Engine. How??

2013-10-09 Thread Patrick Müssig
Hi,

maybe is http://yacy.net/ what are you looking for. You can use Yacy as
Searchengine and fetch over the yacy API the data. Yacy has also a good
crawler to crawling webpages and indexing this pages.

greetz
Patrick Müssig


2013/10/9 Mithil Bhoras 

> Hello, I am a newbie in Django. I am required to do a project in Python
> and I've chosen Django as the Web Framework. My project is a 'Smart' Search
> Engine that retrieves results most relevant to user's query. This website
> will:
>
>1. Index all the web pages available
>2. Use Page Ranking algorithm to update the database as the user uses
>it
>3. Give suggestions for more appropriate queries based on the most
>recent queries that other users world wide entered.
>4. Correct queries if user makes a spelling mistake.
>
> We are a team of four under-graduates in our final year of engineering
> trying to implement this web search engine site. Being new to Django, I've
> no idea how I can achieve this. Of course, I've gone through the Django
> documentations, various tutorials on other web pages and familiarized my
> self with the basics by building simple apps like a Blog. I've a basic
> knowledge of Python and Html so problem there. But I don't know how to go
> ahead from there as I've no idea where to start. Can anyone just tell me or
> at least give me a hint of how I can make this possible? Like how do manage
> the database (I'm using SQLite3), make a form to get input query from the
> user or how do I display the search results? Thanks in advance!
>
> --
> 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/0a3daa6b-2c77-4d21-8cfa-466c2e8c86c1%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CACtvhK5cPUSJrZrZRJShHyP34iyu1_XfPY9L2yv5fxbKKMmZYg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Nested includes and captured parameters

2013-10-09 Thread Jason Mayfield
Nevermind.  Discovered typo in a URLconf regex that was causing the problem.

On Wednesday, October 9, 2013 2:41:45 PM UTC-4, Jason Mayfield wrote:
>
> The docs state that "An included URLconf receives any captured parameters 
> from parent URLconfs".  And that does work as expected, when the child 
> URLconf makes immediate use of the parameter -- that is, the child URLconf 
> is a terminal node and doesn't include any further child URLconfs.
>
> In my particular use-case, I find myself needing to use two levels of 
> URLconf includes, and when I do this, the captured parameter seems to get 
> lost along the way.
>
> Examples:
>
> a)  In this scenario, "my_view" gets app1_pk passed in kwargs (expected 
> behavior).
>
> root urls.py:
> …
> url(r'^app1/(?P\d+)/app2/', include('app2.urls')),
> …
>
> app2.urls.py:
> …
> url(r'^my_view/$', 'app2.views.my_view'),
> …
>
> b)  In this scenario (my use-case), "my_view" does not get app1_pk passed 
> in kwargs (but I do not expect this to be the correct behavior).
>
> root urls.py:
> …
> url(r'^app1/', include('app1.urls')),
> …
>
> app1.urls.py:
> …
> url(r'^(?P\d+)/app2/', include('app2.urls')),
> …
>
> app2.urls.py:
> …
> url(r'^my_view/$', 'app2.views.my_view'),
> …
>
> Is this expected behavior?  Any thoughts?
>
> Thanks in advance,
> Jason
>

-- 
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/97f5aed4-bf7b-462f-9e15-642c2786b596%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Nested includes and captured parameters

2013-10-09 Thread Jason Mayfield
The docs state that "An included URLconf receives any captured parameters 
from parent URLconfs".  And that does work as expected, when the child 
URLconf makes immediate use of the parameter -- that is, the child URLconf 
is a terminal node and doesn't include any further child URLconfs.

In my particular use-case, I find myself needing to use two levels of 
URLconf includes, and when I do this, the captured parameter seems to get 
lost along the way.

Examples:

a)  In this scenario, "my_view" gets app1_pk passed in kwargs (expected 
behavior).

root urls.py:
…
url(r'^app1/(?P\d+)/app2/', include('app2.urls')),
…

app2.urls.py:
…
url(r'^my_view/$', 'app2.views.my_view'),
…

b)  In this scenario (my use-case), "my_view" does not get app1_pk passed 
in kwargs (but I do not expect this to be the correct behavior).

root urls.py:
…
url(r'^app1/', include('app1.urls')),
…

app1.urls.py:
…
url(r'^(?P\d+)/app2/', include('app2.urls')),
…

app2.urls.py:
…
url(r'^my_view/$', 'app2.views.my_view'),
…

Is this expected behavior?  Any thoughts?

Thanks in advance,
Jason

-- 
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/ebe111a9-b0f5-4a7b-9687-dc95ba1b016a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Implementation of a Search Engine. How??

2013-10-09 Thread Mithil Bhoras
Hello, I am a newbie in Django. I am required to do a project in Python and 
I've chosen Django as the Web Framework. My project is a 'Smart' Search 
Engine that retrieves results most relevant to user's query. This website 
will:

   1. Index all the web pages available
   2. Use Page Ranking algorithm to update the database as the user uses it
   3. Give suggestions for more appropriate queries based on the most 
   recent queries that other users world wide entered.
   4. Correct queries if user makes a spelling mistake.

We are a team of four under-graduates in our final year of engineering 
trying to implement this web search engine site. Being new to Django, I've 
no idea how I can achieve this. Of course, I've gone through the Django 
documentations, various tutorials on other web pages and familiarized my 
self with the basics by building simple apps like a Blog. I've a basic 
knowledge of Python and Html so problem there. But I don't know how to go 
ahead from there as I've no idea where to start. Can anyone just tell me or 
at least give me a hint of how I can make this possible? Like how do manage 
the database (I'm using SQLite3), make a form to get input query from the 
user or how do I display the search results? Thanks in advance!   

-- 
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/0a3daa6b-2c77-4d21-8cfa-466c2e8c86c1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Timothy W. Cook
In the ModelAdmin I use a get_form() to test for conditions on the object.
Specifically, if this item has been published then make it read_only.  You
should be able to test for users as well.

I had to add the try/except in order to add new objects because
obj.published doesn't exist on a new object.

See:
https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_form


Here is a snippet:
def get_form(self, request, obj=None, **kwargs):
try:
if obj.published:
self.readonly_fields =
['prj_name','published','schema_code','data_name','description','sem_attr','resource_uri','asserts',

'simple_units','coded_units','normal_status','reference_ranges','min_inclusive','max_inclusive',

'min_exclusive','max_exclusive','total_digits','fraction_digits','magnitude','error','accuracy','magnitude_status',]
except (AttributeError, TypeError) as e:
self.readonly_fields = ['published','schema_code']
return super(DvQuantityAdmin, self).get_form(request, obj, **kwargs)



On Wed, Oct 9, 2013 at 11:06 AM, Victor  wrote:

> Yes, I know but unfortunately if in Admin Site you say that a user cannot
> Add, Delete, and Modify a model if that user is connected he/she doesn't
> see the model itself in the list but only those models for which it has
> some kind of permission. I instead would like to make the model visible but
> not editable for that user.
>
> Ciao
> Vittorio
>
> Il giorno 09/ott/2013, alle ore 14:14, Rafael E. Ferrero ha scritto:
>
> > In Admin Site, you can manage users permissions for Add, Delete, Modify
> of every model on your site.
> >
> >
> > 2013/10/9 Vittorio 
> > For the sake of simplicity let's suppose I have
> >
> > models.py
> >
> > class Book(models.Model):
> > title = models.CharField(max_length=100)
> > authors = models.ManyToManyField(Author)
> > publisher = models.ForeignKey(Publisher)
> >
> > Under admin I would like that some username (say "vic" and  "lucky") can
> edit every field of the change form while other users ("tom","sue") can
> only visualize the same data without modification.  I think to put some "if
> condition" in admin.py of this kind
> >
> >
> > class BookOption(admin.ModelAdmin):
> >if username  in ["tom", "sue"]:
> > readonly_fields = ['title','authors','publisher']
> > fields=(('title'),('authors', 'publisher'))..
> > .
> >admin.site.register(Book,BookOption)
> >
> >
> > How can I do it?
> >
> > Ciao
> > Vittorio
> >
> > --
> > 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/F0A087D2-8E11-4B0B-8D95-6FC131854994%40de-martino.it
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> > --
> > Rafael E. Ferrero
> >
> > --
> > 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/CAJJc_8U3EbZXHVSucFndA25V%3DuYyen%3DGgUsyHmzLncD5DuGi2w%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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/B4D514E2-7FA0-4CB3-A83E-82442A8DAFC6%40gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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 

Re: Looking for a way to detect changes in database records with low storage footprint

2013-10-09 Thread Nikolas Stevenson-Molnar
A hash should work fine. Alternatively, you could diff the two records,
using something like difflib: http://docs.python.org/2/library/difflib.html

_Nik

On 10/9/2013 8:05 AM, DJ-Tom wrote:
> Hi,
>
> a customer has requested a function to "compare" reports.
>
> So let's say I create a database report on Monday, then the data is
> constantly changing the whole week and on the following Monday it
> should be possible to get a report that either contains only changed
> and new records or all records plus a column that indicates that
> something has changed.
>
> It is not important to know exactly which field has changed but only
> that something has changed.
>
> I'm already storing a "change_date" for each record, but this is also
> updated if the user just saves the same data again without actually
> changing any content.
>
> Also it is important to be able to not only compare based on
> date/time, but based on a specific reports status.
>
> So I thought about storing a hash value for every record for each
> report so I could compare this later on.
>
> Is there any functionality that makes creating this hash, e.g. by
> serializing each record into a string and creating a hash from this
> information?
>
> Or does someone have any other (better) idea how to implement this?
>
> Thanks
> Thomas
> -- 
> 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/c8051a13-ac70-4a7f-9498-000f135c1f4f%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/52558D6A.1030305%40consbio.org.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Table in models.py not being created during syncdb

2013-10-09 Thread Edward Lazarenko
Can you tell what did you exactly do, to make it work?

On Wednesday, March 31, 2010 10:16:11 PM UTC+5, wchildsuk wrote:
>
> Hi,
>
> I'm using the django app, django-schedule (http://github.com/thauber/
> django-schedule) and am adding an additional table to map users to
> calendars (see line 253 on dpaste).  When I run syncdb it completely
> ignores my table and doesn't through any errors. Can anyone shed any
> light on way it might be being igored?
>
> My models file is available here:
>
> http://dpaste.com/178158/
>
> Thanks in advance
>
> Wes
>
>

-- 
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/0573be21-ab52-44ec-a005-e8efb3ea09bd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Looking for a way to detect changes in database records with low storage footprint

2013-10-09 Thread DJ-Tom
Hi,

a customer has requested a function to "compare" reports.

So let's say I create a database report on Monday, then the data is 
constantly changing the whole week and on the following Monday it should be 
possible to get a report that either contains only changed and new records 
or all records plus a column that indicates that something has changed.

It is not important to know exactly which field has changed but only that 
something has changed. 

I'm already storing a "change_date" for each record, but this is also 
updated if the user just saves the same data again without actually 
changing any content. 

Also it is important to be able to not only compare based on date/time, but 
based on a specific reports status.

So I thought about storing a hash value for every record for each report so 
I could compare this later on.

Is there any functionality that makes creating this hash, e.g. by 
serializing each record into a string and creating a hash from this 
information?

Or does someone have any other (better) idea how to implement this?

Thanks
Thomas

-- 
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/c8051a13-ac70-4a7f-9498-000f135c1f4f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Ho can I reverse urls inside urls.py?

2013-10-09 Thread DJ-Tom
Hi Tom,

works like a charm - THX!

Cheers 
Thomas

Am Dienstag, 8. Oktober 2013 17:49:18 UTC+2 schrieb Tom Evans:
>
>
> Use reverse_lazy 
>
> https://docs.djangoproject.com/en/1.5/ref/urlresolvers/#reverse-lazy 
>
>
> Cheers 
>
> Tom 
>

-- 
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/8b8f5453-364e-4edb-8536-6bb6eee5de54%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Bill Freeman
It's easy, if you don't insist on making it part of the admin, to do this
with a custom view.  It can pay attention to whatever permissions you like.


On Wed, Oct 9, 2013 at 10:06 AM, Victor  wrote:

> Yes, I know but unfortunately if in Admin Site you say that a user cannot
> Add, Delete, and Modify a model if that user is connected he/she doesn't
> see the model itself in the list but only those models for which it has
> some kind of permission. I instead would like to make the model visible but
> not editable for that user.
>
> Ciao
> Vittorio
>
> Il giorno 09/ott/2013, alle ore 14:14, Rafael E. Ferrero ha scritto:
>
> > In Admin Site, you can manage users permissions for Add, Delete, Modify
> of every model on your site.
> >
> >
> > 2013/10/9 Vittorio 
> > For the sake of simplicity let's suppose I have
> >
> > models.py
> >
> > class Book(models.Model):
> > title = models.CharField(max_length=100)
> > authors = models.ManyToManyField(Author)
> > publisher = models.ForeignKey(Publisher)
> >
> > Under admin I would like that some username (say "vic" and  "lucky") can
> edit every field of the change form while other users ("tom","sue") can
> only visualize the same data without modification.  I think to put some "if
> condition" in admin.py of this kind
> >
> >
> > class BookOption(admin.ModelAdmin):
> >if username  in ["tom", "sue"]:
> > readonly_fields = ['title','authors','publisher']
> > fields=(('title'),('authors', 'publisher'))..
> > .
> >admin.site.register(Book,BookOption)
> >
> >
> > How can I do it?
> >
> > Ciao
> > Vittorio
> >
> > --
> > 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/F0A087D2-8E11-4B0B-8D95-6FC131854994%40de-martino.it
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> >
> > --
> > Rafael E. Ferrero
> >
> > --
> > 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/CAJJc_8U3EbZXHVSucFndA25V%3DuYyen%3DGgUsyHmzLncD5DuGi2w%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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/B4D514E2-7FA0-4CB3-A83E-82442A8DAFC6%40gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAB%2BAj0sAgp3NPgROdd4-ZuarKNGSe723Pon3aZA%2Bm1TqzGx5eg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ModelMultipleChoiceField ignore invalid choices?

2013-10-09 Thread David Cox
This could be handled in the form clean() and/or save() methods using a 
try/catch block and passing on thrown exceptions.  You'd have to figure out 
what would be an acceptable way to handle a form submission with an invalid 
selection, though.

On Monday, October 7, 2013 11:15:43 AM UTC-5, Jon Dufresne wrote:
>
> Hi, 
>
> I am using a ModelForm with a ModelMultipleChoiceField. I would like 
> for this field to silently ignore invalid choices instead of creating 
> a form error. Here is my use case: 
>
> * User A opens form select model choice 1, 2, and 3 
> * User B (different browser) deletes model choice 3 entirely from system 
> * User A submits form and receives error 
>
> I understand why this should be an error in the general case, but in 
> my case, I want this to silently ignore the invalid choice 3 and 
> continue with choice 1 and 2? Is this possible? 
>
> Thanks, 
> Jon 
>

-- 
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/2265a481-1774-4c0f-9e9b-dd2ff3e9b306%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Victor
Yes, I know but unfortunately if in Admin Site you say that a user cannot Add, 
Delete, and Modify a model if that user is connected he/she doesn't see the 
model itself in the list but only those models for which it has some kind of 
permission. I instead would like to make the model visible but not editable for 
that user.

Ciao
Vittorio 

Il giorno 09/ott/2013, alle ore 14:14, Rafael E. Ferrero ha scritto:

> In Admin Site, you can manage users permissions for Add, Delete, Modify of 
> every model on your site.
> 
> 
> 2013/10/9 Vittorio 
> For the sake of simplicity let's suppose I have
> 
> models.py
> 
> class Book(models.Model):
> title = models.CharField(max_length=100)
> authors = models.ManyToManyField(Author)
> publisher = models.ForeignKey(Publisher)
> 
> Under admin I would like that some username (say "vic" and  "lucky") can edit 
> every field of the change form while other users ("tom","sue") can only 
> visualize the same data without modification.  I think to put some "if 
> condition" in admin.py of this kind
> 
> 
> class BookOption(admin.ModelAdmin):
>if username  in ["tom", "sue"]:
> readonly_fields = ['title','authors','publisher']
> fields=(('title'),('authors', 'publisher'))..
> .
>admin.site.register(Book,BookOption)
> 
> 
> How can I do it?
> 
> Ciao
> Vittorio
> 
> --
> 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/F0A087D2-8E11-4B0B-8D95-6FC131854994%40de-martino.it.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
> 
> -- 
> Rafael E. Ferrero
> 
> -- 
> 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/CAJJc_8U3EbZXHVSucFndA25V%3DuYyen%3DGgUsyHmzLncD5DuGi2w%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/B4D514E2-7FA0-4CB3-A83E-82442A8DAFC6%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Retrieving json stored in TextField as json

2013-10-09 Thread Marc Aymerich
Hi,
I'm storing large volumes of json data in a TextFields, Then I have a
view that converts this text data into JSON, but this silly operation
requires a considerable amount of resources for a large dataset.

It would be nice if I'm able to retrieve native JSON directly from the database.

As you can see value is "almost" json, the only problem is that is
wrapped around quotes :)

>>> TimeSerie.objects.filter(type='cpu').values('value')
[{'value': '{"scheduled":2,"total":864,"15min":0.38,"1min":0.3,"5min":0.48}'},
{'value': '{"scheduled":2,"total":859,"15min":0.34,"1min":0.23,"5min":0.32}'},
{'value': '{"scheduled":2,"total":849,"15min":0.33,"1min":0.51,"5min":0.32}'},
{'value': '{"scheduled":2,"total":814,"15min":0.3,"1min":0.2,"5min":0.25}'},
{'value': '{"scheduled":2,"total":817,"15min":0.25,"1min":0.14,"5min":0.17}'},
{'value': '{"scheduled":2,"total":815,"15min":0.22,"1min":0.18,"5min":0.14}'}]

Any suggestion in how I can speed this up by avoiding to convert each
element to json by iterating on the query results?

I'm using psotgresql 9.3 with native json support, not sure if it is
relevant or not :)

-- 
Marc

-- 
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%2BDCN_vTbC0-yOt7cuToYLZSOD%2B%3DZCubLOjgkpu-MyB1VxbGMA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-09 Thread David Cox
I just rtfc, and it might have been a copy-paste mistake, but the 
'str_value' field in your 'DirEnumVal' class has unmatched quotation marks 
for the default attribute.

On Monday, October 7, 2013 8:40:33 PM UTC-5, Doug S wrote:
>
> I don't think I'm making a rookie mistake, I've looked over my code 
> several times.
> I've got two pretty simple django models that are just failing to sync to 
> the db
> during the syncdb there are no errors, even with --verbosity 3
> When I try to make a relation to them I get an error saying the models 
> either don't exist or a re abstract
> In fact when I examine the DB, they are not there.
> syncdb is attempting to sync models before and after these 2 models in the 
> same file.
> I've dropped my DB and started from scratch several times
> I don't know how to debug this issue because I don't know how syncdb works 
> under the covers and what can go wrong.
> Here are my models, they look pretty simple to me:
>
> class DirEnumVal(models.Model):
>
> str_val = models.CharField(max_length=64, default='')
>
> def unicode(self):
>
> return self.str_val
>
> class DirAttr(models.Model):
>
> 
>
> BOOL = 'BOOL'
>
> MONO = 'MONO'
>
> SCAL = 'SCAL'
>
> ENUM = 'ENUM'
>
> 
>
> TYPES = (
>
> (BOOL,'Boolean'),
>
> (MONO,'Monomial'),
>
> (SCAL,'Scalar'),
>
> (ENUM,'Enumeration'),
>
> )
>
> 
>
> val_type = models.CharField(max_length=4, choices=TYPES)
>
> val_key = models.CharField(max_length=32)
>
> default_bool = models.BooleanField(default=True)
>
> default_num = models.IntegerField(default = 0)
>
> default_float = models.FloatField(default=1.0)
>
> enum_choices = models.ManyToManyField(DirEnumVal, null=True, blank=
> True)
>
> default_choice = models.CharField(max_length=64, default='')
>
> required = models.BooleanField(default=True)
>
> 
>
> def unicode(self):
>
> return '{k} :=> {t} ( default = {d} )'.format(
>
> k=self.val_key, t=self.val_type, d=self.default())
>
> I am using a pattern with multiple model files for a single app
>
> my dir structure is:
>
> >app
>
>  > models
>
> - __init__.py 
>
> - model_file1.py
>
> - model_file2.py
>
> and in my __init__.py I've got code to pull all the models together into 
> one module:  app.models
>
>   from __future__ import absolute_import
>
>   from .model_file1 import model1a,model1b,model1c
>
>   from .model_file2 import model2a,model2b,model2c
>
> This way of importing the models has been working long before this trouble 
> of models not being synched came up.
>
> When I access the django project and settings through a python shell I can 
> import the models and instatiate them
>
> but when I save them, PostGres gives me this error:
>
> DatabaseError: current transaction is aborted, commands ignored until end of 
> transaction block
>
>
> This problem surfaced after I installed django-categories and set up some 
> category models.
>
> I had some trouble at first setting that up but I've got the BaseCategory 
> subclasses behaving nicely now
>
> and have started with a fresh DB.
>
> At some point when I was getting django categories to work there was an error 
> when I synched the DB
>
> that said something about an unexcepted special character being somewhere in 
> my code or the django-categories code.
>
> That seemed suspicious but that doesn't show up anymore and I'm using a fresh 
> DB.
>
>
> Does anybody see anything obvious or know what type of problems can cause 
> syncdb to ignore models?
>
> I'm running out of ideas about what is wrong
>
> I'm on Django 1.5 using PostGreSQL & MacOS Lion
>
> Best Doug
>

-- 
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/f187fd4d-9d8f-4047-ba97-05ef5a8f30c9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-09 Thread David Cox
There's a chance that running 'manage.py sqlall' might show errors that 
syncdb can't display before failing.  'manage.py sqlall' validates the SQL 
without trying to commit it, so to save time in the future, you should 
really run it before syncdb every time.

If not, and the app is installed, check import statements, then model field 
constraints, like trying to assign numbers to 'null' fields or violating 
'unique' constraints.

Since the db sync is failing on transaction commit, it sounds more like the 
latter than the former, though.  Good luck.

On Monday, October 7, 2013 8:40:33 PM UTC-5, Doug S wrote:
>
> I don't think I'm making a rookie mistake, I've looked over my code 
> several times.
> I've got two pretty simple django models that are just failing to sync to 
> the db
> during the syncdb there are no errors, even with --verbosity 3
> When I try to make a relation to them I get an error saying the models 
> either don't exist or a re abstract
> In fact when I examine the DB, they are not there.
> syncdb is attempting to sync models before and after these 2 models in the 
> same file.
> I've dropped my DB and started from scratch several times
> I don't know how to debug this issue because I don't know how syncdb works 
> under the covers and what can go wrong.
> Here are my models, they look pretty simple to me:
>
> class DirEnumVal(models.Model):
>
> str_val = models.CharField(max_length=64, default='')
>
> def unicode(self):
>
> return self.str_val
>
> class DirAttr(models.Model):
>
> 
>
> BOOL = 'BOOL'
>
> MONO = 'MONO'
>
> SCAL = 'SCAL'
>
> ENUM = 'ENUM'
>
> 
>
> TYPES = (
>
> (BOOL,'Boolean'),
>
> (MONO,'Monomial'),
>
> (SCAL,'Scalar'),
>
> (ENUM,'Enumeration'),
>
> )
>
> 
>
> val_type = models.CharField(max_length=4, choices=TYPES)
>
> val_key = models.CharField(max_length=32)
>
> default_bool = models.BooleanField(default=True)
>
> default_num = models.IntegerField(default = 0)
>
> default_float = models.FloatField(default=1.0)
>
> enum_choices = models.ManyToManyField(DirEnumVal, null=True, blank=
> True)
>
> default_choice = models.CharField(max_length=64, default='')
>
> required = models.BooleanField(default=True)
>
> 
>
> def unicode(self):
>
> return '{k} :=> {t} ( default = {d} )'.format(
>
> k=self.val_key, t=self.val_type, d=self.default())
>
> I am using a pattern with multiple model files for a single app
>
> my dir structure is:
>
> >app
>
>  > models
>
> - __init__.py 
>
> - model_file1.py
>
> - model_file2.py
>
> and in my __init__.py I've got code to pull all the models together into 
> one module:  app.models
>
>   from __future__ import absolute_import
>
>   from .model_file1 import model1a,model1b,model1c
>
>   from .model_file2 import model2a,model2b,model2c
>
> This way of importing the models has been working long before this trouble 
> of models not being synched came up.
>
> When I access the django project and settings through a python shell I can 
> import the models and instatiate them
>
> but when I save them, PostGres gives me this error:
>
> DatabaseError: current transaction is aborted, commands ignored until end of 
> transaction block
>
>
> This problem surfaced after I installed django-categories and set up some 
> category models.
>
> I had some trouble at first setting that up but I've got the BaseCategory 
> subclasses behaving nicely now
>
> and have started with a fresh DB.
>
> At some point when I was getting django categories to work there was an error 
> when I synched the DB
>
> that said something about an unexcepted special character being somewhere in 
> my code or the django-categories code.
>
> That seemed suspicious but that doesn't show up anymore and I'm using a fresh 
> DB.
>
>
> Does anybody see anything obvious or know what type of problems can cause 
> syncdb to ignore models?
>
> I'm running out of ideas about what is wrong
>
> I'm on Django 1.5 using PostGreSQL & MacOS Lion
>
> Best Doug
>

-- 
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/406e8976-2dad-4e9b-80ed-87f3a1ec869c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Rafael E. Ferrero
In Admin Site, you can manage users permissions for Add, Delete, Modify of
every model on your site.


2013/10/9 Vittorio 

> For the sake of simplicity let's suppose I have
>
> models.py
>
> class Book(models.Model):
> title = models.CharField(max_length=100)
> authors = models.ManyToManyField(Author)
> publisher = models.ForeignKey(Publisher)
>
> Under admin I would like that some username (say "vic" and  "lucky") can
> edit every field of the change form while other users ("tom","sue") can
> only visualize the same data without modification.  I think to put some "if
> condition" in admin.py of this kind
>
>
> class BookOption(admin.ModelAdmin):
>if username  in ["tom", "sue"]:
> readonly_fields = ['title','authors','publisher']
> fields=(('title'),('authors', 'publisher'))..
> .
>admin.site.register(Book,BookOption)
>
>
> How can I do it?
>
> Ciao
> Vittorio
>
> --
> 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/F0A087D2-8E11-4B0B-8D95-6FC131854994%40de-martino.it
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero

-- 
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/CAJJc_8U3EbZXHVSucFndA25V%3DuYyen%3DGgUsyHmzLncD5DuGi2w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-10-09 Thread Jorge Arevalo
Interesting! I'm downloading it. Many thanks!

On Thursday, September 26, 2013 7:54:55 PM UTC+2, Ezequiel wrote:
>
> On Wednesday, September 25, 2013 3:06:55 PM UTC-3, Jorge Arevalo wrote:
>
>> Fine. I don't think my boss is going to pay for PyCharm license, so I'll 
>> probably go for Eclipse now (I don't really like it too much, but if works, 
>> it's ok for me)
>>
>
> PyCharm, which is my favorite IDE, has now a Free Community Edition: 
> https://twitter.com/pycharm/status/382549991165673472
>
> Best,
> Ezequiel
> http://flickrock.com/mikelpierre
>

-- 
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/3899d79b-7f64-451a-9ef3-f29a4d375956%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-10-09 Thread Jorge Arevalo
Yep. VirtualEnvWrapper looks like a winner. And thanks for the suggestion 
about the requirements.txt

On Thursday, September 26, 2013 1:36:21 PM UTC+2, Dump wrote:
>
> I have the same stack, GeoDjango + PostGIS (and all its dependencies like 
> GDAL, Proj, GEOS, etc). My notebook runs Debian (also I have a Mac Book 
> Pro, but I prefer to work on Linux) and I use Digital Ocean to host my 
> projects, also running Debian boxes. Since Debian keeps an older version of 
> PostGIS, I have created my own .deb package of PostGIS 2.1. 
>
> IMHO VirtualEnv and VirtualEnvWrapper is the best way to keep your 
> environment updated with the same versions. I also keep a requirements.txt 
> file into the project (I use Git and Bitbucket) with the output of pip 
> freeze command.  
>
> best regards,
>
>
> On 25 September 2013 15:01, Jorge Arevalo  > wrote:
>
>> Hello,
>>
>> First of all, many thanks for your response. Sorry for the delay 
>> answering this. I was in a business trip. 
>>
>> So, you basically have 2 environments: your own machine, and the Linode 
>> box. You make the development and testing in your machine, and Linode is 
>> for production purposes. And you connect both environments via dvcs 
>> push/pull. Right?
>>
>> I like it because it's simple and doesn't seem to be specially prone to 
>> errors. I'd just like to add a third scenario here, to end up with:
>>
>> - Development environment: my own machine (Mac OS X) with all the 
>> software stack installed.
>> - Testing environment: my new addition. I would like to put this 
>> environment outside of my machine
>> - Production environment: the Linode box.
>>
>> I can do the communication via push/pull, if there's no other way to 
>> "deploy" software to production with Python/Django (it's simple, I like 
>> it). And maybe I can have 2 urls (testing and production) in the Linode 
>> box. Testing just accessible to developers and testers, and production open 
>> to normal users. Does it make sense?
>>
>> Thanks again
>>
>> On Tuesday, September 17, 2013 3:50:55 PM UTC+2, Vernon D. Cole wrote:
>>>
>>>
>>> I installed a client for my favourite distributed version control system 
>>> on my Linode instance.  I have a private repository on a public IP.  
>>> (github, bitbucket, or launchpad will work, depending on your dvcs of 
>>> choice -- I have used all three, and other times I have used a private dvcs 
>>> host, including my Linode server itself.) I "cloned" a "checkout" of my 
>>> django system to the Linode. When I am happy from testing a new version of 
>>> my application:  I push it to the repository,  log in to my Linode using 
>>> ssh, and do a pull.  Easy and error free.  (My django environment is almost 
>>> exactly like yours with PostGIS, etc.)
>>> --
>>>
>>> On Monday, September 16, 2013 6:33:49 PM UTC+1, Jorge Arevalo wrote:

 Hello,

 I'm going to start a project based on (Geo)Django + PostgreSQL/PostGIS 
 + OpenLayers/LeafLet + Bootstrap/Foundation. The project will be deployed 
 to a Linode box. That box will be created with something like this: 
 https://manager.linode.**com/linodes/deploy/**
 linode393074?StackScriptID=**6482

 My work box is a MacBook with Mac OS X 10.6.8. There will be 2 people 
 working on the web app (me and another guy). I have almost total freedom 
 to 
 choose, so I want to choose wisely. The whole point is that these 
 constraints should be satisfied:

 - I need a reliable way to upload the application to the 
 test/production environments. At least the production environment will be 
 a 
 Linode box. I just don't want to upload files via FTP, or manually copy 
 them with rsync, or any other practice easily subject to errors. How do 
 the 
 professional django developers set up their environment in order to deploy 
 the app?

 - I'm not sure about which IDE/editor choose. I don't want to start an 
 editor war, and I've used several options in the past. My main interest 
 is: 
 I want to focus on develop. If Eclipse/Aptana/Eric/PyCharm/**any IDE 
 can be easily "linked" to my environment, that's my choice. For example, 
 if 
 I can deploy my app to test/production environment with a couple of clicks 
 or commands, thanks to a plugin or script, that's great. Like deploying to 
 Heroku or EC2, but with Linode. Is there any IDE specially friendly with 
 this kind of development environment?

 - The other(s) developer(s) must be up ASAP. They can't spend 
 half a day installing and configuring stuff to start being productive. I 
 guess a VirtualBox machine + Vagrant would be a good choice here. But, 
 would it make more difficult the deployment cycle? And using a virtual 
 machine to just open the IDE and develop sounds like a resource waste to 
 me. Is there 

Re: Recommended dev environment for a Django project deployed to Linode

2013-10-09 Thread Jorge Arevalo
Tested. Works great. Thanks a lot!

On Thursday, September 26, 2013 1:13:58 AM UTC+2, Cal Leeming [Simplicity 
Media Ltd] wrote:
>
> +1 for virtualenvwrapper, don't know how I survived without this!!
>
> Cal
>
>
> On Wed, Sep 25, 2013 at 9:59 PM, Roberto López López 
>  > wrote:
>
>>  
>> Check virtualenvwrapper
>>
>> http://virtualenvwrapper.readthedocs.org/en/latest/
>>
>>
>>
>>
>> On 09/25/2013 08:06 PM, Jorge Arevalo wrote:
>>  
>> Fine. I don't think my boss is going to pay for PyCharm license, so I'll 
>> probably go for Eclipse now (I don't really like it too much, but if works, 
>> it's ok for me) 
>>
>>  About virtualenv, is there any method to provide something like a 
>> script to create a virtualenv, install the needed software and have a 
>> working environment in a few commands? Something like "vagrantfile for 
>> virtualenv" http://docs.vagrantup.com/v2/vagrantfile/index.html
>>
>>  Again, many thanks for your useful insights
>>
>> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote: 
>>>
>>>  Answering the other half of your question:  The choice of IDE is not 
>>> nearly as important as its ease of integration with your dvcs.  If you are 
>>> already familiar with a good one, don't change.
>>>
>>> On my present project, my boss and I are both using PyCharm, and my 
>>> other co-worker is using Eclipse, since he is more comfortable (and 
>>> therefore, more productive) with it. Both IDE's have good integration with 
>>> git (my least favourite dvcs, but the boss's choice) and our sharing is 
>>> done using a group private repository on github.  This is on Ubuntu Linux, 
>>> it all works well.   In the evening hours, I use PyCharm on Windows 7 to 
>>> contribute to an open source project hosted on bitbucket using mercurial. 
>>> Both projects end up being tested on the same Linode.
>>>
>>> Yes, use virtualenv.  I also made the mistake of thinking of it as a 
>>> virtual computer.  It is not.  It is only a method of separating Python 
>>> library directories so that you can experiment with different 
>>> configurations easily.  It does not slow anything down, and actually makes 
>>> installation of packages easier.  Use virtualenvwrapper to make switching 
>>> environments easy.  PyCharm also supports virtual environments as well as 
>>> django projects. It is commercial, and suffers from a few Java 
>>> idiosyncrasies, but the boss paid for the license ;-) so I don't mind.
>>>
>>>-- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>> -- 
>>
>> Roberto López López
>> System Developer
>> Parallab, Uni Computing+47 55584091
>>
>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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/7d351100-bf3a-48a7-8001-822c909b7cde%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Recommended dev environment for a Django project deployed to Linode

2013-10-09 Thread Jorge Arevalo
Thanks both for the suggestions! (and sorry for the delay, I was on a 
business trip). Looks like there's a lot of things to learn. I'll probably 
use a staging machine, like suggested. And now I'm between Eclipse, emacs 
and PyCharm. Time to work!

On Wednesday, September 25, 2013 9:48:26 PM UTC+2, Vernon D. Cole wrote:
>
> Yes, I like to have three levels, too.  I call the middle one "staging".  
> You can tear it down and build it up again as many times as needed to get 
> it right.
>
> A ten-year-old PC will work fine for staging practice. Blow the dust out 
> (the dust affects cooling and leads to poor reliability), load Ubuntu, and 
> park it in an unused corner somewhere.  My home-office Linux box is a Dell 
> desktop purchased at a University surplus sale for $20 six or seven years 
> ago. It runs Apache, MySQL, Asterisk, and the Python program that regulates 
> the lights and heat in our Iguana enclosure. The most expensive component 
> (other than the iguana) is a $50 UPS.  Much easier than trying to make your 
> production machine do double duty.
>
> I use a structured settings module to switch back-and-forth between the 
> three levels.  Look at the manage.py and the formhub/settings directory in 
> https://github.com/vernondcole/formhub for an example how to do that.   
> Also look at requirements.pip in that repository for an idea how to load 
> most of the prerequisites automatically. Documentation is in the wiki of 
> https://github.com/modilabs/formhub/wiki/_pages .  (Formhub is a django 
> system used to receive generic survey data taken using android devices 
> offline.)
>
>
>
>
> On Wed, Sep 25, 2013 at 12:49 PM, Bill Freeman  > wrote:
>
>> I guess that it's what you're used to.  I'm perfectly happy with emacs 
>> (less so with vi or vim, but still happy enough).  I'm happy with emac's 
>> python mode, css mode, etc.  There's even supposed to be help for Django 
>> templates now.  I'm using the Espresso add-on for JavaScript.  It's not 
>> everything that the IDEs offer, but I don't have to keep re-learning how to 
>> do things.  vim has some pretty good syntax support too.  I certainly 
>> wouldn't pay for something.  And having installed eclipse, it makes emacs 
>> look light weight.
>>
>> Indeed, I, too, tend to develop and test on my laptop, when I'm happy, 
>> check in my chaanges (mercurial), push to the linode, ssh in, update to 
>> head, and touch the wsgi script file (IIRC).  In a pinch I can directly 
>> edit on the linode, using vim through ssh, or emacs tramp mode over ssh, 
>> or, if you want to install your favorite X based editor on the linode, 
>> through a ssh -Y tunnel.
>>
>> Bill, the curmudgeon
>>
>>
>> On Wed, Sep 25, 2013 at 2:06 PM, Jorge Arevalo 
>> > > wrote:
>>
>>> Fine. I don't think my boss is going to pay for PyCharm license, so I'll 
>>> probably go for Eclipse now (I don't really like it too much, but if works, 
>>> it's ok for me)
>>>
>>> About virtualenv, is there any method to provide something like a script 
>>> to create a virtualenv, install the needed software and have a working 
>>> environment in a few commands? Something like "vagrantfile for virtualenv" 
>>> http://docs.vagrantup.com/v2/vagrantfile/index.html
>>>
>>> Again, many thanks for your useful insights
>>>
>>>
>>> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:

 Answering the other half of your question:  The choice of IDE is not 
 nearly as important as its ease of integration with your dvcs.  If you are 
 already familiar with a good one, don't change.

 On my present project, my boss and I are both using PyCharm, and my 
 other co-worker is using Eclipse, since he is more comfortable (and 
 therefore, more productive) with it. Both IDE's have good integration with 
 git (my least favourite dvcs, but the boss's choice) and our sharing is 
 done using a group private repository on github.  This is on Ubuntu Linux, 
 it all works well.   In the evening hours, I use PyCharm on Windows 7 to 
 contribute to an open source project hosted on bitbucket using mercurial. 
 Both projects end up being tested on the same Linode.

 Yes, use virtualenv.  I also made the mistake of thinking of it as a 
 virtual computer.  It is not.  It is only a method of separating Python 
 library directories so that you can experiment with different 
 configurations easily.  It does not slow anything down, and actually makes 
 installation of packages easier.  Use virtualenvwrapper to make switching 
 environments easy.  PyCharm also supports virtual environments as well as 
 django projects. It is commercial, and suffers from a few Java 
 idiosyncrasies, but the boss paid for the license ;-) so I don't mind.

  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group 

admin.py: putting "if condition" in ModelAdmin according to username

2013-10-09 Thread Vittorio
For the sake of simplicity let's suppose I have

models.py

class Book(models.Model):
title = models.CharField(max_length=100)
authors = models.ManyToManyField(Author)
publisher = models.ForeignKey(Publisher)

Under admin I would like that some username (say "vic" and  "lucky") can edit 
every field of the change form while other users ("tom","sue") can only 
visualize the same data without modification.  I think to put some "if 
condition" in admin.py of this kind


class BookOption(admin.ModelAdmin):
   if username  in ["tom", "sue"]:
readonly_fields = ['title','authors','publisher']
fields=(('title'),('authors', 'publisher'))..
.
   admin.site.register(Book,BookOption)


How can I do it?

Ciao
Vittorio

-- 
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/F0A087D2-8E11-4B0B-8D95-6FC131854994%40de-martino.it.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
Your right... I can't testing now.


2013/10/9 Hélio Miranda 

> gives error:
> 'BaseList' object has no attribute 'values'
>
> The query has to be the same as I stated it works:
> *
> Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
> *
>
> --
> 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/7a4cf4fe-0c5a-40ff-92fc-60c51164239f%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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%2BX6QOWHTn7xc%3DY11b8%2BU5sTP%3DCu03AhSvGM5F3R66wxO8AWUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
gives error:
'BaseList' object has no attribute 'values'

The query has to be the same as I stated it works:
*
Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
*

-- 
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/7a4cf4fe-0c5a-40ff-92fc-60c51164239f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
try this solution
http://plnkr.co/edit/cyM6AmZcyFVUU6soFKhB


2013/10/9 Denis Chernoshchekov 

> ok, i understand, i minute.
>
>
> 2013/10/9 Denis Chernoshchekov 
>
>> *fld_name = 'nationality_in' *must be with double '_'* **fld_name =
>> 'nationality__in'*
>>
>>
>> 2013/10/9 Denis Chernoshchekov 
>>
>>> Sorry, i don't understand you... You can control all your values for all
>>> fields, you can generate dict which you like.
>>>
>>>
>>> 2013/10/9 Hélio Miranda 
>>>
 I put that work, I wanted to know was how to put in the code, because
 you can not do the same to position

 --
 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/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
 .

 For more options, visit https://groups.google.com/groups/opt_out.

>>>
>>>
>>
>

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


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
ok, i understand, i minute.


2013/10/9 Denis Chernoshchekov 

> *fld_name = 'nationality_in' *must be with double '_'* **fld_name =
> 'nationality__in'*
>
>
> 2013/10/9 Denis Chernoshchekov 
>
>> Sorry, i don't understand you... You can control all your values for all
>> fields, you can generate dict which you like.
>>
>>
>> 2013/10/9 Hélio Miranda 
>>
>>> I put that work, I wanted to know was how to put in the code, because
>>> you can not do the same to position
>>>
>>> --
>>> 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/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
>>> .
>>>
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>

-- 
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%2BX6QOUf7Ck0Y9ptjn_FaJLEaPzPdmas01CRPW_QPNVg39%2BD8A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Extension to QuerySet.values()

2013-10-09 Thread Arnaud Delobelle
Hi there,

I quite often find that when using queryset.values() I would like to be 
able to define myself the values of the keys, especially when they span 
models:

e.g.

   my_query_set.values('foo__bar__baz', 'quux', 
'another__long__field__name')

Then I end up with dictionaries with unnecessarily long keys.  What I'd 
like to be able to do is something like:

my_query_set.values('quux', baz='foo__bar__baz', 
name='another__long__field__name')

Executing this would yield dictionaries of the type:

{'quux': 2, 'baz': 'type 2', 'name': 'Frobulon'}


I've had a quick look at the ValuesQuerySet class and there seems to be a 
simple enough way to get this feature.  I'm presenting it in the form of a 
new ValuesQuerySet subclass and a monkey patch to the parent QuerySet. 
 It's not unlikely that it will break some things as this is my first peek 
into the QuerySet class.  I'd like to know if this is something that other 
people feel the need for and if it is worth pushing for inclusion of such a 
feature into django.

Cheers,

Arnaud



from django.db.models.query import QuerySet, ValuesQuerySet


class ValuesDictQuerySet(ValuesQuerySet):

def iterator(self):
# Purge any extra columns that haven't been explicitly asked for
extra_names = list(self.query.extra_select)
field_map = self.field_map
field_names = [field_map.get(fname, fname) for fname in 
self.field_names]
aggregate_names = list(self.query.aggregate_select)

names = extra_names + field_names + aggregate_names

for row in self.query.get_compiler(self.db).results_iter():
yield dict(zip(names, row))

def _clone(self, klass=None, setup=False, **kwargs):
c = super(ValuesDictQuerySet, self)._clone(klass, **kwargs)
c.field_map = self.field_map
return c


def QuerySet_values_dict(self, *field_list, **field_dict):
fields = list(field_list)
fields.extend(field_dict.values())
field_map = dict(zip(field_dict.values(), field_dict.keys()))
return self._clone(klass=ValuesDictQuerySet, setup=True, 
_fields=fields, field_map=field_map)


# Now we monkey-patch QuerySet with the new method
QuerySet.values_dict = QuerySet_values_dict

-- 
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/d4f8d6f0-3723-44d5-991a-9c6b3c13165d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
*fld_name = 'nationality_in' *must be with double '_'* **fld_name =
'nationality__in'*


2013/10/9 Denis Chernoshchekov 

> Sorry, i don't understand you... You can control all your values for all
> fields, you can generate dict which you like.
>
>
> 2013/10/9 Hélio Miranda 
>
>> I put that work, I wanted to know was how to put in the code, because you
>> can not do the same to position
>>
>> --
>> 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/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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%2BX6QOW%3D_kZw7BWo6TWL3fzk92U89i7rqkw8yZ3jg-mxRuwKsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
Sorry, i don't understand you... You can control all your values for all
fields, you can generate dict which you like.


2013/10/9 Hélio Miranda 

> I put that work, I wanted to know was how to put in the code, because you
> can not do the same to position
>
> --
> 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/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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%2BX6QOVmFDZ5kexgJgiec9GeLazOcA7fgAVdp-Ybv%3DfUmgchig%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
was trying something like this:
*if fld_name == 'nationality':*
*fld_name = 'nationality_in'*
*value = 
Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name=value)))
*

But it does not 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/360f22d0-de14-4ec8-b9d4-3c4079f6ee39%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
I put that work, I wanted to know was how to put in the code, because you 
can not do the same to position

-- 
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/7ab55030-ef63-42de-b4b4-cad45b7c287c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
Try this - *Player.objects.filter(country__in=**
Nationality.objects.filter(name='Espanhola').distinct('country').values('country'))
*


2013/10/9 Hélio Miranda 

> yes, that was it ...
> Just one more thing, if I would like to create the nationality of the
> player, so that the filter is:
> *
> Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
> *
> *
> *
> where only the step nationality, as I do, not only gives an if?
>
> --
> 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/c8a6-6f7f-4603-9834-c94e426208e0%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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%2BX6QOVx4ad26UpgA6YEPvQy%3DjNiNfQADgaAPW%2B%2BBNe4xBtexQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
yes, that was it ...
Just one more thing, if I would like to create the nationality of the 
player, so that the filter is:
*
Player.objects.filter(country__in=Country.objects.filter(nationality__in=Nationality.objects.filter(name='Espanhola')))
*
*
*
where only the step nationality, as I do, not only gives an if?

-- 
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/c8a6-6f7f-4603-9834-c94e426208e0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
See, maybe like this?
http://plnkr.co/edit/cyM6AmZcyFVUU6soFKhB


2013/10/9 Hélio Miranda 

> I have code like this:
> http://plnkr.co/edit/L1ByIyFyaEdgwrfVU7Jr
>
> Just do not know how to put this part in the code ...
> Where do I put this part?
>
> --
> 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/5b896e03-fa40-4dbd-8075-8cad2ac954a8%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
I have code like this:
http://plnkr.co/edit/L1ByIyFyaEdgwrfVU7Jr

Just do not know how to put this part in the code ...
Where do I put this part?

-- 
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/5b896e03-fa40-4dbd-8075-8cad2ac954a8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
For position you may have dict like - **{' position__in ':
Position.objects. filter(name=positionpost) }
9 жовт. 2013 11:45, користувач "Hélio Miranda"  написав:

> hi, thanks that helped a lot.
> But I have a problem which is, for example when I do a filter by position,
> is not direct as other fields like name or surname. For the position I have
> to type this:
> *
> Player.objects.filter(position__in=Position.objects.filter(name=positionpost))
> *
> How can I implement this in code?
> Can you help me?
>
> --
> 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/f2e7c115-275d-4fab-9dab-f5c0a10c9544%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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%2BX6QOVRDjrjU3CrDZxsREHYMt5MzuJ5k3_14WPMSycO-fnKMg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
hi, thanks that helped a lot.
But I have a problem which is, for example when I do a filter by position, 
is not direct as other fields like name or surname. For the position I have 
to type this:
*
Player.objects.filter(position__in=Position.objects.filter(name=positionpost))
*
How can I implement this in code?
Can you help me?

-- 
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/f2e7c115-275d-4fab-9dab-f5c0a10c9544%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Denis Chernoshchekov
You can pass filter params like a dict -
Player.objects.filter(**your_dict), so you need only prepare your dict from
POST.
8 жовт. 2013 17:42, користувач "Hélio Miranda"  написав:

> Hi
> Here I am having a problem which is as follows:
> I 'm getting parameters via post to make querys depending on paramtros I
> are passed ... doing gender filters.
> So I'm doing well
> *def filter(request):*
> *if request.method == 'POST':*
> *namepost = request.POST.get('name')*
> *surnamepost = request.POST.get('surname')*
> *
> *
> *if namepost != None and surnamepost != None:*
> *result = [a.get_json() for a in
> Player.objects.filter((Q(name=namepost) & Q(surname=surnamepost)))]*
> *   elif namepost != None and surnamepost == None:*
> *result = [a.get_json() for a in
> Player.objects.filter(name=namepost)]*
> **
> *data = {"meta": {"total_count":len(result)}, "objects": result}*
> *aa = json.dumps(data)*
> *return HttpResponse(aa, content_type='application/json')*
>
> Is working properly , the problem is :
> If it were only these two parameters , there was no problem , was to
> complete the rest of the hypotheses ... the problem is that I can have up
> to 10 parameters passed by post to the filters , and I never know which are
> passed , can be 1 , 2, 4, ... as the user makes the filter ...
>
> But doing so would take a lot of ifs , it would have many chances ...
> is there any way I can do this another way ?
> Someone can help me ?
>
> --
> 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/fc851085-d5bb-4567-b830-d25cdd66e499%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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%2BX6QOXTgDCfXiB_CsqgRjg_V5ngho5gk%3DoZEfP8WhpwfcB2Kg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What is the right location for my django translation files?

2013-10-09 Thread Diederik van der Boor
You can place a new .po file in a `locale` folder of one of your INSTALLED_APPS.
This will be picked up, and can override the locale of mezzanine,
if your app is placed before mezzanine in INSTALLED_APPS.

Off course, run django-admin.py compilemessages in the root folder where the 
`locale` folder exists,
so the .mo file also exists and restart the runserver afterwards.

Greetings,
Diederik


Op 9 okt. 2013, om 08:41 heeft Anton Melser  het 
volgende geschreven:

> I'm giving my first steps with python/django/mezzanine so please bear with me.
> I modified a translation file of the mezzanine's blog application and 
> compiled it OK. Mind you: I literally only modified a couple of words and 
> left the rest intact.
> 
> The only place I found out I could place them in order to test was at the 
> blog app's locale folder 
> (~/MY_VIRTUAL_ENV/lib/python2.7/site-packages/mezzanine/blog/locale/es/LC_MESSAGES).
> 
> It worked fine, but my guts tell me there has to be a better way so I can 
> have this file(s) in some other location WITHIN my own mezzanine application 
> so:
> 
> I can easily maintain them and
> I don't have to keep my whole virtual environment in my SCM's repository.in 
> order to keep track of this single file with just a couple or words modified 
> and that will hardly ever get modified again.
> Great minds think alike? :-). I am in *exactly* the same situation - there 
> are a couple of translations I would like to change slightly in Mezzanine (a 
> capitalisation here, pluralisation there) and I had exactly the same thought. 
> I don't want to have to maintain something completely separately. Did you 
> find an elegant solution?
> 
> 
> -- 
> 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/80e29974-637f-49d4-83e8-f176829cb18e%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/5568572E-18F0-4147-AE21-B6C5BAE54598%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Query parameters for receiving post

2013-10-09 Thread Hélio Miranda
I was testing you sent me, but it is giving me error ... is giving this 
error: *expected string or buffer*

-- 
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/08b4c60e-585e-483c-b520-739a1efa615a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What is the right location for my django translation files?

2013-10-09 Thread Anton Melser

>
> I'm giving my first steps with python/django/mezzanine so please bear with 
> me.
>
> I modified a translation file of the mezzanine's blog application and 
> compiled it OK. Mind you: I literally only modified a couple of words and 
> left the rest intact.
>
> The only place I found out I could place them in order to test was at the 
> blog app's locale folder 
> (~/MY_VIRTUAL_ENV/lib/python2.7/site-packages/mezzanine/blog/locale/es/LC_MESSAGES).
>
> It worked fine, but my guts tell me there has to be a better way so I can 
> have this file(s) in some other location WITHIN my own mezzanine 
> application so:
>
>1. I can easily maintain them and
>2. I don't have to keep my whole virtual environment in my SCM's 
>repository.in order to keep track of this single file with just a 
>couple or words modified and that will hardly ever get modified again.
>
> Great minds think alike? :-). I am in *exactly* the same situation - there 
are a couple of translations I would like to change slightly in Mezzanine 
(a capitalisation here, pluralisation there) and I had exactly the same 
thought. I don't want to have to maintain something completely separately. 
Did you find an elegant solution?

-- 
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/80e29974-637f-49d4-83e8-f176829cb18e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: __unicode__() addition not working in basic poll application.

2013-10-09 Thread Nigel Legg
show us your code, and someone might show you where it is wrong, but the
tutorial is pretty clear on what you have to do.

Cheers, Nigel
07914 740972



On 8 October 2013 22:42, Brachamul  wrote:

> Could someone post what the entire "models.py" file should look like at
> this point?
> I don't think I have indendation problems, but I'm new to both Python &
> Django, so I can't be sure.
> Using Python 2.7.5 and Django 1.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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8aa3f7ef-4252-494e-9334-9f40578a5e8e%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CADeX7vzq-dPF8n_%2B%3Dz8ngndy_LcbGLiapd7ePn%2BT7Z76ng2sQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.