Re: Channels 2.0 close code and http response status

2019-01-23 Thread guillaume
Hey I read the spec of websocket handshake and I believe that in abrupt 
close connection, the server can send either a 403 or 404. I wish there 
were a way to send a 404. :(

On Sunday, June 24, 2018 at 7:21:10 PM UTC+2, Andrew Godwin wrote:
>
> I'm not quite sure - WebSockets do have browser differences. You could 
> also try adding a delay between the accept and the close to see if that 
> changes how they handle it.
>
> Andrew
>
> On Sun, 24 Jun 2018, 06:02 Kirill Tyushchakov,  > wrote:
>
>> Hi, Andrew! Thanks a lot for your response.
>> I've changed my consumer's connect method like this:
>>
>> def connect(self):
>> user = self.scope.get('user')
>> super(NotificationsConsumer, self).connect()
>> if user.is_anonymous:
>> self.close(code=4003)
>>
>>
>>
>> I've tested it in Chrome, Firefox, Safari and IE 11 and here is the 
>> result that I've got:
>> Chrome - 1006
>> IE 11 - 1005
>> Firefox - 4003
>> Safari - 1006
>>
>> It doesn't return 403 HTTP status code. Seems it works fine, but I think 
>> I need to test it more.
>> So the expected close code appears only in Firefox. Should I consider it 
>> as the browser issue?
>>
>>
>> Hi!
>>>
>>> Close code 1006 means that the connection was closed abruptly by the 
>>> other end (basically, the socket just got chopped off without an actual 
>>> close frame being sent).
>>>
>>> This is what happens when you close during the handshake, which is what 
>>> closing during connect() does - at that point, the connection is still HTTP 
>>> before the upgrade has finished, and so Channels sends a HTTP 403 response 
>>> code down instead. Looks like your browser interprets this as code 1006 for 
>>> a websocket.
>>>
>>> There's no way to change the HTTP response code sent when a handshake is 
>>> terminated at the moment - it's hardcoded (as you can see in Daphne's 
>>> serverReject method, here: 
>>> https://github.com/django/daphne/blob/master/daphne/ws_protocol.py#L200
>>> ).
>>>
>>> Given that no browser I know of will actually tell you the HTTP response 
>>> code in this case, I don't think there's much value in letting it be 
>>> changed - you're always going to see an aborted WebSocket connection code 
>>> instead. If you want to provide more detail to the user, you can instead 
>>> accept the socket, letting the handshake finish, and then close it 
>>> immediately with a custom WebSocket close code (you can do all of that 
>>> inside connect, I think).
>>>
>>> Andrew
>>>
>>> On Thu, Jun 21, 2018 at 2:52 PM Kirill Tyushchakov  
>>> wrote:
>>>
 Hello everyone!
 I'm new in Django Channels. I'm using Channels 2.0 and I have few 
 questions about it.
 I'm using JsonWebsocketConsumer class for my consumer and I wrote my 
 definition of connect method like this: 

 def connect(self):
 user = self.scope.get('user')
 if user.is_anonymous:
 super(NotificationsConsumer, self).connect()
 else:
 self.close(code=4003)


 On client side I'm using native JS Websocket. 
 But when I try to connect to this socket as unauthorzied user I get 
 code 1006 and HTTP response status code 403.

 My questions is:
 1) How can I send custom close code to client?
 2) Can I send another HTTP response status code? In my case 401 

 -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to django-users...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/446d3be6-438b-4e59-ad4f-7841895f4fcb%40googlegroups.com
  
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@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/b758b6f7-91f0-43b8-8ea8-087c137598c4%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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

Re: Isolate Django apps in different Docker containers

2016-08-29 Thread Guillaume Dupin
Hello Christian,

Thank you for your help.

Concerning the first and second point, I would indeed have several Django 
app containers (one by functionnal services). But what about applications 
like Django "Admin" for example ? This application needs to be aware of the 
models to administrate so would I have one Admin application per service 
(that is to say as much different Admin apps as Django containers) or one 
central Admin application in a container that would be aware of objects 
present in others Django containers ? And if so, how is it possible to 
configure Django to do that ?

For your last answer, one of the main objective of the project will be to 
be able to integrate specific data model to the generic one in a framework 
approach so I do not have any choice regarding the DB as an integration 
point. My question was more on a technical point of view : Django is able 
to manage different databases but what about the data that must be shared 
by all the Django appliations (like the data used for the "Admin" 
application in the case I mentionned above...)

Thanks again !

Best Regards,

Guillaume

-- 
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/42143161-2e12-4335-aecf-a2420eb94bca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Isolate Django apps in different Docker containers

2016-08-29 Thread Guillaume Dupin
Hello Christian,

Thank you for your help.

Concerning the first and second point, I would indeed have several Django 
app containers (one by functionnal services). But what about applications 
like Django "Admin" for example ? This application needs to be aware of the 
models to administrate so would I have one Admin application per service 
(that is to say as much different Admin apps as Django containers) or one 
central Admin application in a container that would be aware of objects 
present in others Django containers ? And if so, how is it possible to 
configure Django to do that ?

For your last answer, one of the main objective of the project will be to 
be able to integrate specific data model to the generic one in a framework 
approach so I do not have any choice regarding the DB as an integration 
point. My question was more on a technical point of view : Django is able 
to manage different databases but what about the data that must be shared 
by all the Django appliations (like the data used for the "Admin" 
application in the case I mentionned above...)

Thanks again

Best Regards,

Guillaume

Le jeudi 25 août 2016 16:37:25 UTC+2, Christian Ledermann a écrit :
>
> On 25 August 2016 at 14:50, Guillaume Dupin  > wrote: 
> > Hello, 
> > 
> > On a Django project (which will consist of several REST web services), I 
> > would like to isolate my services (each service would be a Django 
> > application) into different Docker containers to aim to a micro-services 
> > architecture. It will allow to benefit of Docker isolation to update 
> > independantly the different apps of the project and also to scale each 
> > service idependantly according to the load increase by using 
> load-balancers 
> > in font of each group of services-containers (plus the numerous 
> advantages 
> > brought by Docker). 
> > I understand that, by doing so, each container will run a Django server 
> and 
> > that this different servers will surely have to share some data. 
> > 
> > First, do you think it is possible to do so ? 
> > I have searched examples of such architectural choice but I always found 
> the 
> > use of Docker to encapsulate a Django project (one container for the 
> server, 
> > one container for the DB for example) and never this idea of "one app 
> per 
> > container" architecture. 
> > Do you think it is a valid approach ? 
>
> yes it is, you just need to setup more than one  django app container 
> and possibly several postgresql containers as well 
>
> > Has someone already tested such a solution ? 
> > One problem I identify is : will each Django server have to be aware of 
> all 
> > the services or not ? 
>
> that is your design decision, if every servioce has dependencies to every 
> other service it  probably is a 'not so good' architecture. services 
> should 
> have minimal dependencies. 
>
> > To go further, if the previous idea is valid, do you think it can be 
> coupled 
> > with a separation of databases ? As Django can already manage different 
> > databases, I imagined that each application could use several databases 
> : a 
> > common Django database (accesible from all the apps) for the generic 
> data 
> > and a specific database for all the app-specific data. 
>
> Using a db as an integration point is not a good idea. 
>
> > It would push further 
> > the isolation of the services and improve the modularity of the whole 
> > project (by allowing to easily delete or add a service without impacting 
> the 
> > others) 
> > 
> > Do you think it is coherent with Django concepts ? 
> > 
> > Thank you for your help 
> > 
> > Regards, 
> > Guillaume 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/2745d24c-8de4-4922-8ace-72feeb8fdfa8%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
> Best Regards, 
>
> Christian Ledermann 
>
> Newark-on-Trent - UK 
> Mobile : +44 7474997517 
>
> https://uk.linkedin.com/in/christianledermann 
> https://github.com/cleder/ 
>
>
> <*)))>{ 
>
> If you save the living

Isolate Django apps in different Docker containers

2016-08-25 Thread Guillaume Dupin
Hello,
 
On a Django project (which will consist of several REST web services), I 
would like to isolate my services (each service would be a Django 
application) into different Docker containers to aim to a micro-services 
architecture. It will allow to benefit of Docker isolation to update 
independantly the different apps of the project and also to scale each 
service idependantly according to the load increase by using load-balancers 
in font of each group of services-containers (plus the numerous advantages 
brought by Docker).
I understand that, by doing so, each container will run a Django server and 
that this different servers will surely have to share some data.
 
First, do you think it is possible to do so ?
I have searched examples of such architectural choice but I always found 
the use of Docker to encapsulate a Django project (one container for the 
server, one container for the DB for example) and never this idea of "one 
app per container" architecture.
Do you think it is a valid approach ? 
Has someone already tested such a solution ? 
One problem I identify is : will each Django server have to be aware of all 
the services or not ?
 
To go further, if the previous idea is valid, do you think it can be 
coupled with a separation of databases ? As Django can already manage 
different databases, I imagined that each application could use several 
databases : a common Django database (accesible from all the apps) for the 
generic data and a specific database for all the app-specific data. It 
would push further the isolation of the services and improve the modularity 
of the whole project (by allowing to easily delete or add a service without 
impacting the others)
 
Do you think it is coherent with Django concepts ?
 
Thank you for your help
 
Regards,
Guillaume

-- 
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/2745d24c-8de4-4922-8ace-72feeb8fdfa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using data migration to create initial users errors

2014-11-28 Thread Guillaume Cisco
Did you find a way to use method create_user in a data migration?
I can't see a way to import the manager for using it.

Le jeudi 16 octobre 2014 23:19:43 UTC+2, Collin Anderson a écrit :
>
> Hi Ben,
>
> Yes, the custom manager objects are not available within migrations. I bet 
> you might be able to import the UserManager and stick it on the User model 
> yourself.
>
> Collin
>
>

-- 
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/f7024bc8-e81f-4f66-8604-58c870963546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread guillaume
Hi Phil,

Actually not at the hasher level, because I need to know the user's details 
as well, but it's a good hint. I should try to subclass to User Model 
set_password method. 

Thanks !

Guillaume

Le mardi 1 juillet 2014 15:03:58 UTC+2, Philip a écrit :
>
>  If the username/whatever is available within the hasher you could create 
> a subclass of the hasher you're using in Django and intercept the 
> plain-text password there, call your API and then call the superclass?
>
> Phil
>
> On 01/07/2014 13:27, guillaume wrote:
>  
> Hi Tom,
>
> Yes indeed, I know that page, but there is no way I can make it the same 
> than the other one which relies on SHA256, some system key I don't know and 
> a random salt. So there is no way for me to find the correct encryption for 
> the remote database, that's why I want to use it's API registration system 
> and feed it with the clear password. 
>
> Best regards
>
> Guillaume
>
> Le mardi 1 juillet 2014 14:17:28 UTC+2, Tom Evans a écrit : 
>>
>> On Tue, Jul 1, 2014 at 1:12 PM, guillaume  
>> wrote: 
>> > 
>> > Hi, 
>> > thanks for your reply. Actually I don't want to store the uncrypted 
>> > password, just submit it to another app registration system, which will 
>> hash 
>> > it then. The two hashing systems are too different and complicated for 
>> me to 
>> > use the django encrypted password in the other application database. 
>> > 
>>
>> How Django hashes passwords is fully configurable, see: 
>>
>> https://docs.djangoproject.com/en/1.6/topics/auth/passwords/ 
>>
>> The setting PASSWORD_HASHERS contains a list of classes that hash 
>> passwords. Simply replace this with your custom hash algorithm, or 
>> calls to your external API that implements your hash algorithm. 
>>
>> Cheers 
>>
>> Tom 
>>
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com .
> To post to this group, send email to django...@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/a7b49845-b8df-4897-b653-17020f339794%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/a7b49845-b8df-4897-b653-17020f339794%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d8a78f4b-1f4d-4307-ac7a-b7704690c557%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread guillaume
Hi Tom,

Yes indeed, I know that page, but there is no way I can make it the same 
than the other one which relies on SHA256, some system key I don't know and 
a random salt. So there is no way for me to find the correct encryption for 
the remote database, that's why I want to use it's API registration system 
and feed it with the clear password. 

Best regards

Guillaume

Le mardi 1 juillet 2014 14:17:28 UTC+2, Tom Evans a écrit :
>
> On Tue, Jul 1, 2014 at 1:12 PM, guillaume  > wrote: 
> > 
> > Hi, 
> > thanks for your reply. Actually I don't want to store the uncrypted 
> > password, just submit it to another app registration system, which will 
> hash 
> > it then. The two hashing systems are too different and complicated for 
> me to 
> > use the django encrypted password in the other application database. 
> > 
>
> How Django hashes passwords is fully configurable, see: 
>
> https://docs.djangoproject.com/en/1.6/topics/auth/passwords/ 
>
> The setting PASSWORD_HASHERS contains a list of classes that hash 
> passwords. Simply replace this with your custom hash algorithm, or 
> calls to your external API that implements your hash algorithm. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a7b49845-b8df-4897-b653-17020f339794%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread guillaume

Hi,
thanks for your reply. Actually I don't want to store the uncrypted 
password, just submit it to another app registration system, which will 
hash it then. The two hashing systems are too different and complicated for 
me to use the django encrypted password in the other application database. 

-- 
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/a8d981e1-addb-45dd-99ec-ee3aa6b422da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pre_save on password

2014-07-01 Thread guillaume
Hi list,

When registering a new user, or a password change, I need to register that 
user, or his new password, in another application through an internal API. 
I'm trying to catch the password from the different form they can be found 
in, but without success. Even the signal pre_save is happening too late 
(password is already encrypted). How can I see it just before it is 
encrypted ? 

Thanks

Guillaume

-- 
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/46c619d4-7499-4d77-afa5-01490cd06c0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


__contains, ok but contains how many ;-) ?

2012-05-09 Thread Guillaume Florent
Hi everybody,
I would like to know if there if a simple way to know how many times a
given field contains a string.
e.g. Note.objects.filter(notedescription__contains='keyword')
What would be the recommended way to know how many times 'keyword' is
hit in the 'notedescriptiont' field? Do I have have to iterate over
the resulting queryset or can someone think of a more elegant way?
(i.e. is adding on the fly a 'count' field to each object in the
queryset feasible?)
Best regards,
G Florent

-- 
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: Can't access database with normal Ubuntu Terminal user

2012-04-17 Thread Guillaume Chorn
Thanks for the input, but I think I'm going to need more help than this.  I
was able to find the pg_hba.conf file, but have no idea how to edit it.
Can anyone help with this?

Sorry, I'm pretty new to all of this (SQL, Linux, etc.) so I'm hoping
someone can provide me fairly detailed instructions.

On Tue, Apr 17, 2012 at 3:03 PM, kenneth gonsalves
wrote:

> On Tue, 2012-04-17 at 14:50 +0800, Guillaume Chorn wrote:
> > FATAL:  Peer authentication failed for user "postgres"
>
> suitably edit pg_hba.conf
> --
> regards
> Kenneth Gonsalves
>
> --
> 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.
>
>

-- 
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: Can't access database with normal Ubuntu Terminal user

2012-04-16 Thread Guillaume Chorn
Something more specific in case it helps: as an example, when I try to
access my admin view while logged in as my regular user ("guillaume")
instead of "postgres", I get the following error:

OperationalError at /admin/

FATAL:  Peer authentication failed for user "postgres"

 Request Method: GET  Request URL: http://127.0.0.1:8000/admin/  Django
Version: 1.3.1  Exception Type: OperationalError  Exception Value:

FATAL:  Peer authentication failed for user "postgres"

 Exception Location:
/usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py
in _cursor, line 140  Python Executable: /usr/bin/python  Python Version:
2.7.2  Python Path:

['/home/guillaume/moisiedarling',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PIL',
 '/usr/lib/python2.7/dist-packages/gst-0.10',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-client',
 '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
 '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
 '/usr/lib/python2.7/dist-packages/ubuntuone-installer',
 '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
 '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

 Server time: Tue, 17 Apr 2012 01:46:23 -0500

On Tue, Apr 17, 2012 at 2:07 PM, Gchorn  wrote:

> I'm not totally sure if this qualifies as a Django question, but it's
> impeding my ability to make a website with Django so I thought I'd ask
> here.  I'm working with Django in Ubuntu 11.10, where I've set up
> PostgreSQL to make and manage databases for my Django-powered website.
> Unfortunately, when working with Django in the Terminal, I need to first
> switch over to the user "postgres" (the user I created when installing
> PostgreSQL) in order to do anything with PostgreSQL or its databases.  This
> becomes a problem when I need to simultaneously access my database and the
> local file system, since my local filesystem is only accessible to my
> normal Ubuntu Terminal user, "guillaume."
>
> I already have the correct user and passwords entered in my settings.py
> file for my database, but this doesn't seem to help--I still need to switch
> over to "posgres" in the Terminal to access my databases.  I'm guessing I
> need to either a) give "guillaume" access to my databases (which I've tried
> reading up on in the PostgreSQL docs, but am still not sure how to
> do...part of it is I'm not sure how to tell apart Ubuntu users, Unix users,
> and Postgres users), or I need to b) give "postgres" access to my local
> file system.  Can anyone tell me which is the better route to follow, and
> how to achieve it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/1NWyssjq5sYJ.
> 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.
>

-- 
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: How to change widgets for admin site?

2012-04-16 Thread Guillaume Chorn
Shoot! I was thinking that might be the case originally, but I must have 
overlooked TextField in the model field docs. Thanks!!!

I'm still curious though--how can I find out what all of the CSS classes are 
that are defined by the default admin style sheet (I guess I'm asking where 
this style sheet normally resides in a typical Django installation)?

On 16 Apr, 2012, at 10:28 PM, Daniel Roseman  wrote:

> On Monday, 16 April 2012 06:24:54 UTC+1, Gchorn wrote:
> Hello, I'm trying to create a blog site using Django (with "Post" as 
> my main model and "text" as the attribute corresponding to the main 
> body of text for each post).  On the admin page, when someone is 
> filling out fields to create a new blog post, I want the "text" entry 
> field to be larger than the default field for a CharField attribute. 
> 
> In this part of the docs: 
> 
> https://docs.djangoproject.com/en/1.4/ref/contrib/admin/ 
> 
> in the "ModelAdmin options" section, under "ModelAdmin.fieldsets", 
> there is an image of pretty much what I want--a set of text entry 
> fields, where one of the fields, named "Content", is much larger than 
> the others to make it easier for whoever uses the admin site to type 
> in larger amounts of text.  However, there isn't any clear explanation 
> that I can find in this section about how to achieve this. 
> 
> The closest thing I can find is a little ways further, there's a 
> section that says you can use "classes" as a field_options dictionary 
> key, and it mentions two classes defined by the default admin style 
> sheet (collapse and wide).  I think I need to specify some kind of 
> class in this way, but I don't know where on my file system the 
> default admin style sheet is located in order to read it and see if 
> there are any classes there I can use. 
> 
> Can anyone help with this?  Is there a built-in CSS class that does 
> what I want, or do I need to write it myself?  If the latter, can 
> anyone tell me where I should write it and where I need to reference 
> it so that it affects the admin site?
> 
> 'content' in that model is a models.TextField, not models.CharField. 
> TextFields by default render with the Textarea widget.
> --
> DR.
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/7aPR5gfE6mYJ.
> 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.

-- 
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: How to change widgets for admin site?

2012-04-16 Thread Guillaume Chorn
Hi Marc,

Thanks for your reply.  Are you referring to the "max_length" element of my
"text" CharField?  If so, I don't think this is the issue; I've set the max
length to 10,000 characters which is quite long.  Also this setting does
not change the size of the text input area relative to my other CharFields
with much shorter max_length values (such as "title", which has a max
length of only 1000).

cheers,
Guillaume

On Mon, Apr 16, 2012 at 4:51 PM, Marc Patermann <
hans.mo...@ofd-z.niedersachsen.de> wrote:

> Hi,
>
> Gchorn schrieb (16.04.2012 07:24 Uhr):
>
>  Hello, I'm trying to create a blog site using Django (with "Post" as
>> my main model and "text" as the attribute corresponding to the main
>> body of text for each post).  On the admin page, when someone is
>> filling out fields to create a new blog post, I want the "text" entry
>> field to be larger than the default field for a CharField attribute.
>>
>> In this part of the docs:
>>
>> https://docs.djangoproject.**com/en/1.4/ref/contrib/admin/<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/>
>>
> what you see in the admin interface is inherited form the model of the
> corresponding object - like your blog post object.
> I think you have to change the field length there.
>
> https://docs.djangoproject.**com/en/1.4/intro/tutorial01/<https://docs.djangoproject.com/en/1.4/intro/tutorial01/>
>
>
> Marc
>
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://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.



Re: Query Set to search for a combination of model fields?

2012-03-16 Thread Guillaume Chorn
Shawn, man thanks!  I actually had no idea about the pipe vs. ampersand
distinction.  I went ahead and changed my code to the following:

def search(request):
query = request.GET.get('q','')
querywords = query.split(' ')
lname=''
for word in querywords[1:-1]:
lname += word+' '
lname += querywords[-1]
if query:
if len(querywords)>1:
qset = (
Q(first_name__icontains=querywords[0]) &
Q(last_name__icontains=lname)|
Q(first_name__icontains=querywords[0])|
Q(last_name__icontains=querywords[0])
)
results = Player.objects.filter(qset).distinct()
results = results.order_by('last_name','first_name')
else:
qset = (
Q(first_name__icontains=querywords[0])|
Q(last_name__icontains=querywords[0])
)
results = Player.objects.filter(qset).distinct()
results = results.order_by('last_name','first_name')
else:
results = []
return render(request,'search.html', {
'results': results,
'query': query,
'querywords':querywords
})

This seems to work; I just need to find a way to separate exact matches
from the rest.  I'm guessing it will involve some logic to forgo the
additional queries if I can find a result for
Q(first_name__exact=querywords[0])
& Q(last_name__exact=lname), but I'm not yet sure how to structure it.

By the way, does anyone know what the default sorting order is for the
results?  You may have noticed I forced a sort order by last name and then
first name, but I find it annoying that I had to do this even though my
primary keys are in this same order.  I thought the default sort order was
by pk?

cheers,
Guillaume

On Fri, Mar 16, 2012 at 11:29 AM, Shawn Milochik  wrote:

> Look at how the Q objects are being used in the example and it's clear why
> that is. It's using the pipe (|) to do an "or" query.
>
> If you want to change how the search works you'll have to add more code:
>
> 1. Split the search parameters on whitespace.
> 2. Create Q objects for searching in either or both fields for the values
> and use pipe (|) and ampersand (&) to "or" or "and" them as needed.
>
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://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.



Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
IT WORKED!!!  Holy cow.  So my main issue was just not using
RequestContext, right?  Either way, thank you SO much.  I have been stuck
at this point for months!  I can now TRULY begin working on my website.
Wow.  Thank you. So. Much.

best,
Guillaume

On Wed, Nov 23, 2011 at 9:53 PM, Ivo Brodien  wrote:

> ok, i think we got it.
>
> def items(request):
> item_list=Item.objects.all()
> return render(request, 'myapp/items.html', {'items_list':items_list},
> content_type="text/css")
>
>
> you are returning html and text/css. Your HTML includes a CSS but that is
> a different story. The Browser will ask for the included CSS file in a
> different request to the server and the server responds with a static file
> from disk without going through any of your views.
>
> so just remove content_type
>
> or put it to text/html which is the default.
>
> Your browser thinks it is a CSS file instead of HTML.
>
> cheers
> Ivo
>
>
> On Nov 23, 2011, at 14:40 , Guillaume Chorn wrote:
>
> Oops, I guess maybe you meant since I've changed the views.py file since I
> last included it?  Here is the newest version:
>
> http://dpaste.com/660808/
>
> thanks,
> Guillaume
>
> On Wed, Nov 23, 2011 at 9:36 PM, Guillaume Chorn  > wrote:
>
>> Sorry, I thought I included my views.py earlier, but here it is:
>>
>> http://dpaste.com/660653/
>>
>> It is the
>>
>> (r'^items/$','myapp.views.items')
>>
>> which is not working.  It shows the expected HTML source--basically,
>> exactly what I have in the template file, except {{ STATIC_URL }} has been
>> changed to '/static' and all of the template tags have been replaced by
>> actual values.  So yes, I think that it's just not rendered.  What could
>> cause this?
>>
>> thanks,
>> Guillaume
>>
>>
>> On Wed, Nov 23, 2011 at 8:23 PM, Ivo Brodien  wrote:
>>
>>> show your myapp.views.py file and is it the
>>>
>>> (r'^home/$','myapp.views.homepage'),
>>>
>>>
>>> which is not working?
>>>
>>> Is it showing the html source that you expect just not rendered or
>>> something else?
>>>
>>> It is always a good idea to provide as much details as possible.
>>>
>>> But yeah, we are getting close.
>>>
>>> cheers
>>> Ivo
>>>
>>>
>>>
>>> Gah!  Removed it, but now when I load up the page, it just shows me HTML
>>> source code.  The rest of the views work fine.
>>>
>>> Sorry for all this trouble.  But at least something is happening with
>>> each change you suggest!  I now have more hope than I've had in quite a
>>> while.  I think we're getting close! =)
>>>
>>> thanks,
>>> Guillaume
>>>
>>> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:
>>>
>>>> you did not read the post by Tom Evans, did you? ;)
>>>>
>>>> remove "django.core.context_processors.tz”,
>>>>
>>>> or just put:
>>>>
>>>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static",
>>>> "django.contrib.messages.context_processors.messages")
>>>>
>>>>
>>>>
>>>> It was a mistake by me. I posted the one from the dev version.
>>>>
>>>> does it work now?
>>>>
>>>>
>>>>
>>>> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>>>>
>>>> Hi,
>>>>
>>>> Thanks for continuing to follow up on this.  Something is definitely
>>>> happening now.  I went ahead and put this into my views.py:
>>>>
>>>> from django.shortcuts import render
>>>>
>>>> def items(request):
>>>> item_list=Item.objects.all()
>>>> return render(request, 'myapp/items.html', {'item_list':item_list},
>>>> content_type="text/css")
>>>>
>>>> And now when I try to load the page, I get the following error:
>>>>
>>>> ImproperlyConfigured at /diseases/
>>>>
>>>> Module "django.core.context_processors" does not define a "tz" callable
>>>> request processor
>>>>

Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
Oops, I guess maybe you meant since I've changed the views.py file since I
last included it?  Here is the newest version:

http://dpaste.com/660808/

thanks,
Guillaume

On Wed, Nov 23, 2011 at 9:36 PM, Guillaume Chorn
wrote:

> Sorry, I thought I included my views.py earlier, but here it is:
>
> http://dpaste.com/660653/
>
> It is the
>
> (r'^items/$','myapp.views.items')
>
> which is not working.  It shows the expected HTML source--basically,
> exactly what I have in the template file, except {{ STATIC_URL }} has been
> changed to '/static' and all of the template tags have been replaced by
> actual values.  So yes, I think that it's just not rendered.  What could
> cause this?
>
> thanks,
> Guillaume
>
>
> On Wed, Nov 23, 2011 at 8:23 PM, Ivo Brodien  wrote:
>
>> show your myapp.views.py file and is it the
>>
>> (r'^home/$','myapp.views.homepage'),
>>
>>
>> which is not working?
>>
>> Is it showing the html source that you expect just not rendered or
>> something else?
>>
>> It is always a good idea to provide as much details as possible.
>>
>> But yeah, we are getting close.
>>
>> cheers
>> Ivo
>>
>>
>>
>> Gah!  Removed it, but now when I load up the page, it just shows me HTML
>> source code.  The rest of the views work fine.
>>
>> Sorry for all this trouble.  But at least something is happening with
>> each change you suggest!  I now have more hope than I've had in quite a
>> while.  I think we're getting close! =)
>>
>> thanks,
>> Guillaume
>>
>> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:
>>
>>> you did not read the post by Tom Evans, did you? ;)
>>>
>>> remove "django.core.context_processors.tz”,
>>>
>>> or just put:
>>>
>>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static",
>>> "django.contrib.messages.context_processors.messages")
>>>
>>>
>>>
>>> It was a mistake by me. I posted the one from the dev version.
>>>
>>> does it work now?
>>>
>>>
>>>
>>> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>>>
>>> Hi,
>>>
>>> Thanks for continuing to follow up on this.  Something is definitely
>>> happening now.  I went ahead and put this into my views.py:
>>>
>>> from django.shortcuts import render
>>>
>>> def items(request):
>>> item_list=Item.objects.all()
>>> return render(request, 'myapp/items.html', {'item_list':item_list},
>>> content_type="text/css")
>>>
>>> And now when I try to load the page, I get the following error:
>>>
>>> ImproperlyConfigured at /diseases/
>>>
>>> Module "django.core.context_processors" does not define a "tz" callable
>>> request processor
>>>
>>> Request Method: GET
>>> Request URL: http://127.0.0.1:8000/diseases/
>>> Django Version: 1.3.1
>>> Exception Type: ImproperlyConfigured
>>> Exception Value:
>>>
>>> Module "django.core.context_processors" does not define a "tz" callable
>>> request processor
>>>
>>> Exception Location:
>>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
>>> in get_standard_processors, line 154
>>> Python Executable:
>>> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>>> Python Version: 2.7.2
>>> Python Path:
>>>
>>> ['/Users/guillaumechorn/Documents/pharmapipe',
>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>>
>>>  
>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>>
>>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>>
>>>  
>>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>>
>>>  '/Library/Frameworks/Python.framework/Versions

Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
Sorry, I thought I included my views.py earlier, but here it is:

http://dpaste.com/660653/

It is the

(r'^items/$','myapp.views.items')

which is not working.  It shows the expected HTML source--basically,
exactly what I have in the template file, except {{ STATIC_URL }} has been
changed to '/static' and all of the template tags have been replaced by
actual values.  So yes, I think that it's just not rendered.  What could
cause this?

thanks,
Guillaume

On Wed, Nov 23, 2011 at 8:23 PM, Ivo Brodien  wrote:

> show your myapp.views.py file and is it the
>
> (r'^home/$','myapp.views.homepage'),
>
>
> which is not working?
>
> Is it showing the html source that you expect just not rendered or
> something else?
>
> It is always a good idea to provide as much details as possible.
>
> But yeah, we are getting close.
>
> cheers
> Ivo
>
>
>
> Gah!  Removed it, but now when I load up the page, it just shows me HTML
> source code.  The rest of the views work fine.
>
> Sorry for all this trouble.  But at least something is happening with each
> change you suggest!  I now have more hope than I've had in quite a while.
> I think we're getting close! =)
>
> thanks,
> Guillaume
>
> On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:
>
>> you did not read the post by Tom Evans, did you? ;)
>>
>> remove "django.core.context_processors.tz”,
>>
>> or just put:
>>
>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static",
>> "django.contrib.messages.context_processors.messages")
>>
>>
>>
>> It was a mistake by me. I posted the one from the dev version.
>>
>> does it work now?
>>
>>
>>
>> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>>
>> Hi,
>>
>> Thanks for continuing to follow up on this.  Something is definitely
>> happening now.  I went ahead and put this into my views.py:
>>
>> from django.shortcuts import render
>>
>> def items(request):
>> item_list=Item.objects.all()
>> return render(request, 'myapp/items.html', {'item_list':item_list},
>> content_type="text/css")
>>
>> And now when I try to load the page, I get the following error:
>>
>> ImproperlyConfigured at /diseases/
>>
>> Module "django.core.context_processors" does not define a "tz" callable
>> request processor
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/diseases/
>> Django Version: 1.3.1
>> Exception Type: ImproperlyConfigured
>> Exception Value:
>>
>> Module "django.core.context_processors" does not define a "tz" callable
>> request processor
>>
>> Exception Location:
>> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
>> in get_standard_processors, line 154
>> Python Executable:
>> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
>> Python Version: 2.7.2
>> Python Path:
>>
>> ['/Users/guillaumechorn/Documents/pharmapipe',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>>
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>>
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>>
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>>
>>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>>
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>>
>>  
>> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']
>>
>> Did something happen to my context.py file?  Here it is:
>>
>> http://dpaste.com/660778/
>>
>> Also, as you can see from the error message above, I am currently using 
>> Django 1.3.1.
>>
>> thanks,
>> Guillaume
>>
>>
>>
>> On Wed, Nov 23, 2011 at 7:10 PM, I

Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
Gah!  Removed it, but now when I load up the page, it just shows me HTML
source code.  The rest of the views work fine.

Sorry for all this trouble.  But at least something is happening with each
change you suggest!  I now have more hope than I've had in quite a while.
I think we're getting close! =)

thanks,
Guillaume

On Wed, Nov 23, 2011 at 8:08 PM, Ivo Brodien  wrote:

> you did not read the post by Tom Evans, did you? ;)
>
> remove "django.core.context_processors.tz”,
>
> or just put:
>
> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static",
> "django.contrib.messages.context_processors.messages")
>
>
>
> It was a mistake by me. I posted the one from the dev version.
>
> does it work now?
>
>
>
> On Nov 23, 2011, at 13:02 , Guillaume Chorn wrote:
>
> Hi,
>
> Thanks for continuing to follow up on this.  Something is definitely
> happening now.  I went ahead and put this into my views.py:
>
> from django.shortcuts import render
>
> def items(request):
> item_list=Item.objects.all()
> return render(request, 'myapp/items.html', {'item_list':item_list},
> content_type="text/css")
>
> And now when I try to load the page, I get the following error:
>
> ImproperlyConfigured at /diseases/
>
> Module "django.core.context_processors" does not define a "tz" callable
> request processor
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/diseases/
> Django Version: 1.3.1
> Exception Type: ImproperlyConfigured
> Exception Value:
>
> Module "django.core.context_processors" does not define a "tz" callable
> request processor
>
> Exception Location:
> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
> in get_standard_processors, line 154
> Python Executable:
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
> Python Version: 2.7.2
> Python Path:
>
> ['/Users/guillaumechorn/Documents/pharmapipe',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>
>  
> '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']
>
> Did something happen to my context.py file?  Here it is:
>
> http://dpaste.com/660778/
>
> Also, as you can see from the error message above, I am currently using 
> Django 1.3.1.
>
> thanks,
> Guillaume
>
>
>
> On Wed, Nov 23, 2011 at 7:10 PM, Ivo Brodien  wrote:
>
>> Hi,
>>
>> STATIC_URL is not working in your template because the template does not
>> get the RequestContext, which has all the variables in it.
>>
>> use the render shortcut [1] instead of render_to_reponse
>>
>> BTW: It seems you are using the development version. You should change to
>> 1.3.1
>>
>> Does this help?
>>
>> [1]  https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
>>
>>
>> On Nov 23, 2011, at 7:33 , Guillaume Chorn wrote:
>>
>> Hi,
>>
>> The location of my CSS file is
>> /Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css.
>> Sorry, I may have missed you asking for this earlier.
>>
>> Here is my views.py:
>>
>> http://dpaste.com/660653/
>>
>> When I hardcode the disk location of the CSS file in the template (like
>> so: > href="/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css"
>> type="text/css" />), the CSS shows up if I open the template file directly
>> using a browser.  But it still doesn't show up when loading up the page on
>> the development server.
>>
>> thanks,
>> Guillaume
>>
>> On Wed, Nov 23, 2011 at 9:57 

Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
Hi,

Thanks for continuing to follow up on this.  Something is definitely
happening now.  I went ahead and put this into my views.py:

from django.shortcuts import render

def items(request):
item_list=Item.objects.all()
return render(request, 'myapp/items.html', {'item_list':item_list},
content_type="text/css")

And now when I try to load the page, I get the following error:

ImproperlyConfigured at /diseases/

Module "django.core.context_processors" does not define a "tz" callable
request processor

Request Method: GET
Request URL: http://127.0.0.1:8000/diseases/
Django Version: 1.3.1
Exception Type: ImproperlyConfigured
Exception Value:

Module "django.core.context_processors" does not define a "tz" callable
request processor

Exception Location:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/context.py
in get_standard_processors, line 154
Python Executable:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.2
Python Path:

['/Users/guillaumechorn/Documents/pharmapipe',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']

Did something happen to my context.py file?  Here it is:

http://dpaste.com/660778/

Also, as you can see from the error message above, I am currently
using Django 1.3.1.

thanks,
Guillaume



On Wed, Nov 23, 2011 at 7:10 PM, Ivo Brodien  wrote:

> Hi,
>
> STATIC_URL is not working in your template because the template does not
> get the RequestContext, which has all the variables in it.
>
> use the render shortcut [1] instead of render_to_reponse
>
> BTW: It seems you are using the development version. You should change to
> 1.3.1
>
> Does this help?
>
> [1]  https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render
>
>
> On Nov 23, 2011, at 7:33 , Guillaume Chorn wrote:
>
> Hi,
>
> The location of my CSS file is
> /Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css.
> Sorry, I may have missed you asking for this earlier.
>
> Here is my views.py:
>
> http://dpaste.com/660653/
>
> When I hardcode the disk location of the CSS file in the template (like
> so:  href="/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css"
> type="text/css" />), the CSS shows up if I open the template file directly
> using a browser.  But it still doesn't show up when loading up the page on
> the development server.
>
> thanks,
> Guillaume
>
> On Wed, Nov 23, 2011 at 9:57 AM, Ivo Brodien  wrote:
>
>> Hi,
>>
>> looks fine.
>>
>> yes, show your views.py
>>
>> and you can also hardcode the STATIC_URL in the template to see if the
>> path: src=“/static/stylesheet.css” works.
>>
>> or simply open http://127.0.0.1:8000/static/stylesheet.css in your
>> browser.
>>
>> Again: Where is that CSS file on your disk?
>>
>> On Nov 23, 2011, at 2:46 , Guillaume Chorn wrote:
>>
>> Sorry, I think I made something confusing.  In my original file, I only
>> pasted the URL pattern for the site homepage.  However, this is not the
>> page I'm trying to style (or link to the CSS file).  The page I'm trying to
>> link to the CSS file is a separate one, which I have previously referred to
>> as http://127.0.0.1:8000/view/, but which I will hereafter refer to as
>> http://127.0.0.1:8000/items/ (and will now include below).  I previously
>> used the term "view" to imply a general myapp.views.view, but will
>> hereafter refer to it as myapp.views.items.  Hope that makes sense.  I've
>> used dpaste to share my code as suggested.
>>
>> Here is my settings.py file:
>>
>> http://dpaste.com/660563/
>>
>> Here is the template which I want to style:
>>
>> http://dpaste.com/660565/
>>
>> And here is my urls.py file:
>>
>> http://dpaste.com/660568/
>>
>> 

Re: How-to for static files?

2011-11-23 Thread Guillaume Chorn
Hi,

The location of my CSS file is
/Users/guillaumechorn/Documents/project/myapp/static/stylesheet.css.
Sorry, I may have missed you asking for this earlier.

Here is my views.py:

http://dpaste.com/660653/

When I hardcode the disk location of the CSS file in the template (like so:
), the CSS shows up if I open the template file directly
using a browser.  But it still doesn't show up when loading up the page on
the development server.

thanks,
Guillaume

On Wed, Nov 23, 2011 at 9:57 AM, Ivo Brodien  wrote:

> Hi,
>
> looks fine.
>
> yes, show your views.py
>
> and you can also hardcode the STATIC_URL in the template to see if the
> path: src=“/static/stylesheet.css” works.
>
> or simply open http://127.0.0.1:8000/static/stylesheet.css in your
> browser.
>
> Again: Where is that CSS file on your disk?
>
> On Nov 23, 2011, at 2:46 , Guillaume Chorn wrote:
>
> Sorry, I think I made something confusing.  In my original file, I only
> pasted the URL pattern for the site homepage.  However, this is not the
> page I'm trying to style (or link to the CSS file).  The page I'm trying to
> link to the CSS file is a separate one, which I have previously referred to
> as http://127.0.0.1:8000/view/, but which I will hereafter refer to as
> http://127.0.0.1:8000/items/ (and will now include below).  I previously
> used the term "view" to imply a general myapp.views.view, but will
> hereafter refer to it as myapp.views.items.  Hope that makes sense.  I've
> used dpaste to share my code as suggested.
>
> Here is my settings.py file:
>
> http://dpaste.com/660563/
>
> Here is the template which I want to style:
>
> http://dpaste.com/660565/
>
> And here is my urls.py file:
>
> http://dpaste.com/660568/
>
> Let me know if anything else is needed, such as the views.py file or
> something.
>
> thanks,
> Guillaume
>
> On Wed, Nov 23, 2011 at 7:33 AM, Ivo Brodien  wrote:
>
>> In your original post you had the url like this:
>>
>> (r'^home/$','myapp.views.homepage'),
>>
>>
>> than your the url starts with view instead of home so there might be
>> something wrong.
>>
>> just paste these files into somthing like dpaste.com
>>
>> - settings.py
>> - myapp.views.homepage
>> - urls.py
>>
>> cheers
>>
>>
>> On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:
>>
>> Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.
>> Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated
>> tuple into the settings.py file, I tried to restart the development server
>> to see if it worked and it didn't.  I checked the page source again and
>> it's still looking for /view/stylesheet.css.  Am I missing something else?
>>
>> thanks,
>> Guillaume
>>
>> On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien  wrote:
>>
>>>
>>> Finally, I have another question.  In my settings.py file, there is 
>>> actually no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the 
>>> documentation
>>>
>>>
>>> yes.
>>>
>>> put this in there:
>>>
>>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static","django.core.context_processors.tz","django.contrib.messages.context_processors.messages")
>>>
>>>
>>> and try again.
>>>
>>> What happens in your template is that {{ STATIC_URL }} is empty because
>>> the context processor ““django.core.context_processors.static”” did not put
>>> the STATIC_URL into the context. so your path to the file becomes:
>>> /view/stylesheet.css instead of /static/stylesheet.css
>>>
>>> You have to put the CSS file in a directory called static as mentioned
>>> before.
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>

-- 
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: How-to for static files?

2011-11-22 Thread Guillaume Chorn
Sorry, I think I made something confusing.  In my original file, I only
pasted the URL pattern for the site homepage.  However, this is not the
page I'm trying to style (or link to the CSS file).  The page I'm trying to
link to the CSS file is a separate one, which I have previously referred to
as http://127.0.0.1:8000/view/, but which I will hereafter refer to as
http://127.0.0.1:8000/items/ (and will now include below).  I previously
used the term "view" to imply a general myapp.views.view, but will
hereafter refer to it as myapp.views.items.  Hope that makes sense.  I've
used dpaste to share my code as suggested.

Here is my settings.py file:

http://dpaste.com/660563/

Here is the template which I want to style:

http://dpaste.com/660565/

And here is my urls.py file:

http://dpaste.com/660568/

Let me know if anything else is needed, such as the views.py file or
something.

thanks,
Guillaume

On Wed, Nov 23, 2011 at 7:33 AM, Ivo Brodien  wrote:

> In your original post you had the url like this:
>
> (r'^home/$','myapp.views.homepage'),
>
>
> than your the url starts with view instead of home so there might be
> something wrong.
>
> just paste these files into somthing like dpaste.com
>
> - settings.py
> - myapp.views.homepage
> - urls.py
>
> cheers
>
>
> On Nov 23, 2011, at 0:29 , Guillaume Chorn wrote:
>
> Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.
> Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated
> tuple into the settings.py file, I tried to restart the development server
> to see if it worked and it didn't.  I checked the page source again and
> it's still looking for /view/stylesheet.css.  Am I missing something else?
>
> thanks,
> Guillaume
>
> On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien  wrote:
>
>>
>> Finally, I have another question.  In my settings.py file, there is actually 
>> no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the 
>> documentation
>>
>>
>> yes.
>>
>> put this in there:
>>
>> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static","django.core.context_processors.tz","django.contrib.messages.context_processors.messages")
>>
>>
>> and try again.
>>
>> What happens in your template is that {{ STATIC_URL }} is empty because
>> the context processor ““django.core.context_processors.static”” did not put
>> the STATIC_URL into the context. so your path to the file becomes:
>> /view/stylesheet.css instead of /static/stylesheet.css
>>
>> You have to put the CSS file in a directory called static as mentioned
>> before.
>>
>>
>>
>>
>>
>
>

-- 
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: How-to for static files?

2011-11-22 Thread Guillaume Chorn
Thank you Ivo.  Your suggestion makes a lot of sense so I tried it out.
Unfortunately, after adding TEMPLATE_CONTEXT_PROCESSORS and its associated
tuple into the settings.py file, I tried to restart the development server
to see if it worked and it didn't.  I checked the page source again and
it's still looking for /view/stylesheet.css.  Am I missing something else?

thanks,
Guillaume

On Tue, Nov 22, 2011 at 10:42 PM, Ivo Brodien  wrote:

>
> Finally, I have another question.  In my settings.py file, there is actually 
> no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed in the 
> documentation
>
>
> yes.
>
> put this in there:
>
> ("django.contrib.auth.context_processors.auth","django.core.context_processors.debug","django.core.context_processors.i18n","django.core.context_processors.media","django.core.context_processors.static","django.core.context_processors.tz","django.contrib.messages.context_processors.messages")
>
>
> and try again.
>
> What happens in your template is that {{ STATIC_URL }} is empty because
> the context processor ““django.core.context_processors.static”” did not put
> the STATIC_URL into the context. so your path to the file becomes:
> /view/stylesheet.css instead of /static/stylesheet.css
>
> You have to put the CSS file in a directory called static as mentioned
> before.
>
>
>
>
>

-- 
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: How-to for static files?

2011-11-22 Thread Guillaume Chorn
Hm, this might be something.  I never thought of viewing the source for my
HTML page.  Actually, what I get when I do that is the following:



And then when I click on the "stylesheet.css" hyperlink, I get what
looks like another source page, but this one is some kind of error
page (just to clarify in case
it's necessary, the page http://127.0.0.1:8000/view/ is the original
view my question was referring to, the one that isn't showing any of
the desired CSS):
http://www.w3.org/TR/html4/loose.dtd";>


  
  Page not found at /view/stylesheet.css
  


  
Page not found (404)

  
Request Method:
GET
  
  
Request URL:
  http://127.0.0.1:8000/view/stylesheet.css
  

  
  

  
  Using the URLconf defined in project.urls,
  Django tried these URL patterns, in this order:
  
  
 
(LIST OF URL PATTERNS)
.
 
  The current URL, view/stylesheet.css, didn't
match any of these.

  

  

  You're seeing this error because you have DEBUG = True in
  your Django settings file. Change that to False, and Django
  will display a standard 404 page.

  


It looks like it's trying to open a page called
http://127.0.0.1:8000/view/stylesheet.css that I didn't include in my
URL conf.  Is this what I'm missing?  Do I need such a
page in order for Django to be able to use "stylesheet.css" while
running the dev server?  And if so, how do I create it (aside from
writing a URL pattern in the urls.py
file)?

Finally, I have another question.  In my settings.py file, there is
actually no section for TEMPLATE_CONTEXT_PROCESSORS.  I have noticed
in the documentation
that it seems like it's supposed to be in the settings.py file, but
mine doesn't have such a section (nor do I remember it ever being
there).  Should I just add it in?

thanks,
Guillaume

On Tue, Nov 22, 2011 at 6:56 PM, Ivo Brodien  wrote:

> Does your generated HTML source say:
>
>  type="text/css" />
>
> ??
>
> In your settings the TEMPLATE_CONTEXT_PROCESSORS
>
> should have:
>
> “django.core.context_processors.static”
>
> The CSS File should go into a folder: myapp/static/stylesheet.css
>
> > urlpatterns += staticfiles_urlpatterns()
>
> I think you don’t need this. If you have the static app in your
> INSTALLED_APPS, it does this for you because it overrides te runserver
> command.
>
> good luck
>
> On Nov 22, 2011, at 11:16 , Gchorn wrote:
>
> > Oh yes, I definitely have this in my INSTALLED_APPS list (as simply
> > 'myapp').  Sorry I left it out; I thought this was necessary
> > regardless of whether or not I was using static files, so I didn't
> > include it in the list of settings I changed just to enable static
> > files.   I do want to reiterate that I followed the tutorial closely
> > in creating my project so I already have pretty much anything from
> > there.
> >
> > Any other ideas?
> >
> > thanks,
> > Guillaume
> >
> > On Nov 22, 2:47 pm, Xavier Ordoquy  wrote:
> >> Hi,
> >>
> >>> What follows are my current settings.  In settings.py, I have:
> >>
> >>> STATIC_URL = '/static/'
> >>> INSTALLED_APPS = ('django.contrib.staticfiles',)
> >>
> >> In order to get their static files served, apps need to be listed in
> the INSTALLED_APPS list.
> >> As you don't mention it, you probably need to add myapp in the
> INSTALLED_APPS.
> >>
> >> Regards,
> >> Xavier,
> >> Linovia.
> >
> > --
> > 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.
> >
>
>

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



Create a modular application

2011-10-12 Thread Guillaume DE BURE
Hi people,

I just started a new open source project aimed at small companies that would 
need a tool to manage its resources 
(http://github.com/myOpenCompany/myOpenCompany not much to see at the 
moment...), and one of the central idea would be modularization: 

For example, we will start with an "employee" and a "hardware" module. The 
hardware module allows tracking the phones and laptops affected to 
employees. In the employee property page, the list of hardware for this 
employee is displayed.

Now, if the company does not need the "hardware" module, the property page 
will of course not contain this information. This is implies some kind of 
dependency between the two modules, and that the "employee" module is somehow 
aware of the information that the "hardware" module can provide.

The application will contain probably many modules (attendance management, 
skills, missions, training...)

Being still quite new to django, I have some very basic questions on this:
* Should each module be a django app ? Or is it something different ?
* Is there already something existing (a third party app ?) to provide this 
kind of mechanism ?
* If not, does anyone has experience implementing such behaviour ?

Thanks in advance for any feedback,

Guillaume
-- 
Skrooge, a free, Open Source, personal finances software
http://skrooge.org

-- 
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: Displaying information as a table?

2011-09-03 Thread Guillaume DE BURE
Le Samedi 3 Septembre 2011 09:02:52 Levi Campbell a écrit :
> In a django template, what's the best way to display information from
> the models as a table? I've had no luck searching the documentation
> and google.
> 
> 

As far as I can tell, there is no way to do it fully automatically, but you can 
use the built-in ListView or DetailView with your own defined 
template. IMHO, this is a good balance between automation and customization.
-- 
Skrooge, a free, Open Source, personal finances software
http://skrooge.org

-- 
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: modelForm has no _default_manager

2011-08-19 Thread Guillaume DE BURE
Thanks, I overlooked the documentation... Will check this!

Guillaume
Le 19 août 2011 14:49, "Daniel Roseman"  a écrit :
> On Friday, 19 August 2011 11:15:53 UTC+1, gdebure wrote:
>>
>> Hi Everyone,
>>
>> I've been discovering Django for a few weeks, and love it so far :)
>> However I am facing an issue with a modelForm. As I couldn't find my
>> answer through googling, I thought you might be able to help...
>>
>> == context ==
>> I have an object (called "Domain") that has an "owner" attribute that
>> links to a user. using guardian (http://packages.python.org/django-
>> guardian/ <http://packages.python.org/django-guardian/>), I would like to

>> automatically setup a per object
>> permission on this Domain for its Owner
>>
>> == code ==
>> Please see : http://pastebin.com/4Uf31Q52
>>
>> == error ==
>> Whenever I try to access the update page that should contain the Form,
>> I get the error:
>>
>> type object 'DomainForm' has no attribute '_default_manager'
>>
>> (Full traceback at http://dpaste.com/598065/)
>>
>> Please note that this does not seem to be the same as the
>> "AttributeError: 'str' object has no attribute '_default_manager'" for
>> which I saw many things on google, but that do not seem to apply to my
>> case.
>>
>> Thanks a lot for any guidance you may provide :)
>>
>> Guillaume
>
>
> You've simply put the form class as the `model` parameter in the URLconf.
> You need to use the `form_class` parameter instead.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/q-_GkaiJzxAJ.
> 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.
>

-- 
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: Django can't see my static files

2011-08-04 Thread Guillaume Chorn
Hi All,

It's been a couple of days since I last wrote and no response so I'm trying
again (see below).  Please help if you can; without being able to link to
external static files I really can't do anything else with my site.  CSS is
the very least of my concerns--worst case I can include that info in each
HTML file--but I need to be able to use some basic javascript for my site
and right now, because of this issue, I can't even do that.  Is there anyone
who could help me troubleshoot this?  Anyone??

thanks,
Guillaume

On Wed, Aug 3, 2011 at 12:20 PM, Guillaume Chorn
wrote:

> Ok, so I did use quotes in my link, and I changed my STATIC_URL setting (in
> settings.py) from '/static/' to 'http://127.0.0.1:8000/static/' (I am
> currently using the built-in development server at this address), but still
> no luck.
>
> I'm not sure exactly what you mean by my "staticfiles settings."  (Sorry,
> once again I'm a total beginner so please bear with me.)  My current
> settings related to static files in 'settings.py' are as follows:
>
> STATIC_ROOT = ''
> STATIC_URL = 'http://127.0.0.1:8000/static/'
> ADMIN_MEDIA_PREFIX = '/static/admin/'
> STATICFILES_DIRS =
> ('/Users/guillaumechorn/Documents/website/mainapp/static')
>
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder'
> )
>
> Below are the full contents of my urls.py file:
>
> from django.conf.urls.defaults import *
>
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
> (r'^home/$','mainapp.views.homepage'),
> (r'^mainapp/$','mainapp.views.index'),
> (r'^mainapp/(?P\d+)/$', 'mainapp.views.detail'),
> (r'^products/$','mainapp.views.productindex'),
> (r'^products/(?P\d+)/$','mainapp.views.productdetail'),
> (r'^news/$','mainapp.views.news'),
> (r'^events/(?P\d+)/$','mainapp.views.eventdetail'),
> (r'^partners/$','mainapp.views.partners'),
> (r'^admin/', include(admin.site.urls)),
> )
> urlpatterns += staticfiles_urlpatterns()
>
> Once again, I'm using the following to link to my CSS file:
>
> 
>
> Am I still missing something?  Did I enter in anything incorrectly?
>
> thanks,
> Guillaume
>
>
> On Tue, Aug 2, 2011 at 6:06 PM, Thomas Orozco 
> wrote:
>
>> Last thing, I made a typo, the address you could use should start with
>> http, like: http://127.0.0.1/static/
>> Le 2 août 2011 12:01, "Thomas Orozco"  a
>> écrit :
>>
>> > A little detail, but you never know: you should put some ' ' in your
>> link.
>> > Like this :
>> >
>> > 
>> >
>> >
>> > If there are spaces in your path, this could cause the lookup to fail.
>> >
>> > And even if that's not the case, don't rely on the user's browser to fix
>> > coding mistakes.
>> > Le 2 août 2011 10:28, "Guillaume Chorn"  a
>> écrit :
>> >> Thomas and Lokesh,
>> >>
>> >> Thanks very much for your help. I've modified the link in my HTML file
>> to
>> >> be:
>> >>
>> >> > }}stylesheet.css
>> >> />
>> >>
>> >> where "stylesheet" is the name of the CSS file, and this file is
>> located
>> >> inside the directory listed under STATIC_DIRS in my settings.py file.
>> As
>> >> mentioned in my prior email, I also already have STATIC_URL =
>> '/static/'
>> > in
>> >> my settings.py file, and I have the correct methods listed under
>> >> STATICFILES_FINDERS.
>> >>
>> >> But it is still not working. Do I have a syntax error somewhere? Or am
>> I
>> >> still missing something in another file?
>> >>
>> >> thanks,
>> >> Guillaume
>> >>
>> >> On Mon, Aug 1, 2011 at 6:45 PM, Thomas Orozco <
>> g.orozco.tho...@gmail.com
>> >>wrote:
>> >>
>> >>> If your css file is locatedr in your staticfiles dir, you should use
>> >>> something such as {{ STATIC_URL }}main.css, assuming your CSS file is
>> > called
>> >>> main and is located in one of the STATIC_DIR

Re: Django can't see my static files

2011-08-02 Thread Guillaume Chorn
Ok, so I did use quotes in my link, and I changed my STATIC_URL setting (in
settings.py) from '/static/' to 'http://127.0.0.1:8000/static/' (I am
currently using the built-in development server at this address), but still
no luck.

I'm not sure exactly what you mean by my "staticfiles settings."  (Sorry,
once again I'm a total beginner so please bear with me.)  My current
settings related to static files in 'settings.py' are as follows:

STATIC_ROOT = ''
STATIC_URL = 'http://127.0.0.1:8000/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
STATICFILES_DIRS =
('/Users/guillaumechorn/Documents/website/mainapp/static')
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder'
)

Below are the full contents of my urls.py file:

from django.conf.urls.defaults import *
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^home/$','mainapp.views.homepage'),
(r'^mainapp/$','mainapp.views.index'),
(r'^mainapp/(?P\d+)/$', 'mainapp.views.detail'),
(r'^products/$','mainapp.views.productindex'),
(r'^products/(?P\d+)/$','mainapp.views.productdetail'),
(r'^news/$','mainapp.views.news'),
(r'^events/(?P\d+)/$','mainapp.views.eventdetail'),
(r'^partners/$','mainapp.views.partners'),
(r'^admin/', include(admin.site.urls)),
)
urlpatterns += staticfiles_urlpatterns()

Once again, I'm using the following to link to my CSS file:



Am I still missing something?  Did I enter in anything incorrectly?

thanks,
Guillaume

On Tue, Aug 2, 2011 at 6:06 PM, Thomas Orozco wrote:

> Last thing, I made a typo, the address you could use should start with
> http, like: http://127.0.0.1/static/
> Le 2 août 2011 12:01, "Thomas Orozco"  a
> écrit :
>
> > A little detail, but you never know: you should put some ' ' in your
> link.
> > Like this :
> >
> > 
> >
> >
> > If there are spaces in your path, this could cause the lookup to fail.
> >
> > And even if that's not the case, don't rely on the user's browser to fix
> > coding mistakes.
> > Le 2 août 2011 10:28, "Guillaume Chorn"  a
> écrit :
> >> Thomas and Lokesh,
> >>
> >> Thanks very much for your help. I've modified the link in my HTML file
> to
> >> be:
> >>
> >>  }}stylesheet.css
> >> />
> >>
> >> where "stylesheet" is the name of the CSS file, and this file is located
> >> inside the directory listed under STATIC_DIRS in my settings.py file. As
> >> mentioned in my prior email, I also already have STATIC_URL = '/static/'
> > in
> >> my settings.py file, and I have the correct methods listed under
> >> STATICFILES_FINDERS.
> >>
> >> But it is still not working. Do I have a syntax error somewhere? Or am I
> >> still missing something in another file?
> >>
> >> thanks,
> >> Guillaume
> >>
> >> On Mon, Aug 1, 2011 at 6:45 PM, Thomas Orozco <
> g.orozco.tho...@gmail.com
> >>wrote:
> >>
> >>> If your css file is locatedr in your staticfiles dir, you should use
> >>> something such as {{ STATIC_URL }}main.css, assuming your CSS file is
> > called
> >>> main and is located in one of the STATIC_DIRS.
> >>>
> >>> Using staticfiles_dirs in a template makes no sense. Not only your are
> >>> passing a parameter that has to do with your system configuration and
> not
> >>> your urls, but you are also using a directory instead of a file.
> >>>
> >>> In short, it is the static_url parameter that should be passed to form
> a
> >>> URL.
> >>> Le 1 août 2011 12:17, "Gchorn"  a écrit :
> >>>
> >>> > Hello All,
> >>> >
> >>> > I'm using Django to develop a website, and I'm having trouble getting
> >>> > it to see my static files. I've looked through Django's static file
> >>> > documentation and the steps I've taken to get Django to see my files
> >>> > (using a CSS file as an example) are as follows:
> >>> >
> >>> > First, I created a folder called "static" inside the main app folder
> >>> >

Re: Django can't see my static files

2011-08-02 Thread Guillaume Chorn
Thomas and Lokesh,

Thanks very much for your help.  I've modified the link in my HTML file to
be:



where "stylesheet" is the name of the CSS file, and this file is located
inside the directory listed under STATIC_DIRS in my settings.py file.  As
mentioned in my prior email, I also already have STATIC_URL = '/static/' in
my settings.py file, and I have the correct methods listed under
STATICFILES_FINDERS.

But it is still not working.  Do I have a syntax error somewhere?  Or am I
still missing something in another file?

thanks,
Guillaume

On Mon, Aug 1, 2011 at 6:45 PM, Thomas Orozco wrote:

> If your css file is locatedr in your staticfiles dir, you should use
> something such as {{ STATIC_URL }}main.css, assuming your CSS file is called
> main and is located in one of the STATIC_DIRS.
>
> Using staticfiles_dirs in a template makes no sense. Not only your are
> passing a parameter that has to do with your system configuration and not
> your urls, but you are also using a directory instead of a file.
>
> In short, it is the static_url parameter that should be passed to form a
> URL.
> Le 1 août 2011 12:17, "Gchorn"  a écrit :
>
> > Hello All,
> >
> > I'm using Django to develop a website, and I'm having trouble getting
> > it to see my static files. I've looked through Django's static file
> > documentation and the steps I've taken to get Django to see my files
> > (using a CSS file as an example) are as follows:
> >
> > First, I created a folder called "static" inside the main app folder
> > for this project. Then, I added "/static/" to the STATIC_URLS section
> > of the settings.py file, and I also added the full path to my CSS file
> > under the STATICFILES_DIRS section of settings.py.
> >
> > Then I added the line:
> >
> > from django.template import RequestContext, loader
> >
> > As well as "context_instance= RequestContext(request)" as a third
> > argument to the "return render_to_response()" call.
> >
> > Finally, in my url.py file, I added this line at the top:
> >
> > from django.contrib.staticfiles.urls import staticfiles_urlpatterns
> >
> > And this line at the bottom (separate from the initial "urlpatterns =
> > patterns()" call):
> >
> > urlpatterns += staticfiles_urlpatterns()
> >
> > In my HTML/Django template, I added the following link to my CSS file:
> >
> > 
> >
> > But then after all of this, when I perform a "python manage.py
> > runserver" to preview the website, Django still does not appear to
> > find the external CSS file. I must still be missing something but I'm
> > not sure what--does anyone know???
> >
> > I'm sure I'm missing something very basic but I'm a total beginner so
> > please be patient with me, I probably need a lot of very specific
> > instructions...
> >
> > thanks,
> > Guillaume
> >
> > --
> > 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.
> >
>
> --
> 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.
>

-- 
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: Product to help Localize Django Application

2010-12-21 Thread Guillaume Piot
You need to look into the Rosetta application for Django. It will turn your 
translation file into paginated form with a textarea for each strings/sentences.

Regards

Guillaume Piot

On 21 Dec 2010, at 15:58, Eric wrote:

> We have a Django application that we would like to localize in
> Spanish. However, nobody in our group speaks Spanish and so, we have
> sent the po file out for translating. This has caused problems because
> some of the editors get confused by the file structure.
> 
> So, I was wondering if there is an application out there that will
> take the po file as input and iterate over the strings and prompt for
> the translation which is then written back to the po file.
> 
> 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.
> 

-- 
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: Using _default_manager in a model causes many idle MySQL connections. (Django 1.0)

2009-04-01 Thread Guillaume Carbonneau

I too am interested in seeing this patch. I'm getting lots of idle
connections in postgres

On Mar 31, 5:26 am, J  wrote:
> Hello Michael,
>
> Would you share your temp patch here?
>
> TIA,
>
> J
>
> On Mar 20, 12:52 am, MikeL  wrote:
>
> > I wasn't sure where this stuff was being tracked, but I did find a
> > circular reference in the database wrapper. The DatabaseCreation and
> > DatabaseIntrospection objects being created in the MySQL wrapper where
> > passing references of itself, but there wasn't a per-defined method
> > for removing those references.
>
> > Should BaseDatabaseIntrospection and BaseDatabaseCreation be holding a
> > weakref of the database wrapper instead?
> > Or is there some connection pooling system that needs to be aware of
> > the Mulit-db stuff?
> > Does any of this seem sane?
>
> > My _hack_ (temp and not perfect I know) involved a class wrapping
> > around QuerySet and monitoring the clone counts (split per wrapper
> > instance) so when the final QuerySet was deleted it would clear the
> > two references allowing the database wrapper to be garbage collected.
>
> > TIA,
>
> > Michael LaRue
>
> > On Mar 19, 2:10 pm, Alex Gaynor  wrote:
>
> > > On Thu, Mar 19, 2009 at 5:06 PM, MikeL  wrote:
>
> > > > I'm using the code from:
>
> > > >http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/
>
> > > > After repeated use, there can be over a hundred idling connection to
> > > > MySQL for both production and development builds. Removing the
> > > > Multiple DB in the model causes the symptoms to stop.
>
> > > > I've been trying to track down where the circular reference (if it's
> > > > that) is causing the connections to not be closed/deleted without much
> > > > luck. Is this use of _default_manager just plain flawed? If not, does
> > > > anyone know if there is a working fix?
>
> > > > TIA,
>
> > > > Michael LaRue
>
> > > It's not a default manager issue, the issue is by default django closes 
> > > the
> > > connection at the end of the request, but it only tracks the default
> > > connection, so your cusotm multidb support isn't tracked.
>
> > > Alex
>
> > > --
> > > "I disapprove of what you say, but I will defend to the death your right 
> > > to
> > > say it." --Voltaire
> > > "The people's good is the highest law."--Cicero
>
>

--~--~-~--~~~---~--~~
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: add a to_kml routine ti contrib.gis.gdal

2008-11-16 Thread guillaume

Hi Justin,

Sorry for the delay, I've been on the road the past 10 days...
Your help is great on this, as it gives a cleaner result than my
"parse the crap" hack. But I had to find a fast solution, and I'm
completely numb with ctypes.
KML support in geodjango is just great, as it allows people to build
easily Google Earth web services from their data. The potentiallity of
the stuff is huge !

Regards,

Guillaume

On 12 nov, 03:04, Justin Bronn <[EMAIL PROTECTED]> wrote:
> Guillaume,
>
> I had forgot that GDAL now can export toKML, I appreciate you taking
> the initiative here.  I think I've identified what's causing you grief
> -- ctypes prototypes must _strictly_ follow what is defined in the C
> API.  In `ogr_api.h` the definition is:
>
> char   CPL_DLL *OGR_G_ExportToKML( OGRGeometryH, const char*
> pszAltitudeMode );
>
> In the wrappers you're leaving out the altitude mode (a character
> pointer).  Thus, the `to_kml` wrapper would be:
>
>     to_kml = string_output(lgdal.OGR_G_ExportToKML, [c_void_p,
> c_char_p], str_result=True)
>
> I don't know what altitude modes GDAL accepts, but since GeoDjango
> doesn't support 3D geometries (yet), we just won't specify it.  In
> other words we want to pass in a NULL pointer valuer for the altitude
> mode -- in `OGRGeometry` we'll define the `kml` property as follows:
>
>     @property
>     defkml(self):
>         "Returns theKMLrepresentation of the Geometry."
>         return to_kml(self._ptr, None) # in ctypes None == NULL
> pointer
>
> Using this I was able to getKMLfrom GDAL directly, and without any
> of the special character problems you had.  If you put this in a
> ticket I'll definitely consider it's inclusion into GeoDjango.
>
> Best Regards,
> -Justin
>
> On Nov 5, 3:17 am, guillaume <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
>
> > I'm trying to add a to_kml ogr support togeodjangoand I'm facing a
> > problem :
> > I've added to geom.py the line :
> > to_kml = string_output(lgdal.OGR_G_ExportToKML, [c_void_p],
> > str_result=True)
> > and added to geometrie.py :
> > @property
> >     defkml(self):
> >         "Returns theKMLrepresentation of the Geometry."
> >         return to_kml(self._ptr)
>
> > But actually, the string returned contains some special encoding
> > characters in the "altitudeMode" tag :
> > (* 4  > altitudeMode>(* 4  > altitudeMode>
> > which doesn't allow GoogleErath to read the generated output.
>
> > How can I handle these characters ? where do they come from ?
>
> > Regards,
>
> > Guillaume
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



add a to_kml routine ti contrib.gis.gdal

2008-11-05 Thread guillaume

Hi,

I'm trying to add a to_kml ogr support to geodjango and I'm facing a
problem :
I've added to geom.py the line :
to_kml = string_output(lgdal.OGR_G_ExportToKML, [c_void_p],
str_result=True)
and added to geometrie.py :
@property
def kml(self):
"Returns the KML representation of the Geometry."
return to_kml(self._ptr)

But actually, the string returned contains some special encoding
characters in the "altitudeMode" tag :
(*��4 ��(*��4 ��
which doesn't allow GoogleErath to read the generated output.

How can I handle these characters ? where do they come from ?

Regards,

Guillaume
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjango - Ogr seg fault

2008-10-10 Thread guillaume

Ok, I've found the answer myself :
it happens when mod_php is also activated.
let mod_python goes alone and it's fine. Don't know why though...



On 10 oct, 15:01, guillaume <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm experiencing trouble when using geodjango.gdal :
> from a standard python console, pnt = OGRGeometry(someWKT) goes fine
> but when using it in Django run by Apache 2.2 mod_python, I get a
> seg_fault.
>
> Would anyone know why ?
>
> regards
>
> Guillaume
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



GeoDjango - Ogr seg fault

2008-10-10 Thread guillaume

Hi,

I'm experiencing trouble when using geodjango.gdal :
from a standard python console, pnt = OGRGeometry(someWKT) goes fine
but when using it in Django run by Apache 2.2 mod_python, I get a
seg_fault.

Would anyone know why ?

regards

Guillaume
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "ColorField"?

2008-09-04 Thread guillaume

Hi Sean,

I'm very interested in how you made the ColorField work as I didn't
manage to do that !

Help appreciated !

Regards,

Guillaume

On 21 juil, 21:05, Sean Legassick <[EMAIL PROTECTED]> wrote:
> On 8 Jul 2008, at 04:24, Leaf wrote:
>
>
>
> > Does anyone know if there is such thing as a ColorField - something
> > that stores a hex value and has a JavaScript-powered color picker
> > beside it? If there is, where can I get it? If there isn't, how would
> > I go about writing one?
>
> I've uploaded a snippet athttp://www.djangosnippets.org/snippets/900/
>
> (note this works with current trunk - i.e. post newforms-admin merge.  
> If you need it for the old admin I also have the code knocking about,  
> it's fairly similar - let me know and I'll post it here).
>
> Sean
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unaccountable syntax error

2008-09-04 Thread guillaume

Sorry guys, I just need a tip :

where do you get your models.ColorField from ? I've upgraded to django
1.0, and don't have it !

Regards,

Guillaume

On 30 août, 16:03, Leaf <[EMAIL PROTECTED]> wrote:
> Of course. I just look at the error actually occurs on, not the
> context. I guess even Python's awesome debugging still has limits.
> What happened was that I forgot a parenthesis at the end of the
> previous line. Thanks for giving me the tip.
>
> On Aug 30, 9:57 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Sat, Aug 30, 2008 at 9:50 AM, Leaf <[EMAIL PROTECTED]> wrote:
>
> > > I'm having a problem when I try to validate my models. The interpreter
> > > somehow takes offense at this line:
>
> > >    box_text_color = models.ColorField("Box Text Color")
>
> > > I'm using a custom "ColorField" here. What I don't understand is that
> > > it seems almost identical to this ColorField, which it did accept:
>
> > >    bg_color = models.ColorField("Background Color")
>
> > > When it rejected it, the flow looked like this:
>
> > >  File "/Users/leaf/Django/devsite/../devsite/djstyles/models.py",
> > > line 47
> > >    box_text_color = models.ColorField("Box Text Color")
> > >                        ^
> > > SyntaxError: invalid syntax
>
> > > The caret was pointing at the r in "box_text_color". Does anyone know
> > > how this could have happened?
>
> > What's on the line above that?  That's probably where the trouble begins.
>
> > Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Running doctests

2008-09-01 Thread Guillaume Lederrey

Thanks for your very fast answer ! But ... see inline

2008/9/1 Malcolm Tredinnick <[EMAIL PROTECTED]>:
>
>
> On Mon, 2008-09-01 at 22:48 +0200, Guillaume Lederrey wrote:
>> Hello !
>>
>> I have an app that has a "utils.py" module. I have written quite a few
>> doctests inline. Now my problem is to actually run those tests.
>> Reading the documentation, I get the feeling that I should be able to
>> call them from the tests.py file, but I cant find an example. I have
>> seen a few projects where there is doctests in tests.py that test
>> other modules, but it seems to me that this defeats the purpose of
>> having the tests inline, very close to the implementation.
>
> Right now, Django's testing framework looks for doctests in two places:
> the "models" module and the "tests" module.
>
> It doesn't entirely defeat the purpose, since you can pull in tests from
> other places into "tests" for example, but it doesn't scan every single
> file.

What do you mean by "since you can pull in tests from other places
into "tests"" ? I am pretty new to python, and I might me missing
something obvious here ...

Thanks for the help !


> Regards,
> Malcolm
>
>
>
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Running doctests

2008-09-01 Thread Guillaume Lederrey

Hello !

I have an app that has a "utils.py" module. I have written quite a few
doctests inline. Now my problem is to actually run those tests.
Reading the documentation, I get the feeling that I should be able to
call them from the tests.py file, but I cant find an example. I have
seen a few projects where there is doctests in tests.py that test
other modules, but it seems to me that this defeats the purpose of
having the tests inline, very close to the implementation.

Did I miss something ?

Thanks for your help !

MrG


-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "core" is not a field constructor argument anymore

2008-09-01 Thread Guillaume Lederrey

2008/8/30 James Bennett <[EMAIL PROTECTED]>:
>
> On Fri, Aug 29, 2008 at 5:58 PM, Guillaume Lederrey
> <[EMAIL PROTECTED]> wrote:
>> After updating to the latest trunk, I get a couple of errors when I
>> have field that define "core=True". After digging into the code, I
>> find changeset 8616 (http://code.djangoproject.com/changeset/8616)
>> that documents that. However, this doesnt seem to be include in the
>> backward incompatible changes
>> (http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges).
>
> You want to read the section on the admin changes; basically, anything
> you used to use to specify/control admin behavior (which is what
> 'core' did) has changed.

My mistake, I didnt read carefully enough ...

Thanks for the pointer !

MrG

> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
>
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Working but ugly model code. Need advice.

2008-09-01 Thread Guillaume Lederrey

If you just want to have a clean working solution, have a look at
django-photologue (http://code.google.com/p/django-photologue/). It is
amazing, and really easy to integrate well. Also have a look at
sorl-thumbnail (http://code.google.com/p/sorl-thumbnail/).

If you want to write your own code and make it a bit cleaner, I think
you should first try to break things a bit more
(http://en.wikipedia.org/wiki/Separation_of_concerns). For example,
having different picture sizes is a presentation problem, not a
persistence problem. So if you solve the that in a template tag, it
will probably be much cleaner.

Just my own 2 cents ... and yes, I know that I didnt really answer
your question ... sorry

  Good luck !

2008/8/29 drbig <[EMAIL PROTECTED]>:
>
> Hi!
>
> Before I paste the code here is what I want to achieve:
> 1) All content is supplied via django admin, no custom upload/edit
> forms
> 2) The Photo class holds title and note (the text data), two images
> (full and thumb), and stats data of hits and comments count
> 3) The stamp should be updated only when the text data or full image
> change (only full as...)
> 4) When image is uploaded it should be resized if too large and the
> thumbnail should be auto(re)generated
>
> Here is the code:
> from django.db import models
> from django.conf import settings
> from PIL import Image
> from datetime import datetime as dt
> import md5, time, os
>
> class Tag(models.Model):
>stamp = models.DateTimeField(auto_now = True)
>name = models.CharField(max_length = 32)
>
>class Meta:
>ordering = ['name']
>get_latest_by = '-stamp'
>
>def __unicode__(self):
>return self.name
>
> class Photo(models.Model):
>stamp = models.DateTimeField(auto_now_add = True)
>title = models.CharField(max_length = 255)
>note = models.TextField()
>content_hash = models.CharField(max_length = 32, editable = False)
>upload_image = models.ImageField(upload_to = 'photos/tmp', blank =
> True)
>ifull = models.CharField(max_length = 128, editable = False)
>ithumb = models.CharField(max_length = 128, editable = False)
>image_hash = models.CharField(max_length = 32, editable = False)
>hits = models.PositiveIntegerField(default = 0, editable = False)
>comments_count = models.PositiveIntegerField(default = 0, editable =
> False)
>tags = models.ManyToManyField(Tag)
>
>class Meta:
>ordering = ['-stamp']
>get_latest_by = '-stamp'
>
>def __unicode__(self):
>return self.title
>
>def save(self):
>try:
>new_hash =
> md5.new(self.upload_image.read(num_bytes = 1024)).hexdigest()
>if new_hash != self.image_hash:
>if self.ifull:
>name = self.ifull.split('/')
> [-1]
>else:
>name = str(int(time.time())) +
> '.jpg'
>img =
> Image.open(self.upload_image.path)
>img.load()
>self.upload_image.delete(save = False)
>if img.size > (800, 600):
>img.thumbnail((800, 600),
> Image.ANTIALIAS)
>img.save(settings.MEDIA_ROOT + 'photos/
> full/' + name, 'jpeg')
>img.thumbnail((128, 128),
> Image.ANTIALIAS)
>img.save(settings.MEDIA_ROOT + 'photos/
> thumb/' + name, 'jpeg')
>self.ifull = '/data/photos/full/' +
> name
>self.ithumb = '/data/photos/thumb/' +
> name
>self.image_hash = new_hash
>self.stamp = dt.now()
>except Exception, e:
>pass
>new_hash = md5.new(self.title + self.note).hexdigest()
>if new_hash != self.content_hash:
>self.content_hash = new_hash
>self.stamp = dt.now()
>super(Photo, self).save()
>
>def delete(self):
>if self.ifull:
>name = self.ifull.split('/')[-1]
>try:
>os.remove(settings.MEDIA_ROOT +
> 'photos/thumb/' + name)
>os.remove(settings.MEDIA_ROOT +
> 'photos/full/' + name)
>except Exception, e:
>pass
>super(Photo, self).delete()
>
> class Comment(models.Model):
>stamp = models.DateTimeField(auto_now_add = True)
>ip = models.IPAddressField()
>signature = models.CharField(max_length = 64)
>content = models.TextField()
>

"core" is not a field constructor argument anymore

2008-08-29 Thread Guillaume Lederrey

Hello !

After updating to the latest trunk, I get a couple of errors when I
have field that define "core=True". After digging into the code, I
find changeset 8616 (http://code.djangoproject.com/changeset/8616)
that documents that. However, this doesnt seem to be include in the
backward incompatible changes
(http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges).

So ... if anybody else has the same problem ...

-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to locate the OS currently logged in user??

2008-08-27 Thread Guillaume Lederrey

2008/8/27 PeteDK <[EMAIL PROTECTED]>:
> On 21 Aug., 16:25, "Guillaume Lederrey" <[EMAIL PROTECTED]>
> wrote:
>> 2008/8/21 PeteDK <[EMAIL PROTECTED]>:
>> > On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]>
>> > wrote:
>> >> 2008/8/21 PeteDK <[EMAIL PROTECTED]>:
>> >> I'm still not clear on how your user log into the server. Via SSH,
>> >> HTTP Auth, other ?
>>
>> > Sorry i failed to answer your question. I must admit i don't know
>> > exactly how the user logs in. I will try to get that information :-)
>>
>> I'm pretty sure we will be able to give you more meaningful answers
>> with that piece of information ... ;-)
>
> I now have some new information. I now believe that what i need is the
> visitors information.
>
> On another system on the same network(written in Perl) it is done this
> way:
> $loginbruger=uc($ENV{AUTHENTICATE_SAMACCOUNTNAME});
>
> (loginbruger is danish for loginuser)
>
> can i do the same thing in python?? get the visitors username?

Again, without understanding how the users log into the server, we can
only guess ...

SAMACCOUNTNAME makes me think about Windows (SAM = Security Account
Manager), but that's just based on the name, and that name could well
mean something else in your context.

>From what I understand, the name is stored in an environment variable
(but I dont know how it gets there). Usually, the environment of a
process isnt changed from the outside after creation. And Django is a
long running process, so it should not pick up users logging in after
startup. But I can be completely wrong on that one ...

Assuming I am wrong above, you should be able to access the same
environment variable from python code with :

import os
loginbruger = os.environ['AUTHENTICATE_SAMACCOUNTNAME']

More infos on http://docs.python.org/lib/os-procinfo.html

The real problem I see there is that if there is multiple users
connected to the server, I dont see how the right user could be
associated with an HTTP session ...

Good luck, and please, try to get the info on how the login process works !



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dynamic creation of model with geodjango ?

2008-08-25 Thread guillaume

Hi Justin,

Glad to hear you too actually ! Your analysis is completely right !
I've already build an app which allows to feed a postgis database with
Django. But geodata is completely disconnected from the app itself. So
yes, the idea would be to automatically build a geodjango model from
that table, and publish it on the admin site to let people manage the
data from there. And I definitely understand it is not trivial at
all !

Regards,

Guillaume

On 19 août, 16:57, Justin Bronn <[EMAIL PROTECTED]> wrote:
> > Yes, actually I didn't hope anything else.
> > I'll try to catch somegeodjangoguys up in Cape Town FOSS4G to have a
> > chat about this. It can be something I can find funding for, as it is
> > extremely critical in deploying Spatial data infrastructures.
>
> Guillaume,
>
> Howdy -- nice hearing from you again.  Unfortunately, I won't be in
> Cape Town, but Travis Pinney and Josh Livni will be there 
> representingGeoDjango.
>
> I've successfully created dynamic models in private, production code
> usingGeoDjango, but not quite to the full extent I think you want.
> If I understand, you wish to go from spatial data source (e.g.,
> shapefile) -> admin automatically, with the intermediate step of
> creating spatial database tables and importing.  I believe this is
> possible, but not trivial.
>
> Regards,
> -Justin
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to locate the OS currently logged in user??

2008-08-21 Thread Guillaume Lederrey

2008/8/21 PeteDK <[EMAIL PROTECTED]>:
>
>
>
> On 21 Aug., 13:10, "Guillaume Lederrey" <[EMAIL PROTECTED]>
> wrote:
>> 2008/8/21 PeteDK <[EMAIL PROTECTED]>:
>>
>>
>>
>> > The server is running Debian Linux and they are logging on to the
>> > server using the username and password stored in the active directory
>> > on one of the other servers.
>>
>> I'm still not clear on how your user log into the server. Via SSH,
>> HTTP Auth, other ?
>
> Sorry i failed to answer your question. I must admit i don't know
> exactly how the user logs in. I will try to get that information :-)

I'm pretty sure we will be able to give you more meaningful answers
with that piece of information ... ;-)

  MrG


-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to locate the OS currently logged in user??

2008-08-21 Thread Guillaume Lederrey

2008/8/21 PeteDK <[EMAIL PROTECTED]>:
>
> The server is running Debian Linux and they are logging on to the
> server using the username and password stored in the active directory
> on one of the other servers.

I'm still not clear on how your user log into the server. Via SSH,
HTTP Auth, other ?



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Browser timeout on long processes

2008-08-20 Thread Guillaume Lederrey

2008/8/20 Julien Phalip <[EMAIL PROTECTED]>:
>
>> If the view is running a loop -  how would you provide a variable to another
>> view (that Ajax is calling) about the situation? Let's say a percentage
>> complete -- I immediately think of a global variable, but am not sure how
>> this works in a multi-user web situation.
>
> You could use the cache by setting a key that the other view can look
> up.

The (arguably) right way to store / share data in a webapp is to use
the session. Django provides good session management as explained in
http://www.djangoproject.com/documentation/sessions/

Good luck !

  MrG


> Julien
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to locate the OS currently logged in user??

2008-08-20 Thread Guillaume Lederrey

2008/8/20 PeteDK <[EMAIL PROTECTED]>:
> I want to retreive the name of the currently logged in user on the OS
> on which my django app lives.
> Is this possible?

You should realize that there is no direct connection between the user
logged in the webserver and the user connecting via HTTP to your
Django app. There is nothing preventing a user to connect to your
Django app without logging to the server first ...

> The thing is. The app is to be used in a private environment, so all
> the users have to log on to the webserver first(this cant be changed).
> I would be nice to avoid having them to log into the django app
> afterwards.

So what you seem to be looking for is a Single Sign On (SSO) solution.
I dont know of any standard way to do that under Linux, but if you are
using Windows, there is a standard mechanism for that. I think it is
based on Kerberos and integrates with Active Directory. I'm far from a
Windows expert, so dont ask me for the details, but I have been using
this solution :

* use IIS as a front proxy, IIS will do the authentication
* IIS will forward the request to the backend server (in your case
Django, running on Apache or even running on IIS)
* the request is forwarded with additional HTTP headers describing the
authentication (including the username)
* you can then write a specialized authentication middleware that will
use those headers to associate the session with the user

> So after they are logged into the webserver it would be fair to assume
> they are authorised users and if i could just locate their OS username
> somehow then i could use this username to login the current user, in
> the background with a standard password.
>
> I hope you get my meaning:)
>
> i have looked into the python standard library, and a module named
> getpass() however i cant get i to work:-(
>
> i hope someone has a clever idea to solve this problem.
>
> Thanks! :)
>
> /Pete
>
> PS: and the webserver runs linux. :-)
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/
* http://trock.ch/
Others :
* http://kiva.org/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dynamic creation of model with geodjango ?

2008-08-19 Thread guillaume

Yes, actually I didn't hope anything else.
I'll try to catch some geodjango guys up in Cape Town FOSS4G to have a
chat about this. It can be something I can find funding for, as it is
extremely critical in deploying Spatial data infrastructures.

Regards,

Guillaume

On 19 août, 15:24, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-08-19 at 06:18 -0700, guillaume wrote:
> > Hi Dane,
>
> > Thanks for these informations. Does it mean that a model dynamically
> > created will now appear in admin section ?
>
> The previous poster described a way to inspect an existing data source
> and print out the model definition to stdout. You will then need to
> paste that output into a models file (and possibly edit it, if anything
> needs tweaking, which is why any inspectdb-like operations prints out
> the result). The model isn't "dynamically created" at all.
>
> It will appear in the admin if you put it into a models file *and* write
> an admin class for it, as per normal.
>
> If you really want to dynamically create models, you'll need to poke
> around the internals of Django a lot, since that isn't documented
> (oustide of docstrings and the code) and isn't public API, so is subject
> to change without notice in the future. If you have to ask on this list
> how to do that, quite honestly, you probably aren't ready to take that
> step, because it does require confidence at reading the source and
> understanding it. You'll want to start with
> django.db.models.base.ModelBase.__new__ to see how model classes are
> created, for example. Reading that will give you an idea of whether
> you're going to able to understand the code or not.
>
> And if you do understand that and feel comfortable playing with it --
> please feel free to do so. I'm not saying "don't do that." Rather, I'm
> cautioning that this is deep internals stuff and if you're looking for
> step-by-step instructions or support, you're going to have to adjust
> your expectations.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dynamic creation of model with geodjango ?

2008-08-19 Thread guillaume

Hi Dane,

Thanks for these informations. Does it mean that a model dynamically
created will now appear in admin section ?

Regards,

Guillaume

On 18 août, 19:22, springmeyer <[EMAIL PROTECTED]> wrote:
> Guillame,
>
> Absolutely. GeoDjango can be used to read new or existing geographic
> datasources from dozens of formats. GeoDjango provides a ctypes
> interface to the foundational GDAL/OGR library, which is the open
> source industry standard for format translation. Look for the utility
> called `orginspect`.
>
> While the GeoDjango documentation is still being worked on, the
> Docstrings are excellent.  To see how ogrinspect works you'll need to
> do nothing but (a sample project and shapefile can be downloaded 
> fromhttp://code.google.com/p/geodjango-basic-apps/wiki/GeographicAdminQui...
>
> >>> from django.contrib.gis.utils import ogrinspect
> >>> help(ogrinspect)
>
> Help on function ogrinspect in module
> django.contrib.gis.utils.ogrinspect:
>
> ogrinspect(*args, **kwargs)
>     Given a data source (either a string or a DataSource object) and a
> string
>     model name this function will generate a GeoDjango model.
>
>     Usage:
>
>     >>> from django.contrib.gis.utils import ogrinspect
>     >>> ogrinspect('/path/to/shapefile.shp','NewModel')
>
>     ...will print model definition to stout
>
>     or put this in a python script and use to redirect the output to a
> new
>     model like:
>
>     $ python generate_model.py > myapp/models.py
>
>     # generate_model.py
>     from django.contrib.gis.utils import ogrinspect
>     shp_file = 'data/mapping_hacks/world_borders.shp'
>     model_name = 'WorldBorders'
>
>     print ogrinspect(shp_file, model_name, multi_geom=True, srid=4326,
>                      geom_name='shapes', blank=True)
> :
>
> Cheers,
>
> Dane
>
> On Aug 13, 12:39 am, guillaume <[EMAIL PROTECTED]>
> wrote:
>
> > Hi,
>
> > I'm pretty glad to see that GeoDjango has joined the main trunk. As it
> > is a great tool for managing geographic data, I am wondering if it is
> > possible to create a new model dynamically. Imagine you want to add a
> > new geographic data source to your app, how can it be done ?
>
> > Regards,
>
> > Guillaume
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time and attendance management system

2008-05-29 Thread Guillaume Lederrey

I'm afraid you missed step 7 :

7) profit !

2008/5/29 Tim Chase <[EMAIL PROTECTED]>:
>
>> hi...related to the same problem i also have to designe
>> forms,reports and tables for ma data base ...will plz guide me
>
> It's a fairly trivial process so I will guide you:
>
> 1) get a server (I recommend Debian GNU/Linux)
> 2) install the following:
>
>   Python
>   Django
>   a web-server such as Apache/lighttpd
>   a web-server interface:  mod_python/mod_wsgi/fastcgi/etc
>   a database (PostgreSQL, MySQL or sqlite are popular choices)
>
> 3) do lots of hard work:
>   - design your application, data-structures, and tests
>   - implement your design
>
> 4) deploy your design
>
> 5) fix bugs
>
> 6) repeat steps 3-6 until your code is perfect
>
> I leave step #3 as an exercise to the reader.  If you get stuck
> on particular issues, this list and the comp.lang.python mailing
> list are helpful places to get specific help.  However, as
> friendly as both places are, neither will be a replacement for
> doing the hard work yourself.
>
> -tim
>
>
>
>
>
>
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: time and attendance management system

2008-05-29 Thread Guillaume Lederrey

Your question is very general, so it is difficult to give you a
meaningful answer ... If you give us a much more precise description
of your problem, or if you ask much more specific questions, you might
get a useful answer.

Here is a probably completely off-topic answer :

You will make your employee database using Django model as described
in the tutorial
(http://www.djangoproject.com/documentation/tutorial01/#creating-models)
or described in more details in the documentation
(http://www.djangoproject.com/documentation/model-api/). You might
also find appropriate examples in
http://www.djangoproject.com/documentation/models/

Good luck !

  MrG

2008/5/29 sesh <[EMAIL PROTECTED]>:
>
> i want to make time and attendance management system but how i make
> data base for employees for thisits realy argent
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: urls() and request.user

2008-05-12 Thread Guillaume Lederrey

Hello !

I finally choose to create a decorator to implement this
functionality. I wanted something more generic than a wrapper in my
urls.py. The solution seems to work fine for me, and if anybody want
to do the same, the code is at
http://www.djangosnippets.org/snippets/753/

Of course, any suggestions of improvements are welcomed ...

MrG

2008/5/5 Nathaniel Whiteinge <[EMAIL PROTECTED]>:
>
>  On May 4, 5:42 am, "Guillaume Lederrey" <[EMAIL PROTECTED]>
>  wrote:
>
> > I havent done any functional programming in a long time , but ... isnt
>  > there a way to use an anonymous function (if that's what it is called)
>  > and do the wrapper "inline" ? Something like :
>
>  Yeah, something like that would work, although tying it into your
>  example above would look pretty ugly, I'm guessing::
>
> (r'^test/$', lambda request: HttpResponse('Hello, %s' %
>  request.user)),
>
>  If you're only trying to get the currently logged in user into the
>  template context, it's already there as ``{{ user }}`` if you're using
>  generic views [1]. Sorry I didn't mention that in my first reply.
>
>  .. [1] 
> http://www.djangoproject.com/documentation/templates_python/#django-core-context-processors-auth
>
>
> >
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Empty Result set

2008-05-07 Thread Guillaume Lederrey

2008/5/6 jwwest <[EMAIL PROTECTED]>:
>  What's the preferred method of checking to see if a result set is
>  empty in a view? For instance, I'm writing blog software and have a
>  view by year method. If there are no posts, I want to raise a http404.
>
>  I've tried == {} and == [] to no avail.

Maybe you could have a look at
http://www.djangoproject.com/documentation/shortcuts/#get-list-or-404
...

Good luck !


-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: urls() and request.user

2008-05-04 Thread Guillaume Lederrey

2008/5/2 Nathaniel Whiteinge <[EMAIL PROTECTED]>:
>
>  On May 1, 10:04 am, "Guillaume Lederrey"
>
> <[EMAIL PROTECTED]> wrote:
>  > This of course doesnt work because the request isnt in the scope. I
>  > could redefine a view in my views.py and do the work on the request
>  > manually, but i have a feeling there is a solution to do that directly
>  > in my urls.py.
>
>  Sorry, there isn't a way to get at the request object in your urlconf.
>  You'll have to make a wrapper around the generic view -- when the
>  wrapper is small, I often just put it in my ``urls.py``::
>
> from django.conf.urls.defaults import *
> from whereever.youput.create_update import update_object
>
> urlpatterns = patterns('',
> ('^pattern/$', 'path.to.this.urlconf.mywrapper'),
> )
>
> def mywrapper(request):
> ...
> return update_object(request, ...)

I havent done any functional programming in a long time , but ... isnt
there a way to use an anonymous function (if that's what it is called)
and do the wrapper "inline" ? Something like :

urlpatterns = patterns('',
('^pattern/$', lambda(request)(
return update_object(request, ...)
),
)

Thanks for your help !



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



urls() and request.user

2008-05-01 Thread Guillaume Lederrey

Hello !

I am trying to use the update_object generic view  in
http://www.djangosnippets.org/snippets/635/

I am using it directly in my urls.py like this :

url(r'^(?P\d+)/edit/$',
permission_required('change_news')(update_object),
{
'model' : News,
'model_form' : NewsForm,
'login_required' : True,
},
),

which works fine. Now, I am trying to add an extra field like this :

url(r'^(?P\d+)/edit/$',
permission_required('change_news')(update_object),
{
'model' : News,
'model_form' : NewsForm,
'login_required' : True,
'extra_field' : {
'author' : request.user,
}
},
),

This of course doesnt work because the request isnt in the scope. I
could redefine a view in my views.py and do the work on the request
manually, but i have a feeling there is a solution to do that directly
in my urls.py.

any idea ?

Thanks !

  Guillaume


-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: date_based.archive_index and "IS NULL" query

2008-05-01 Thread Guillaume Lederrey

I forgot to add :

I'm running django-trunk, so it might be related to the queryset
refactoring merge ?

2008/5/1 Guillaume Lederrey <[EMAIL PROTECTED]>:
> Hello !
>
>  I am getting a strange query from the archive_index generic view :
>
>   SELECT DISTINCT CAST(DATE_FORMAT(`news_news`.`publication_date`,
>  '%Y-01-01 00:00:00') AS DATETIME) FROM `news_news` WHERE
>  `news_news`.`publication_date` IS NULL ORDER BY 1 ASC
>
>  I dont understand where the "IS NULL" comes from. As all the news in
>  my database have a publication_date, this query returns nothing and no
>  news is displayed.
>
>  Any help appreciated !
>
>  Here is my ulrs.py :
>
>  urlpatterns = patterns('',
> url(r'^$',
> date_based.archive_index,
> {
> 'queryset' : News.objects.all(),
> 'date_field' : 'publication_date',
> 'allow_future' : True,
> },
> ),
>  )
>
>
>  and the model :
>
>  class News(models.Model):
> """ News model """
> title = models.CharField(max_length=100, unique=True)
> slug = models.SlugField(prepopulate_from=("title",),
> unique_for_date='publication_date')
> author = models.ForeignKey(User)
> creation_date  = models.DateField(auto_now_add=True)
> modification_date = models.DateField(auto_now=True)
> publication_date = models.DateField(blank=True, null=True)
> ask_promotion = models.BooleanField(default=False,
> help_text=_("Ask for this news
>  to be promoted on the front page. For example, an artist might be able
>  to write news for its next gig, and have the news appear on the
>  artist's page, but not on the front page. The artist can ask a
>  moderator to promote the news on the front page by checking this
>  field."))
> promoted = models.BooleanField(default=False,
>help_text=_("If this field is
>  checked, the news will appear on the front page."))
> trock_news = models.BooleanField(default=False,
>  help_text=_("Check this field if
>  you want this news to be published in the next TrocK news."))
> text = models.TextField(blank=True)
>
> class Meta:
> """
> Defines meta data on the model.
> """
> verbose_name_plural = _('news')
> ordering = ['-publication_date', 'title',]
> permissions = (
> ("export_trock_news", _("Can export the list of news
>  selected for the next TrocK news")),
> )
>
> class Admin:
> """
> This model is available in the admin interface.
> """
> list_display = ('title', 'publication_date',)
>
> def __unicode__(self):
> return '%s' % self.title
>
> @permalink
> def get_absolute_url(self):
> """
> The URL to this news in the date based view.
> """
> return ('news_detail', (), {
> 'year' : self.publication_date.year,
> 'month' : self.publication_date.month,
> 'day' : self.publication_date.day,
> 'slug' : self.slug,
> })
>
> @permalink
> def get_absolute_url_by_id(self):
> """
> The URL to this news in the ID based view.
> """
> return ('news_detail_by_id', (), {
> 'object_id' : self.pk,
> })
>
>
>
>  --
>  Jabber : [EMAIL PROTECTED]
>  Skype : Guillaume.Lederrey
>  Projects :
>  * http://rwanda.ledcom.ch/
>



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



date_based.archive_index and "IS NULL" query

2008-05-01 Thread Guillaume Lederrey

Hello !

I am getting a strange query from the archive_index generic view :

 SELECT DISTINCT CAST(DATE_FORMAT(`news_news`.`publication_date`,
'%Y-01-01 00:00:00') AS DATETIME) FROM `news_news` WHERE
`news_news`.`publication_date` IS NULL ORDER BY 1 ASC

I dont understand where the "IS NULL" comes from. As all the news in
my database have a publication_date, this query returns nothing and no
news is displayed.

Any help appreciated !

Here is my ulrs.py :

urlpatterns = patterns('',
url(r'^$',
date_based.archive_index,
{
'queryset' : News.objects.all(),
'date_field' : 'publication_date',
'allow_future' : True,
},
),
)


and the model :

class News(models.Model):
""" News model """
title = models.CharField(max_length=100, unique=True)
slug = models.SlugField(prepopulate_from=("title",),
unique_for_date='publication_date')
author = models.ForeignKey(User)
creation_date  = models.DateField(auto_now_add=True)
modification_date = models.DateField(auto_now=True)
publication_date = models.DateField(blank=True, null=True)
ask_promotion = models.BooleanField(default=False,
help_text=_("Ask for this news
to be promoted on the front page. For example, an artist might be able
to write news for its next gig, and have the news appear on the
artist's page, but not on the front page. The artist can ask a
moderator to promote the news on the front page by checking this
field."))
promoted = models.BooleanField(default=False,
   help_text=_("If this field is
checked, the news will appear on the front page."))
trock_news = models.BooleanField(default=False,
 help_text=_("Check this field if
you want this news to be published in the next TrocK news."))
text = models.TextField(blank=True)

class Meta:
"""
Defines meta data on the model.
"""
verbose_name_plural = _('news')
ordering = ['-publication_date', 'title',]
permissions = (
("export_trock_news", _("Can export the list of news
selected for the next TrocK news")),
)

class Admin:
"""
This model is available in the admin interface.
"""
list_display = ('title', 'publication_date',)

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

@permalink
def get_absolute_url(self):
"""
The URL to this news in the date based view.
"""
return ('news_detail', (), {
'year' : self.publication_date.year,
'month' : self.publication_date.month,
'day' : self.publication_date.day,
'slug' : self.slug,
})

@permalink
def get_absolute_url_by_id(self):
"""
The URL to this news in the ID based view.
"""
return ('news_detail_by_id', (), {
'object_id' : self.pk,
})



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Which kind of model inheritance is most suited?

2008-04-30 Thread Guillaume Lederrey

2008/4/29 francesco <[EMAIL PROTECTED]>:
>  I'd like to implement two kind of users in my system: a buyer and a
>  seller.
>  Both kind of users should, of course, inherit from a user model.
>  As I'd like to use the authentication framework from django.contrib,
>  should I have the "user" as table in the database or can I get by with
>  an abstract inheritance where no table is created for the user?

Hello !

In my experience, inheritance is overkill in this case. Composition is
very often a better alternative. In most cases, if you can express
your model both with inheritance and with composition, you should use
composition.

Let's be a bit more clear :

In your case, you can model with composition : a user has a function
(seller or buyer). It gives you a bit more functionnality (a user can
be both a seller and a buyer) and a bit more flexibility (a buyer can
become a seller, or the opposite).

Inheritance is a very strong relationship. It cant be changed
dynamically. It should be used carefully ...

Good luck !

   MrG



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Largest django sites?

2008-04-23 Thread Guillaume Lederrey

2008/4/23 bcurtu <[EMAIL PROTECTED]>:
>  But, turning back to my question... Can you tell these sites with
>  thousands or hundreds of thousands hits per minute? Ok, let's leave
>  apart their stats... Any big name on the internet? slashdot? twitter
>  is RoR...

Pownce (http://pownce.com/) is built with Django.

-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: DateField widget, ModelForm and javascript

2008-04-22 Thread Guillaume Lederrey

2008/4/22 Peter Melvyn <[EMAIL PROTECTED]>:
>
>  On 4/21/08, Rishabh Manocha <[EMAIL PROTECTED]> wrote:
>
>  >  I'd be interested in knowing how to get it to show up too (what JS/CSS
>  >  files need to be added, whether there is some setting we can use in
>  >  the python code itself or do we have to print out each field
>  >  independently and insert the appropriate code for the picker etc.).
>
>  Date/Time pickers are bound via widget's class names vDateField and
>  vTimeField, hence you need to define them in your form definition.

That's the kind of solution I was thinking about. I actually would
like all of my DateFields to have a calendar widget. Is it possible to
register a custom Date widget as the default widget used by ModelForm
? Being able to create the Forms from the Models is a great
simplification for all the simple UI. It gets a bit less simple if all
those forms have to be customized to include a CSS class ...

Thank you for your help !

  MrG



-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DateField widget, ModelForm and javascript

2008-04-21 Thread Guillaume Lederrey

Hello !

I have a model that I try to edit with a ModelForm. This model has a
DateField property. I render the form in my template with a simple :

{{ form.as_p }}

I expected the DateField to be displayed as in the admin interface,
with a javascript date picker. But I only get a text field. The value
format is validated as a date format, so I expect the field is treated
as a DateField.

Is there a way to automagically get the javascript date picker, or is
it something I have to add manually ?

Thanks for your help !

   MrG

-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Distributed databases

2008-04-16 Thread Guillaume Lederrey

On 16/04/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>  display this data. Would be also possible, to have different database
>  types (i would like to have several sqlite databases and one postgres
>  running)?
>
>  I need all this for scalability reasons. I am choosing framework for

IMHO : scalability & sqlite are not words I would put together that
easily. But I have to admit I havent dont any measurements. I have no
idea how Django can help you to solve your problem (I am pretty new to
Django) but I would suggest that you do some more research on the
exact scalability requirements that you have ...

  Good luck !

MrG


-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Enterprise applications with Django

2008-04-16 Thread Guillaume Lederrey

On 16/04/2008, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>
>  I guess YouTube is highly concurrent, distributed ...
>
>  I think you can create enterprise applications with django and python.
>
>  What do you think is possible with Java, that you can't do with python?

Having your production team agree to deploy python apps on the
production server is probably the hardest part !

Jokes apart, here is a couple of things I would not know how to do in
Python. Maybe they exist (I'm far from a Python /  Django expert) :

* distributed transaction (2-phase commit)
* a good admin console so that a production team can :
  - tune database connection pools easily
  - deploy to a server farm easily (for availability)
  - other day to day admin tasks ...

The admin console probably exists at some place like Google (or other
big Python fans) but is not readily available commercially (read as :
with commercial support). And that is a no-go for most of the
enterprises I know ...




-- 
Jabber : [EMAIL PROTECTED]
Skype : Guillaume.Lederrey
Projects :
* http://rwanda.ledcom.ch/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ManytoMany relationship question

2008-03-25 Thread guillaume

Hi list,

I'm building an app where a model has a manyTomany relationship with
User model.
There are two things I can't figure out :
1. How can I add to User admin form the list of items related to it ?
2. How can I add a specific field to the relation table ?

Thanks,

Guillaume
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: GeoDjango : Error in admin site with geom fields

2007-09-17 Thread guillaume

seems there's a bad trick like this indeed. I'm gonna check this all.

Thanks for the clue

On 16 sep, 19:38, "Ariel Mauricio Nunez Gomez"
<[EMAIL PROTECTED]> wrote:
> Did you have a previous geos installation??
> Maybe you have some old .so's that are being linked instead of the new ones.
>
> Ariel


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



GeoDjango : Error in admin site with geom fields

2007-09-16 Thread guillaume

Hi,
I've build up a small geodjango app. Using the admin-site to view the
records of my table gives me :
/usr/lib/libgeos_c.so: undefined symbol: GEOSGeomFromHEX_buf

my geos version is 3.0.0.RC4

my model is :
class commune(models.Model, models.GeoMixin):
depcom = models.CharField(maxlength=5, primary_key=True)
nom = models.CharField(maxlength=100)
dep = models.CharField(maxlength=3,db_index=True)
cheflieu = models.PositiveSmallIntegerField()
ct = models.CharField(maxlength=5)
ar = models.CharField(maxlength=4)
cdc = models.CharField(maxlength=1,null=True)
rang = models.CharField(maxlength=1,null=True)
depar = models.CharField(maxlength=4)
depct = models.CharField(maxlength=5)
pop1999 = models.IntegerField(null=True)
uu = models.CharField(maxlength=5,null=True)
rang_uu = models.CharField(maxlength=30,null=True)
the_geom = models.MultiPolygonField(srid=27572)

objects = models.GeoManager()

class Admin:
pass

any idea ?

Thanks

Guillaume


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newform and File Upload problem

2007-05-08 Thread guillaume

Thanks a lot! It works for FileFiels as well!

Yours,
Guillaume.

Le mardi 08 mai 2007 � 00:20 +, scadink a �crit :
> File uploads haven't been completed in newforms.  It's not a great
> situation, but that's what happens with software that's currently in
> development.
> 
> What I did in my view that worked:
> 
> p = Picture()
> p.title = clean_data['title']
> p.save_image_file(image['filename'], image['content'])
> 
> Basically, the relevant part is the save_blank_file (where blank is
> the name of the part of the model to be saved).
> 
> Hopefully this will work for you!
> Sean.
> 
> On May 7, 3:11 pm, guillaume <[EMAIL PROTECTED]> wrote:
> > Well, my message was maybe a little long. I still have not found answers
> > to my problem.
> > To make it short, Is there anywhere a short example of file upload using
> > newform ?
> > The most simple thing with a model with 1 FileField, the smallest
> > template and form associated and the handling code.
> >
> > That would be great, and probably useful for some other django beginers.
> >
> > Yours,
> > Guillaume.
> >
> > Le lundi 07 mai 2007 ? 08:41 -0700, [EMAIL PROTECTED] a ?crit :
> >
> > > Hello everybody.
> >
> > > I am a Django newbie experimenting with some stuff. I am very
> > > impressed by the framework, that made me want to learn more about it.
> > > I am trying to do some file upload but I have a problem.
> > > I tried many information sources but could not find a simple example
> > > of what I am trying to do. I have a few question...
> >
> > > Well, It should be very simple, I just want to upload a file on the
> > > server on the MEDIA directory.
> > > I use the up to date SVN version ( 5156 ).
> >
> > > I put sipets of code below, the things I dont anderstand are:
> > > * The {{form.updateFile_file}} tag produces nothing the first time I
> > > load my page. Is it normal behavior?
> >
> > > * The validation raises an AttributeError with message: 'dict' object
> > > has no attribute 'startswith'
> > > The lower part of the stack is :
> > > /home/guillaume/dev/Python/django_src/django/db/models/fields/
> > > __init__.py in isWithinMediaRoot
> > >  628.  # If the raw path is passed in, validate it's under the
> > > MEDIA_ROOT.
> > >  629. def isWithinMediaRoot(field_data, all_data):
> >
> > >  630. f = os.path.abspath(os.path.join(settings.MEDIA_ROOT,
> > > field_data)) ...
> >
> > >  631. if not
> > > f.startswith(os.path.abspath(os.path.normpath(settings.MEDIA_ROOT))):
> > >  632. raise validators.ValidationError, _("Enter a valid filename.")
> >
> > > * If I disable the validation, I have an error because Django tries to
> > > insert the file data into the database as a string...
> >
> > > Well I probably missed something very simple, but I cannot figure
> > > it ...
> >
> > > Might a Django Guru engilten me ?
> >
> > > Yours,
> > > Guillaume.
> >
> > > 
> >
> > > My model :
> >
> > > #-
> > > class StockUpdateFile( models.Model ):
> >
> > > updateFile  = models.FileField( upload_to = 'updatefiles/%Y/%m/
> > > %d' )
> > > fdate   = models.DateField( auto_now_add = True )
> >
> > > def __str__( self ):
> > > return "file %1-%2-%3" % str( distributor ) % str( fdate ) %
> > > str( updateFile )
> >
> > > class Admin:
> > > pass
> >
> > > --
> > > The form is:
> >
> > > class UploadForm( forms.Form ):
> > > updateFile = forms.Field( widget = forms.FileInput() )
> >
> > > 
> > > My template is:
> >
> > >  > > method="post" >
> >
> > >   
> > >   {{form.updateFile}}:{{form.updateFile_file}}
> > >   
> > >   
> > > 
> >
> > > -

Re: Newform and File Upload problem

2007-05-07 Thread guillaume

Well, my message was maybe a little long. I still have not found answers
to my problem.
To make it short, Is there anywhere a short example of file upload using
newform ?
The most simple thing with a model with 1 FileField, the smallest
template and form associated and the handling code.

That would be great, and probably useful for some other django beginers.

Yours,
Guillaume.

Le lundi 07 mai 2007 � 08:41 -0700, [EMAIL PROTECTED] a �crit :
> Hello everybody.
> 
> I am a Django newbie experimenting with some stuff. I am very
> impressed by the framework, that made me want to learn more about it.
> I am trying to do some file upload but I have a problem.
> I tried many information sources but could not find a simple example
> of what I am trying to do. I have a few question...
> 
> Well, It should be very simple, I just want to upload a file on the
> server on the MEDIA directory.
> I use the up to date SVN version ( 5156 ).
> 
> I put sipets of code below, the things I dont anderstand are:
> * The {{form.updateFile_file}} tag produces nothing the first time I
> load my page. Is it normal behavior?
> 
> * The validation raises an AttributeError with message: 'dict' object
> has no attribute 'startswith'
> The lower part of the stack is :
> /home/guillaume/dev/Python/django_src/django/db/models/fields/
> __init__.py in isWithinMediaRoot
>  628.  # If the raw path is passed in, validate it's under the
> MEDIA_ROOT.
>  629. def isWithinMediaRoot(field_data, all_data):
> 
>  630. f = os.path.abspath(os.path.join(settings.MEDIA_ROOT,
> field_data)) ...
> 
>  631. if not
> f.startswith(os.path.abspath(os.path.normpath(settings.MEDIA_ROOT))):
>  632. raise validators.ValidationError, _("Enter a valid filename.")
> 
> * If I disable the validation, I have an error because Django tries to
> insert the file data into the database as a string...
> 
> Well I probably missed something very simple, but I cannot figure
> it ...
> 
> Might a Django Guru engilten me ?
> 
> Yours,
> Guillaume.
> 
> 
> 
> My model :
> 
> #-
> class StockUpdateFile( models.Model ):
> 
> updateFile  = models.FileField( upload_to = 'updatefiles/%Y/%m/
> %d' )
> fdate   = models.DateField( auto_now_add = True )
> 
> def __str__( self ):
> return "file %1-%2-%3" % str( distributor ) % str( fdate ) %
> str( updateFile )
> 
> class Admin:
> pass
> 
> --
> The form is:
> 
> class UploadForm( forms.Form ):
> updateFile = forms.Field( widget = forms.FileInput() )
> 
> 
> My template is:
> 
>  method="post" >
> 
>   
>   {{form.updateFile}}:{{form.updateFile_file}}
>   
>   
> 
>  
> -
> And the code handling the form is:
> 
> def uploadFile(request, template='uploadfile.html' ):
> 
> errors = {}
> 
> form = UploadForm()
> 
> if( request.FILES ):
> 
> manip = StockUpdateFile.AddManipulator()
> newData = request.POST.copy()
> newData.update( request.FILES )
> 
> errors = manip.get_validation_errors( newData )
> 
> if( not errors):
> 
> manip.do_html2python( newData )
> newFile = manip.save( newData )
> else:
> form = UploadForm()
> 
> return render_to_response( template,
>context_instance =
> RequestContext( request, {'form': form,
>  
> 'errors' : errors } ))
> 
> 
> > 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mod_python/sqlite status

2007-01-16 Thread Guillaume Valadon


Hi,

What is the status of mod_python and sqlite ?
Do you think that I should switch to another database instead ?

Thanks,
Guillaume

ps: note that after hours of fights, it is working on my gentoo with
the following packages. But runserver is now broken.
net-www/apache-2.0.58-r2
dev-python/mod_python-3.1.4-r1
dev-db/sqlite-3.2.1-r3
dev-db/sqlite-3.2.1-r3 (3)


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Configurable LDAP authentication

2006-08-15 Thread Guillaume Pratte

Hello,

I took the code from http://www.carthage.edu/webdev/?p=12, adapted it
and generalized it so you can specify LDAP server and other
configuration items in settings.py.

>From the README :

===
LDAP authentication backend for Django.

The following variables must be set in your settings.py :

-
AUTH_LDAP_SERVER = 'ldapserver.yourdomain.com'
AUTH_LDAP_PORT = 389
AUTH_LDAP_DOMAIN = 'yourdomain.com'
AUTH_LDAP_SEARCH_STRING = "uid=%s,ou=People,dc=yourdomain,dc=com"

AUTHENTICATION_BACKENDS = (
 'django.contrib.auth.ldap_backend.LDAPBackend',
)

-

The %s in AUTH_LDAP_SEARCH_STRING will be replaced with the username.


There is no explicit copyright in the code found at
http://www.carthage.edu/webdev/?p=12,
so this code is released under public domain, hoping the original
author agrees with that.
===



The code :

===
# Based on http://www.carthage.edu/webdev/?p=12
#
# There is no explicit copyright in the original code,
# so this code is released under public domain, hoping
# the original author agrees with that.

import ldap
from django.contrib.auth.models import User
from django.conf import settings

class LDAPBackend:
def authenticate(self, username=None, password=None):

# Authenticate the base user so we can search
try:
l = ldap.open(settings.AUTH_LDAP_SERVER,
settings.AUTH_LDAP_PORT)
l.protocol_version = ldap.VERSION3
l.simple_bind_s(settings.AUTH_LDAP_SEARCH_STRING %
username, password)
except ldap.INVALID_CREDENTIALS:
# Name or password were bad. Fail.
return None

try:
user = User.objects.get(username__exact=username)
except:
# Theoretical backdoor could be input right here. We don't
# want that, so input an unused random password here.
# The reason this is a backdoor is because we create a
# User object for LDAP users so we can get permissions,
# however we -don't- want them able to login without
# going through LDAP with this user. So we effectively
# disable their non-LDAP login ability by setting it to a
# random password that is not given to them. In this way,
# static users that don't go through ldap can still login
# properly, and LDAP users still have a User object.
from random import choice
import string
temp_pass = ""
for i in range(8):
temp_pass = temp_pass + choice(string.letters)
user = User.objects.create_user(username,
username + '@' + settings.AUTH_LDAP_DOMAIN,
temp_pass)
user.is_staff = False
user.save()
# Success.
return user

def get_user(self, user_id):
""" Used by Django to get the user object onced logged in"""
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
===

Copy the code into
/usr/lib/python2.4/site-packages/django/contrib/auth/ldap_backend.py

Guillaume Pratte

--
Any views and opinions expressed in this email are solely those of the
author and do not necessarily represent those of Revolution Linux.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Not failing silently on undefined variables in the template system?

2006-07-28 Thread Guillaume Pratte

It's not about "crashing" the templating engine, but more ensuring that all 
variables defined in the template are filled.

What I wan't to do is to create applications configuration files from a 
template. It's not a web-related project at all, but since I find Django so 
well done, I was trying to use it for something it was not conceived to 
perform.

I found Cheetah fits more my needs for what I intend to do. Thanks for your 
quick replies.

Guillaume

Le mercredi 26 juillet 2006 17:26, Bill de hÓra a écrit :
> I'd assumed you were define variable values in one place and passing
> them into a template to generate your configuration files from the view.
> As an approach to verification, crashing the templating engine doesn't
> seem necessary, but I don't understand your setup.
>
> cheers
> Bill
>
> Guillaume Pratte wrote:
> > To verify the variables before passing control to the template system is
> > not a viable solution, and would break the DRY principle (Don't Repeate
> > Yourself). I would have to know what variables are defined in my
> > templates in my code calling the template, thus duplicating the
> > information and rendering my code harder to maintain.
> >
> > Guillaume
> >
> > Le mercredi 26 juillet 2006 14:10, Bill de hÓra a écrit :
> >> I'd say verify the variable set in the view before you emit and fail at
> >> that point. Failing at the template allows designers to break sites.
> >>
> >> Guillaume Pratte wrote:
> >>> In http://www.djangoproject.com/documentation/templates_python/ you can
> >>> read :
> >>>
> >>>In Django 0.91, if a variable doesn't exist, the template system
> >>> fails silently. The variable is replaced with an empty string.
> >>>
> >>> This is controlled with the silent_variable_failure variable set to
> >>> True in the ObjectDoesNotExists exception.
> >>>
> >>> I would like to use Django's templating system to generate
> >>> configuration files from a template. Thus, I would like Django to
> >>> inform me (raise an exception) if a variable if not found instead of
> >>> failing silently.
> >>>
> >>> Is this possible? It does not seems so with the current code.
>
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Not failing silently on undefined variables in the template system?

2006-07-26 Thread Guillaume Pratte

To verify the variables before passing control to the template system is not a 
viable solution, and would break the DRY principle (Don't Repeate Yourself). 
I would have to know what variables are defined in my templates in my code 
calling the template, thus duplicating the information and rendering my code 
harder to maintain.

Guillaume

Le mercredi 26 juillet 2006 14:10, Bill de hÓra a écrit :
> I'd say verify the variable set in the view before you emit and fail at
> that point. Failing at the template allows designers to break sites.
>
> Guillaume Pratte wrote:
> > In http://www.djangoproject.com/documentation/templates_python/ you can
> > read :
> >
> >    In Django 0.91, if a variable doesn't exist, the template system fails
> >    silently. The variable is replaced with an empty string.
> >
> > This is controlled with the silent_variable_failure variable set to True
> > in the ObjectDoesNotExists exception.
> >
> > I would like to use Django's templating system to generate configuration
> > files from a template. Thus, I would like Django to inform me (raise an
> > exception) if a variable if not found instead of failing silently.
> >
> > Is this possible? It does not seems so with the current code.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Not failing silently on undefined variables in the template system?

2006-07-26 Thread Guillaume Pratte

In http://www.djangoproject.com/documentation/templates_python/ you can read :

   In Django 0.91, if a variable doesn't exist, the template system fails
   silently. The variable is replaced with an empty string. 

This is controlled with the silent_variable_failure variable set to True in 
the ObjectDoesNotExists exception.

I would like to use Django's templating system to generate configuration files 
from a template. Thus, I would like Django to inform me (raise an exception) 
if a variable if not found instead of failing silently.

Is this possible? It does not seems so with the current code.

Thanks,

Guillaume Pratte

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: More than one ForeignKey referencing the same model?

2006-07-18 Thread Guillaume Pratte

This seems indeed to be the solution!

class Host(models.Model):
   [...]
   person_in_charge = models.ForeignKey(Person,
 related_name='hosts_in_primary_charge_set')
   backup_person = models.ForeignKey(Person,
 related_name='hosts_in_secondary_charge_set')

Thanks.

Le mardi 18 juillet 2006 15:32, Corey Oordt a écrit :
> Take a look at this page for a start:
> http://www.djangoproject.com/documentation/models/m2o_recursive2/
>
> It's for one-to-many, but it might work...
>
> Corey
>
> On Jul 18, 2006, at 3:20 PM, Guillaume Pratte wrote:
> > Hello,
> >
> > I have an error with a model and would like to know if it is something
> > impossible to do in Django or should be considered a bug...
> >
> > I modeled a rudimentary inventory system : I have Hosts and Persons
> > responsible for them (Admin class omitted).
> >
> > class Person(models.Model):
> > name = models.CharField(maxlength=100)
> >
> > class OperatingSystem(models.Model):
> > name = models.CharField(maxlength=100)
> > version = models.CharField(maxlength=20)
> >
> > class Host(models.Model):
> > name = models.CharField(maxlength=100)
> > os = models.ForeignKey(OperatingSystem)
> > ip = models.IPAddressField()
> > person_in_charge = models.ForeignKey(Person)
> > backup_person = models.ForeignKey(Person)
> >
> >
> > Django gives me the following error when validating the models :
> >
> > Validating models...
> > invs.host: Accessor for field 'person_in_charge' clashes with related
> > field 'Person.host_set'. Add a related_name argument to the definition
> > for 'person_in_charge'.
> > invs.host: Accessor for field 'backup_person' clashes with related
> > field 'Person.host_set'. Add a related_name argument to the definition
> > for 'backup_person'.
> > 2 errors found.
> >
> >
> > If I comment out "backup_person", it works.
> >
> > I don't want to use a ManyToMany relationship, because then would
> > not be able
> > to differentiate the principal from the backup.
> >
> > Is there a way around?
> >
> > Thanks,
> >
> > Guillaume Pratte
>
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



More than one ForeignKey referencing the same model?

2006-07-18 Thread Guillaume Pratte

Hello,

I have an error with a model and would like to know if it is something 
impossible to do in Django or should be considered a bug...

I modeled a rudimentary inventory system : I have Hosts and Persons 
responsible for them (Admin class omitted).

class Person(models.Model):
name = models.CharField(maxlength=100)

class OperatingSystem(models.Model):
name = models.CharField(maxlength=100)
version = models.CharField(maxlength=20)

class Host(models.Model):
name = models.CharField(maxlength=100)
os = models.ForeignKey(OperatingSystem)
ip = models.IPAddressField()
person_in_charge = models.ForeignKey(Person)
backup_person = models.ForeignKey(Person)


Django gives me the following error when validating the models :

Validating models...
invs.host: Accessor for field 'person_in_charge' clashes with related 
field 'Person.host_set'. Add a related_name argument to the definition 
for 'person_in_charge'.
invs.host: Accessor for field 'backup_person' clashes with related 
field 'Person.host_set'. Add a related_name argument to the definition 
for 'backup_person'.
2 errors found.


If I comment out "backup_person", it works.

I don't want to use a ManyToMany relationship, because then would not be able 
to differentiate the principal from the backup.

Is there a way around?

Thanks,

Guillaume Pratte

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---