Django admin filters + select2 + loading many options asynchronously

2021-08-04 Thread Federico Capoano
Hi everyone,

when adding adming filters by foreign key in the admin, sometimes the 
possible values are too many to load.

So I am thinking, why not load values asynchronously and show these with 
select2?
Probably only a certain number of values should be fetched and then while 
scrolling more values should be loaded.

I am wondering, is there any solution for this already?

Thanks in advance
Best regards

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9f5c5bd9-d172-41d1-89f2-68b36b3050f5n%40googlegroups.com.


SynchronousOnlyOperation: bug or misconfiguration?

2020-12-18 Thread Federico Capoano
I have a celery task which performs queries and network operations.

When deployed with celery with gevent concurrency, I occasionally (but not 
always) get reports of SynchronousOnlyOperation exceptions being raised.

I described the problem in detail on StackOverflow: SynchronousOnlyOperation 
from celery task using gevent execution pool 

.

I tried debugging the issue and looking for information about similar 
issues with django+celery+gevent with little luck, but I have started to 
wonder if the fact that Django is raising this error there is a bug.

I see this error is raised if django detects an event loop, should this 
apply also to when gevent is using the eventloop?

Thanks in advance
Best regards
Federico

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a9366b47-55f2-4481-ab3d-391f22cec9edn%40googlegroups.com.


Re: Django key/value JSON widget

2020-08-19 Thread Federico Capoano
On Wed, Aug 19, 2020 at 3:43 AM Roger Gammans 
wrote:

> Hi
>
> Thanks that looks useful.
>
> On my rather long TODO list is to turn use this (
> https://github.com/josdejong/jsoneditor
> ) npm package to build a less
> restrictive json widget...
>

There's already several packages for that. Try googling django-jsoneditor
,

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAERYH6XjB%2BSRP7QQLBxWYsdZQNBntUECHLx9UN7HEHbffjp8cg%40mail.gmail.com.


Re: Django key/value JSON widget

2020-08-17 Thread Federico Capoano

Since I wasn't able to find a package which had this kind of widget, I 
scratched my own itch and published django-flat-json-widget 
<https://github.com/openwisp/django-flat-json-widget#django-flat-json-widget>
.
I hope it will be useful to others as well, I included a gif that shows the 
widget in action.

Best regards
Federico Capoano
On Wednesday, July 22, 2020 at 1:34:01 PM UTC-5 Federico Capoano wrote:

> Hey everyone,
>
> I'm looking for a key/value widget to edit a JSON flat object, like this 
> widget here: 
> https://django-hstore.readthedocs.io/en/latest/#django-admin-widget (I 
> made this one a while ago, but I'm not maintaining that project anymore).
>
> But I'm having no luck in finding it, there must already be some, right?
>
> Thanks in advance
> Federico
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/27e1347b-6a17-4892-8ca8-736bcc6c6c27n%40googlegroups.com.


Django key/value JSON widget

2020-07-22 Thread Federico Capoano
Hey everyone,

I'm looking for a key/value widget to edit a JSON flat object, like this 
widget here: 
https://django-hstore.readthedocs.io/en/latest/#django-admin-widget (I made 
this one a while ago, but I'm not maintaining that project anymore).

But I'm having no luck in finding it, there must already be some, right?

Thanks in advance
Federico

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e47d28d9-78dc-49d1-ad18-ffe81acdbeabn%40googlegroups.com.


Re: Callable field in fieldset's field

2020-04-16 Thread 'Federico Capoano' via Django users
Is this the kind of thing you're looking for?
https://github.com/openwisp/openwisp-firmware-upgrader/tree/1e9fa26d75a48ae9274c2708ea9a10134a2bb9d0/openwisp_firmware_upgrader/base/admin.py#L150-L186

Fed


On Wednesday, April 15, 2020 at 4:15:48 PM UTC-5, Gagan Deep wrote:
>
> Greetings of the day, 
>
> I have defined a model admin inheriting from admin.ModelAdmin class. There 
> is one of the fields which I want to show on the admin dashboard which is a 
> function. I read in Django docs that for a callable function to be a field, 
> it should be added in readonly_fields. So far, it was working great. The 
> problem arose when I mentioned that callable field in the fieldset. 
>
> This worked fine:
> class Myadmin(admin.ModelAdmin):
> readonly_fields = ('my_callable_field', )
> fields = ('my_callable_field' )
>
>
> But, doing this popped Unknown field(s) (my_callable_field) specified for 
> . Check fields/fieldsets/exclude attributes of class Myadmin
> class Myadmin(admin.ModelAdmin):
> readonly_fields = ('my_callable_field', )
> fieldsets = (
> (None, {'fields': ('my_callable_field',)}),
> )
>
> I don't understand why this is happening.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd24c6eb-fcaa-41dc-ac78-6f2ba700c5e9%40googlegroups.com.


Re: Any django reusable app for outdoor & indoor location, GPS tracking?

2018-05-04 Thread 'Federico Capoano' via Django users
Hey everyone,

I forgot to follow up on this thread.

django-loci <https://github.com/openwisp/django-loci> now provides 
abstract/base classes for models, admin, channels so other developers can 
use this reusable app as a kind of library.

There's ample room for improving this new reusable app but nonetheless I 
hope it will be a useful addition to the django ecosystem.

Best regards
Federico


On Tuesday, November 21, 2017 at 3:34:16 PM UTC+1, Federico Capoano wrote:
>
> Hi everyone,
>
> I'd like to provide an update on this topic.
>
> First of all, I think my initial question was not 100% clear.
>
> For indoor location and GPS tracking I meant the following:
>
> Indoor location: being able to specify the location of an object in 
> buildings, having their floorplan(s).
> GPS tracking: being able to track objects that move around, in the case of 
> OpenWISP <http://openwisp.org> these objects will be most likely be 
> network/radio/wifi devices.
>
> In the end I didn't find any reusable app so I started working on a new 
> app which I named django-loci <https://github.com/openwisp/django-loci>. 
> It's not released yet but it kinda works, I have shown a prototype of this 
> work during this presentation (I'm linking the exact second in which I show 
> it): https://www.youtube.com/watch?v=WgVduiZzuA0 (the recording was 
> slightly disturbed so bear with it while you wait for the floorplan demo to 
> show up.
>
> Like the other OpenWISP 2 base modules, I will soon provide abstract base 
> models, base views and other classes/functions that third party apps can 
> import in their project and extend.
> We have done this for django-x509 
> <https://github.com/openwisp/django-x509> and is going quite well, since 
> other developers who don't use OpenWISP are using django-x509 in their 
> project, reporting bugs and sending patches.
>
> I'll send another announcement when we hit the 0.1 release of django-loci, 
> hopefully it will be useful to other people and/or we'll be able to collect 
> useful feedback and/or suggestions.
>
> Federico
>
> PS: if you are curious to know more about the modular architecture of 
> OpenWISP 2, there's a presentation which has a good level of detail 
> https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world
>
>
> On Tuesday, September 26, 2017 at 12:13:30 PM UTC+2, Federico Capoano 
> wrote:
>>
>> Hi everyone,
>>
>> before building my own reusable app all over again, I wanted to ask here 
>> if there is any reusable django app that does indoor location and or GPS 
>> tracking.
>> I'm not looking for something full featured, but rather a starting point 
>> to which I can contribute to.
>>
>> Best regards
>> Federico Capoano
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ad3fc1ca-f377-4536-8475-7a02774c5bc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Any django reusable app for outdoor & indoor location, GPS tracking?

2017-11-21 Thread 'Federico Capoano' via Django users
Hi everyone,

I'd like to provide an update on this topic.

First of all, I think my initial question was not 100% clear.

For indoor location and GPS tracking I meant the following:

Indoor location: being able to specify the location of an object in 
buildings, having their floorplan(s).
GPS tracking: being able to track objects that move around, in the case of 
OpenWISP <http://openwisp.org> these objects will be most likely be 
network/radio/wifi devices.

In the end I didn't find any reusable app so I started working on a new app 
which I named django-loci <https://github.com/openwisp/django-loci>. It's 
not released yet but it kinda works, I have shown a prototype of this work 
during this presentation (I'm linking the exact second in which I show 
it): https://www.youtube.com/watch?v=WgVduiZzuA0 (the recording was 
slightly disturbed so bear with it while you wait for the floorplan demo to 
show up.

Like the other OpenWISP 2 base modules, I will soon provide abstract base 
models, base views and other classes/functions that third party apps can 
import in their project and extend.
We have done this for django-x509 <https://github.com/openwisp/django-x509> 
and is going quite well, since other developers who don't use OpenWISP are 
using django-x509 in their project, reporting bugs and sending patches.

I'll send another announcement when we hit the 0.1 release of django-loci, 
hopefully it will be useful to other people and/or we'll be able to collect 
useful feedback and/or suggestions.

Federico

PS: if you are curious to know more about the modular architecture of 
OpenWISP 2, there's a presentation which has a good level of 
detail 
https://www.slideshare.net/FedericoCapoano/applying-the-unix-philosophy-to-django-projects-a-report-from-the-real-world


On Tuesday, September 26, 2017 at 12:13:30 PM UTC+2, Federico Capoano wrote:
>
> Hi everyone,
>
> before building my own reusable app all over again, I wanted to ask here 
> if there is any reusable django app that does indoor location and or GPS 
> tracking.
> I'm not looking for something full featured, but rather a starting point 
> to which I can contribute to.
>
> Best regards
> Federico Capoano
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/552281bc-87b1-43e5-9812-cfcd2f1ced91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin: is there an event, or another way to call a Javascript function, when a Django Admin Popup (the green plus icon) completes ?

2017-09-30 Thread 'Federico Capoano' via Django users
Opened a new thread on 
django-developers: 
https://groups.google.com/d/msg/django-developers/BsudgRRCKb4/airBUyhaAwAJ



On Saturday, September 30, 2017 at 6:32:51 PM UTC+2, Federico Capoano wrote:
>
> Hi James,
>
> I was banging my head on the wall for this issue, you saved me some 
> precious time, thank you!
>
> I wonder why such a mechanism is not included by default into Django, I 
> will bring up this issue on the development mailing list.
>
> Federico
>
>
>
> On Thursday, November 26, 2015 at 11:58:22 AM UTC+1, James Murty wrote:
>>
>> Hi,
>>
>> Below is a Javascript file with the hackery we use to trigger a change 
>> event when the add/change popup window is dismissed, which works for Django 
>> 1.7 at least.
>>
>> Hopefully it will help, or at least point you in the right direction.
>>
>> Regards,
>> James
>>
>> /*
>>  * Trigger change events when Django admin's popup window is dismissed
>>  */
>> (function($) {
>> $(document).ready(function() {
>>
>> // HACK to override `dismissRelatedLookupPopup()` and
>> // `dismissAddAnotherPopup()` in Django's RelatedObjectLookups.js 
>> to
>> // trigger change event when an ID is selected or added via popup.
>> function triggerChangeOnField(win, chosenId) {
>> var name = windowname_to_id(win.name);
>> var elem = document.getElementById(name);
>> $(elem).change();
>> }
>> window.ORIGINAL_dismissRelatedLookupPopup = 
>> window.dismissRelatedLookupPopup
>> window.dismissRelatedLookupPopup = function(win, chosenId) {
>> ORIGINAL_dismissRelatedLookupPopup(win, chosenId);
>> triggerChangeOnField(win, chosenId);
>> }
>> window.ORIGINAL_dismissAddAnotherPopup = 
>> window.dismissAddAnotherPopup
>> window.dismissAddAnotherPopup = function(win, chosenId) {
>> ORIGINAL_dismissAddAnotherPopup(win, chosenId);
>> triggerChangeOnField(win, chosenId);
>> }
>>
>> });
>> })(jQuery);
>>
>>
>>
>> On Wednesday, 25 November 2015 21:39:06 UTC+11, boito...@gmail.com wrote:
>>>
>>> Hi,
>>>
>>>   I see this question is not receiving a lot of love. Perhaps we can try 
>>> to approach it differently then:
>>>  What is the mechanism that populates back the parentform select once 
>>> the pop-up form is completed and saved ? (As I have very limited experience 
>>> with front-end web technologies, I would not know where to look for the 
>>> code implementing that functionnality).
>>>
>>> From here, perhaps we can try to hook some custom Javascript.
>>>
>>> Thank you for reading,
>>>   Ad
>>>
>>> Le vendredi 20 novembre 2015 09:55:10 UTC+1, boito...@gmail.com a 
>>> écrit :
>>>>
>>>> Hi,
>>>>
>>>>   We are developing an application that relies on dynamic admin pages 
>>>> (based on some custom ajax). The high level idea is that, when the user 
>>>> changes the value in a select html element that is mapped to a 
>>>> ForeignKey on another model, we call a JS function (which triggers an 
>>>> asynchronous request that changes the current admin form on completion).
>>>>
>>>>
>>>> To achieve that, we listen to the change event of said select (to call 
>>>> the JS function when it is fired), which works fine when the user 
>>>> clicks a value directly in the drop-down menu proposed by the select.
>>>>
>>>> Sadly, when this select is populated through the Admin Popup 
>>>> functionality (the process that starts by clicking the green plus icon to 
>>>> open a popup window, and that completes when the user click the save 
>>>> button 
>>>> on the popup window), it seems that the change event is not fired for 
>>>> the select, as our callback is not executed, even though the selected 
>>>> value 
>>>> is actually changed.
>>>>
>>>> Is there another event we can listen to to get the same behaviour than 
>>>> when the user clicks a value directly from the list ? Or any other method 
>>>> to call our JS function when the select value is set through the popup 
>>>> completion ?
>>>>
>>>> Thank you for reading,
>>>>   Ad
>>>>
>>>> (Full disclosure: I first tried my luck with a question on SO 
>>>> <http://stackoverflow.com/q/33789528/1027706>, without great success)
>>>>
>>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6172c177-174d-46f5-9018-e016ff58d092%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin: is there an event, or another way to call a Javascript function, when a Django Admin Popup (the green plus icon) completes ?

2017-09-30 Thread 'Federico Capoano' via Django users
Hi James,

I was banging my head on the wall for this issue, you saved me some 
precious time, thank you!

I wonder why such a mechanism is not included by default into Django, I 
will bring up this issue on the development mailing list.

Federico



On Thursday, November 26, 2015 at 11:58:22 AM UTC+1, James Murty wrote:
>
> Hi,
>
> Below is a Javascript file with the hackery we use to trigger a change 
> event when the add/change popup window is dismissed, which works for Django 
> 1.7 at least.
>
> Hopefully it will help, or at least point you in the right direction.
>
> Regards,
> James
>
> /*
>  * Trigger change events when Django admin's popup window is dismissed
>  */
> (function($) {
> $(document).ready(function() {
>
> // HACK to override `dismissRelatedLookupPopup()` and
> // `dismissAddAnotherPopup()` in Django's RelatedObjectLookups.js 
> to
> // trigger change event when an ID is selected or added via popup.
> function triggerChangeOnField(win, chosenId) {
> var name = windowname_to_id(win.name);
> var elem = document.getElementById(name);
> $(elem).change();
> }
> window.ORIGINAL_dismissRelatedLookupPopup = 
> window.dismissRelatedLookupPopup
> window.dismissRelatedLookupPopup = function(win, chosenId) {
> ORIGINAL_dismissRelatedLookupPopup(win, chosenId);
> triggerChangeOnField(win, chosenId);
> }
> window.ORIGINAL_dismissAddAnotherPopup = 
> window.dismissAddAnotherPopup
> window.dismissAddAnotherPopup = function(win, chosenId) {
> ORIGINAL_dismissAddAnotherPopup(win, chosenId);
> triggerChangeOnField(win, chosenId);
> }
>
> });
> })(jQuery);
>
>
>
> On Wednesday, 25 November 2015 21:39:06 UTC+11, boito...@gmail.com wrote:
>>
>> Hi,
>>
>>   I see this question is not receiving a lot of love. Perhaps we can try 
>> to approach it differently then:
>>  What is the mechanism that populates back the parentform select once 
>> the pop-up form is completed and saved ? (As I have very limited experience 
>> with front-end web technologies, I would not know where to look for the 
>> code implementing that functionnality).
>>
>> From here, perhaps we can try to hook some custom Javascript.
>>
>> Thank you for reading,
>>   Ad
>>
>> Le vendredi 20 novembre 2015 09:55:10 UTC+1, boito...@gmail.com a écrit :
>>>
>>> Hi,
>>>
>>>   We are developing an application that relies on dynamic admin pages 
>>> (based on some custom ajax). The high level idea is that, when the user 
>>> changes the value in a select html element that is mapped to a 
>>> ForeignKey on another model, we call a JS function (which triggers an 
>>> asynchronous request that changes the current admin form on completion).
>>>
>>>
>>> To achieve that, we listen to the change event of said select (to call 
>>> the JS function when it is fired), which works fine when the user 
>>> clicks a value directly in the drop-down menu proposed by the select.
>>>
>>> Sadly, when this select is populated through the Admin Popup 
>>> functionality (the process that starts by clicking the green plus icon to 
>>> open a popup window, and that completes when the user click the save button 
>>> on the popup window), it seems that the change event is not fired for 
>>> the select, as our callback is not executed, even though the selected value 
>>> is actually changed.
>>>
>>> Is there another event we can listen to to get the same behaviour than 
>>> when the user clicks a value directly from the list ? Or any other method 
>>> to call our JS function when the select value is set through the popup 
>>> completion ?
>>>
>>> Thank you for reading,
>>>   Ad
>>>
>>> (Full disclosure: I first tried my luck with a question on SO 
>>> , without great success)
>>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff3a3421-11ca-4a17-99f3-c427240b6941%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Any django reusable app for outdoor & indoor location, GPS tracking?

2017-09-26 Thread 'Federico Capoano' via Django users
Hi everyone,

before building my own reusable app all over again, I wanted to ask here if 
there is any reusable django app that does indoor location and or GPS 
tracking.
I'm not looking for something full featured, but rather a starting point to 
which I can contribute to.

Best regards
Federico Capoano

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5add2c0f-3a30-46ea-91b8-c02f01d2ad5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django m2m through model with classic admin widget

2016-08-22 Thread 'Federico Capoano' via Django users
Glad to know there's an accepted ticket for this.

Right now I'm not sure I'll be able to work on it and will probably use a 
less pretty workaround, but I'm coming to Django Under The Hood and I'm 
pretty sure I will participate in the sprints, so if I cannot work on it 
now I already have a ticket to work on by then.

Thanks
Federico


On Monday, August 22, 2016 at 2:24:17 PM UTC+2, Tim Graham wrote:
>
> I haven't look into what's needed to make this work on current Django 
> versions, however, if you're interested in contributing to Django, there's 
> an open ticket to allow using the widget as long as there aren't any extra 
> required fields on the through model: 
> https://code.djangoproject.com/ticket/12203
>
> On Monday, August 22, 2016 at 6:00:06 AM UTC-4, Federico Capoano wrote:
>>
>> Hi,
>>
>> this is a tough question, i've posted it to stackoverflow here:
>>
>> http://stackoverflow.com/questions/39076392/django-m2m-through-model-with-classic-admin-widget
>>
>> I include the text of the question here to make it easier to respond:
>>
>> I need to customise a through model of a many-to-many relationship, the 
>> customisation is subtle, because the user won't need do act manually, I try 
>> to explain myself better by explaining my use case with the following 
>> pseudo code:
>>
>>
>> RouterConfiguration- vpn (many-to-many through VpnClient)# other fields
>> VpnClient- router: ForeignKey to RouterConfiguration- vpn: ForeignKey to 
>> Vpn- cert: ForeignKey to Cert
>> Vpn# other fields
>> Cert# (stores x509 certificates)# other fields
>>
>>
>> The through model VpnClient has only one additional field, a ForeignKey
>>  to Cert, but I want VpnClient to automatically create a Cert instance 
>> without user interaction and until here there is no problem.
>>
>> The problem comes in the Django Admin, because as far as I understood, it 
>> is not possible to use the classic many2many widget when using a through 
>> model:
>>
>> When you specify an intermediary model using the through argument to a 
>> ManyToManyField, the admin will not display a widget by default. This is 
>> because each instance of that intermediary model requires more information 
>> than could be displayed in a single widget, and the layout required for 
>> multiple widgets will vary depending on the intermediate model.
>>
>> Reference: 
>> https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#working-with-many-to-many-intermediary-models
>>
>> But I don't want the user to insert any extra information. I just want to 
>> be able to control the model so it can perform a series of actions 
>> automatically.
>>
>> So my question is: is it possible to have the classic admin widget with a 
>> custom through model? If there's no easy solution maybe I could try with a 
>> custom widget? Or maybe there is an alternative way to accomplish what I 
>> need?
>>
>>
>> Thanks to anyone who can give me any useful suggestion.
>>
>> Federico
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2b165e8f-58bb-4918-b41d-13eebb42c15a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django m2m through model with classic admin widget

2016-08-22 Thread 'Federico Capoano' via Django users
Hi,

this is a tough question, i've posted it to stackoverflow here:
http://stackoverflow.com/questions/39076392/django-m2m-through-model-with-classic-admin-widget

I include the text of the question here to make it easier to respond:

I need to customise a through model of a many-to-many relationship, the 
customisation is subtle, because the user won't need do act manually, I try 
to explain myself better by explaining my use case with the following 
pseudo code:


RouterConfiguration- vpn (many-to-many through VpnClient)# other fields
VpnClient- router: ForeignKey to RouterConfiguration- vpn: ForeignKey to Vpn- 
cert: ForeignKey to Cert
Vpn# other fields
Cert# (stores x509 certificates)# other fields


The through model VpnClient has only one additional field, a ForeignKey to 
Cert, but I want VpnClient to automatically create a Cert instance without 
user interaction and until here there is no problem.

The problem comes in the Django Admin, because as far as I understood, it 
is not possible to use the classic many2many widget when using a through 
model:

When you specify an intermediary model using the through argument to a 
ManyToManyField, the admin will not display a widget by default. This is 
because each instance of that intermediary model requires more information 
than could be displayed in a single widget, and the layout required for 
multiple widgets will vary depending on the intermediate model.

Reference: 
https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#working-with-many-to-many-intermediary-models

But I don't want the user to insert any extra information. I just want to 
be able to control the model so it can perform a series of actions 
automatically.

So my question is: is it possible to have the classic admin widget with a 
custom through model? If there's no easy solution maybe I could try with a 
custom widget? Or maybe there is an alternative way to accomplish what I 
need?


Thanks to anyone who can give me any useful suggestion.

Federico

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4488bb17-dabd-4bef-9fa4-7707a4b76c9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Supporting a wider range of awesome PostgreSQL features in Django - including hstore, JSON and full text search

2014-02-23 Thread Federico Capoano
I found this on django's blog:

https://www.kickstarter.com/projects/mjtamlyn/improved-postgresql-support-in-django

Very interesting!

Anybody knows if they intend to redevelop everything from scratch or reuse 
and improve existing implementations?

Federico

-- 
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/0ce88480-2143-4e40-9b09-ca47c3234b52%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: GenericIPAddressField validation error not translated

2011-08-18 Thread Federico Capoano
How can I contribute?


On Aug 13, 6:50 am, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Aug 11, 2011 at 2:58 PM, Federico Capoano
> <nemesis.des...@libero.it>wrote:
>
> > Hi all,
>
> > i'm using the new GenericIPAddressField and validation errors are not
> > translated to the language of my project.
>
> > Pheraps this field hasn't been internationalized yet?
>
> Correct. Updating translations are done as part of the release process. If
> you're pulling new code out of the repo, it won't have translations.
>
> Karen
> --http://tracey.org/kmt/

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



GenericIPAddressField validation error not translated

2011-08-11 Thread Federico Capoano
Hi all,

i'm using the new GenericIPAddressField and validation errors are not
translated to the language of my project.

Pheraps this field hasn't been internationalized yet?

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



Receiving [Django] ERROR via email even if DEBUG = True

2011-07-20 Thread Federico Capoano
Hi,

i'm using django 1.4 alpha from SVN. I get email notification for
errors on my local machine which I use to develop.

How can I turn these notifications off?

DEBUG is True on my settings.py.

Thanks

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



Re: database i18n

2011-02-23 Thread Federico Capoano
Thanks Hernik. I liked the idea of django-i18n-model but I couldn't
get it working. Now I'm about to try django-transmeta.


On Feb 23, 10:34 am, "Henrik Genssen" <henrik.gens...@miadi.net>
wrote:
> I feel, this should be something integrated into Django, too.
>
> So far I am using transdb (but I am still sitting on Django 1.1).
>
> advantage:
> - all translations in one field as a dict so easy searchable, if icontains is 
> all you want
>
> disadvantages:
> - all translations in one field as a dict, therefor finds other rows having a 
> similar phrase (in other languages), too, as you must use icontains
> - you can not use startswith or endswith
> - no support for django-tagging
>
> regards
>
> Henrik
>
>
>
>
>
>
>
> >reply to message:
> >date: 22.02.2011 13:13:18
> >from: "Federico Capoano" <nemesis.des...@libero.it>
> >to: "Django users" <django-users@googlegroups.com>
> >subject: [] database i18n
>
> >I'm quite surprised that django doesn't have a native i18n solution
> >for models.
>
> >I've been trying some apps but one doesn't work with latest versions,
> >one is no longer developed, another one has no documentation, another
> >one simply doesn't work.
>
> >Tomorrow I'm going to try again and pheraps try some new ones.
>
> >What is your opinion regarding this matter? Is there an app you
> >suggest?
>
> >--
> >You received this message because you are subscribed to the Google Groups 
> >"Django users" group.
> >To post to this group, send email to django-users@googlegroups.com.
> >To unsubscribe from this group, send email to 
> >django-users+unsubscr...@googlegroups.com.
> >For more options, visit this group 
> >athttp://groups.google.com/group/django-users?hl=en.

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



database i18n

2011-02-22 Thread Federico Capoano
I'm quite surprised that django doesn't have a native i18n solution
for models.

I've been trying some apps but one doesn't work with latest versions,
one is no longer developed, another one has no documentation, another
one simply doesn't work.

Tomorrow I'm going to try again and pheraps try some new ones.

What is your opinion regarding this matter? Is there an app you
suggest?

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



Re: Caught UnicodeDecodeError when using {% get_available_languages as langs %}

2010-11-26 Thread Federico Capoano
Thanks Tom.



On Nov 26, 9:15 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Fri, Nov 26, 2010 at 7:46 PM, Federico Capoano
>
>
>
>
>
>
>
>
>
> <nemesis.des...@libero.it> wrote:
> > Hi all,
>
> > this is my settings.py
>
> > _ = lambda s: s
>
> > LANGUAGES = (
> >  ('en', _('English')),
> >  ('es', _('Español')),
> >  ('it', _('Italiano')),
> > )
>
> > When I use {% get_available_languages as langs %}
>
> > I get this error:
>
> > TemplateSyntaxError at /
> > Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode
> > byte 0xc3 in position 4: ordinal not in range(128)
>
> > Am I doing something wrong?
>
> Mark the strings correctly as unicode, eg _(u'Español'). I'm assuming
> your file encoding on settings.py is UTF-8.
>
> HTH
>
> Tom

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



Re: Caught UnicodeDecodeError when using {% get_available_languages as langs %}

2010-11-26 Thread Federico Capoano
1.3 alpha 1 SVN-14688


On Nov 26, 8:46 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hi all,
>
> this is my settings.py
>
> _ = lambda s: s
>
> LANGUAGES = (
>   ('en', _('English')),
>   ('es', _('Español')),
>   ('it', _('Italiano')),
> )
>
> When I use {% get_available_languages as langs %}
>
> I get this error:
>
> TemplateSyntaxError at /
> Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode
> byte 0xc3 in position 4: ordinal not in range(128)
>
> Am I doing something wrong?

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



Caught UnicodeDecodeError when using {% get_available_languages as langs %}

2010-11-26 Thread Federico Capoano
Hi all,

this is my settings.py

_ = lambda s: s

LANGUAGES = (
  ('en', _('English')),
  ('es', _('Español')),
  ('it', _('Italiano')),
)

When I use {% get_available_languages as langs %}

I get this error:

TemplateSyntaxError at /
Caught UnicodeDecodeError while rendering: 'ascii' codec can't decode
byte 0xc3 in position 4: ordinal not in range(128)

Am I doing something wrong?

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



Re: Set Language in the Admin

2010-11-23 Thread Federico Capoano
I got rid of the LocaleMiddleware.

To translate the frontend of the application I'm using
http://bitbucket.org/carljm/django-localeurl/overview

It seems the best solution for me.




On Nov 18, 1:29 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
> Thanks
>
> On Nov 16, 11:19 am, Tom Evans <tevans...@googlemail.com> wrote:
>
>
>
>
>
>
>
> > On Tue, Nov 16, 2010 at 9:58 AM, Federico Capoano
>
> > <nemesis.des...@libero.it> wrote:
> > > This will affect the frontend too?
>
> > Yes, I'd replace it with a customized version of the LocaleMiddleware,
> > something like this ought to do the trick:
>
> > from django.middleware.locale import LocaleMiddleware
> > from django.utils import translation
>
> > class LocaleButNotInAdminMiddleware(LocaleMiddleware):
> >   KWARG = 'DisableLocalisation'
> >   def process_view(self, request, view_func, view_args, view_kwargs):
> >     disable_localisation = self.KWARG in view_kwargs and
> > view_kwargs.pop(self.KWARG)
> >     if disable_localisation:
> >       translation.deactivate()
> >       if hasattr(request, 'LANGUAGE_CODE')
> >         del request.LANGUAGE_CODE
> >   def process_response(self, request, response):
> >     if hasattr(request, 'LANGUAGE_CODE'):
> >       super(LocaleButNotInAdminMiddleware,
> > self).process_response(request, response)
> >     return response
>
> > and then change how you include the admin into your urlconf from
> > something like this:
>
> >   urlpatterns = patterns('',
> >     (r'^admin/(.*)', include(admin.site.urls)),
> >   )
>
> > to something like this:
>
> >   urlpatterns = patterns('',
> >     (r'^admin/(.*)', include(admin.site.urls), {'DisableLocalisation': 
> > True}),
> >   )
>
> > So that it disables the effects of the LocaleMiddleware when the view
> > to be served will be passed the appropriate kwarg, and the kwarg is
> > passed to the view by configuring it so in the urlconf. The kwarg
> > should never make it to the admin views.
>
> > Cheers
>
> > Tom

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



Re: Set Language in the Admin

2010-11-18 Thread Federico Capoano
Thanks

On Nov 16, 11:19 am, Tom Evans <tevans...@googlemail.com> wrote:
> On Tue, Nov 16, 2010 at 9:58 AM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > This will affect the frontend too?
>
> Yes, I'd replace it with a customized version of the LocaleMiddleware,
> something like this ought to do the trick:
>
> from django.middleware.locale import LocaleMiddleware
> from django.utils import translation
>
> class LocaleButNotInAdminMiddleware(LocaleMiddleware):
>   KWARG = 'DisableLocalisation'
>   def process_view(self, request, view_func, view_args, view_kwargs):
>     disable_localisation = self.KWARG in view_kwargs and
> view_kwargs.pop(self.KWARG)
>     if disable_localisation:
>       translation.deactivate()
>       if hasattr(request, 'LANGUAGE_CODE')
>         del request.LANGUAGE_CODE
>   def process_response(self, request, response):
>     if hasattr(request, 'LANGUAGE_CODE'):
>       super(LocaleButNotInAdminMiddleware,
> self).process_response(request, response)
>     return response
>
> and then change how you include the admin into your urlconf from
> something like this:
>
>   urlpatterns = patterns('',
>     (r'^admin/(.*)', include(admin.site.urls)),
>   )
>
> to something like this:
>
>   urlpatterns = patterns('',
>     (r'^admin/(.*)', include(admin.site.urls), {'DisableLocalisation': True}),
>   )
>
> So that it disables the effects of the LocaleMiddleware when the view
> to be served will be passed the appropriate kwarg, and the kwarg is
> passed to the view by configuring it so in the urlconf. The kwarg
> should never make it to the admin views.
>
> Cheers
>
> Tom

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



Re: Nested Categories in Admin

2010-11-17 Thread Federico Capoano
Sorry I couldn't find anything, I'll search more.


On Nov 16, 3:00 pm, derek <gamesb...@gmail.com> wrote:
> You will need to use Javascipt: handwritten or via framework e.g.
> JQuery. Its been asked about before on this mailing list and numerous
> people have blogged on it.
>
> On Nov 16, 11:58 am, Federico Capoano <nemesis.des...@libero.it>
> wrote:
>
>
>
>
>
>
>
> > Any suggestion?
>
> > On Nov 14, 6:15 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
>
> > > Hi all,
>
> > > I would like to find a way to get categories and subcategories
> > > displayed in the admin, in the form of a multiple select.
>
> > > Like:
>
> > > parent
> > > child1
> > > child2
> > > parent2
> > > child3
>
> > > Do I have to make a custom field or is there already a solution
> > > around?
>
> > > Thanks

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



Re: Nested Categories in Admin

2010-11-16 Thread Federico Capoano
Any suggestion?


On Nov 14, 6:15 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hi all,
>
> I would like to find a way to get categories and subcategories
> displayed in the admin, in the form of a multiple select.
>
> Like:
>
> parent
> child1
> child2
> parent2
> child3
>
> Do I have to make a custom field or is there already a solution
> around?
>
> Thanks

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



Re: Set Language in the Admin

2010-11-16 Thread Federico Capoano
This will affect the frontend too?


On Nov 16, 4:57 am, someLiang <k.cancer.2...@gmail.com> wrote:
> just make it seems like this:
>
> MIDDLEWARE_CLASSES = (
>     'django.middleware.common.CommonMiddleware',
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     #'django.middleware.locale.LocaleMiddleware',
>     'django.middleware.csrf.CsrfViewMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'django.contrib.messages.middleware.MessageMiddleware',
> )
>
> 2010/11/16 someLiang <k.cancer.2...@gmail.com>
>
>
>
>
>
>
>
>
>
> > perhaps you need to comment the statement in your setting.py
>
> > 'django.middleware.locale.LocaleMiddleware',
>
> > 2010/11/15 Federico Capoano <nemesis.des...@libero.it>
>
> > Hi guys,
>
> >> i'm developing an app in 3 languages, en, es and it.
>
> >> My browser accepts all of them with priority to italian.
>
> >> Since I've done that the admin started to show up in italian. How can
> >> I force it back to english?
>
> >> In the setting I put
>
> >> LANGUAGE_CODE = 'en-gb'
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-us...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@google
> >>  groups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
> > --
> > Rita Liang
>
> --
> Rita Liang

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



Re: OT: getting strange attempted gets

2010-11-14 Thread Federico Capoano
No one is attacking your server, that's just the django server telling
you what's going on in your app (when you perform any action the
server logs it).

On Nov 14, 4:50 pm, John Fabiani  wrote:
> Hi,
> I'm a newbie to not only django but web programming in general.
>
> I have noticed that when I run my "python mange.py runserver" command I see
> strange entries that have nothing to do with my programming efforts.
>
> GET some URL  (not mine)  returns 404
> or
> CONNECTION some IP address (not on my network)   returns 404
>
> Does the above type entries reveal someone is attacking my server?
>
> Johnf

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



Nested Categories in Admin

2010-11-14 Thread Federico Capoano
Hi all,

I would like to find a way to get categories and subcategories
displayed in the admin, in the form of a multiple select.

Like:

parent
child1
child2
parent2
child3

Do I have to make a custom field or is there already a solution
around?

Thanks

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



Set Language in the Admin

2010-11-14 Thread Federico Capoano
Hi guys,

i'm developing an app in 3 languages, en, es and it.

My browser accepts all of them with priority to italian.

Since I've done that the admin started to show up in italian. How can
I force it back to english?

In the setting I put

LANGUAGE_CODE = 'en-gb'

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



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
I wanted to write this post anyway, gives a quick solution to upload
files above the public directory and serve the files with django-
filetransfers. Hopefully it will be easier to find from search
engines.

http://nemesisdesign.net/blog/coding/django-private-file-upload-and-serving/




On Sep 30, 10:40 am, Xavier Ordoquy <xordo...@linovia.com> wrote:
> Hi,
>
> To me, it looks like the documentation already gave the answer.
>
> Regards,
> Xavier.
>
> Le 30 sept. 2010 à 10:37, Federico Capoano a écrit :
>
>
>
> > PS: i'll post a solution so other noobs like me will see how to do
> > that..
>
> > On 30 Set, 10:35, Federico Capoano <nemesis.des...@libero.it> wrote:
> >> Yes you're right, I'm trying it out. I'll post a solution when I'm
> >> done.
>
> >> On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote:
>
> >>> Well, the documentation already tells you about 
> >>> it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> >>> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
> >>>> Is this not possible? I wonder why Django force to upload files only
> >>>> in a certain directory and doesn't allow more flexibility.
>
> >>>> On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> >>>>> Hi everyone,
>
> >>>>> is it possible to write a custom model filefield that upload files
> >>>>> somewhere above the public directory?
>
> >>>> --
> >>>> You received this message because you are subscribed to the Google 
> >>>> Groups "Django users" group.
> >>>> To post to this group, send email to django-us...@googlegroups.com.
> >>>> To unsubscribe from this group, send email to 
> >>>> django-users+unsubscr...@googlegroups.com.
> >>>> For more options, visit this group 
> >>>> athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
PS: i'll post a solution so other noobs like me will see how to do
that..


On 30 Set, 10:35, Federico Capoano <nemesis.des...@libero.it> wrote:
> Yes you're right, I'm trying it out. I'll post a solution when I'm
> done.
>
> On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote:
>
>
>
> > Well, the documentation already tells you about 
> > it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> > Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
> > > Is this not possible? I wonder why Django force to upload files only
> > > in a certain directory and doesn't allow more flexibility.
>
> > > On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> > >> Hi everyone,
>
> > >> is it possible to write a custom model filefield that upload files
> > >> somewhere above the public directory?
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.

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



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
Yes you're right, I'm trying it out. I'll post a solution when I'm
done.


On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote:
> Well, the documentation already tells you about 
> it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
>
>
> > Is this not possible? I wonder why Django force to upload files only
> > in a certain directory and doesn't allow more flexibility.
>
> > On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> >> Hi everyone,
>
> >> is it possible to write a custom model filefield that upload files
> >> somewhere above the public directory?
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



Re: Upload above apache web root?

2010-09-30 Thread Federico Capoano
Is this not possible? I wonder why Django force to upload files only
in a certain directory and doesn't allow more flexibility.



On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hi everyone,
>
> is it possible to write a custom model filefield that upload files
> somewhere above the public directory?

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



Upload above apache web root?

2010-09-29 Thread Federico Capoano
Hi everyone,

is it possible to write a custom model filefield that upload files
somewhere above the public directory?

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



Re: File Upload Content Type Verification

2010-09-24 Thread Federico Capoano
Thanks.

I'm concerned about the possibility of uploading and executing a
script on the server. Just this. I think I can avoid this by hiding
the file somewhere behind the public folder so the content is not
accessible via http.



On 24 Set, 13:31, Tom Evans <tevans...@googlemail.com> wrote:
> On Fri, Sep 24, 2010 at 12:23 PM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > I can't trust the user because this field will be used in the
> > frontend, which will be an app similar to the django admin, but much
> > more limited.
>
> > So according to what you said, there is no standard way to do this.
> > the second solution seems interesting.
>
> > But what if I wanted to restrict to images?
>
> > What's the best way to avoid security issues? Maybe store the file
> > somewhere hidden would be safer?
>
> Depends what you mean by 'standard'. I would consider it standard to
> validate user supplied input, and that process is the same regardless
> of filetype, the only thing that changes is how you validate the
> input.
>
> For images, you can simply use a ImageField, which uses PIL to
> validate that the uploaded file is an image file supported by PIL.
>
> I don't understand what security issues you are referring to.
>
> Cheers
>
> Tom

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



Re: File Upload Content Type Verification

2010-09-24 Thread Federico Capoano
I can't trust the user because this field will be used in the
frontend, which will be an app similar to the django admin, but much
more limited.

So according to what you said, there is no standard way to do this.
the second solution seems interesting.

But what if I wanted to restrict to images?

What's the best way to avoid security issues? Maybe store the file
somewhere hidden would be safer?




On 24 Set, 13:08, Tom Evans <tevans...@googlemail.com> wrote:
> On Fri, Sep 24, 2010 at 11:28 AM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > Is there a way we can check if a certain file being uploaded is really
> > what it claims to be?
> > Let's say I want to restrict files to PDF only, then I take a php
> > script and I rename it PDF I can still upload it if using the
> > following custom FileField that I just worked out yesterday:
>
> If you're not willing to trust the user, then you must validate the
> uploaded file. I can think of three straightforward ways to do so:
>
> 1) Use file(1) to determine the true file type. This will be just a
> guess from the opening few bytes of the file, and could be fooled by
> clever manipulation of the uploaded file.
>
> 2) Use ghostscript and it's utilities to validate the pdf file.
> Something along these lines:
>
>   try:
>       is_pdf = (subprocess.check_call(['pdf2ps', '/path/to/file.pdf',
> '/dev/null']) == 0)
>   except subprocessCalledProcessError:
>       is_pdf = False
>
> 3) Use a pure python library like pyPdf to examine it. I wouldn't
> recommend this, it's a bit old and crufty.
>
> Cheers
>
> Tom

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



File Upload Content Type Verification

2010-09-24 Thread Federico Capoano
Is there a way we can check if a certain file being uploaded is really
what it claims to be?
Let's say I want to restrict files to PDF only, then I take a php
script and I rename it PDF I can still upload it if using the
following custom FileField that I just worked out yesterday:

from django.db.models import FileField
from django.forms import forms
from django.template.defaultfilters import filesizeformat
from django.utils.translation import ugettext_lazy as _

class ContentTypeRestrictedFileField(FileField):
"""
Same as forms.FileField, but you can specify a content_type and
max_upload_size.
"""
def __init__(self, *args, **kwargs):
self.content_types = kwargs.pop("content_types")
self.max_upload_size = kwargs.pop("max_upload_size")

super(ContentTypeRestrictedFileField, self).__init__(*args,
**kwargs)

def clean(self, *args, **kwargs):
data = super(ContentTypeRestrictedFileField,
self).clean(*args, **kwargs)

file = data.file
content_type = file.content_type

if content_type in self.content_types:
if file._size > self.max_upload_size:
raise forms.ValidationError(_('Please keep filesize
under %s. Current filesize %s') %
(filesizeformat(self.max_upload_size), filesizeformat(file._size)))
else:
raise forms.ValidationError(_('The only filetype allowed
is PDF.'))

return data


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



Re: Help with file upload using ModelForm

2010-09-23 Thread Federico Capoano
Sorry ignore this.

Changed from:
form = PdfForm(
initial ={
'name': pdf.name,
'description': pdf.description,
'file': pdf.file,
}
)

to:
form = PdfForm(instance = pdf)

and it works fine.


On 23 Set, 17:43, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hello to all,
>
> maybe is something really silly, but I don't get it.
>
> I'm using ModelForm to edit a database object that has a file input.
>
> The  tag has enctype="multipart/form-data" and the view uses
> request.FILES.
>
> I can add and edit files without problems, but there is a case in
> which editing a file does not work:
> when I don't want to change the file I simply leave the field blank
> and I get a validation error saying that the file field is required.
>
> What am I missing?

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



Help with file upload using ModelForm

2010-09-23 Thread Federico Capoano
Hello to all,

maybe is something really silly, but I don't get it.

I'm using ModelForm to edit a database object that has a file input.

The  tag has enctype="multipart/form-data" and the view uses
request.FILES.

I can add and edit files without problems, but there is a case in
which editing a file does not work:
when I don't want to change the file I simply leave the field blank
and I get a validation error saying that the file field is required.

What am I missing?

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



Re: What's the best way to develop an app that is similar the django admin?

2010-09-23 Thread Federico Capoano
Thanks for the answers guy, I knew a little bit model forms, but I'll
check out also the other solution.


On 22 Set, 09:29, Matthias Kestenholz <matthias.kestenh...@gmail.com>
wrote:
> On Mon, Sep 20, 2010 at 3:13 PM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > Hi all,
>
> > I try to explain it clearly.
>
> > I have to develop an application that will implement similar
> > functionality and look of the django admin, but in the frontend.
>
> > So this application will have files management, clients management,
> > and much more similar stuff, with add new, edit, delete, file upload
> > and so on.
>
> > Is there a way you would advice to do this?
>
> There are a few implementations around which try to do something like
> that. One of them is my django_modelviews project -- it's unreleased,
> undocumented, but I use it on several sites in production. Short usage
> instructions:
>
> http://github.com/matthiask/modelviews/
>
> 1. Add django_modelviews to INSTALLED_APPS
> 2. Create a ModelView instance somewhere in your views.py, f.e. for
> your Client model:
>
> from yourapp.models import Client
> from django_modelviews import generic
> client_views = generic.ModelView(Client)
>
> 3. Create a URL entry:
>
> from yourapp.views import client_views
> urlpatterns = patterns('',
>     url(r'^clients/', include(client_views.urls)),
> )
>
> If the code does not work for you or does not fit your needs, maybe it
> can still serve as an inspiration for your own project.
>
> Matthias
>
> --
> Django CMS building toolkit:http://www.feinheit.ch/labs/feincms-django-cms/

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



What's the best way to develop an app that is similar the django admin?

2010-09-20 Thread Federico Capoano
Hi all,

I try to explain it clearly.

I have to develop an application that will implement similar
functionality and look of the django admin, but in the frontend.

So this application will have files management, clients management,
and much more similar stuff, with add new, edit, delete, file upload
and so on.

Is there a way you would advice to do this?

Thanks a lot.
Federico

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



Re: Converting a query using extra from Postgres to Mysql

2010-08-25 Thread Federico Capoano
it was simple:

locations = Location.objects.filter(category=category.id,
status=2).extra(
select={'image': 'SELECT locations_images.image FROM
locations_images WHERE locations_images.location_id =
locations_location.id ORDER BY locations_images.order ASC LIMIT 1'
},
).only('name', 'slug')



On Aug 25, 7:29 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hi to all django users,
>
> i just completed a project in which I used the extra() database API
> function in order to save the number of query used. Unfortunately the
> production server doesn't use Postgres but MySQL.
>
> I don't know why but I'm not making it to convert the query so it's
> compatible with MySQL, is there any good mate that can help me on
> this?
>
> This is the code:
>
> locations = Location.objects.filter(category=category.id,
> status=2).extra(
>         select={
>             'image': 'SELECT "locations_images"."image" FROM
> "locations_images" '
>             'WHERE ('
>                 '"locations_images"."location_id" =
> "locations_location"."id"::integer '
>             ')'
>             ' ORDER BY "locations_images"."order" ASC LIMIT 1'
>         },
>     ).only('name', 'slug')

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



Converting a query using extra from Postgres to Mysql

2010-08-25 Thread Federico Capoano
Hi to all django users,

i just completed a project in which I used the extra() database API
function in order to save the number of query used. Unfortunately the
production server doesn't use Postgres but MySQL.

I don't know why but I'm not making it to convert the query so it's
compatible with MySQL, is there any good mate that can help me on
this?

This is the code:

locations = Location.objects.filter(category=category.id,
status=2).extra(
select={
'image': 'SELECT "locations_images"."image" FROM
"locations_images" '
'WHERE ('
'"locations_images"."location_id" =
"locations_location"."id"::integer '
')'
' ORDER BY "locations_images"."order" ASC LIMIT 1'
},
).only('name', 'slug')

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



Re: UnicodeDecodeError (ordinal not in range) when deleting an inline item - 1.2.1

2010-06-27 Thread Federico Capoano
Thanks for your help. I've been able to fix the problem thanks also to
the Rackspace technical support.

This is the answer, i post it cos it might be useful to someone else:

"Greetings,

I've added the two lines you provided to /etc/sysconfig/httpd - a file
which is 'sourced' by the apache startup script and exists for exactly
this kind of need.

To get these statements to take effect, I've restarted the httpd
service.  Those two new environment variables should now exist on all
Apache processes and their child processes.

Please test and let me know of you're still seeing the UnicodeError,
some other error, or if things are now working properly.

Pleasure to help you;  If you have any concerns or questions, please
let me know."




On Jun 21, 12:42 pm, Matt Hoskins  wrote:
> Federico,
>
> When trying out what Karen suggests then in the unlikely event that
> Red Hat doesn't load the environment variables from /etc/apache2/
> envvars, one way to find it without consulting documents is to look at
> the apache start-up script (e.g. /usr/sbin/apache2ctl) so find that on
> your server and look at what that loads - for example the copy I've
> got has the following:
>
> # the path to the environment variable file
> test -z "$APACHE_ENVVARS" && APACHE_ENVVARS='/etc/apache2/envvars'
> # pick up any necessary environment variables
> if test -f $APACHE_ENVVARS; then
>   . $APACHE_ENVVARS
> fi
>
> Of course as you can see from that it's possible to set an environment
> variable before running apache2ctl to change the location of envvars,
> but it's unlikely they'd do that.
>
> Matt
>
>
>
>
>
> > I am not familiar with Red Hat so I can't give you any more specific advice
> > than that. If it does not use /etc/apache2/envvars (or if you are using some
> > server other than Apache), then you need to consult the Red Hat doc or
> > forums to find out how to configure your web server to run with a LANG other
> > than C or whatever it is currently using.- Hide quoted text -
>
> - Show quoted text -

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



Re: UnicodeDecodeError (ordinal not in range) when deleting an inline item - 1.2.1

2010-06-20 Thread Federico Capoano
I logged onto the server via SSH and tried the command "locale", the
following is what I get:

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Any hint?



On Jun 19, 5:25 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
> The same code on my computer offline works without problems, so I
> guess It's a server configuration problem, what do you think?
>
> I read the this bit 
> here:http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...
>
> And it says to write something similar to:
>
> export LANG='en_US.UTF-8'
> export LC_ALL='en_US.UTF-8'
>
> But where? I've looked around the net but I can't understand how do I
> set this environment variables? The server I'm talking about is a Red
> Hat Linux Enterprise.
>
> I can't fix this problem. I hope my client doesn't get pissed off at
> me :-S
>
> On Jun 15, 9:47 am, Matt Hoskins <skaffe...@googlemail.com> wrote:
>
> > >   File "/usr/lib/python2.3/site-packages/sorl/thumbnail/utils.py",
> > > line 36, in all_thumbnails
> > >     if os.path.isfile(os.path.join(path, file)):
>
> > >   File "/usr/local/lib/python2.6/posixpath.py", line 68, in join
> > >     path +=  b
>
> > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> > > 13: ordinal not in range(128)
>
> > What this error means is that either path or b is a normal (non-
> > unicode) string and contains a non-ascii character (perhaps the
> > character Ã) at position 13 and the other one is a unicode string.
> > When python concatenates a non-unicode string and a unicode string it
> > tries to convert the non-unicode string to unicode using the ascii
> > encoding.
>
> > As to which is which... well I've had a brief glance at the sorl code
> > and it'll take more time than I can be bothered to spend to figure out
> > which :). My guess is that the filename coming from Django is coming
> > in as a unicode string, although sorl has a number of normal string
> > literals in it I suspect that's making it through as unicode... So
> > that perhaps leaves your sorl path configurations - perhaps you're not
> > configuring the directory paths for sorl using unicode strings and
> > that's causing the problem.
>
> > Matt

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



Re: UnicodeDecodeError (ordinal not in range) when deleting an inline item - 1.2.1

2010-06-19 Thread Federico Capoano
The same code on my computer offline works without problems, so I
guess It's a server configuration problem, what do you think?

I read the this bit here:
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror

And it says to write something similar to:

export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'

But where? I've looked around the net but I can't understand how do I
set this environment variables? The server I'm talking about is a Red
Hat Linux Enterprise.

I can't fix this problem. I hope my client doesn't get pissed off at
me :-S




On Jun 15, 9:47 am, Matt Hoskins  wrote:
> >   File "/usr/lib/python2.3/site-packages/sorl/thumbnail/utils.py",
> > line 36, in all_thumbnails
> >     if os.path.isfile(os.path.join(path, file)):
>
> >   File "/usr/local/lib/python2.6/posixpath.py", line 68, in join
> >     path +=  b
>
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
> > 13: ordinal not in range(128)
>
> What this error means is that either path or b is a normal (non-
> unicode) string and contains a non-ascii character (perhaps the
> character Ã) at position 13 and the other one is a unicode string.
> When python concatenates a non-unicode string and a unicode string it
> tries to convert the non-unicode string to unicode using the ascii
> encoding.
>
> As to which is which... well I've had a brief glance at the sorl code
> and it'll take more time than I can be bothered to spend to figure out
> which :). My guess is that the filename coming from Django is coming
> in as a unicode string, although sorl has a number of normal string
> literals in it I suspect that's making it through as unicode... So
> that perhaps leaves your sorl path configurations - perhaps you're not
> configuring the directory paths for sorl using unicode strings and
> that's causing the problem.
>
> Matt

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



Re: Seeking Django vs. Joomla comparison

2010-06-19 Thread Federico Capoano
Bytheway Joomla is also a framework.. is a Content Management
Framework. I've been using it for years but I have to say that from a
performance point of view is CRAP.

I also think that the scopes of Django and Joomla are very different.
Django will never have the large adoption that Joomla has, because
Joomla is focused on the community and has a so called community
driven development (hilarious from my point of view).
Django has a development that is driven by a community of smart
developers, while Joomla has a development that is driven by a
community in which the majority are not-so-good self-proclaimed web
masters that do absurd feature requests.

Joomla is for the mass, Django is for the nieche.. and personally I'm
happy with it.


On Jun 16, 9:24 pm, Hooshyar  wrote:
> Many thanks to V and others who have contributed to this topic.
>
> More info. I guess I am coming up to speed now. The decision makers
> are not managers, but a private organization who members will read
> both proposals and ask questions from both vendors. At then end they
> vote democratically. One member, one vote. For the most part the
> members are not computer experts. They care about ease of use as they
> would be operating the final programs/modules -- be it updating the
> content of the public side of the web site or in the back-office
> applications. For this reason I have suspected that a simple user
> interface will do the job, and therefore, I am better off just develop
> the programs as opposed to adopting one CMS and be restricted to that
> interface. I have a team of Django developers. I cannot say we are the
> best, but we are very comfortable and rapid developers in the Django
> environment.
>
> Good questions, V. Thanks
> .
>
>
>
> > You need to answer questions like:
> > - Will your platform be flexible enough to support changing
> > requirements?
> > - Will the client be able to find maintainers if you get hit by a bus
> > or are too busy to work on the site?
> > - If the site is redesigned in 2-3 years, how difficult will it be to
> > migrate the current content?
> > - How easy will the site be to use for the content editors?
> > - If 3rd party functionality is buggy or ceases to be maintained, how
> > difficult will it be to fix/maintain internally?
> > - Will the site be as easy to maintain, improve 2 years from now as it
> > is now?
> > - When a new version of your platform is released, how easy will the
> > upgrade process be?
>
> > These questions directly effect the viability of your proposal to your
> > client in the long run. I think platforms in general come out better
> > than CMSs in these areas (and Django in particular).
>
> > Here is a general critique of CMS systems in general compared to
> > frameworks:http://sunlightlabs.com/blog/2009/content-management-systems-just-don...
>
> Great article. I learned few things. Specially this one: "... but the
> software crosses the line into content management systems when it
> starts providing default user-experiences out of the box. This means
> you have to un-do the way default behavior works and apply what you
> want as desired behavior rather than writing behavior from scratch."
>
> Very interesting. He explained this one in such a way even a 4-year-
> old could understand.
>
> Regards,
> Hooshyar

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



UnicodeDecodeError (ordinal not in range) when deleting an inline item - 1.2.1

2010-06-14 Thread Federico Capoano
Hello to all.

Version 1.2.1:

In the admin, just noticed that when I delete any of the dynamic
inlines (an image basically) of a form and then I hit the SAVE button
the image is deleted successfully but I get this error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
13: ordinal not in range(128)

Can someone gives me a suggestion about what this error is about? I
can't understand.

Complete traceback:

  File "/usr/lib/python2.3/site-packages/django/core/handlers/
base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/lib/python2.3/site-packages/django/contrib/admin/
options.py", line 239, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)

  File "/usr/lib/python2.3/site-packages/django/utils/decorators.py",
line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "/usr/lib/python2.3/site-packages/django/views/decorators/
cache.py", line 69, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

  File "/usr/lib/python2.3/site-packages/django/contrib/admin/
sites.py", line 190, in inner
return view(request, *args, **kwargs)

  File "/usr/lib/python2.3/site-packages/django/utils/decorators.py",
line 21, in _wrapper
return decorator(bound_func)(*args, **kwargs)

  File "/usr/lib/python2.3/site-packages/django/utils/decorators.py",
line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "/usr/lib/python2.3/site-packages/django/utils/decorators.py",
line 17, in bound_func
return func(self, *args2, **kwargs2)

  File "/usr/lib/python2.3/site-packages/django/db/transaction.py",
line 299, in _commit_on_success
res = func(*args, **kw)

  File "/usr/lib/python2.3/site-packages/django/contrib/admin/
options.py", line 898, in change_view
self.save_formset(request, form, formset, change=True)

  File "/usr/lib/python2.3/site-packages/django/contrib/admin/
options.py", line 603, in save_formset
formset.save()

  File "/usr/lib/python2.3/site-packages/django/forms/models.py", line
487, in save
return self.save_existing_objects(commit) +
self.save_new_objects(commit)

  File "/usr/lib/python2.3/site-packages/django/forms/models.py", line
604, in save_existing_objects
obj.delete()

  File "/usr/lib/python2.3/site-packages/django/db/models/base.py",
line 639, in delete
delete_objects(seen_objs, using)

  File "/usr/lib/python2.3/site-packages/django/db/models/query.py",
line 1346, in delete_objects
signals.post_delete.send(sender=cls, instance=instance)

  File "/usr/lib/python2.3/site-packages/django/dispatch/
dispatcher.py", line 162, in send
response = receiver(signal=self, sender=sender, **named)

  File "/usr/lib/python2.3/site-packages/django/db/models/fields/
files.py", line 270, in delete_file
file.delete(save=False)

  File "/usr/lib/python2.3/site-packages/sorl/thumbnail/fields.py",
line 114, in delete
delete_thumbnails(relative_source_path)

  File "/usr/lib/python2.3/site-packages/sorl/thumbnail/utils.py",
line 111, in delete_thumbnails
prefix)

  File "/usr/lib/python2.3/site-packages/sorl/thumbnail/utils.py",
line 101, in thumbnails_for_file
subdir='')

  File "/usr/lib/python2.3/site-packages/sorl/thumbnail/utils.py",
line 36, in all_thumbnails
if os.path.isfile(os.path.join(path, file)):

  File "/usr/local/lib/python2.6/posixpath.py", line 68, in join
path +=  b

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
13: ordinal not in range(128)

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



Re: pg_get_serial_sequence("unknown", "unknown") - revision 13336

2010-06-10 Thread Federico Capoano
Yea, you're right, thank you so much guys.

I downloaded django 1.2.1 stable and put that for the moment.

When I'll have time I will upgrade postgres.



On Jun 9, 6:24 pm, Matt Hoskins <skaffe...@googlemail.com> wrote:
> Hi Federico,
>
> From the discussion on django-developers it looks like the patch will
> be reverted soon so you may find in due course things will start
> working again with SVN for the 1.2 branch (however with Django 1.3
> support for 7 will likely be dropped). It doesn't sound like you
> particularly need to be using the SVN version, since 1.2 has been
> released, so I'd suggest just grabbing 1.2.1 and using that instead of
> SVN for your blog as that doesn't have the patch which broke things
> working with postgresql 7.
>
> In terms of upgrading from 7 to 8 on debian it's the same as upgrading
> from 7 to 8 on any system, you have to do it via data dumps and
> imports rather than postgresql being able to upgrade the data files in-
> place. There were some changes in the dump formats so to do a big jump
> safely unfortunately what you really need is to run the pg_dump
> command from version 8 talking to your version 7 server, and even then
> with the later versions of 8 if you were using the tsearch2 full-text
> index module there can be some problems as it's moved to being in the
> core. Have a look at the section of the postgresql manual on migration
> and if you want to know the gory details of any backwards-incompatible
> changes also at the release notes for the 8.0 release and every minor
> release up to the version you're intending to run (you can skip over
> the point release release notes tho' as they don't tend to introduce
> backwards-incompatibilities in point release changes). It will, in
> part, depend on whether your version of webmin works with version 8.
>
> I guess you'll have to make the jump to 8 eventually tho' even if you
> hold off for now :)
>
> Matt
>
> On Jun 9, 2:53 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
>
>
>
> > I see. I think I'd like to upgrade postgresql .. but I don't know what
> > would happen with webmin.
> > Maybe I'll go to ask to the webmin support.
>
> > Do you think upgrading from 7 to 8 is a difficult task on debian?
>
> > I also think it should be written in the documentation and release
> > notes.

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



Re: pg_get_serial_sequence("unknown", "unknown") - revision 13336

2010-06-09 Thread Federico Capoano
I see. I think I'd like to upgrade postgresql .. but I don't know what
would happen with webmin.
Maybe I'll go to ask to the webmin support.

Do you think upgrading from 7 to 8 is a difficult task on debian?

I also think it should be written in the documentation and release
notes.



On Jun 9, 1:28 pm, Matt Hoskins  wrote:
> ... Replying to my own post on this bit... of course the older Django
> 1.1.x can still be used with the older PostgreSQL 7 without hitting
> this issue regardless as I'm assuming the patch for #8901 isn't being
> applied back to the 1.1 series :). Perhaps worth being explicit in the
> Django documentation for 1.2 about which PostgreSQL version is
> required as a minimum (both for the benefit of users and also for
> anyone submitting patches to the PostgreSQL back-end so they know what
> they have to work with!).
>
>
>
> > Russ - I guess the choice is either a note in the Django docs/release
> > notes about this issue and suggesting anyone on 7 adds in
> > pg_get_serial_sequence as per the above link (if that does indeed
> > work) or alternatively change the code touched by #8901 such that it
> > only adds the calls to pg_get_serial_sequence for version 8 onwards
> > and for version 7 it either reverts to guessing the sequence name as
> > it used to (with a caveat in the documentation that for long model or
> > field names there will be the errors that #8901 fixes) or
> > alternatively it calls the SQL listed in the above pgfoundry link to
> > fish out the sequence names itself (it could call that sql always
> > regardless of postgresql version but I guess there's a tiny risk that
> > in a later version of postgresql the catalog structure could change so
> > calling pg_get_serial_sequence is preferred when it's available).

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



Re: pg_get_serial_sequence("unknown", "unknown") - revision 13336

2010-06-09 Thread Federico Capoano
I have PostgreSQL version 7.4.27 on my server. The reason for which I
use this version is that is the latest version available for webmin
and my VPS use  it.
What can I do?

I checked the release notes and I didn't notice anything about this
bit. Before upgrading to the last revision I had probably the trunk
equivalent to the just released 1.2

Thanks for your help.



On Jun 9, 1:51 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> On Wed, Jun 9, 2010 at 5:47 AM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > Hello to all,
>
> > I just upgraded to revision 13336, I tried then to add a post on my
> > blog but I got an error. I tried then to save any other object in the
> > admin but I get always the same error:
>
> > "DatabaseError: function pg_get_serial_sequence("unknown", "unknown")
> > does not exist
> > HINT:  No function matches the given name and argument types. You may
> > need to add explicit type casts."
>
> The call to pg_get_serial_sequence() was added recently, so for some reason,
>
> The most obvious possible reason -- what version of Postgres are you
> using? Very old (pre-8.0) Postgres doesn't have the
> pg_set_serial_sequence() function defined.
>
> Failing that, we'll need to do some more investigation; Can you
> provide any other details of your setup that will help us narrow down
> the problem?
>
> Yours,
> Russ Magee %-)

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



Re: How to enable Static Generator

2010-06-09 Thread Federico Capoano
I wrote a blog post about it here:
http://nemesisdesign.net/blog/coding/setup-django-staticgenerator-apache-mod_wsgi/

On May 20, 1:29 pm, vikk  wrote:
> Hi all,
>
> I got some of the documents to enable static generator but still for
> away from the result.
> Please show me the way to implement it for my site so that I can
> enhance the performance.
> I am using apache + mod_wsgi.
> I need to get detail about the apache configuration. How can I
> configure it for the specific urls ?
>
> Thanks in advance for your valuable reply.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



pg_get_serial_sequence("unknown", "unknown") - revision 13336

2010-06-08 Thread Federico Capoano
Hello to all,

I just upgraded to revision 13336, I tried then to add a post on my
blog but I got an error. I tried then to save any other object in the
admin but I get always the same error:

"DatabaseError: function pg_get_serial_sequence("unknown", "unknown")
does not exist
HINT:  No function matches the given name and argument types. You may
need to add explicit type casts."

Traceback (most recent call last):

  File "/usr/local/lib/python2.6/site-packages/django/core/handlers/
base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
options.py", line 239, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/views/decorators/
cache.py", line 69, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
sites.py", line 190, in inner
return view(request, *args, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 21, in _wrapper
return decorator(bound_func)(*args, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 76, in _wrapped_view
response = view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/utils/
decorators.py", line 17, in bound_func
return func(self, *args2, **kwargs2)

  File "/usr/local/lib/python2.6/site-packages/django/db/
transaction.py", line 299, in _commit_on_success
res = func(*args, **kw)

  File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
options.py", line 795, in add_view
self.save_model(request, new_object, form, change=False)

  File "/usr/local/lib/python2.6/site-packages/django/contrib/admin/
options.py", line 597, in save_model
obj.save()

  File "/usr/local/lib/python2.6/site-packages/django/db/models/
base.py", line 435, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)

  File "/usr/local/lib/python2.6/site-packages/django/db/models/
base.py", line 528, in save_base
result = manager._insert(values, return_id=update_pk, using=using)

  File "/usr/local/lib/python2.6/site-packages/django/db/models/
manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)

  File "/usr/local/lib/python2.6/site-packages/django/db/models/
query.py", line 1479, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)

  File "/usr/local/lib/python2.6/site-packages/django/db/models/sql/
compiler.py", line 789, in execute_sql
self.query.model._meta.db_table, self.query.model._meta.pk.column)

  File "/usr/local/lib/python2.6/site-packages/django/db/backends/
postgresql/operations.py", line 59, in last_insert_id
cursor.execute("SELECT CURRVAL(pg_get_serial_sequence('%s','%s'))"
% (table_name, pk_name))

  File "/usr/local/lib/python2.6/site-packages/django/db/backends/
postgresql_psycopg2/base.py", line 44, in execute
return self.cursor.execute(query, args)

Could anyone please help me and tell me what's this? It seems I'm the
only one getting this.

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



Re: Disabling (or find a workaround for) the comment security checks

2010-05-07 Thread Federico Capoano
Thanks for the suggestion.

Even if I suppose not, would it be possible to generate the correct
security hash with javascript?



On May 6, 5:03 pm, Alex Robbins <alexander.j.robb...@gmail.com> wrote:
> Also, as I think more about this, are you sure you need static
> generator? You might get sufficient speed just by using cache.
> Premature optimization is bad
>
> On May 6, 8:37 am, Alex Robbins <alexander.j.robb...@gmail.com> wrote:
>
>
>
>
>
> > Disclaimer:
> >Disablingthesecuritystuff makes it really likely you'll getcomment
> > spammed. You should set up some kind of akismet protection on the
> > backend if you disable thesecurity.
>
> > If you don't want the checking then you probably want a customcomment
> > form.
> > You can use this method to setup a new 
> > form:http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#dja...
>
> > Then use the form base classes with the functionality you want.
> > (You'll probably want to exclude the CommentSecurityForm, and include
> > the generic foreign key information some other 
> > way.)http://docs.djangoproject.com/en/dev/ref/contrib/comments/forms/
>
> > Hope that helps!
> > Alex
>
> > On May 5, 5:59 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
>
> > > Hello to all,
>
> > > I've just launched my new web-site powered by django and i'm very
> > > satisfied.
>
> > > I've implemented StaticGenerator to improve the performance and
> > > loading speed and I have to admit is brilliant.
>
> > > Unfortunately i've noticed thecommentsystem doesn't work. This
> > > happens because the pages of the blog are saved as static html pages,
> > > so the timestamp and csfrsecuritystuff are the one saved when the
> > > page was generated.
>
> > > I gotta find a fix for this, because I really want my blog pages to be
> > > saved as static html cos this is the best solution to obtain fast
> > > loading speed without overloading my little VPS.
>
> > > I think I can generate the timestamp with javascript, but what about
> > > the other two fields (csrfmiddlewaretoken andsecurityhash)?
>
> > > If you want to take a look closely this is the 
> > > url:http://nemesisdesign.net/blog/
> > > I hope i'm not breaching any rule by posting the url.
>
> > > Thanks
> > > Federico
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > django-users+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/django-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Re: Django 1.2 release candidate available

2010-05-06 Thread Federico Capoano
I've been using the beta for a while and it works pretty good for what
I've seen.



On May 6, 6:40 am, James Bennett  wrote:
> Tonight we're proud to announce, finally, the first Django 1.2 release
> candidate. If all goes well, it will also be the *only* release
> candidate, and Django 1.2 final will release one week from today.
>
> For more information, consult:
>
> * The Django project 
> weblog:http://www.djangoproject.com/weblog/2010/may/05/12-rc-1/
> * The release notes:http://docs.djangoproject.com/en/dev/releases/1.2-rc-1/
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

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



Disabling (or find a workaround for) the comment security checks

2010-05-05 Thread Federico Capoano
Hello to all,

I've just launched my new web-site powered by django and i'm very
satisfied.

I've implemented StaticGenerator to improve the performance and
loading speed and I have to admit is brilliant.

Unfortunately i've noticed the comment system doesn't work. This
happens because the pages of the blog are saved as static html pages,
so the timestamp and csfr security stuff are the one saved when the
page was generated.

I gotta find a fix for this, because I really want my blog pages to be
saved as static html cos this is the best solution to obtain fast
loading speed without overloading my little VPS.

I think I can generate the timestamp with javascript, but what about
the other two fields (csrfmiddlewaretoken and security hash)?

If you want to take a look closely this is the url: 
http://nemesisdesign.net/blog/
I hope i'm not breaching any rule by posting the url.

Thanks
Federico

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



Re: JOIN instead of multiple SELECT

2010-04-01 Thread Federico Capoano
What about this solution to generate static files?

http://superjared.com/projects/static-generator/



On Apr 1, 12:49 am, Rolando Espinoza La Fuente <dark...@gmail.com>
wrote:
> On Wed, Mar 31, 2010 at 5:22 PM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > Thanks,
>
> > how many things i've learnt today, to optimize the number and length
> > of query by using:
>
> > * select_related
> > * only
> > * extra
>
> > Do you think the performance gain is worth the work?
>
> Yes. Specially in loops where you have:
>
> # in your view
> posts = Post.objects.all()[:20]
>
> # in your template
> {% for post in posts %}
>     {{ post.title }}
>     {{ post.category.name }}
>     {{ post.owner.username }}
> {% endfor %}
>
> post.category and post.owner will hit the database each loop.
>
> > And I've a curiosity more to ask:
> > If I use the cache framework, once the results are cached the will the
> > database be hit again?
>
> No. But you need to take care of invalidation.
>
> There are few apps that provide drop-out solution for caching at orm level:
>  * cache machine -http://jbalogh.me/2010/02/09/cache-machine/
>  * cachebot 
> -http://blog.davidziegler.net/post/429237463/announcing-django-cachebot
>  * johnny cache -http://jmoiron.net/blog/is-johnny-cache-for-you/
>
> Regards,
>
> ~Rolando

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



Re: JOIN instead of multiple SELECT

2010-04-01 Thread Federico Capoano
Very cool, if the database won't be hit often and I manage to use the
new template caching functionality added to Django 1.2 the result will
be really performant.

Thank you very much, I save these info on caching for future
reference.



On Apr 1, 12:49 am, Rolando Espinoza La Fuente <dark...@gmail.com>
wrote:
> On Wed, Mar 31, 2010 at 5:22 PM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > Thanks,
>
> > how many things i've learnt today, to optimize the number and length
> > of query by using:
>
> > * select_related
> > * only
> > * extra
>
> > Do you think the performance gain is worth the work?
>
> Yes. Specially in loops where you have:
>
> # in your view
> posts = Post.objects.all()[:20]
>
> # in your template
> {% for post in posts %}
>     {{ post.title }}
>     {{ post.category.name }}
>     {{ post.owner.username }}
> {% endfor %}
>
> post.category and post.owner will hit the database each loop.
>
> > And I've a curiosity more to ask:
> > If I use the cache framework, once the results are cached the will the
> > database be hit again?
>
> No. But you need to take care of invalidation.
>
> There are few apps that provide drop-out solution for caching at orm level:
>  * cache machine -http://jbalogh.me/2010/02/09/cache-machine/
>  * cachebot 
> -http://blog.davidziegler.net/post/429237463/announcing-django-cachebot
>  * johnny cache -http://jmoiron.net/blog/is-johnny-cache-for-you/
>
> Regards,
>
> ~Rolando

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



Re: JOIN instead of multiple SELECT

2010-03-31 Thread Federico Capoano
Thanks,

how many things i've learnt today, to optimize the number and length
of query by using:

* select_related
* only
* extra

Do you think the performance gain is worth the work?

And I've a curiosity more to ask:
If I use the cache framework, once the results are cached the will the
database be hit again?

Best Regards
Federico

On Mar 31, 10:49 pm, Rolando Espinoza La Fuente <dark...@gmail.com>
wrote:
> On Wed, Mar 31, 2010 at 3:30 PM, Federico Capoano
>
> <nemesis.des...@libero.it> wrote:
> > Hello to all,
>
> > has been a while i've been wondering how to optimize Django's queries
> > to the database, for example by setting it to use JOIN to retrieve
> > foreign keys instead of multiple selects.
>
> > for example if I have a blog object that has a category foreign key
> > and I write in a template
>
> > {{ blog.category.slug }}
>
> > I get another query to select the category.
>
> > Is there a way I can use a JOIN instead to avoid multiple queries?
>
> select_related() ?
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4
>
> ~Rolando

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



JOIN instead of multiple SELECT

2010-03-31 Thread Federico Capoano
Hello to all,

has been a while i've been wondering how to optimize Django's queries
to the database, for example by setting it to use JOIN to retrieve
foreign keys instead of multiple selects.

for example if I have a blog object that has a category foreign key
and I write in a template

{{ blog.category.slug }}

I get another query to select the category.

Is there a way I can use a JOIN instead to avoid multiple queries?

Does this have sense for performance optimization?

Thanks
Federico

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



Re: Retrievecomments for a given model

2010-03-24 Thread Federico Capoano
I made a custom template tag.



On Mar 24, 7:45 pm, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hello to all,
>
> I don't understand how I can retrieve the most recent comments for a
> given model, something like:
>
> {% load comments %}
> {% get_comment_list for post as comment_list %}
>
> By using this code I get an empty list..
>
> :-S

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



Retrievecomments for a given model

2010-03-24 Thread Federico Capoano
Hello to all,

I don't understand how I can retrieve the most recent comments for a
given model, something like:

{% load comments %}
{% get_comment_list for post as comment_list %}

By using this code I get an empty list..

:-S

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



Re: preventing template from converting html entities

2010-03-11 Thread Federico Capoano
Hey sorry guys, i couldn't find this post anymore!

Thanks for the answers but i've found the resolution to my problem in
the documentation, i just forgot in the beginning where it says about

{% autoescape off %}

This is the tag to use to prevent the template system from converting



in

"

Example:

Test

Becomes

Test

Causing serious problems on some browsers, cos the html is not valid.

While

{% autoescape off %}Test{% endautoescape %}

will output correctly

Test.

Didn't try force_escape, but that sounds the opposite of what I want
to do..

Thanks.

PS: Django is great, no doubt the best framework I ever used.


On Feb 25, 3:35 pm, Alex Robbins <alexander.j.robb...@gmail.com>
wrote:
> Oops, it would actually be
> title={% filter force_escape %}{{ villa.name }}{% endfilter %}
>
> Sorry.
> --
> Alex Robbins
> 5Q Communications, Inc.http://www.5Qcommunications.com/
> alex.robb...@5qcommunications.com
> 800-747-4214 ext 913 (p)http://www.ask5q.com/twitter/
>
> On Thu, Feb 25, 2010 at 8:33 AM, Alex Robbins
>
>
>
> <alexander.j.robb...@gmail.com> wrote:
> > I think you can do that with title={% filter force_escape
> > %}"{{ villa.name }}"{% endfilter %}. Haven't tried it though.
>
> > Alex
>
> > On Feb 24, 8:36 am, Federico Capoano <nemesis.des...@libero.it> wrote:
> >> Hello to all,
>
> >> simple question:
>
> >> I have the following HTML in a template:
> >> 
>
> >> But it gets rendered this way:
> >> 
>
> >> That is, the  entity is converted to the respective character,
> >> ". Very nice, but i'd need 
>
> >> Is there a filter or something i can use to tell the Django Template
> >> System to render  ?
>
> >> Thanks in advance.
>
> >> Federico
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

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



preventing template from converting html entities

2010-02-24 Thread Federico Capoano
Hello to all,

simple question:

I have the following HTML in a template:


But it gets rendered this way:


That is, the  entity is converted to the respective character,
". Very nice, but i'd need 

Is there a filter or something i can use to tell the Django Template
System to render  ?

Thanks in advance.

Federico


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