Re: IDE to practice django template language

2013-04-18 Thread Apokalyptica Painkiller
Now i'm using this: http://ninja-ide.org/. I don't know if this is what you
need, but why don't you try it.

See you


2013/4/18 Srinivasa Rao 

> Hi, I am new to this djnago, can you suggest any
> development environment to practice template language. thanks,Srini
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
I live each day
Like it's my last
I live for rock and roll
I never look back

I'm a rocker
Do as I feel as I say
I'm a rocker
And no one can take that away

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




IDE to practice django template language

2013-04-18 Thread Srinivasa Rao
Hi, I am new to this djnago, can you suggest any development environment to 
practice template language. thanks,Srini

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Fixtures and non-ascii data error reporting bug

2013-04-18 Thread Колпаков Евгений
Hi everybody.

I have a UTF-8 encoded fixture (initial_data.yaml, but I think it's 
irrelevant) that contains some data to create auth.Group models. The names 
of models are non-ascii characters. Syncdb and loaddata works smoothly, so 
it's *not* a question "my non-ascii data is not loading".

The problem is, since auth.Group.name is unique field, runs of 
loaddata/syncdb against non-empty database results in 

UnicodeEncodeError: 'ascii' codec can't encode characters in position 
229-242: ordinal not in range(128)

I've debugged a bit and it turns out that:

   1. Fixture is deserialized successfully
   2. Some data in the fixture is loaded into the DB
   3. The load process fails due to duplicate auth.Group.name (that's 
   perfectly valid)

But, instead of displaying meaningful error message like

Could not load auth.Group(pk=None): duplicate key value violates unique 
constraint "auth_group_name_key"
DETAIL:  Key (name)=(Администраторы) already exists.

loaddata fails with abovementioned error. It feels like the error 
processing for loaddata/syncdb is not very friendly to non-ascii data. 

I think it's a bug in django, but FAQ on submitting bugs requires posting 
here first, so I must obey :)

So, the questions are:

   1. Is it really a bug or I'm just trying to do something not really 
   clever
   2. If I'm following the wrong path, what are the best-practices on 
   providing initial authentication data (e.g. default admin accounts, set of 
   groups and permissions, etc.)

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Inheritance question: Multiple roles for users

2013-04-18 Thread M Hill

>
> Model inheritance is not the same as object inheritance. 
>
> If you are doing non abstract inheritance, then there is no difference 
> between a derived model, and a model that has a foreign key to the 
> parent class. In a derived model, the foreign key is a OneToOneField, 
> with null=False, blank=True. In other words, inheritance is exactly 
> the same as composition for non abstract inheritance. The main 
> difference is that if you inherit, the fields that are actually in the 
> parent table magically appear as attributes of your derived object and 
> all your queries involving this table require a join. Magic is bad, 
> extra joins are bad, magic that causes extra joins are double bad. 
>

Tom, Many thanks for the detailed reply. 

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to check for a specific field change in a model?

2013-04-18 Thread Lachlan Musicman
There is actually, via a third party app that makes it all dead
simple, it's called django-model-utils and is available here:

https://github.com/carljm/django-model-utils

Credit where it's due, I discovered this wonderful module via PyDanny
and Audrey's Two Scoops book.

Cheers
L.

On 19 April 2013 09:15, akaariai  wrote:
> On 18 huhti, 20:34, deepankar bajpeyi  wrote:
>> I have my models.py :
>>
>> class Hotel(models.Model):
>> name = models.CharField(max_length=20)
>> currency = models.ForeignKey(Currency)
>>
>> class Currency(models.Mode):
>> code = models.CharField(max_length=3)
>> name = models.CharField(max_length=10)
>>
>> Whenever the currency field in hotel is changing I need to be able to do
>> something. So I have a function like :
>>
>> @receiver(pre_save,sender=Hotel)def update_something(sender,**kwargs)
>> obj = kwargs['instance']
>> old_object = Hotel.objects.get(pk=obj.pk)
>> '''
>>  Now I can do anything here comparing the oldo  object with the instance
>> '''
>>
>> The thing is I don't want to make a query for this, since then the purpose
>> of signals becomes stupid and I become a fool.
>>
>> So I should be able to do something like :
>>
>> updated = kwargs['update_fields']
>> new_currency = updated['currency']
>>
>> Is their a way I can find out that change for *ONLY* one particular field
>> say currency ,instead of doing a query like this. I want to get the changes
>> related to the currency foreign key and update things before I save.
>>
>> Thanks :)
>
> Unfortunately there isn't any good way to do this, just doing an extra
> query on save seems like the best way forward.
>
> Django doesn't currently store the DB fetched values anywhere. The
> reason for this is that doing so is somewhat expensive. It would be
> nice to offer doing this as an option, this would allow for some nice
> features, like automatic update of only changed fields, and updatable
> natural primary keys.
>
>  - Anssi
>
> --
> 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?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to check for a specific field change in a model?

2013-04-18 Thread akaariai
On 18 huhti, 20:34, deepankar bajpeyi  wrote:
> I have my models.py :
>
> class Hotel(models.Model):
>     name = models.CharField(max_length=20)
>     currency = models.ForeignKey(Currency)
>
> class Currency(models.Mode):
>     code = models.CharField(max_length=3)
>     name = models.CharField(max_length=10)
>
> Whenever the currency field in hotel is changing I need to be able to do
> something. So I have a function like :
>
> @receiver(pre_save,sender=Hotel)def update_something(sender,**kwargs)
>     obj = kwargs['instance']
>     old_object = Hotel.objects.get(pk=obj.pk)
>     '''
>      Now I can do anything here comparing the oldo  object with the instance
>     '''
>
> The thing is I don't want to make a query for this, since then the purpose
> of signals becomes stupid and I become a fool.
>
> So I should be able to do something like :
>
> updated = kwargs['update_fields']
> new_currency = updated['currency']
>
> Is their a way I can find out that change for *ONLY* one particular field
> say currency ,instead of doing a query like this. I want to get the changes
> related to the currency foreign key and update things before I save.
>
> Thanks :)

Unfortunately there isn't any good way to do this, just doing an extra
query on save seems like the best way forward.

Django doesn't currently store the DB fetched values anywhere. The
reason for this is that doing so is somewhat expensive. It would be
nice to offer doing this as an option, this would allow for some nice
features, like automatic update of only changed fields, and updatable
natural primary keys.

 - Anssi

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-04-18 Thread akaariai
On 18 huhti, 22:07, Greg H  wrote:
> Running into a similar issue on my own project, seems to be when you try an
> cache a model which has a related model which in turn has a many to many
> field. So for example, I have an instance of a Student, which has a
> ForeignKey to Book, which in turn has a ManyToMany to Author. If I try and
> cache my Student instance, I get that pickling error. In Django 1.4 it
> worked fine, but not in 1.5.
>
> Figure out a resolution to this?

The problem is that for an instance of a class to be picklable the
class must be available as a module level attribute somewhere. For
dynamically created classes this is usually not true - they aren't
available at module level. One set of such classes is automatically
created through models for m2m fields. The automatic through classes
could explain the ManyToMany problem.

All in all this looks like a regression that should be fixed in 1.5. I
created a ticket for this, see: https://code.djangoproject.com/ticket/20289

 - Anssi

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Matt Andrews
I wouldn't say huge (see the page/view in question at 
http://www.scenepointblank.com) -- I grab a bunch of things and then 
display them, mostly truncated (with HTML stripped out, usually for the 
homepage). The custom template tags take a bunch of arguments (say for a 
news post, it takes arguments about where to show the photo, how large to 
make the headline, etc) so there's lots of loading of views inside loops 
for each news story etc.

I've tried experimenting before with the template fragment caching and saw 
little in the way of results.


On Thursday, 18 April 2013 13:40:10 UTC+1, Shawn Milochik wrote:
>
> Hit send too soon:
>
>
> https://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching
>
>
> On Thu, Apr 18, 2013 at 8:39 AM, Shawn Milochik 
>  > wrote:
>
>> Yes, it does look like template tags are taking some time. Is the page 
>> huge? Are you doing a ton of formatting? Is there something you could maybe 
>> move to server-side?
>>
>> Also, this might help with caching bits of your output: 
>>
>>
>> On Thu, Apr 18, 2013 at 6:17 AM, Matt Andrews 
>> > > wrote:
>>
>>>
>>> On Thursday, 18 April 2013 10:45:40 UTC+1, Tom Evans wrote:
>>>
>>> On Wed, Apr 17, 2013 at 11:18 PM, Matt Andrews  
 wrote: 
 > Hi all. 
 > 
 > Having performance problems with my Django app. I've posted here 
 before 
 > talking about this: one theory for my slowness woes was that I'm 
 using raw 
 > SQL for everything after getting sick of Django doing things weirdly 
 > (duplicating queries, adding bizarre things like "LIMIT 3453453" to 
 queries, 
 > not being able to JOIN things like I wanted etc). I'm not opposed to 
 going 
 > back to the ORM but need to know if this is where my bottleneck is. 
 > 
 > I've run a profiler against my code and the results are here: 
 > http://pastebin.com/raw.php?i=**HQf9bqGp
 >  
 > 
 > On my local machine (a not very powerful laptop) I see Django Debug 
 Toolbar 
 > load times of ~1900ms for my site homepage. This includes 168ms of db 
 calls 
 > (11 queries, which I think are fairly well-tuned, indexed, etc). I 
 cache 
 > pretty well on production but load times are still slow -- some of 
 this may 
 > be down to my cheap webhost, though. In my settings I enabled 
 > django.template.loaders.**cached.Loader but this doesn't seem to 
 make much 
 > difference. 
 > 
 > I'm having trouble seeing what the profiler results above are telling 
 me: 
 > can anyone shed any light? 

 Most of your time is spent in pprint, which was called over 14,000 
 times to generate your page. Over 2 seconds spent printing out debug. 
 This should be telling you "don't use pprint when you want to see how 
 fast your code is". 

 Cheers 

 Tom 

>>>
>>> Good point Tom, apologies. Here's the profiler results with DebugToolbar 
>>> switched off (and ordered by cumulative time, thanks Shawn!): 
>>> http://pastebin.com/raw.php?i=y3iP0cLn
>>>
>>> The top one is obviously my "home" method inside my views, but I'm 
>>> struggling to get more from it than that. Lots of template rendering, but 
>>> caching not helping here...?
>>>  
>>> -- 
>>> 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?hl=en.
>>> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error "Table 'django_comments' doesn't exist" - only in apache2 not in dev-server

2013-04-18 Thread Michael Muster
Sorry for spamming, but after removing
another entry from views.py and restarting apache
it works, 

Thanks for your help!



On Thursday 18 April 2013 22:26:10 Michael Muster wrote:
> On Thursday 18 April 2013 22:04:11 Michael Muster wrote:
> > Hi,
> > 
> > I don`t know what ack-grep does, but i think
> > 
> > find . -type f  | grep django_comments
> > 
> > should be something similar.
> 
> Sorry, this should be:
> 
>   find . -type f  -exec grep -l "django_comments" {} +
> 
> I removed one entry from url.py, but the error is still
> present.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error "Table 'django_comments' doesn't exist" - only in apache2 not in dev-server

2013-04-18 Thread Michael Muster
On Thursday 18 April 2013 10:21:35 Richard Jelte wrote:
> There are a lot of different places where that can be coming from (anywhere
> that's trying to import django_comments for example).
> 
> Try doing an ack-grep in your repo for any mention of django_comments that
> you might have missed when you were removing the app.
> 

Hi,

I don`t know what ack-grep does, but i think 

find . -type f  | grep django_comments

should be something similar.

But running this command in my
projects-folder finds nothing

Also im still confused that i get the error
only when running the project with apache, 
not with the development-server.

I assumed that they should behave the same?


--
michael




-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Pickling of dinamically created models.Model subclasses: "attribute lookup failed", django 1.5

2013-04-18 Thread Greg H
Running into a similar issue on my own project, seems to be when you try an 
cache a model which has a related model which in turn has a many to many 
field. So for example, I have an instance of a Student, which has a 
ForeignKey to Book, which in turn has a ManyToMany to Author. If I try and 
cache my Student instance, I get that pickling error. In Django 1.4 it 
worked fine, but not in 1.5.

Figure out a resolution to this?

On Tuesday, March 19, 2013 10:17:46 PM UTC-7, Sir Anthony wrote:
>
> Hello,
> I'm using 
> django-audit-logwitch 
> actively creates dynamic models by calling type('%sAuditLogEntry' 
> % meta_name, (models.Model,), 
> attrs).
>  
> In django 1.5 I getting error when trying to cache it (pickling phase). 
> Example error string: Can't pickle  'testproject.models.TestItemAuditLogEntry'>: attribute lookup 
> testproject.models.TestItemAuditLogEntry failed. I think it because pickle 
> tries to use class name with current environment.
> I looked in django sources and found that this 
> commitis
>  cause of such behaviour. 
> I'm not sure it is django bug (I'll write a ticket with test case and 
> probably patch, instead), maybe I just need to made some hacks on my side, 
> like implement intermediate model with custom __reduce__ like in 1.4 django 
> or something alike.
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Random translation text showing up while the rest is not translated.

2013-04-18 Thread Cody Scott


I have marked text for translation, and also database content with the 
dbgettext mdoule.

So I do:

syncdb
add some content
dbgettext_export
makemessages -l ja
add all of the translations
compilemessages

Then I change the /en/ to /ja/ to see the page in Japanese, but only two 
things are translated.

'Yes' and 'No'.

Except the displayed 'No' is not even the translation text for 'No'

Nothing else on the page is getting translated.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to check for a specific field change in a model?

2013-04-18 Thread deepankar bajpeyi

>
> I have my models.py :
>
> class Hotel(models.Model):
> name = models.CharField(max_length=20)
> currency = models.ForeignKey(Currency)
>
> class Currency(models.Mode):
> code = models.CharField(max_length=3)
> name = models.CharField(max_length=10)
>
>  

> Whenever the currency field in hotel is changing I need to be able to do 
> something. So I have a function like :
>
>  

> @receiver(pre_save,sender=Hotel)
> def update_something(sender,**kwargs)
> obj = kwargs['instance']
> old_object = Hotel.objects.get(pk=obj.pk)
> ''' Now I can do anything here comparing the oldo object with the instance 
> '''
> Now I can do anything here comparing the oldo object with the instance
> '''
> The thing is I don't want to make a query for this, since then the purpose 
> of signals becomes stupid and I become a fool.
> So I should be able to do something like :
> updated = kwargs['update_fields']
> new_currency = updated['currency']
>
>  

> Is their a way I can find out that change for *ONLY* one particular field 
> say currency ,instead of doing a query like this. I want to get the 
> changes related to the currency foreign key and update things before I 
> save.
>
> Thanks 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to check for a specific field change in a model?

2013-04-18 Thread deepankar bajpeyi


I have my models.py :

class Hotel(models.Model):
name = models.CharField(max_length=20)
currency = models.ForeignKey(Currency)

class Currency(models.Mode):
code = models.CharField(max_length=3)
name = models.CharField(max_length=10)

Whenever the currency field in hotel is changing I need to be able to do 
something. So I have a function like :

@receiver(pre_save,sender=Hotel)def update_something(sender,**kwargs)
obj = kwargs['instance']
old_object = Hotel.objects.get(pk=obj.pk)
'''
 Now I can do anything here comparing the oldo  object with the instance
'''

The thing is I don't want to make a query for this, since then the purpose 
of signals becomes stupid and I become a fool.

So I should be able to do something like :

updated = kwargs['update_fields']
new_currency = updated['currency']

Is their a way I can find out that change for *ONLY* one particular field 
say currency ,instead of doing a query like this. I want to get the changes 
related to the currency foreign key and update things before I save.

Thanks :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Error "Table 'django_comments' doesn't exist" - only in apache2 not in dev-server

2013-04-18 Thread Richard Jelte
There are a lot of different places where that can be coming from (anywhere 
that's trying to import django_comments for example).

Try doing an ack-grep in your repo for any mention of django_comments that 
you might have missed when you were removing the app.

On Thursday, April 18, 2013 7:17:07 AM UTC-6, Michael Muster wrote:
>
>  Hi,
>
> a few days ago i decided to stop using the django-comments framework, 
>
> i removed the entry from settings.py and deleted the tables in my database.
>
> Now if i want to delete an user via the admin interface i get an error 
>
> in my apache/error log (see below)
>
> The strange thing is, if i'm using the development server i get no error
>
> at all and the user is deleted silently...
>
> Any idea what is going wrong here?
>
> Django 1.5.1
>
> libapache2-mod-wsgi 3.3-4
>
> mysql 5.5.30
>
> [Thu Apr 18 15:03:26 2013] [error] Internal Server Error: /admin/auth/user/
>
> [Thu Apr 18 15:03:26 2013] [error] Traceback (most recent call last):
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/core/handlers/base.py", line 115, in get_response
>
> [Thu Apr 18 15:03:26 2013] [error] response = callback(request, 
>
> *callback_args, **callback_kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/options.py", line 372, in wrapper
>
> [Thu Apr 18 15:03:26 2013] [error] return 
> self.admin_site.admin_view(view)
>
> (*args, **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/utils/decorators.py", line 91, in _wrapped_view
>
> [Thu Apr 18 15:03:26 2013] [error] response = view_func(request, 
> *args, 
>
> **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
>
> [Thu Apr 18 15:03:26 2013] [error] response = view_func(request, 
> *args, 
>
> **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/sites.py", line 202, in inner
>
> [Thu Apr 18 15:03:26 2013] [error] return view(request, *args, 
> **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/utils/decorators.py", line 25, in _wrapper
>
> [Thu Apr 18 15:03:26 2013] [error] return bound_func(*args, **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/utils/decorators.py", line 91, in _wrapped_view
>
> [Thu Apr 18 15:03:26 2013] [error] response = view_func(request, 
> *args, 
>
> **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/utils/decorators.py", line 21, in bound_func
>
> [Thu Apr 18 15:03:26 2013] [error] return func(self, *args2, **kwargs2)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/options.py", line 1205, in changelist_view
>
> [Thu Apr 18 15:03:26 2013] [error] response = 
>
> self.response_action(request, queryset=cl.get_query_set(request))
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/options.py", line 960, in response_action
>
> [Thu Apr 18 15:03:26 2013] [error] response = func(self, request, 
>
> queryset)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/actions.py", line 35, in delete_selected
>
> [Thu Apr 18 15:03:26 2013] [error] queryset, opts, request.user, 
>
> modeladmin.admin_site, using)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/util.py", line 109, in get_deleted_objects
>
> [Thu Apr 18 15:03:26 2013] [error] collector.collect(objs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/contrib/admin/util.py", line 160, in collect
>
> [Thu Apr 18 15:03:26 2013] [error] return super(NestedObjects, 
>
> self).collect(objs, source_attr=source_attr, **kwargs)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/db/models/deletion.py", line 225, in collect
>
> [Thu Apr 18 15:03:26 2013] [error] elif sub_objs:
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/db/models/query.py", line 141, in __nonzero__
>
> [Thu Apr 18 15:03:26 2013] [error] return type(self).__bool__(self)
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/db/models/query.py", line 135, in __bool__
>
> [Thu Apr 18 15:03:26 2013] [error] next(iter(self))
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> packages/django/db/models/query.py", line 123, in _result_iter
>
> [Thu Apr 18 15:03:26 2013] [error] self._fill_cache()
>
> [Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
>
> 

Re: How to view your translated site?

2013-04-18 Thread Cody Scott
I agree that link is much better, I got the other one from settings.py


On Thu, Apr 18, 2013 at 12:41 PM, Tom Evans wrote:

> On Thu, Apr 18, 2013 at 5:23 PM, Cody Scott 
> wrote:
> > Thanks, I went here
> http://www.i18nguy.com/unicode/language-identifiers.html
> > ctrl+ f "japanese" saw jp on the left hand side. I thought ja was a
> > localization of jp so it would be jp-ja.
> >
>
> The columns listed on that page are "region code", "region name",
> "language". You can't use region code for language, eg the region code
> 'ca' represents 'Canada', but the language code 'ca' represents
> Catalan. It's important to use the right one.
>
> If you're looking for the right ISO-639-1 language code to use, the
> best reference is a list of ISO-639-1 codes:
>
> http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/pCJlPwvkirQ/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to view your translated site?

2013-04-18 Thread Tom Evans
On Thu, Apr 18, 2013 at 5:23 PM, Cody Scott  wrote:
> Thanks, I went here http://www.i18nguy.com/unicode/language-identifiers.html
> ctrl+ f "japanese" saw jp on the left hand side. I thought ja was a
> localization of jp so it would be jp-ja.
>

The columns listed on that page are "region code", "region name",
"language". You can't use region code for language, eg the region code
'ca' represents 'Canada', but the language code 'ca' represents
Catalan. It's important to use the right one.

If you're looking for the right ISO-639-1 language code to use, the
best reference is a list of ISO-639-1 codes:

http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to view your translated site?

2013-04-18 Thread Cody Scott
Thanks, I went here http://www.i18nguy.com/unicode/language-identifiers.html 
ctrl+ 
f "japanese" saw jp on the left hand side. I thought ja was a localization 
of jp so it would be jp-ja.

On Thursday, 18 April 2013 11:42:37 UTC-4, Cody Scott wrote:
>
> I am trying to view my site in japanese. I have create the translations 
> and compiled them with compilemessages.
>
> In my urls.py I have 
>
> urlpatterns = i18n_patterns('',
> #...)
>
>
> Settings.py
>
>
> LANGUAGE_CODE = 'en-us'
> #Used for translationsgettext = lambda s: sLANGUAGES = (
> ('en', gettext('English')),
> ('jp', gettext('Japanese')),)
>
>
> But when I try to access a url with /jp/ at the start I get that there is 
> only /en/
>
>
> Using the URLconf defined in PLP.urls, Django tried these URL patterns, in 
> this order:^en/The current URL, jp/accounts/login, didn't match any of these.
>
>  
>
> I am using dbgettext so I also have my database content translated in my 
> messages.
>
> But how can I display it
>
> {% trans "Question:" %}{% trans {{question.question}} %}
>
> Could not parse the remainder: '{{question.question}}' from 
> '{{question.question}}'
>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How to view your translated site?

2013-04-18 Thread Tom Evans
On Thu, Apr 18, 2013 at 4:42 PM, Cody Scott  wrote:
> I am trying to view my site in japanese. I have create the translations and
> compiled them with compilemessages.
>
> In my urls.py I have
>
> urlpatterns = i18n_patterns('',
> #...
> )
>
>
> Settings.py
>
>
> LANGUAGE_CODE = 'en-us'
>
> #Used for translations
> gettext = lambda s: s
> LANGUAGES = (
> ('en', gettext('English')),
> ('jp', gettext('Japanese')),
> )

Django only supports translations that Django itself has a base
translation for. Django has a Japanese translation, but it uses the
correct ISO-639-1 language name for it, 'ja'. Since you have 'jp',
this doesn't correspond to a language that django has a base
translation for, and so it is ignored.

>
>
> But when I try to access a url with /jp/ at the start I get that there is
> only /en/
>
>
> Using the URLconf defined in PLP.urls, Django tried these URL patterns, in
> this order:
> ^en/
> The current URL, jp/accounts/login, didn't match any of these.
>
>
>
> I am using dbgettext so I also have my database content translated in my
> messages.
>
> But how can I display it
>
> {% trans "Question:" %}{% trans {{question.question}} %}
>
> Could not parse the remainder: '{{question.question}}' from
> '{{question.question}}'
>

You can't use {{ }} inside a template tag, but you don't need to. {%
trans %} is expecting either a string literal or a variable, so give
it the variable - {% trans question.question %}.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




How to view your translated site?

2013-04-18 Thread Cody Scott
I am trying to view my site in japanese. I have create the translations and 
compiled them with compilemessages.

In my urls.py I have 

urlpatterns = i18n_patterns('',
#...)


Settings.py


LANGUAGE_CODE = 'en-us'
#Used for translationsgettext = lambda s: sLANGUAGES = (
('en', gettext('English')),
('jp', gettext('Japanese')),)


But when I try to access a url with /jp/ at the start I get that there is only 
/en/


Using the URLconf defined in PLP.urls, Django tried these URL patterns, in this 
order:^en/The current URL, jp/accounts/login, didn't match any of these.

 

I am using dbgettext so I also have my database content translated in my 
messages.

But how can I display it

{% trans "Question:" %}{% trans {{question.question}} %}

Could not parse the remainder: '{{question.question}}' from 
'{{question.question}}'


-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-newsletter, cron job not working

2013-04-18 Thread Shawn Milochik
Here's an example of something taken straight from my crontab from a
WebFaction account:

44 * * * * cd ~/webapps/awstats_milocast;./update_awstats.sh

This runs on minute 44 of every hour. There are five "time" parameters. The
first one is "minute." If you set a number there, it'll run on that minute
every hour.


On Thu, Apr 18, 2013 at 6:16 AM, Tom Evans  wrote:

> On Wed, Apr 17, 2013 at 7:38 PM, frocco  wrote:
> > Hello,
> >
> > Can someone give me an example of running a cronjob hourly?
> > I am on webfaction and cannot get this working.
> >
> > I tried
> >
> > @hourly /usr/local/bin/python2.7 ~/webapps/ntw/myproject/manage.py runjob
> > submit
> >
> > I get no email
> >
> > If I SSH in and sunit manually, it works fine
>
> Specify the full, absolute path to the file. Cron won't expand '~'.
>
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Inheritance question: Multiple roles for users

2013-04-18 Thread Tom Evans
On Thu, Apr 18, 2013 at 5:11 AM, M Hill  wrote:
> I've searched this group for threads related to multitable inheritance.  The
> one most similar to my query so far was titled "multiple children in
> multitable inheritance", from Apr. 2008.  Like the original poster, I'd
> thought of Bar as a possible subclass of Place, which might share the same
> Place parent/base class as a Restaurant.  However, that analogy doesn't
> quite capture what I'm trying to do, so I'll use another.
>
> Say I am managing a martial arts tournament, where Members participate.  I
> would use Member as the base class that would hold all the details common to
> each person, which would include the login name.
>
> Some Members are qualified to be Judges, Timekeepers, Referees, etc.  So
> those people can assume multiple roles at a tournament, but only one such
> role at a time.
>
> The main reason I'd like to subclass Member is so that person-specific and
> role-specific information can be displayed depending on the Member's current
> role.  I saw Malcolm Tredinnick's comment to the effect that the answer to
> using inheritance is usually "no".  However, if I think about using
> Many-to-Many relations to track the Member's available roles, I run into the
> problem that not every Member will be a Judge, so I can't just have a
> "Member.roles -> intermediateTable <- subclass" field.
>
> Furthermore, I need to delegate to another class of Member (TourneyAdmin?)
> the ability to add/manage/remove Members and their roles, and it would be
> very convenient if the admin interface could be used for that purpose.
> However, I can write my own management screens if that turns out to be
> necessary.
>
> I would be very grateful for suggestions on how best to handle this type of
> use case.  I'm sure it's been solved (many times) before, but it seems quite
> difficult to come up with just the right search terms to zero in on the
> right threads without a bunch of false positives.
>
> Thank you.
>

Model inheritance is not the same as object inheritance.

If you are doing non abstract inheritance, then there is no difference
between a derived model, and a model that has a foreign key to the
parent class. In a derived model, the foreign key is a OneToOneField,
with null=False, blank=True. In other words, inheritance is exactly
the same as composition for non abstract inheritance. The main
difference is that if you inherit, the fields that are actually in the
parent table magically appear as attributes of your derived object and
all your queries involving this table require a join. Magic is bad,
extra joins are bad, magic that causes extra joins are double bad.

If you are doing abstract inheritance, then there is no corresponding
base table. In this scenario, to my mind, it is not really
inheritance, the base model only contributes some code and some field
definitions and there is no "is-a" relationship.
Abstract inheritance is very good if you need to define a replaceable
class - it must have these fields, it must have these methods, but you
can add extra fields if you desire.

So, to your hypothetical problem. You have users. Some users are
special users. Special users need some extra attributes store about
them. You need an easy way to determine when a user is a special user.

First, have a User class. I'd use d.c.auth.User, or one derived from
d.c.auth.AbstractBaseUser.

Each special kind of user needs a model too, eg Judge. Each one should
have a OneToOne foreign key to User. You can make this by deriving
each class from User, but I wouldn't bother.

Create a d.c.auth.Group for each type of user. Groups are an object
you can hang Permissions on, and users can be added to as many groups
as necessary. Use the admin to add Permissions to Groups. If you need
more permissions for a specific model, add them to that model's Meta
class.

When you create a Judge instance, add the relevant User to the
relevant Group. When you delete a Judge, remove the User from the
Group. Use signals to hook into this.

Use the permission_required decorator to protect views that should
only be accessible to specific user types. Use a permission you
earlier added to a group.

To determine if someone is a Judge, you look either at their
permissions or their Groups. This could involve extra queries. To work
around this, you can denormalise this information into boolean flags
on the User. Add fields like is_judge to your custom user model, and
populate this data when adding/deleting Judge instances, again using
signals.

In the end, you would end up with view code looking something like this:

@permission_required('myapp.is_judge')
def scoreboard(request):
  judge = request.user.judge
  …


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, 

Error "Table 'django_comments' doesn't exist" - only in apache2 not in dev-server

2013-04-18 Thread Michael Muster
Hi,

a few days ago i decided to stop using the django-comments framework, 
i removed the entry from settings.py and deleted the tables in my database.
Now if i want to delete an user via the admin interface i get an error 
in my apache/error log (see below)

The strange thing is, if i'm using the development server i get no error
at all and the user is deleted silently...


Any idea what is going wrong here?

Django 1.5.1
libapache2-mod-wsgi 3.3-4
mysql 5.5.30


[Thu Apr 18 15:03:26 2013] [error] Internal Server Error: /admin/auth/user/
[Thu Apr 18 15:03:26 2013] [error] Traceback (most recent call last):
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/core/handlers/base.py", line 115, in get_response
[Thu Apr 18 15:03:26 2013] [error] response = callback(request, 
*callback_args, **callback_kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/options.py", line 372, in wrapper
[Thu Apr 18 15:03:26 2013] [error] return self.admin_site.admin_view(view)
(*args, **kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/utils/decorators.py", line 91, in _wrapped_view
[Thu Apr 18 15:03:26 2013] [error] response = view_func(request, *args, 
**kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
[Thu Apr 18 15:03:26 2013] [error] response = view_func(request, *args, 
**kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/sites.py", line 202, in inner
[Thu Apr 18 15:03:26 2013] [error] return view(request, *args, **kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/utils/decorators.py", line 25, in _wrapper
[Thu Apr 18 15:03:26 2013] [error] return bound_func(*args, **kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/utils/decorators.py", line 91, in _wrapped_view
[Thu Apr 18 15:03:26 2013] [error] response = view_func(request, *args, 
**kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/utils/decorators.py", line 21, in bound_func
[Thu Apr 18 15:03:26 2013] [error] return func(self, *args2, **kwargs2)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/options.py", line 1205, in changelist_view
[Thu Apr 18 15:03:26 2013] [error] response = 
self.response_action(request, queryset=cl.get_query_set(request))
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/options.py", line 960, in response_action
[Thu Apr 18 15:03:26 2013] [error] response = func(self, request, 
queryset)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/actions.py", line 35, in delete_selected
[Thu Apr 18 15:03:26 2013] [error] queryset, opts, request.user, 
modeladmin.admin_site, using)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/util.py", line 109, in get_deleted_objects
[Thu Apr 18 15:03:26 2013] [error] collector.collect(objs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/contrib/admin/util.py", line 160, in collect
[Thu Apr 18 15:03:26 2013] [error] return super(NestedObjects, 
self).collect(objs, source_attr=source_attr, **kwargs)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/deletion.py", line 225, in collect
[Thu Apr 18 15:03:26 2013] [error] elif sub_objs:
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/query.py", line 141, in __nonzero__
[Thu Apr 18 15:03:26 2013] [error] return type(self).__bool__(self)
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/query.py", line 135, in __bool__
[Thu Apr 18 15:03:26 2013] [error] next(iter(self))
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/query.py", line 123, in _result_iter
[Thu Apr 18 15:03:26 2013] [error] self._fill_cache()
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/query.py", line 927, in _fill_cache
[Thu Apr 18 15:03:26 2013] [error] 
self._result_cache.append(next(self._iter))
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/query.py", line 301, in iterator
[Thu Apr 18 15:03:26 2013] [error] for row in compiler.results_iter():
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-
packages/django/db/models/sql/compiler.py", line 775, in results_iter
[Thu Apr 18 15:03:26 2013] [error] for rows in self.execute_sql(MULTI):
[Thu Apr 18 15:03:26 2013] [error]   File "/usr/lib/python2.7/dist-

Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Shawn Milochik
Hit send too soon:

https://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching


On Thu, Apr 18, 2013 at 8:39 AM, Shawn Milochik  wrote:

> Yes, it does look like template tags are taking some time. Is the page
> huge? Are you doing a ton of formatting? Is there something you could maybe
> move to server-side?
>
> Also, this might help with caching bits of your output:
>
>
> On Thu, Apr 18, 2013 at 6:17 AM, Matt Andrews wrote:
>
>>
>> On Thursday, 18 April 2013 10:45:40 UTC+1, Tom Evans wrote:
>>
>> On Wed, Apr 17, 2013 at 11:18 PM, Matt Andrews 
>>> wrote:
>>> > Hi all.
>>> >
>>> > Having performance problems with my Django app. I've posted here
>>> before
>>> > talking about this: one theory for my slowness woes was that I'm using
>>> raw
>>> > SQL for everything after getting sick of Django doing things weirdly
>>> > (duplicating queries, adding bizarre things like "LIMIT 3453453" to
>>> queries,
>>> > not being able to JOIN things like I wanted etc). I'm not opposed to
>>> going
>>> > back to the ORM but need to know if this is where my bottleneck is.
>>> >
>>> > I've run a profiler against my code and the results are here:
>>> > http://pastebin.com/raw.php?i=**HQf9bqGp
>>> >
>>> > On my local machine (a not very powerful laptop) I see Django Debug
>>> Toolbar
>>> > load times of ~1900ms for my site homepage. This includes 168ms of db
>>> calls
>>> > (11 queries, which I think are fairly well-tuned, indexed, etc). I
>>> cache
>>> > pretty well on production but load times are still slow -- some of
>>> this may
>>> > be down to my cheap webhost, though. In my settings I enabled
>>> > django.template.loaders.**cached.Loader but this doesn't seem to make
>>> much
>>> > difference.
>>> >
>>> > I'm having trouble seeing what the profiler results above are telling
>>> me:
>>> > can anyone shed any light?
>>>
>>> Most of your time is spent in pprint, which was called over 14,000
>>> times to generate your page. Over 2 seconds spent printing out debug.
>>> This should be telling you "don't use pprint when you want to see how
>>> fast your code is".
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>
>> Good point Tom, apologies. Here's the profiler results with DebugToolbar
>> switched off (and ordered by cumulative time, thanks Shawn!):
>> http://pastebin.com/raw.php?i=y3iP0cLn
>>
>> The top one is obviously my "home" method inside my views, but I'm
>> struggling to get more from it than that. Lots of template rendering, but
>> caching not helping here...?
>>
>> --
>> 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?hl=en.
>> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Shawn Milochik
Yes, it does look like template tags are taking some time. Is the page
huge? Are you doing a ton of formatting? Is there something you could maybe
move to server-side?

Also, this might help with caching bits of your output:


On Thu, Apr 18, 2013 at 6:17 AM, Matt Andrews  wrote:

>
> On Thursday, 18 April 2013 10:45:40 UTC+1, Tom Evans wrote:
>
> On Wed, Apr 17, 2013 at 11:18 PM, Matt Andrews 
>> wrote:
>> > Hi all.
>> >
>> > Having performance problems with my Django app. I've posted here before
>> > talking about this: one theory for my slowness woes was that I'm using
>> raw
>> > SQL for everything after getting sick of Django doing things weirdly
>> > (duplicating queries, adding bizarre things like "LIMIT 3453453" to
>> queries,
>> > not being able to JOIN things like I wanted etc). I'm not opposed to
>> going
>> > back to the ORM but need to know if this is where my bottleneck is.
>> >
>> > I've run a profiler against my code and the results are here:
>> > http://pastebin.com/raw.php?i=**HQf9bqGp
>> >
>> > On my local machine (a not very powerful laptop) I see Django Debug
>> Toolbar
>> > load times of ~1900ms for my site homepage. This includes 168ms of db
>> calls
>> > (11 queries, which I think are fairly well-tuned, indexed, etc). I
>> cache
>> > pretty well on production but load times are still slow -- some of this
>> may
>> > be down to my cheap webhost, though. In my settings I enabled
>> > django.template.loaders.**cached.Loader but this doesn't seem to make
>> much
>> > difference.
>> >
>> > I'm having trouble seeing what the profiler results above are telling
>> me:
>> > can anyone shed any light?
>>
>> Most of your time is spent in pprint, which was called over 14,000
>> times to generate your page. Over 2 seconds spent printing out debug.
>> This should be telling you "don't use pprint when you want to see how
>> fast your code is".
>>
>> Cheers
>>
>> Tom
>>
>
> Good point Tom, apologies. Here's the profiler results with DebugToolbar
> switched off (and ordered by cumulative time, thanks Shawn!):
> http://pastebin.com/raw.php?i=y3iP0cLn
>
> The top one is obviously my "home" method inside my views, but I'm
> struggling to get more from it than that. Lots of template rendering, but
> caching not helping here...?
>
> --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: models.ManyToManyField

2013-04-18 Thread Gabriel
The first solution works like this:
If you create a foreign key from ModelA to ModelB, Django automatically
create something like B.modela_set that works just like the objects
attribute, but just for the A objects that are related to B, right?
That's why you can du stuff like attore.film_set.all() to get all the films
the actor was in. Django creates film_set for you in Attore instances
because you have a ForeignKey from Film to Attore

So, if you wanna list all the films for each actor, something like

actors_dict = dict()
actors = Attore.objects.all()
for actor in actors:
  full_name = '{} {}'.format(actor.nome, actor.cognome)
  actors_list[actor.cognome] = [film.titolo for film in
actor.film_set.all()]

Then actors_list would be a dictionary like:
{
  'Nicholas Cage': ['Gone in 60 Seconds', 'Face Off'],
  'Jack Nicholson': ['Batman', 'The Shining']
}


There are different ways of doing this, and I get the feeling you'd like
something with templates. But this is pretty much the gist of it.

- Gabe


On Thu, Apr 18, 2013 at 5:44 AM, Federico Erbea  wrote:

> I think it is the first solution that you have proposed, but I can't
> figure out how to use it. Also, is there a way to make sure that the ID is
> automatically taken? With a proper publisher for loop I would like all the
> lists of movies for each actor.
>
> This is my urls.py
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
> (r'^Film$', 'Database.views.film'),
> )
>
> and this is my views.py
>
> from django.shortcuts import render_to_response
> from django.template import RequestContext
> from models import *
>
> def film(request):
> film = Film.objects.all()
> return render_to_response('Film.html'**, { 'film': film, })
>
> Thanks for the help.
>
> --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Inheritance question: Multiple roles for users

2013-04-18 Thread M Hill
I've searched this group for threads related to multitable inheritance.  
The one most similar to my query so far was titled "multiple children in 
multitable inheritance", from Apr. 2008.  Like the original poster, I'd 
thought of Bar as a possible subclass of Place, which might share the same 
Place parent/base class as a Restaurant.  However, that analogy doesn't 
quite capture what I'm trying to do, so I'll use another.

Say I am managing a martial arts tournament, where Members participate.  I 
would use Member as the base class that would hold all the details common 
to each person, which would include the login name.

Some Members are qualified to be Judges, Timekeepers, Referees, etc.  So 
those people can assume multiple roles at a tournament, but only one such 
role at a time.

The main reason I'd like to subclass Member is so that person-specific 
*and*role-specific information can be displayed depending on the Member's 
current role.  I saw Malcolm Tredinnick's comment to the effect that the 
answer to using inheritance is usually "no".  However, if I think about 
using Many-to-Many relations to track the Member's available roles, I run 
into the problem that not every Member will be a Judge, so I can't just 
have a "Member.roles -> intermediateTable <- subclass" field.

Furthermore, I need to delegate to another class of Member (TourneyAdmin?) 
the ability to add/manage/remove Members and their roles, and it would be 
very convenient if the admin interface could be used for that purpose.  
However, I can write my own management screens if that turns out to be 
necessary.

I would be very grateful for suggestions on how best to handle this type of 
use case.  I'm sure it's been solved (many times) before, but it seems 
quite difficult to come up with just the right search terms to zero in on 
the right threads without a bunch of false positives.

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Matt Andrews

On Thursday, 18 April 2013 10:45:40 UTC+1, Tom Evans wrote:

> On Wed, Apr 17, 2013 at 11:18 PM, Matt Andrews 
>  
> wrote: 
> > Hi all. 
> > 
> > Having performance problems with my Django app. I've posted here before 
> > talking about this: one theory for my slowness woes was that I'm using 
> raw 
> > SQL for everything after getting sick of Django doing things weirdly 
> > (duplicating queries, adding bizarre things like "LIMIT 3453453" to 
> queries, 
> > not being able to JOIN things like I wanted etc). I'm not opposed to 
> going 
> > back to the ORM but need to know if this is where my bottleneck is. 
> > 
> > I've run a profiler against my code and the results are here: 
> > http://pastebin.com/raw.php?i=HQf9bqGp 
> > 
> > On my local machine (a not very powerful laptop) I see Django Debug 
> Toolbar 
> > load times of ~1900ms for my site homepage. This includes 168ms of db 
> calls 
> > (11 queries, which I think are fairly well-tuned, indexed, etc). I cache 
> > pretty well on production but load times are still slow -- some of this 
> may 
> > be down to my cheap webhost, though. In my settings I enabled 
> > django.template.loaders.cached.Loader but this doesn't seem to make much 
> > difference. 
> > 
> > I'm having trouble seeing what the profiler results above are telling 
> me: 
> > can anyone shed any light? 
>
> Most of your time is spent in pprint, which was called over 14,000 
> times to generate your page. Over 2 seconds spent printing out debug. 
> This should be telling you "don't use pprint when you want to see how 
> fast your code is". 
>
> Cheers 
>
> Tom 
>

Good point Tom, apologies. Here's the profiler results with DebugToolbar 
switched off (and ordered by cumulative time, thanks Shawn!): 
http://pastebin.com/raw.php?i=y3iP0cLn

The top one is obviously my "home" method inside my views, but I'm 
struggling to get more from it than that. Lots of template rendering, but 
caching not helping here...?

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django-newsletter, cron job not working

2013-04-18 Thread Tom Evans
On Wed, Apr 17, 2013 at 7:38 PM, frocco  wrote:
> Hello,
>
> Can someone give me an example of running a cronjob hourly?
> I am on webfaction and cannot get this working.
>
> I tried
>
> @hourly /usr/local/bin/python2.7 ~/webapps/ntw/myproject/manage.py runjob
> submit
>
> I get no email
>
> If I SSH in and sunit manually, it works fine

Specify the full, absolute path to the file. Cron won't expand '~'.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help interpreting profiler results (or: why is my app so slow?)

2013-04-18 Thread Tom Evans
On Wed, Apr 17, 2013 at 11:18 PM, Matt Andrews  wrote:
> Hi all.
>
> Having performance problems with my Django app. I've posted here before
> talking about this: one theory for my slowness woes was that I'm using raw
> SQL for everything after getting sick of Django doing things weirdly
> (duplicating queries, adding bizarre things like "LIMIT 3453453" to queries,
> not being able to JOIN things like I wanted etc). I'm not opposed to going
> back to the ORM but need to know if this is where my bottleneck is.
>
> I've run a profiler against my code and the results are here:
> http://pastebin.com/raw.php?i=HQf9bqGp
>
> On my local machine (a not very powerful laptop) I see Django Debug Toolbar
> load times of ~1900ms for my site homepage. This includes 168ms of db calls
> (11 queries, which I think are fairly well-tuned, indexed, etc). I cache
> pretty well on production but load times are still slow -- some of this may
> be down to my cheap webhost, though. In my settings I enabled
> django.template.loaders.cached.Loader but this doesn't seem to make much
> difference.
>
> I'm having trouble seeing what the profiler results above are telling me:
> can anyone shed any light?

Most of your time is spent in pprint, which was called over 14,000
times to generate your page. Over 2 seconds spent printing out debug.
This should be telling you "don't use pprint when you want to see how
fast your code is".

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What to Django people have to say about Javascript frameworks to complement Django's philosophy on the front end

2013-04-18 Thread Doug Snyder
Sorry, looks like I was wrong about batman. It can work with django, I just
forget sometimes that more people watch movies than write web apps.


On Thu, Apr 18, 2013 at 3:34 AM, Doug Snyder  wrote:

> Another interesting library just launched is Webbot (
> http://www.webbot.ws/Home ). This is actually a python lib intended for
> django and app engine that lets you write generalized front end UI's using
> python and has a GUI that helps you build them by generating python for the
> UI without writing any code. It looks like an awesome idea, but I'm sure
> its not super mature yet but it looks like an abstract frame work that can
> be built off to build in support for what ever front end technologies you
> choose. It would be cool to see this project grow and for people to
> contribute code that adapts the abstract python UI representations to
> different javascript and front end libraries and technologies. The author,
> Timothy Crosley is on this Google Group and Webbot also has its own Google
> Group here: https://groups.google.com/forum/?fromgroups=#!forum/webbot
>
>
> On Thu, Apr 18, 2013 at 2:12 AM, Doug Snyder wrote:
>
>> Another framework I looked at is SproutCore. This seems to be more
>> focused around widgets like many javascript libraries have been before it.
>> I'm not sure how extensible these widgets are and how quickly I would run
>> into limitations of using them for things they weren't specifically
>> designed for.
>>
>>
>> On Thu, Apr 18, 2013 at 1:53 AM, Doug S  wrote:
>>
>>> I hope this is OK to talk Javascript in this Django group, I'm hoping
>>> its relevant to enough Django folks to not be distracting.
>>> I'm relatively new to Django, but my impression is that a few years ago
>>> most django people prescribed to the wisdom of keeping javascript to a
>>> minimum and just using simple JQuery to do simple tasks. Now I think heavy
>>> Javascript usage is more of reality especially with the shift to more
>>> mobile web apps, and that the Javascript community is stepping up and
>>> providing some nice frameworks that can make django people feel a little
>>> more at home using javascript, more high level frameworks that use MVC
>>> architecture. I'm starting a few projects where I'll want to essentially
>>> mirror my django models on the front end to allow editing with out page
>>> refreshes, front end form validation, and switching between views that are
>>> downloaded in one request but displayed only according to the state of the
>>> front end javascript view state. I want nice seemless AJAX communcation
>>> between the front and back end. I'm aware of a few Javascript libraries
>>> that are focused around these things and improving javascript web app
>>> development in general. KnockOutJS caught my eye at first and I did some
>>> work with that. I found some things worked really fast and really easy, but
>>> then once I tried more complex things I saw what I think where limitations
>>> in its extensibility. Since I'm pretty inexperienced with it, I'm not sure
>>> if this was my lack of experience or deficiencies in the framework. Then I
>>> found out about Ember,js and it seemed to me like a more complete framework
>>> ( it tagline is 'Ambitious Web Apps' ) that could probably handle almost
>>> any situation that I would use it for, although for simple views it
>>> required a tad more code to be written than KnockOutJS. My first experience
>>> with Ember last weekend was pretty frustrating, working off what looks like
>>> the only example in the docs and finding myself buried in errors that were
>>> entirely foreign to me. This may be beginners luck but I also heard someone
>>> more experienced express frustration with the learning curve and lack of
>>> examples in the docs. I've just become aware of a number of Javascript
>>> libraries that seem to do related things that will be useful for my needs
>>> above. AngularJS I think is gaining popularity quickly and seems to be
>>> selling itself as a simple solution that can be extended in any variety of
>>> ways ( much like django ). I tend to feel good about trusting Google but I
>>> wonder if what I think is a more structured approach in Ember js is a wiser
>>> choice for me. I've also read about Spine, which describes itself as a
>>> simple lightweight MVC framework. Backbone is apparently a library entirely
>>> concerned with front end data models but not databinding or routing. I
>>> found a library called Batman intended for Rails but since a Google search
>>> for django and batman is all about movies and not programming I'm guessing
>>> no one has adapted this JS lib for django. All of what I'm writing is not
>>> based on expertise or experience, what I'm really hoping for is some hints
>>> from django people about what they use or what the pros and cons of the
>>> different options for javascript frameworks are, and to encourage
>>> discussion about this that 

Re: models.ManyToManyField

2013-04-18 Thread Federico Erbea
I think it is the first solution that you have proposed, but I can't figure 
out how to use it. Also, is there a way to make sure that the ID is 
automatically taken? With a proper publisher for loop I would like all the 
lists of movies for each actor.

This is my urls.py

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^Film$', 'Database.views.film'),
)

and this is my views.py

from django.shortcuts import render_to_response
from django.template import RequestContext
from models import *

def film(request):
film = Film.objects.all()
return render_to_response('Film.html', { 'film': film, })

Thanks for the help.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: models.ManyToManyField

2013-04-18 Thread Federico Erbea
I think it is the first solution that you have proposed, but I can't figure 
out how to use it. Also, is there a way to make sure that the ID is 
automatically taken? With a proper publisher for loop I would like all the 
lists of movies for each actor.

This is my urls.py

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^Film$', 'Database.views.film'),
)

and this is my views.py

from django.shortcuts import render_to_response
from django.template import RequestContext
from models import *

def film(request):
film = Film.objects.all()
return render_to_response('Film.html', { 'film': film, 'regista': 
regista, })

Thanks for the help.

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What to Django people have to say about Javascript frameworks to complement Django's philosophy on the front end

2013-04-18 Thread Doug Snyder
Another interesting library just launched is Webbot (
http://www.webbot.ws/Home ). This is actually a python lib intended for
django and app engine that lets you write generalized front end UI's using
python and has a GUI that helps you build them by generating python for the
UI without writing any code. It looks like an awesome idea, but I'm sure
its not super mature yet but it looks like an abstract frame work that can
be built off to build in support for what ever front end technologies you
choose. It would be cool to see this project grow and for people to
contribute code that adapts the abstract python UI representations to
different javascript and front end libraries and technologies. The author,
Timothy Crosley is on this Google Group and Webbot also has its own Google
Group here: https://groups.google.com/forum/?fromgroups=#!forum/webbot


On Thu, Apr 18, 2013 at 2:12 AM, Doug Snyder  wrote:

> Another framework I looked at is SproutCore. This seems to be more focused
> around widgets like many javascript libraries have been before it. I'm not
> sure how extensible these widgets are and how quickly I would run into
> limitations of using them for things they weren't specifically designed for.
>
>
> On Thu, Apr 18, 2013 at 1:53 AM, Doug S  wrote:
>
>> I hope this is OK to talk Javascript in this Django group, I'm hoping its
>> relevant to enough Django folks to not be distracting.
>> I'm relatively new to Django, but my impression is that a few years ago
>> most django people prescribed to the wisdom of keeping javascript to a
>> minimum and just using simple JQuery to do simple tasks. Now I think heavy
>> Javascript usage is more of reality especially with the shift to more
>> mobile web apps, and that the Javascript community is stepping up and
>> providing some nice frameworks that can make django people feel a little
>> more at home using javascript, more high level frameworks that use MVC
>> architecture. I'm starting a few projects where I'll want to essentially
>> mirror my django models on the front end to allow editing with out page
>> refreshes, front end form validation, and switching between views that are
>> downloaded in one request but displayed only according to the state of the
>> front end javascript view state. I want nice seemless AJAX communcation
>> between the front and back end. I'm aware of a few Javascript libraries
>> that are focused around these things and improving javascript web app
>> development in general. KnockOutJS caught my eye at first and I did some
>> work with that. I found some things worked really fast and really easy, but
>> then once I tried more complex things I saw what I think where limitations
>> in its extensibility. Since I'm pretty inexperienced with it, I'm not sure
>> if this was my lack of experience or deficiencies in the framework. Then I
>> found out about Ember,js and it seemed to me like a more complete framework
>> ( it tagline is 'Ambitious Web Apps' ) that could probably handle almost
>> any situation that I would use it for, although for simple views it
>> required a tad more code to be written than KnockOutJS. My first experience
>> with Ember last weekend was pretty frustrating, working off what looks like
>> the only example in the docs and finding myself buried in errors that were
>> entirely foreign to me. This may be beginners luck but I also heard someone
>> more experienced express frustration with the learning curve and lack of
>> examples in the docs. I've just become aware of a number of Javascript
>> libraries that seem to do related things that will be useful for my needs
>> above. AngularJS I think is gaining popularity quickly and seems to be
>> selling itself as a simple solution that can be extended in any variety of
>> ways ( much like django ). I tend to feel good about trusting Google but I
>> wonder if what I think is a more structured approach in Ember js is a wiser
>> choice for me. I've also read about Spine, which describes itself as a
>> simple lightweight MVC framework. Backbone is apparently a library entirely
>> concerned with front end data models but not databinding or routing. I
>> found a library called Batman intended for Rails but since a Google search
>> for django and batman is all about movies and not programming I'm guessing
>> no one has adapted this JS lib for django. All of what I'm writing is not
>> based on expertise or experience, what I'm really hoping for is some hints
>> from django people about what they use or what the pros and cons of the
>> different options for javascript frameworks are, and to encourage
>> discussion about this that might be useful to a lot of django people
>> looking to bridge the front end with backend. Feel free to stretch the
>> boundaries of my questions if you even think I've given any clear
>> boundaries, assume that you know more than I, and if you're wrong, no
>> worries, this discussion is as much for your 

Re: What to Django people have to say about Javascript frameworks to complement Django's philosophy on the front end

2013-04-18 Thread Thomas Weholt
I've looked at some of the frameworks you mention and I'm by no means a
javascript or javascript framework expert, but I'm working on a re-usable
app for django which will provide a rich client/server-side API with some
glue-code for KnockOutJs, HandbrakeJs etc. It makes it a lot easier to
build viewmodels for KnockoutJS, manipulate data client-side and update
data server side. The project is not restricted to KnockoutJS, but includes
helper routines especially aimed at Knockout and a few other well tested
frameworks.

The goal is not to replace any of the javascript frameworks, but to make it
easy for django-apps to create more modern looking and working web pages
with as little work as possible. Something like what the
django.contrib.admin-package has done for the backend, but for the frontend
instead ;-).

It's still pre-alpha, but I'll announce version 0.1 in a short while.


On Thu, Apr 18, 2013 at 8:12 AM, Doug Snyder  wrote:

> Another framework I looked at is SproutCore. This seems to be more focused
> around widgets like many javascript libraries have been before it. I'm not
> sure how extensible these widgets are and how quickly I would run into
> limitations of using them for things they weren't specifically designed for.
>
>
> On Thu, Apr 18, 2013 at 1:53 AM, Doug S  wrote:
>
>> I hope this is OK to talk Javascript in this Django group, I'm hoping its
>> relevant to enough Django folks to not be distracting.
>> I'm relatively new to Django, but my impression is that a few years ago
>> most django people prescribed to the wisdom of keeping javascript to a
>> minimum and just using simple JQuery to do simple tasks. Now I think heavy
>> Javascript usage is more of reality especially with the shift to more
>> mobile web apps, and that the Javascript community is stepping up and
>> providing some nice frameworks that can make django people feel a little
>> more at home using javascript, more high level frameworks that use MVC
>> architecture. I'm starting a few projects where I'll want to essentially
>> mirror my django models on the front end to allow editing with out page
>> refreshes, front end form validation, and switching between views that are
>> downloaded in one request but displayed only according to the state of the
>> front end javascript view state. I want nice seemless AJAX communcation
>> between the front and back end. I'm aware of a few Javascript libraries
>> that are focused around these things and improving javascript web app
>> development in general. KnockOutJS caught my eye at first and I did some
>> work with that. I found some things worked really fast and really easy, but
>> then once I tried more complex things I saw what I think where limitations
>> in its extensibility. Since I'm pretty inexperienced with it, I'm not sure
>> if this was my lack of experience or deficiencies in the framework. Then I
>> found out about Ember,js and it seemed to me like a more complete framework
>> ( it tagline is 'Ambitious Web Apps' ) that could probably handle almost
>> any situation that I would use it for, although for simple views it
>> required a tad more code to be written than KnockOutJS. My first experience
>> with Ember last weekend was pretty frustrating, working off what looks like
>> the only example in the docs and finding myself buried in errors that were
>> entirely foreign to me. This may be beginners luck but I also heard someone
>> more experienced express frustration with the learning curve and lack of
>> examples in the docs. I've just become aware of a number of Javascript
>> libraries that seem to do related things that will be useful for my needs
>> above. AngularJS I think is gaining popularity quickly and seems to be
>> selling itself as a simple solution that can be extended in any variety of
>> ways ( much like django ). I tend to feel good about trusting Google but I
>> wonder if what I think is a more structured approach in Ember js is a wiser
>> choice for me. I've also read about Spine, which describes itself as a
>> simple lightweight MVC framework. Backbone is apparently a library entirely
>> concerned with front end data models but not databinding or routing. I
>> found a library called Batman intended for Rails but since a Google search
>> for django and batman is all about movies and not programming I'm guessing
>> no one has adapted this JS lib for django. All of what I'm writing is not
>> based on expertise or experience, what I'm really hoping for is some hints
>> from django people about what they use or what the pros and cons of the
>> different options for javascript frameworks are, and to encourage
>> discussion about this that might be useful to a lot of django people
>> looking to bridge the front end with backend. Feel free to stretch the
>> boundaries of my questions if you even think I've given any clear
>> boundaries, assume that you know more than I, and if you're wrong, no
>> worries, this 

Re: What to Django people have to say about Javascript frameworks to complement Django's philosophy on the front end

2013-04-18 Thread Russell Keith-Magee
On Thu, Apr 18, 2013 at 1:53 PM, Doug S  wrote:

> I hope this is OK to talk Javascript in this Django group, I'm hoping its
> relevant to enough Django folks to not be distracting.
> I'm relatively new to Django, but my impression is that a few years ago
> most django people prescribed to the wisdom of keeping javascript to a
> minimum and just using simple JQuery to do simple tasks.
>

This is incorrect. What we've said is that Django is a server side
framework, and the choice to use a JavaScript library/framework is a
client-side choice. As a framework, Django has quite deliberately remained
agnostic on your client side choices.

That said, there are many web applications written in Django that have rich
client-side experiences, based upon integration with various JavaScript
libraries. However, this integration isn't managed as part of Django's core
- it's the role of third-party libraries that you can use within your
Django project that exploit Django's APIs.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: What to Django people have to say about Javascript frameworks to complement Django's philosophy on the front end

2013-04-18 Thread Doug Snyder
Another framework I looked at is SproutCore. This seems to be more focused
around widgets like many javascript libraries have been before it. I'm not
sure how extensible these widgets are and how quickly I would run into
limitations of using them for things they weren't specifically designed for.


On Thu, Apr 18, 2013 at 1:53 AM, Doug S  wrote:

> I hope this is OK to talk Javascript in this Django group, I'm hoping its
> relevant to enough Django folks to not be distracting.
> I'm relatively new to Django, but my impression is that a few years ago
> most django people prescribed to the wisdom of keeping javascript to a
> minimum and just using simple JQuery to do simple tasks. Now I think heavy
> Javascript usage is more of reality especially with the shift to more
> mobile web apps, and that the Javascript community is stepping up and
> providing some nice frameworks that can make django people feel a little
> more at home using javascript, more high level frameworks that use MVC
> architecture. I'm starting a few projects where I'll want to essentially
> mirror my django models on the front end to allow editing with out page
> refreshes, front end form validation, and switching between views that are
> downloaded in one request but displayed only according to the state of the
> front end javascript view state. I want nice seemless AJAX communcation
> between the front and back end. I'm aware of a few Javascript libraries
> that are focused around these things and improving javascript web app
> development in general. KnockOutJS caught my eye at first and I did some
> work with that. I found some things worked really fast and really easy, but
> then once I tried more complex things I saw what I think where limitations
> in its extensibility. Since I'm pretty inexperienced with it, I'm not sure
> if this was my lack of experience or deficiencies in the framework. Then I
> found out about Ember,js and it seemed to me like a more complete framework
> ( it tagline is 'Ambitious Web Apps' ) that could probably handle almost
> any situation that I would use it for, although for simple views it
> required a tad more code to be written than KnockOutJS. My first experience
> with Ember last weekend was pretty frustrating, working off what looks like
> the only example in the docs and finding myself buried in errors that were
> entirely foreign to me. This may be beginners luck but I also heard someone
> more experienced express frustration with the learning curve and lack of
> examples in the docs. I've just become aware of a number of Javascript
> libraries that seem to do related things that will be useful for my needs
> above. AngularJS I think is gaining popularity quickly and seems to be
> selling itself as a simple solution that can be extended in any variety of
> ways ( much like django ). I tend to feel good about trusting Google but I
> wonder if what I think is a more structured approach in Ember js is a wiser
> choice for me. I've also read about Spine, which describes itself as a
> simple lightweight MVC framework. Backbone is apparently a library entirely
> concerned with front end data models but not databinding or routing. I
> found a library called Batman intended for Rails but since a Google search
> for django and batman is all about movies and not programming I'm guessing
> no one has adapted this JS lib for django. All of what I'm writing is not
> based on expertise or experience, what I'm really hoping for is some hints
> from django people about what they use or what the pros and cons of the
> different options for javascript frameworks are, and to encourage
> discussion about this that might be useful to a lot of django people
> looking to bridge the front end with backend. Feel free to stretch the
> boundaries of my questions if you even think I've given any clear
> boundaries, assume that you know more than I, and if you're wrong, no
> worries, this discussion is as much for your education as it is for mine.
>
>  --
> 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?hl=en.
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.