Re: Inspecting objects

2011-07-12 Thread Jonas Geiregat

Op 13-jul-2011, om 08:25 heeft Jirka Vejrazka het volgende geschreven:

>> Thank you all for your help!!!
> 
> I know I'm a bit late to the party (blame timezones :), but thought
> I'd put my 2 cents worth in :)
> 
> For inspecting models from command lines (usually when working with
> models from legacy databases) I often use model_to_dict which is
> "hidden" in django.forms.models.



This is new for me. I've noticed before that django's API docs doesn't all 
function available. There's probably a good reason for it.

What's the advantage of using model_to_dict against dict(some_queryset) ?

-- 
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: Inspecting objects

2011-07-12 Thread Jonas Geiregat
I like to add:

import pdb; pdb.set_trace();

To my code.

Reload the page.

Go to the development server instance. You'll see that the page hangs forever 
,since we started the python debugger. 
Now you can easily inspect all variables, classes and functions from PDB. 
Of course you're not limited to using set_trace().

Good luck !


>> Thank you all for your help!!!
> 
> I know I'm a bit late to the party (blame timezones :), but thought
> I'd put my 2 cents worth in :)
> 
> For inspecting models from command lines (usually when working with
> models from legacy databases) I often use model_to_dict which is
> "hidden" in django.forms.models.
> 
 from django.forms.models import model_to_dict
 print model_to_dict(some_model)
> 
>  HTH
> 
> Jirka
> 
> -- 
> 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.
> 


Jonas Geiregat
jo...@geiregat.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.



AW: Trouble overriding registration templates

2011-07-12 Thread Szabo, Patrick (LNG-VIE)
Did you write your own view for that purpose ?!

In that view you could use render_to_response and pass you own template
to that.

 

Von: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] Im Auftrag von Joshua Russo
Gesendet: Mittwoch, 13. Juli 2011 04:24
An: django-users@googlegroups.com
Betreff: Trouble overriding registration templates

 

I want to use my own logout template but it doesn't want to pick it up.
The login template worked just fine, but for anything that's already in
the admin's template/registration folder, it only wants to use those. I
tried putting my templates folder before the admin templates folder in
the list of template folder in the settings file but that didn't do
anything. Any suggestions? 

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


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 





-- 
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: get all objects that are related to current, reverse look up

2011-07-12 Thread Jonas Geiregat

Op 12-jul-2011, om 09:18 heeft bruno desthuilliers het volgende geschreven:

> On Jul 12, 4:32 am, garagefan  wrote:
>> simply put, here's my code
>> 
>> class ContentBlock(Orderable, Displayable):
>>   location = models.ManyToManyField(ContentBlockLocation, blank=True,
>> null=True, help_text="list of locations to display content block")
>>   page = models.ManyToManyField(Page, blank=True, null=True,
>> help_text="list of pages to display content block")
>>   height = models.IntegerField(blank=True, null=True)
>>   width = models.IntegerField(blank=True, null=True)
>> 
>>   def __unicode__(self):
>> return self.title
>> 
>> class StaticContent(Displayable, RichText):
>>  content_block =  models.ForeignKey(ContentBlock, blank=True,
>> null=True)
>> 
>> class StaticContent2(Displayable, RichText):
>>  content_block =  models.ForeignKey(ContentBlock, blank=True,
>> null=True)
>> 
>> putting together a template tag that will return all the items
>> associated with a given ContentBlock, but i would like to do so
>> without knowing upfront all of the classes that have a foreign key to
>> ContentBlock as i'll want to be able to add more content types at any
>> time
> 
> 
> Are you sure your data model is right ?
> 

Displayable and RichText are probably classes that inherit from 
django.db.models.Model.




-- 
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: Inspecting objects

2011-07-12 Thread Jirka Vejrazka
> Thank you all for your help!!!

I know I'm a bit late to the party (blame timezones :), but thought
I'd put my 2 cents worth in :)

For inspecting models from command lines (usually when working with
models from legacy databases) I often use model_to_dict which is
"hidden" in django.forms.models.

>>> from django.forms.models import model_to_dict
>>> print model_to_dict(some_model)

  HTH

 Jirka

-- 
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: problem submitting form data to database (django)

2011-07-12 Thread Venkatraman S
Can you paste the following database settings  from your settings.py? Is it
something like this...

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'dbDev.db',
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for default.
Not used with sqlite3.
}
}

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Brent
I'm using python manage.py runserver, and I have restarted it dozens
of times.

On Jul 12, 8:58 pm, Micky Hulse  wrote:
> On Tue, Jul 12, 2011 at 7:57 PM, Brent  wrote:
> > Unfortunately, no matter what kind of path I put for
> > AUTH_PROFILE_MODULE, the same error appears.
>
> I don't know your setup, but have your tried restating Apache? That's
> probably a stupid question/suggestion, but maybe worth a shot?

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Micky Hulse
On Tue, Jul 12, 2011 at 7:57 PM, Brent  wrote:
> Unfortunately, no matter what kind of path I put for
> AUTH_PROFILE_MODULE, the same error appears.

I don't know your setup, but have your tried restating Apache? That's
probably a stupid question/suggestion, but maybe worth a shot?

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Brent
Unfortunately, no matter what kind of path I put for
AUTH_PROFILE_MODULE, the same error appears.

On Jul 12, 5:51 pm, Andre Terra  wrote:
> As the traceback helpfully states,
>
> Exception Type: SiteProfileNotAvailable at /profile/Exception Value:
> Unable to load the profile model, check AUTH_PROFILE_MODULE in your
> project settings
>
> http://www.google.com/search?&q=django+Unable+to+load+the+profile+mod...
>
> check out the first result.
>
> Cheers,
> André
>
> On Tue, Jul 12, 2011 at 8:09 PM, Brent  wrote:
> > Good idea. Unfortunately, I tried that, but it results in a
> > SiteProfileNotAvailable error:
>
> >http://dpaste.com/567421/
>
> > On Jul 12, 3:15 pm, Andre Terra  wrote:
> > > Instead of using get or create, why not setting up a post_save signal
> > > for the User model so that users always have a profile associated with
> > > them?
>
> > > Cheers,
> > > Andre
>
> > > On 7/12/11, Brent  wrote:
>
> > > > Thanks for the help guys.
>
> > > > Micky, that tutorial looks very good. I think I almost have it
> > > > working. Just one more error:
>
> > > >http://dpaste.com/567361/
>
> > > > Andre, thanks for mentioning Pinax. I'll give it a shot if this
> > > > doesn't work out. I have a year of python experience, but I haven't
> > > > written anything web/database related.
>
> > > > On Jul 12, 11:34 am, Micky Hulse  wrote:
> > > >> This tutorial helped me:
>
> > > >>http://www.turnkeylinux.org/blog/django-profile
>
> > > >> Note: The above tutorial uses an FK to User model... The Django docs
> > > >> suggest a OneToOne field.
>
> > > >> Hope that helps.
>
> > > >> Micky
>
> > > > --
> > > > 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.
>
> > > --
> > > Sent from my mobile device
>
> > --
> > 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: Form wizard get_template_names()

2011-07-12 Thread Dario Vergara
Here is the solution:

def get_template_names(self):
next_step = int(self.steps.current)
return 'step_%s.html' % next_step


Simple solution. What is confusing is that the documentation says that
get_template_names() should return a list.

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



Trouble overriding registration templates

2011-07-12 Thread Joshua Russo
I want to use my own logout template but it doesn't want to pick it up. The 
login template worked just fine, but for anything that's already in the 
admin's template/registration folder, it only wants to use those. I tried 
putting my templates folder before the admin templates folder in the list of 
template folder in the settings file but that didn't do anything. Any 
suggestions?

-- 
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/-/VcsTSOx1iSoJ.
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: something about django mysql database long connection

2011-07-12 Thread Kejun He
hi,
I am sorry. My English is very bad.

Yes, i want to make persistent databases connection on each session.


and yesterday i try to modify the  code on
"site-packages\django\db\__init__.py"

def close_connection(**kwargs):
for conn in connections.all():
conn.close()
#signals.request_finished.connect(close_connection) <---


could it work?

regards,
he




On Mon, Jul 11, 2011 at 7:31 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

>
>
> On Mon, Jul 11, 2011 at 4:49 AM, oops  wrote:
>
>> hi,
>> Now, i am doing a django project, and use models to do all operation
>> about data in mysql db.
>>
>> and i think that it would connect to database whenever  do some
>> operation like 'XXX.objects.all()' , may be it would cast much of
>> resource on database connection. So i need a connection never being
>> desconnected.
>>
>
> At as best guess (as the question is somewhat broken), are you asking how
> to make persistent connections which are guaranteed to never time out in a
> single session?
>
> Could you clarify a little more on your question please?
>
> Cal
>
>
>>
>> Does django has this function?  And how to do for it??
>>
>> thank you
>> rgs,
>> he
>>
>> --
>> 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: Duplicate Key Error in Cache

2011-07-12 Thread Issac Kelly
I would guess your quickest way forward is to change backends, as it
appears that this is a larger issue with database transactions between
threads, which is a couple of years old.

I've been tinkering with LocalMemCache for a really small site, and
django-redis-cache as a toy, I know that some have used it in
production, but I haven't, and adding another piece to your deployment
isn't always a good idea.

It's also possible that memcached is a good fit for what you're doing.

On Jul 12, 12:09 pm, gamingdroid  wrote:
> I ran into this problem using django core's database cache:
>
> ERROR:  duplicate key value violates unique constraint "cache_pkey"
> STATEMENT:  INSERT INTO "cache" (cache_key, value, expires) VALUES (E':
> 1:cms-menu_nodes_en-us_1', E'gAJdcQEoY21lbnVzLmJhc2UKTmF2aW
> LOG:  server process (PID 8453) was terminated by signal 9: Killed
> LOG:  terminating any other active server processes
> LOG:  all server processes terminated; reinitializing
> FATAL:  could not create shared memory segment: Cannot allocate memory
> DETAIL:  Failed system call was shmget(key=5432001, size=29278208,
> 03600).
>
> I looked in the table and sure enough, there is an entry for the key ':
> 1:cms-menu_nodes_en-us_1'. I found a similar issue here (http://
> stackoverflow.com/questions/1189541/django-cache-set-causing-duplicate-
> key-error), but was unable to exactly understand what the issue is.
>
> Sounds like a bug in django core, since if a key exist, it should
> update the record. It looks as if somebody posted a ticket here
> (https://code.djangoproject.com/ticket/11569), but not entireloy sure
> if it is related. This problem sort of renders the database backend
> useless. I would fix it if I knew how and contribute back, but really
> don't know how.
>
> Anyone have any ideas or suggestions?

-- 
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: problem submitting form data to database (django)

2011-07-12 Thread Andre Terra
Also try different ports and opening the server for external IPs to make
sure this isn't a network issue

C:\>manage.py runserver 0.0.0.0:11010

and then http://localhost:11010



Cheers,
André Terra


On Tue, Jul 12, 2011 at 10:16 PM, Issac Kelly  wrote:

> A few things to check:
>
> Is runserver (python manage.py runserver) running? does it crash when
> you try to submit your form?
>
> Have you done a syncdb successfully? If so, then django can connect to
> your database, and that's probably not the problem.
>
> I would guess it's something in your view (or maybe your urls)
>
> On Jul 12, 8:52 pm, sq1020  wrote:
> > I'm pretty new to Django and web development in general so the answer
> > to this question may be rather obvious. I've created a ModelForm in
> > Django so that the data submitted by a user is saved in a database.
> > When the user submits the form, I believe the data validates but it
> > can't connect to the database server i.e. firefox says: can't
> > establish a connection to the server at 127.0.0.1:8000. Keep in mind
> > I'm running the development server on windows. And my database is in
> > SQLite. Do I have to do something with my database in order for it to
> > accept data?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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: problem submitting form data to database (django)

2011-07-12 Thread Issac Kelly
A few things to check:

Is runserver (python manage.py runserver) running? does it crash when
you try to submit your form?

Have you done a syncdb successfully? If so, then django can connect to
your database, and that's probably not the problem.

I would guess it's something in your view (or maybe your urls)

On Jul 12, 8:52 pm, sq1020  wrote:
> I'm pretty new to Django and web development in general so the answer
> to this question may be rather obvious. I've created a ModelForm in
> Django so that the data submitted by a user is saved in a database.
> When the user submits the form, I believe the data validates but it
> can't connect to the database server i.e. firefox says: can't
> establish a connection to the server at 127.0.0.1:8000. Keep in mind
> I'm running the development server on windows. And my database is in
> SQLite. Do I have to do something with my database in order for it to
> accept data?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



problem submitting form data to database (django)

2011-07-12 Thread sq1020
I'm pretty new to Django and web development in general so the answer
to this question may be rather obvious. I've created a ModelForm in
Django so that the data submitted by a user is saved in a database.
When the user submits the form, I believe the data validates but it
can't connect to the database server i.e. firefox says: can't
establish a connection to the server at 127.0.0.1:8000. Keep in mind
I'm running the development server on windows. And my database is in
SQLite. Do I have to do something with my database in order for it to
accept data?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Simple example of custom user profile fields?

2011-07-12 Thread Andre Terra
As the traceback helpfully states,

Exception Type: SiteProfileNotAvailable at /profile/Exception Value:
Unable to load the profile model, check AUTH_PROFILE_MODULE in your
project settings

http://www.google.com/search?&q=django+Unable+to+load+the+profile+model%2C+check+AUTH_PROFILE_MODULE+in+your+project+settings

check out the first result.


Cheers,
André


On Tue, Jul 12, 2011 at 8:09 PM, Brent  wrote:

> Good idea. Unfortunately, I tried that, but it results in a
> SiteProfileNotAvailable error:
>
> http://dpaste.com/567421/
>
> On Jul 12, 3:15 pm, Andre Terra  wrote:
> > Instead of using get or create, why not setting up a post_save signal
> > for the User model so that users always have a profile associated with
> > them?
> >
> > Cheers,
> > Andre
> >
> > On 7/12/11, Brent  wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > Thanks for the help guys.
> >
> > > Micky, that tutorial looks very good. I think I almost have it
> > > working. Just one more error:
> >
> > >http://dpaste.com/567361/
> >
> > > Andre, thanks for mentioning Pinax. I'll give it a shot if this
> > > doesn't work out. I have a year of python experience, but I haven't
> > > written anything web/database related.
> >
> > > On Jul 12, 11:34 am, Micky Hulse  wrote:
> > >> This tutorial helped me:
> >
> > >>http://www.turnkeylinux.org/blog/django-profile
> >
> > >> Note: The above tutorial uses an FK to User model... The Django docs
> > >> suggest a OneToOne field.
> >
> > >> Hope that helps.
> >
> > >> Micky
> >
> > > --
> > > 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.
> >
> > --
> > Sent from my mobile device
>
> --
> 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: Inspecting objects

2011-07-12 Thread Lukich
Thank you all for your help!!!

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Brent
Good idea. Unfortunately, I tried that, but it results in a
SiteProfileNotAvailable error:

http://dpaste.com/567421/

On Jul 12, 3:15 pm, Andre Terra  wrote:
> Instead of using get or create, why not setting up a post_save signal
> for the User model so that users always have a profile associated with
> them?
>
> Cheers,
> Andre
>
> On 7/12/11, Brent  wrote:
>
>
>
>
>
>
>
>
>
> > Thanks for the help guys.
>
> > Micky, that tutorial looks very good. I think I almost have it
> > working. Just one more error:
>
> >http://dpaste.com/567361/
>
> > Andre, thanks for mentioning Pinax. I'll give it a shot if this
> > doesn't work out. I have a year of python experience, but I haven't
> > written anything web/database related.
>
> > On Jul 12, 11:34 am, Micky Hulse  wrote:
> >> This tutorial helped me:
>
> >>http://www.turnkeylinux.org/blog/django-profile
>
> >> Note: The above tutorial uses an FK to User model... The Django docs
> >> suggest a OneToOne field.
>
> >> Hope that helps.
>
> >> Micky
>
> > --
> > 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.
>
> --
> Sent from my mobile device

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



Looking for Django Developers in the Region of Vienna Austria

2011-07-12 Thread Robert Boulanger
Hi Guys,

we are looking for a Django Developer in the Region of Vienna, Austria.

Starting with the end of August 2011, we need a freelancer Django/Python 
Developer for an international Company, in Vienna/Austria.
The work will be on-site at the customers place, about 40 hours a week.
We will pay around 65 Euros per hour, additional local sales tax (20 %).
This job will be for 6 to 12 months eventually longer. Office place, 
computer and infrastructure comes from us.
Payment every month.
Working languages: German and English.

If you are interested, please contact me via EMail at r...@me.com

thanks for your interest


Robert Boulanger

-- 
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/-/lGKw8zWV7zIJ.
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: Simple example of custom user profile fields?

2011-07-12 Thread Andre Terra
Instead of using get or create, why not setting up a post_save signal
for the User model so that users always have a profile associated with
them?

Cheers,
Andre

On 7/12/11, Brent  wrote:
> Thanks for the help guys.
>
> Micky, that tutorial looks very good. I think I almost have it
> working. Just one more error:
>
> http://dpaste.com/567361/
>
> Andre, thanks for mentioning Pinax. I'll give it a shot if this
> doesn't work out. I have a year of python experience, but I haven't
> written anything web/database related.
>
> On Jul 12, 11:34 am, Micky Hulse  wrote:
>> This tutorial helped me:
>>
>> http://www.turnkeylinux.org/blog/django-profile
>>
>> Note: The above tutorial uses an FK to User model... The Django docs
>> suggest a OneToOne field.
>>
>> Hope that helps.
>>
>> Micky
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Brent
Running syncdb again didn't seem to fix it. I tried deleting the
database entirely, and starting from a new database, but that also
didn't work.

On Jul 12, 2:28 pm, Shawn Milochik  wrote:
> On Tue, Jul 12, 2011 at 5:26 PM, Brent  wrote:
> > Thanks for the help guys.
>
> > Micky, that tutorial looks very good. I think I almost have it
> > working. Just one more error:
>
> >http://dpaste.com/567361/
>
> Looks like maybe you didn't run syncdb after adding something to 
> INSTALLED_APPS.

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Shawn Milochik
On Tue, Jul 12, 2011 at 5:26 PM, Brent  wrote:
> Thanks for the help guys.
>
> Micky, that tutorial looks very good. I think I almost have it
> working. Just one more error:
>
> http://dpaste.com/567361/
>


Looks like maybe you didn't run syncdb after adding something to INSTALLED_APPS.

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Brent
Thanks for the help guys.

Micky, that tutorial looks very good. I think I almost have it
working. Just one more error:

http://dpaste.com/567361/

Andre, thanks for mentioning Pinax. I'll give it a shot if this
doesn't work out. I have a year of python experience, but I haven't
written anything web/database related.

On Jul 12, 11:34 am, Micky Hulse  wrote:
> This tutorial helped me:
>
> http://www.turnkeylinux.org/blog/django-profile
>
> Note: The above tutorial uses an FK to User model... The Django docs
> suggest a OneToOne field.
>
> Hope that helps.
>
> Micky

-- 
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: Inspecting objects

2011-07-12 Thread Andre Terra
You should actually use dir() or vars() rather than __dict__.

Here's a thorough explanation, along with an example serializer which might
need to access an object's attributes:

http://blog.enterthefoo.com/2008/08/pythons-vars.html



Regards,
André Terra

On Tue, Jul 12, 2011 at 4:52 PM, Marc Aymerich  wrote:

> On Tue, Jul 12, 2011 at 7:25 PM, Lukich  wrote:
> > Hi.  I have just started diving into Django and this question came up
> > - is there a way for me to examine all the attribute values of an
> > object?  In Rails there's such a thing as debug statement which spits
> > out all the details about the object.  From what I have seen so far in
> > Django, I can either do a __unicode__() trick, but it forces me to
> > specify which attribute to show.  I also read about dir() and
> > __dict__, but they show me sets of attributes without their values. Is
> > there something I'm missing? Thank you!
>
> Hi Luka,
> I get the object attributes and their values with __dict__, It's not
> enough for your case?
>
> >>> Domain.objects.all()[1].__dict__
> {'name_ptr_id': 2L, 'name': u'pangea', 'extension': u'org',
> 'slave_refresh': u'1d', 'min_caching_time': u'1h', '_state':
> , 'is_mail':
> False, 'slave_retry': u'2h', 'is_hosted': False, 'expire':
> datetime.date(2012, 7, 31), 'active': True, 'is_purchased': False,
> 'slave_expiration': u'4w', 'id': 2L, 'serial': 203308L}
>
> --
> 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+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: Inspecting objects

2011-07-12 Thread Marc Aymerich
On Tue, Jul 12, 2011 at 7:25 PM, Lukich  wrote:
> Hi.  I have just started diving into Django and this question came up
> - is there a way for me to examine all the attribute values of an
> object?  In Rails there's such a thing as debug statement which spits
> out all the details about the object.  From what I have seen so far in
> Django, I can either do a __unicode__() trick, but it forces me to
> specify which attribute to show.  I also read about dir() and
> __dict__, but they show me sets of attributes without their values. Is
> there something I'm missing? Thank you!

Hi Luka,
I get the object attributes and their values with __dict__, It's not
enough for your case?

>>> Domain.objects.all()[1].__dict__
{'name_ptr_id': 2L, 'name': u'pangea', 'extension': u'org',
'slave_refresh': u'1d', 'min_caching_time': u'1h', '_state':
, 'is_mail':
False, 'slave_retry': u'2h', 'is_hosted': False, 'expire':
datetime.date(2012, 7, 31), 'active': True, 'is_purchased': False,
'slave_expiration': u'4w', 'id': 2L, 'serial': 203308L}

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Simple example of custom user profile fields?

2011-07-12 Thread Micky Hulse
This tutorial helped me:

http://www.turnkeylinux.org/blog/django-profile

Note: The above tutorial uses an FK to User model... The Django docs
suggest a OneToOne field.

Hope that helps.

Micky

-- 
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: Inspecting objects

2011-07-12 Thread Andre Terra
Useful, if the code is well documented:
http://www.java2s.com/Code/Python/Utility/CheapandsimpleAPIhelper.htm

IIRC, use it like:

from apihelper import info
info(object, spacing=20)


Cheers,
André


On Tue, Jul 12, 2011 at 2:44 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> In fact, if anyone wants to extend on this concept, I'd be more than happy
> to provide some assistance :)
>
>
> On Tue, Jul 12, 2011 at 6:39 PM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>>
>>
>> On Tue, Jul 12, 2011 at 6:25 PM, Lukich  wrote:
>>
>>> Hi.  I have just started diving into Django and this question came up
>>> - is there a way for me to examine all the attribute values of an
>>> object?  In Rails there's such a thing as debug statement which spits
>>> out all the details about the object.  From what I have seen so far in
>>> Django, I can either do a __unicode__() trick, but it forces me to
>>> specify which attribute to show.  I also read about dir() and
>>> __dict__, but they show me sets of attributes without their values. Is
>>> there something I'm missing? Thank you!
>>>
>>
>> Ah, yeah I know what you mean. You want the PHP equivalent of "vardump".
>>
>> I'm not aware of anything that does it, but it would be easy to make, by
>> extending on dir:
>>
>> def inspectobj(obj):
>> return dict(map(lambda x: (x, getattr(obj, x)), dir(obj)))
>>
>> pprint.pprint(inspectobj(django.db))
>> pprint.pprint(inspectobj(str))
>> pprint.pprint(inspectobj(django))
>>
>> This is very very very basic, and you'd need to add all sorts of
>> conditionals in there to make it extract the information you want in a
>> proper, recursive fashion (and telling it how to deal with unbound methods
>> etc), but it's a start.
>>
>> Enjoy :)
>>
>> Cal
>>
>>
>>
>>> Luka
>>>
>>>
>>> --
>>> 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: Simple example of custom user profile fields?

2011-07-12 Thread Andre Terra
On Tue, Jul 12, 2011 at 2:51 PM, Brent  wrote:

> Hi,
>
> Does anyone know of a simple, working example of custom user profile
> fields?
>
> I want to have a custom field, say, "favorite color," which is unique
> to each user. Then I want users to be able to login, and be taken to a
> page called "profile" that displays that custom field.
>
> So far, I have logging in working, and I can display built-in fields
> like username and email, but I am not able to get the custom fields
> working.
>

This is probably because you're looking at a ModelForm for the User model,
when you should have two different ModelForms, one for User and one for
UserProfile, run validation on each and save each separately. Or have just
one Form which implements its own save() method (which is basically the only
relevant difference between Forms and ModelForms).

Following tutorials have been informative, but after reading every
> tutorial I could get my hands on, I still receive errors like "no such
> table" or "SiteProfileNotAvailable" or just syntax errors. I've
> invested a significant amount of time into learning Django, but I am
> starting to consider switching to another product.
>
> Thanks in advance.
>


The learning curve can be steep at first, but once you get the gist of it it
becomes a breeze (and a pleasure) to develop for Django. I have to ask,
though: how familiar are you with Python? Trying to learn both at the same
time can be quite daunting and it is very recommended that you play around
with python for at least a couple of months before jumping into django.

At the same time, applications like django-registration and django-profiles
exist precisely so that you don't have to reinvent the wheel. I personally
don't use them, but a lot of people do.

Other developers also recommend Pinax, which I personally have never used (I
mostly build intranet websites), but it can be quite the tool depending on
your project's goals.



Cheers,
André

-- 
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: Simple example of custom user profile fields?

2011-07-12 Thread Shawn Milochik

https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users

Everything you should need is in here. Once you have something started I 
can probably help out if you have any specific questions.
Also, as long as you have a one-to-one field there's really no need to 
use the get_profile() function.



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



Simple example of custom user profile fields?

2011-07-12 Thread Brent
Hi,

Does anyone know of a simple, working example of custom user profile
fields?

I want to have a custom field, say, "favorite color," which is unique
to each user. Then I want users to be able to login, and be taken to a
page called "profile" that displays that custom field.

So far, I have logging in working, and I can display built-in fields
like username and email, but I am not able to get the custom fields
working.

Following tutorials have been informative, but after reading every
tutorial I could get my hands on, I still receive errors like "no such
table" or "SiteProfileNotAvailable" or just syntax errors. I've
invested a significant amount of time into learning Django, but I am
starting to consider switching to another product.

Thanks in advance.

-- 
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: Inspecting objects

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
In fact, if anyone wants to extend on this concept, I'd be more than happy
to provide some assistance :)

On Tue, Jul 12, 2011 at 6:39 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

>
>
> On Tue, Jul 12, 2011 at 6:25 PM, Lukich  wrote:
>
>> Hi.  I have just started diving into Django and this question came up
>> - is there a way for me to examine all the attribute values of an
>> object?  In Rails there's such a thing as debug statement which spits
>> out all the details about the object.  From what I have seen so far in
>> Django, I can either do a __unicode__() trick, but it forces me to
>> specify which attribute to show.  I also read about dir() and
>> __dict__, but they show me sets of attributes without their values. Is
>> there something I'm missing? Thank you!
>>
>
> Ah, yeah I know what you mean. You want the PHP equivalent of "vardump".
>
> I'm not aware of anything that does it, but it would be easy to make, by
> extending on dir:
>
> def inspectobj(obj):
> return dict(map(lambda x: (x, getattr(obj, x)), dir(obj)))
>
> pprint.pprint(inspectobj(django.db))
> pprint.pprint(inspectobj(str))
> pprint.pprint(inspectobj(django))
>
> This is very very very basic, and you'd need to add all sorts of
> conditionals in there to make it extract the information you want in a
> proper, recursive fashion (and telling it how to deal with unbound methods
> etc), but it's a start.
>
> Enjoy :)
>
> Cal
>
>
>
>> Luka
>>
>>
>> --
>> 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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
Of course :) I'll make sure to take a high quality recording and stick it on
YT.

Cal

On Tue, Jul 12, 2011 at 6:31 PM, Venkatraman S  wrote:

> Can you please ..please...please..please record this session!?
>
> -V
>
> --
> 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: Inspecting objects

2011-07-12 Thread Cal Leeming
On Tue, Jul 12, 2011 at 6:25 PM, Lukich  wrote:

> Hi.  I have just started diving into Django and this question came up
> - is there a way for me to examine all the attribute values of an
> object?  In Rails there's such a thing as debug statement which spits
> out all the details about the object.  From what I have seen so far in
> Django, I can either do a __unicode__() trick, but it forces me to
> specify which attribute to show.  I also read about dir() and
> __dict__, but they show me sets of attributes without their values. Is
> there something I'm missing? Thank you!
>

Ah, yeah I know what you mean. You want the PHP equivalent of "vardump".

I'm not aware of anything that does it, but it would be easy to make, by
extending on dir:

def inspectobj(obj):
return dict(map(lambda x: (x, getattr(obj, x)), dir(obj)))

pprint.pprint(inspectobj(django.db))
pprint.pprint(inspectobj(str))
pprint.pprint(inspectobj(django))

This is very very very basic, and you'd need to add all sorts of
conditionals in there to make it extract the information you want in a
proper, recursive fashion (and telling it how to deal with unbound methods
etc), but it's a start.

Enjoy :)

Cal



> Luka
>
> --
> 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: Inspecting objects

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
On Tue, Jul 12, 2011 at 6:25 PM, Lukich  wrote:

> Hi.  I have just started diving into Django and this question came up
> - is there a way for me to examine all the attribute values of an
> object?  In Rails there's such a thing as debug statement which spits
> out all the details about the object.  From what I have seen so far in
> Django, I can either do a __unicode__() trick, but it forces me to
> specify which attribute to show.  I also read about dir() and
> __dict__, but they show me sets of attributes without their values. Is
> there something I'm missing? Thank you!
>

Ah, yeah I know what you mean. You want the PHP equivalent of "vardump".

I'm not aware of anything that does it, but it would be easy to make, by
extending on dir:

def inspectobj(obj):
return dict(map(lambda x: (x, getattr(obj, x)), dir(obj)))

pprint.pprint(inspectobj(django.db))
pprint.pprint(inspectobj(str))
pprint.pprint(inspectobj(django))

This is very very very basic, and you'd need to add all sorts of
conditionals in there to make it extract the information you want in a
proper, recursive fashion (and telling it how to deal with unbound methods
etc), but it's a start.

Enjoy :)

Cal



> Luka
>
> --
> 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: Django form validation.. does anyone else find it awkward??

2011-07-12 Thread Andre Terra
On Tue, Jul 12, 2011 at 2:25 PM, Venkatraman S  wrote:

>
>
> On Tue, Jul 12, 2011 at 9:12 PM, Andre Terra  wrote:
>
>> May I ask if you are managing to do this (and, if so, how) without
>>> writing duplicate logic?
>>>
>>
>> This, to me, is a key area for improvement. Aside from the development
>> challenge the idea imposes, an extra issue with writing DRY validation for
>> django and javascript is that the project doesn't officially endorse any
>> javascript library (there's been extensive discussion about this), but
>> nobody says it's not okay to write an app that uses jQuery, for example.
>>
>
>
> A probable approach would be , probably, for the form renderer to
> *automatically* clone the validation logic written in clean() to js? (!!)
>

Cloning validation from clean() would be nearly impossible, as the developer
is free to write any python code in that logic. A small, achievable step
would be adding things like required fields to a on-the-fly generated js
validator.


>
>
>> My issue with uni-form and the like is that these apps get hard to extend
>> once you find a fringe-case for your app. I tried using it once and soon
>> enough I was writing so much custom code that I decided to drop uni-form
>> altogether.
>>
>
> Can you educate us on the use-case; i am just curious.
>

I don't remember correctly as it was a long time ago, but I think it had
something to do with customizing how fieldsets were rendered, and how I
needed different html markup. I can dig up the source later if you really
want to know.


History shows good ideas *do *get implemented, and Alex Gaynor is, imho, the
>> developer to look at for examples on how to write quality django apps (for
>> instance, take a look at https://github.com/alex/django-filter/
>> which is pretty small, but
>> very django-like, even though he's not really proud of the API for that app
>> in particular)
>>
>
> An awsum app that is! I was even more excited when i looked at its code. So
> little, but so powerful!
>

It's a great app indeed, I use it on every single project now.

That's what he gets from knowing django's internals so well =)


Cheers!

-- 
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: Inspecting objects

2011-07-12 Thread Venkatraman S
On Tue, Jul 12, 2011 at 10:55 PM, Lukich  wrote:

> Hi.  I have just started diving into Django and this question came up
> - is there a way for me to examine all the attribute values of an
> object?  In Rails there's such a thing as debug statement which spits
> out all the details about the object.  From what I have seen so far in
> Django, I can either do a __unicode__() trick, but it forces me to
> specify which attribute to show.  I also read about dir() and
> __dict__, but they show me sets of attributes without their values. Is
> there something I'm missing? Thank you!
>

What would be the probable use-case?

-- 
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-12 Thread Venkatraman S
Can you please ..please...please..please record this session!?

-V

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



Inspecting objects

2011-07-12 Thread Lukich
Hi.  I have just started diving into Django and this question came up
- is there a way for me to examine all the attribute values of an
object?  In Rails there's such a thing as debug statement which spits
out all the details about the object.  From what I have seen so far in
Django, I can either do a __unicode__() trick, but it forces me to
specify which attribute to show.  I also read about dir() and
__dict__, but they show me sets of attributes without their values. Is
there something I'm missing? Thank you!
Luka

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread Venkatraman S
On Tue, Jul 12, 2011 at 9:12 PM, Andre Terra  wrote:

> May I ask if you are managing to do this (and, if so, how) without
>> writing duplicate logic?
>>
>
> This, to me, is a key area for improvement. Aside from the development
> challenge the idea imposes, an extra issue with writing DRY validation for
> django and javascript is that the project doesn't officially endorse any
> javascript library (there's been extensive discussion about this), but
> nobody says it's not okay to write an app that uses jQuery, for example.
>


A probable approach would be , probably, for the form renderer to
*automatically* clone the validation logic written in clean() to js? (!!)



> My issue with uni-form and the like is that these apps get hard to extend
> once you find a fringe-case for your app. I tried using it once and soon
> enough I was writing so much custom code that I decided to drop uni-form
> altogether.
>

Can you educate us on the use-case; i am just curious.


> History shows good ideas *do *get implemented, and Alex Gaynor is, imho,
> the developer to look at for examples on how to write quality django apps
> (for instance, take a look at https://github.com/alex/django-filter/
> which is pretty small, but very
> django-like, even though he's not really proud of the API for that app in
> particular)
>

An awsum app that is! I was even more excited when i looked at its code. So
little, but so powerful!

-V

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
Some interesting thoughts here. I once attempted to make a merge between
Django validation and jQuery validation (spent several weeks on it), but my
approach wasn't dynamic enough, and ended up not being used again.

Personally, I'd like to see some sort of standardized JS library which
works seamlessly with Django form validation, but it is an absolute PITA.

Cal

On Tue, Jul 12, 2011 at 4:42 PM, Andre Terra  wrote:

> May I ask if you are managing to do this (and, if so, how) without
>> writing duplicate logic?
>>
>
> This, to me, is a key area for improvement. Aside from the development
> challenge the idea imposes, an extra issue with writing DRY validation for
> django and javascript is that the project doesn't officially endorse any
> javascript library (there's been extensive discussion about this), but
> nobody says it's not okay to write an app that uses jQuery, for example.
>
> My issue with uni-form and the like is that these apps get hard to extend
> once you find a fringe-case for your app. I tried using it once and soon
> enough I was writing so much custom code that I decided to drop uni-form
> altogether.
>
> The issue of form validation being complex has also been discussed on
> django-developers, and I don't mind to be rude, but this kind of "wouldn't
> it be nice" discussions usually end in some core developer saying "go ahead
> and show us some code, then we can think about merging it into django".
> Django has an extensive to-do list (we're only at version 1.4!) and Keith is
> usually the first to say that unless there's code to go along with the
> proposal, there's not a lot they can do about it.
>
> History shows good ideas *do *get implemented, and Alex Gaynor is, imho,
> the developer to look at for examples on how to write quality django apps
> (for instance, take a look at https://github.com/alex/django-filter/
> which is pretty small, but very
> django-like, even though he's not really proud of the API for that app in
> particular).
>
>
> If any of you take a step into writing a better API for form validation,
> I'm sure the core devs will be more than excited to take a look at,
> considering how the current implementation is still obscure in some steps
> (or lacking sugar), e.g. self._errors["subject"] = self.error_class([msg])
>
> But first one needs to decide if he's cleaning up django's API (hard) or
> writing integrated js-python validation (harder).
>
>
> Cheers,
> André Terra
>
>
>
> On Tue, Jul 12, 2011 at 12:08 PM, Derek  wrote:
>
>>
>> On Jul 12, 10:15 am, Venkatraman S  wrote:
>> > On Tue, Jul 12, 2011 at 1:23 PM, Cal Leeming [Simplicity Media Ltd] <
>> >
>> >
>> > cal.leem...@simplicitymedialtd.co.uk> wrote:
>> > > On 12 Jul 2011 08:13, "bruno desthuilliers" <
>> bruno.desthuilli...@gmail.com>
>> > > wrote:
>> >
>> > > > On Jul 12, 3:37 am, Venkatraman S  wrote:
>> >
>> > > > > On the validation, yes, it is a little pesky. But, offlate, i am
>> trying
>> > > to
>> > > > > *understand* it better and trying to move the logic
>> > > > > to the client. For eg. jquery-validate does bulk of the stuff on
>> client
>> > > side
>> > > > > - atleast for required fields. So, moving
>> > > > > bulk of the validation to the client helps in avoiding a few http
>> > > calls.
>> >
>> > > > Client-side validation may be fine from a UX POV, but you just CAN
>> NOT
>> > > > rely on it - I mean, unless you're happy with unvalidated user
>> > > > inputs
>> >
>> > > +1
>> >
>> > True; the validation *should* be present in the server, but i am trying
>> to
>> > move the *same*
>> > validation(as much as possible) to the client *too*, so that the http
>> calls
>> > be avoided.
>>
>> May I ask if you are managing to do this (and, if so, how) without
>> writing duplicate logic?
>>
>> --
>> 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.



Duplicate Key Error in Cache

2011-07-12 Thread gamingdroid
I ran into this problem using django core's database cache:

ERROR:  duplicate key value violates unique constraint "cache_pkey"
STATEMENT:  INSERT INTO "cache" (cache_key, value, expires) VALUES (E':
1:cms-menu_nodes_en-us_1', E'gAJdcQEoY21lbnVzLmJhc2UKTmF2aW
LOG:  server process (PID 8453) was terminated by signal 9: Killed
LOG:  terminating any other active server processes
LOG:  all server processes terminated; reinitializing
FATAL:  could not create shared memory segment: Cannot allocate memory
DETAIL:  Failed system call was shmget(key=5432001, size=29278208,
03600).

I looked in the table and sure enough, there is an entry for the key ':
1:cms-menu_nodes_en-us_1'. I found a similar issue here (http://
stackoverflow.com/questions/1189541/django-cache-set-causing-duplicate-
key-error), but was unable to exactly understand what the issue is.

Sounds like a bug in django core, since if a key exist, it should
update the record. It looks as if somebody posted a ticket here
(https://code.djangoproject.com/ticket/11569), but not entireloy sure
if it is related. This problem sort of renders the database backend
useless. I would fix it if I knew how and contribute back, but really
don't know how.

Anyone have any ideas or suggestions?

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread Andre Terra
>
> May I ask if you are managing to do this (and, if so, how) without
> writing duplicate logic?
>

This, to me, is a key area for improvement. Aside from the development
challenge the idea imposes, an extra issue with writing DRY validation for
django and javascript is that the project doesn't officially endorse any
javascript library (there's been extensive discussion about this), but
nobody says it's not okay to write an app that uses jQuery, for example.

My issue with uni-form and the like is that these apps get hard to extend
once you find a fringe-case for your app. I tried using it once and soon
enough I was writing so much custom code that I decided to drop uni-form
altogether.

The issue of form validation being complex has also been discussed on
django-developers, and I don't mind to be rude, but this kind of "wouldn't
it be nice" discussions usually end in some core developer saying "go ahead
and show us some code, then we can think about merging it into django".
Django has an extensive to-do list (we're only at version 1.4!) and Keith is
usually the first to say that unless there's code to go along with the
proposal, there's not a lot they can do about it.

History shows good ideas *do *get implemented, and Alex Gaynor is, imho, the
developer to look at for examples on how to write quality django apps (for
instance, take a look at https://github.com/alex/django-filter/
which is pretty small, but very
django-like, even though he's not really proud of the API for that app in
particular).


If any of you take a step into writing a better API for form validation, I'm
sure the core devs will be more than excited to take a look at, considering
how the current implementation is still obscure in some steps (or lacking
sugar), e.g. self._errors["subject"] = self.error_class([msg])

But first one needs to decide if he's cleaning up django's API (hard) or
writing integrated js-python validation (harder).


Cheers,
André Terra


On Tue, Jul 12, 2011 at 12:08 PM, Derek  wrote:

>
> On Jul 12, 10:15 am, Venkatraman S  wrote:
> > On Tue, Jul 12, 2011 at 1:23 PM, Cal Leeming [Simplicity Media Ltd] <
> >
> >
> > cal.leem...@simplicitymedialtd.co.uk> wrote:
> > > On 12 Jul 2011 08:13, "bruno desthuilliers" <
> bruno.desthuilli...@gmail.com>
> > > wrote:
> >
> > > > On Jul 12, 3:37 am, Venkatraman S  wrote:
> >
> > > > > On the validation, yes, it is a little pesky. But, offlate, i am
> trying
> > > to
> > > > > *understand* it better and trying to move the logic
> > > > > to the client. For eg. jquery-validate does bulk of the stuff on
> client
> > > side
> > > > > - atleast for required fields. So, moving
> > > > > bulk of the validation to the client helps in avoiding a few http
> > > calls.
> >
> > > > Client-side validation may be fine from a UX POV, but you just CAN
> NOT
> > > > rely on it - I mean, unless you're happy with unvalidated user
> > > > inputs
> >
> > > +1
> >
> > True; the validation *should* be present in the server, but i am trying
> to
> > move the *same*
> > validation(as much as possible) to the client *too*, so that the http
> calls
> > be avoided.
>
> May I ask if you are managing to do this (and, if so, how) without
> writing duplicate logic?
>
> --
> 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: speeding up iterating over query set

2011-07-12 Thread Andre Terra
Have you looked at haystack?

http://haystacksearch.org/


Cheers,
André

On Tue, Jul 12, 2011 at 10:49 AM, Michel30  wrote:

> I have tried and I think I have it mostly working: it returns ALL
> unique docid's.
>
> What is left is that my code is part of a search function. Originally
> I got normalized keywords from a user and used those Q-objects to look
> for keywords in a selected set of columns.
>
> I still have to figure out how to get that into the SQL part..
>
> On Jul 12, 3:29 pm, bruno desthuilliers
>  wrote:
> > On Jul 12, 12:26 pm, Michel30  wrote:
> >
> > > Hi guys,
> >
> > > I've been trying your suggestions but I'm afraid I'm stretching the
> > > limits of my Python/Django abilities ;-)
> >
> > > Bruno got it right: what I want is a queryset of "model" with distinct
> > > docid having the highest version number, sorted by revisiondate.
> >
> > (snip)
> > > My code does this, but the loop that selects the distinct docid's is
> > > what makes it terribly slow...
> >
> > Then why don't you just try the solution(s) I posted ?
>
> --
> 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: speeding up iterating over query set

2011-07-12 Thread bruno desthuilliers
On Jul 12, 3:49 pm, Michel30  wrote:
> I have tried and I think I have it mostly working: it returns ALL
> unique docid's.
>
> What is left is that my code is part of a search function. Originally
> I got normalized keywords from a user and used those Q-objects to look
> for keywords in a selected set of columns.
>
> I still have to figure out how to get that into the SQL part..

With the 2-fold solution I suggested (raw SQL query to retrieve latest
revisions then "normal" ORM query) you may not have to "get that into
the SQL part" - just use it in the second "normal" ORM query.

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread Derek

On Jul 12, 10:15 am, Venkatraman S  wrote:
> On Tue, Jul 12, 2011 at 1:23 PM, Cal Leeming [Simplicity Media Ltd] <
>
>
> cal.leem...@simplicitymedialtd.co.uk> wrote:
> > On 12 Jul 2011 08:13, "bruno desthuilliers" 
> > wrote:
>
> > > On Jul 12, 3:37 am, Venkatraman S  wrote:
>
> > > > On the validation, yes, it is a little pesky. But, offlate, i am trying
> > to
> > > > *understand* it better and trying to move the logic
> > > > to the client. For eg. jquery-validate does bulk of the stuff on client
> > side
> > > > - atleast for required fields. So, moving
> > > > bulk of the validation to the client helps in avoiding a few http
> > calls.
>
> > > Client-side validation may be fine from a UX POV, but you just CAN NOT
> > > rely on it - I mean, unless you're happy with unvalidated user
> > > inputs
>
> > +1
>
> True; the validation *should* be present in the server, but i am trying to
> move the *same*
> validation(as much as possible) to the client *too*, so that the http calls
> be avoided.

May I ask if you are managing to do this (and, if so, how) without
writing duplicate logic?

-- 
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: speeding up iterating over query set

2011-07-12 Thread Michel30
I have tried and I think I have it mostly working: it returns ALL
unique docid's.

What is left is that my code is part of a search function. Originally
I got normalized keywords from a user and used those Q-objects to look
for keywords in a selected set of columns.

I still have to figure out how to get that into the SQL part..

On Jul 12, 3:29 pm, bruno desthuilliers
 wrote:
> On Jul 12, 12:26 pm, Michel30  wrote:
>
> > Hi guys,
>
> > I've been trying your suggestions but I'm afraid I'm stretching the
> > limits of my Python/Django abilities ;-)
>
> > Bruno got it right: what I want is a queryset of "model" with distinct
> > docid having the highest version number, sorted by revisiondate.
>
> (snip)
> > My code does this, but the loop that selects the distinct docid's is
> > what makes it terribly slow...
>
> Then why don't you just try the solution(s) I posted ?

-- 
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: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
Hi all,

Great response to this, 45 registered votes in total.

The webcast will take place on Monday 29th August 2011 - (Minimum resolution
1920x1080)

However, because the time zone results are almost split 50/50, I'm going to
allow users to select from two time slots, if the results are still split
50/50, then I'll do both an afternoon and evening session.

Please use this form to register your place.
https://spreadsheets.google.com/a/foxwhisper.co.uk/spreadsheet/viewform?formkey=dENPX3BMUUFMbi1CbElwV3BvOEdkNmc6MQ

Cal

-- 
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: Problem with user.username

2011-07-12 Thread Tom Evans
On Tue, Jul 12, 2011 at 2:25 PM, bruno desthuilliers
 wrote:
> On Jul 12, 3:07 pm, Tom Evans  wrote:
> (snip)
>> Programming by permutation is never a good strategy.
>
> Indeed. Yet:
>
>> A typical view using RequestContext and render_to_response should look
>> like this:
>>
>> def someview(request):
>>   ctxt = RequestContext({
>>     'hello': 'world',
>>   })
>>   return render_to_response('sometemplate.html', context_instance=ctxt)
>
> which is NOT what you'll find in django's doc nor in about 99+% of the
> available snippets, pluggable apps and other available source code
> examples which all use the same pattern as the OP.
>

Looks exactly like the example from [1], apart from using
render_to_response shortcut rather than manually rendering the
template.

Cheers

Tom

[1] 
https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext

-- 
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: speeding up iterating over query set

2011-07-12 Thread bruno desthuilliers
On Jul 12, 12:26 pm, Michel30  wrote:
> Hi guys,
>
> I've been trying your suggestions but I'm afraid I'm stretching the
> limits of my Python/Django abilities ;-)
>
> Bruno got it right: what I want is a queryset of "model" with distinct
> docid having the highest version number, sorted by revisiondate.
>
(snip)
> My code does this, but the loop that selects the distinct docid's is
> what makes it terribly slow...

Then why don't you just try the solution(s) I posted ?

-- 
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: Problem with user.username

2011-07-12 Thread Tom Evans
On Tue, Jul 12, 2011 at 2:07 PM, Tom Evans  wrote:
> On Tue, Jul 12, 2011 at 1:41 PM, nicolas HERSOG  wrote:
>> Hi !
>>
>> It's very strange, i just found a way to solve my probleme but i don't have
>> 'django.core.context_processors.request' in my TEMPLATE_CONTEXT_PROCESSORS.
>>
>> For solve my problem i added in my views.py :
>> from django.shortcuts import render_to_response
>>
>> this is my previous index views who didn t work :
>>
>>  def index(request):
>>  videos = Video.objects.all()
>>  t = loader.get_template('myFront/index.html')
>>  c = Context({
>>  'datas': datas,
>>  })
>>  return HttpResponse(t.render(c))
>>
>> and this is the solving one :
>>  def index(request):
>>  videos = Video.objects.all()
>>  t = loader.get_template('myFront/index.html')
>>  c = Context({
>>  'datas': datas,
>>  })
>>
>>  return render_to_response('empireFront/index.html', c,
>> context_instance=RequestContext(request))
>>
>> Is a a correct way to do in Django ?
>>
>> I'ill try your solution too,
>>
>> Thx :)
>>
>
> Programming by permutation is never a good strategy.
> render_to_response() takes 4 arguments[1]
>
> render_to_response(template_name[, dictionary][, context_instance][, 
> mimetype])
>
> In your 'working but no idea why' example, you are providing a Context
> as the dictionary, which works as contexts are dict-like in their
> nature, and a RequestContext (with no values) as the context. The
> contents of the supplied dictionary are merged* into the context.
>
> A typical view using RequestContext and render_to_response should look
> like this:
>
> def someview(request):
>  ctxt = RequestContext({
>    'hello': 'world',
>  })
>  return render_to_response('sometemplate.html', context_instance=ctxt)

I did this from memory, and omitted the very important first argument
to RequestContext (doh!). It should look like this:

def someview(request):
  ctxt = RequestContext(request, {
'hello': 'world',
  })
 return render_to_response('sometemplate.html', context_instance=ctxt)

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Problem with user.username

2011-07-12 Thread bruno desthuilliers
On Jul 12, 3:07 pm, Tom Evans  wrote:
(snip)
> Programming by permutation is never a good strategy.

Indeed. Yet:

> A typical view using RequestContext and render_to_response should look
> like this:
>
> def someview(request):
>   ctxt = RequestContext({
>     'hello': 'world',
>   })
>   return render_to_response('sometemplate.html', context_instance=ctxt)

which is NOT what you'll find in django's doc nor in about 99+% of the
available snippets, pluggable apps and other available source code
examples which all use the same pattern as the OP.

I'm not the last to be somewhat vocal about antipatterns and bad form
and I totally agree on your comment about programming by permutation,
but whether you use one or another (both legal) form to call
render_to_response is a matter of personal preference.

FWIW, I prefer the "canonical" way which let me build my context dict
outside of the call to render_to_response ;)

-- 
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: Problem with user.username

2011-07-12 Thread nicolas HERSOG
Thx !

I'll read this and try to implement the "right way" :)

thx Tom

On Tue, Jul 12, 2011 at 3:07 PM, Tom Evans  wrote:

> On Tue, Jul 12, 2011 at 1:41 PM, nicolas HERSOG 
> wrote:
> > Hi !
> >
> > It's very strange, i just found a way to solve my probleme but i don't
> have
> > 'django.core.context_processors.request' in my
> TEMPLATE_CONTEXT_PROCESSORS.
> >
> > For solve my problem i added in my views.py :
> > from django.shortcuts import render_to_response
> >
> > this is my previous index views who didn t work :
> >
> >  def index(request):
> >  videos = Video.objects.all()
> >  t = loader.get_template('myFront/index.html')
> >  c = Context({
> >  'datas': datas,
> >  })
> >  return HttpResponse(t.render(c))
> >
> > and this is the solving one :
> >  def index(request):
> >  videos = Video.objects.all()
> >  t = loader.get_template('myFront/index.html')
> >  c = Context({
> >  'datas': datas,
> >  })
> >
> >  return render_to_response('empireFront/index.html', c,
> > context_instance=RequestContext(request))
> >
> > Is a a correct way to do in Django ?
> >
> > I'ill try your solution too,
> >
> > Thx :)
> >
>
> Programming by permutation is never a good strategy.
> render_to_response() takes 4 arguments[1]
>
> render_to_response(template_name[, dictionary][, context_instance][,
> mimetype])
>
> In your 'working but no idea why' example, you are providing a Context
> as the dictionary, which works as contexts are dict-like in their
> nature, and a RequestContext (with no values) as the context. The
> contents of the supplied dictionary are merged* into the context.
>
> A typical view using RequestContext and render_to_response should look
> like this:
>
> def someview(request):
>  ctxt = RequestContext({
>'hello': 'world',
>  })
>  return render_to_response('sometemplate.html', context_instance=ctxt)
>
> It is therefore pointless to provide a Context as the dictionary
> parameter, and an empty RequestContext as the context parameter.
>
> Cheers
>
> Tom
>
> [1]
> https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render-to-response
>
> * Not really. Contexts actually have a stack of dictionaries, and
> works down through the stack to resolve a variable used in a template.
> It is easier to think of it as merging them though.
>
> --
> 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: Problem with user.username

2011-07-12 Thread Tom Evans
On Tue, Jul 12, 2011 at 1:41 PM, nicolas HERSOG  wrote:
> Hi !
>
> It's very strange, i just found a way to solve my probleme but i don't have
> 'django.core.context_processors.request' in my TEMPLATE_CONTEXT_PROCESSORS.
>
> For solve my problem i added in my views.py :
> from django.shortcuts import render_to_response
>
> this is my previous index views who didn t work :
>
>  def index(request):
>  videos = Video.objects.all()
>  t = loader.get_template('myFront/index.html')
>  c = Context({
>  'datas': datas,
>  })
>  return HttpResponse(t.render(c))
>
> and this is the solving one :
>  def index(request):
>  videos = Video.objects.all()
>  t = loader.get_template('myFront/index.html')
>  c = Context({
>  'datas': datas,
>  })
>
>  return render_to_response('empireFront/index.html', c,
> context_instance=RequestContext(request))
>
> Is a a correct way to do in Django ?
>
> I'ill try your solution too,
>
> Thx :)
>

Programming by permutation is never a good strategy.
render_to_response() takes 4 arguments[1]

render_to_response(template_name[, dictionary][, context_instance][, mimetype])

In your 'working but no idea why' example, you are providing a Context
as the dictionary, which works as contexts are dict-like in their
nature, and a RequestContext (with no values) as the context. The
contents of the supplied dictionary are merged* into the context.

A typical view using RequestContext and render_to_response should look
like this:

def someview(request):
  ctxt = RequestContext({
'hello': 'world',
  })
  return render_to_response('sometemplate.html', context_instance=ctxt)

It is therefore pointless to provide a Context as the dictionary
parameter, and an empty RequestContext as the context parameter.

Cheers

Tom

[1] 
https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render-to-response

* Not really. Contexts actually have a stack of dictionaries, and
works down through the stack to resolve a variable used in a template.
It is easier to think of it as merging them though.

-- 
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: Problem with user.username

2011-07-12 Thread nicolas HERSOG
Hi !

It's very strange, i just found a way to solve my probleme but i don't have
'django.core.context_processors.request' in my TEMPLATE_CONTEXT_PROCESSORS.

For solve my problem i added in my views.py :
from django.shortcuts import render_to_response

this is my previous index views who didn t work :

 def index(request):
 videos = Video.objects.all()
 t = loader.get_template('myFront/index.html')
 c = Context({
 'datas': datas,
 })
 return HttpResponse(t.render(c))

and this is the solving one :
 def index(request):
 videos = Video.objects.all()
 t = loader.get_template('myFront/index.html')
 c = Context({
 'datas': datas,
 })

 return render_to_response('empireFront/index.html', c,
context_instance=RequestContext(request))

Is a a correct way to do in Django ?

I'ill try your solution too,

Thx :)





On Tue, Jul 12, 2011 at 12:33 PM, Kenneth Gonsalves
wrote:

> On Mon, 2011-07-11 at 23:31 -0700, Suprnaturall wrote:
> > The problem is : when i m in login.html i see my user.username, but
> > when i submit the login form and being redirect to index i don t
> > retrieve the user.username.
>
> do you have this in your settings.py:
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>'django.core.context_processors.request',
>...
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.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.
>
>

-- 
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: block bots and spiders

2011-07-12 Thread Phang Mulianto
yes Bruno, that's what i mean, so this is doable.. and also can prevent DDOS
attack to your core web server...

On Tue, Jul 12, 2011 at 6:28 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Jul 12, 11:57 am, Phang Mulianto  wrote:
> > hi..
> >
> > why not block the spiders in the web server environtment .
> > i think it is better than has to put the code in the apps.
> >
> > is it possible ? because i had read that some web server can block
> > unnecesary request before reach the real web server..like nginx,
> lighttpd,
> > etc..
>
>
> On Apache I'm using mod_rewrite to block bad-behaving bots.
>
> --
> 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: Django example for searching in address book with over 1000 entries

2011-07-12 Thread Venkatraman S
On Tue, Jul 12, 2011 at 4:23 PM, Gelonida N  wrote:

>
> I'd like to implement a simple django address book Application with over
> 1000 entries.
>
> I'm still struggling whether (and if yes how) to use Ajax or not
> for searching a contact.
>
> Ideally I would start filtering the entries while typing a name in the
> search field)
>
>
> I'd like to use the application from a smart phone the network might be
> slow and searching a person shouldn't be too sluggish.
>
> Does anyone have recommendations / suggestions a pointer to a sample app
> / tuytorial doing something similiar?
>
>
Try out a combo of ajax-selects and django-filters;
otherwise handcode this using jquery - its pretty simple (can take some
inspiration from ajax-selects).

-V

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



Django example for searching in address book with over 1000 entries

2011-07-12 Thread Gelonida N
Hi,


I'd like to implement a simple django address book Application with over
1000 entries.

I'm still struggling whether (and if yes how) to use Ajax or not
for searching a contact.

Ideally I would start filtering the entries while typing a name in the
search field)


I'd like to use the application from a smart phone the network might be
slow and searching a person shouldn't be too sluggish.

Does anyone have recommendations / suggestions a pointer to a sample app
/ tuytorial doing something similiar?

Thanks in advance






-- 
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: Problem with user.username

2011-07-12 Thread Kenneth Gonsalves
On Mon, 2011-07-11 at 23:31 -0700, Suprnaturall wrote:
> The problem is : when i m in login.html i see my user.username, but
> when i submit the login form and being redirect to index i don t
> retrieve the user.username. 

do you have this in your settings.py:

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.request',
...
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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: block bots and spiders

2011-07-12 Thread bruno desthuilliers
On Jul 12, 11:57 am, Phang Mulianto  wrote:
> hi..
>
> why not block the spiders in the web server environtment .
> i think it is better than has to put the code in the apps.
>
> is it possible ? because i had read that some web server can block
> unnecesary request before reach the real web server..like nginx, lighttpd,
> etc..


On Apache I'm using mod_rewrite to block bad-behaving bots.

-- 
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: speeding up iterating over query set

2011-07-12 Thread Michel30
Hi guys,

I've been trying your suggestions but I'm afraid I'm stretching the
limits of my Python/Django abilities ;-)

Bruno got it right: what I want is a queryset of "model" with distinct
docid having the highest version number, sorted by revisiondate.

If have the following result of my
found_entries = model.objects.filter((Q-
objects),obsolete=0).order_by('-version','docid') :

++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  1 | 1 |   1 | 2000-02-10   |
|  2 | 2 |   1 | 2000-02-11   |
|  3 | 3 |   1 | 2000-02-12   |
|  4 | 3 |   3 | 2000-02-13   |
|  5 | 2 |   3 | 2000-02-14   |
|  6 | 1 |   3 | 2000-02-15   |
++---+-+--+

Then I want to retrieve only these results, sorted on revisiondate:

++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  6 | 1 |   3 | 2000-02-15   |
|  5 | 2 |   3 | 2000-02-14   |
|  4 | 3 |   3 | 2000-02-13   |
++---+-+--+

My code does this, but the loop that selects the distinct docid's is
what makes it terribly slow...

Hope this clarifies it.

-- 
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: speeding up iterating over query set

2011-07-12 Thread Michel30
Hi guys,

I've been trying your suggestions but I'm afraid I'm stretching the
limits of my Python/Django abilities ;-)

Bruno got it right: what I want is a queryset of "model" with distinct
docid having the highest version number, sorted by revisiondate.

If have the following result of my
found_entries = model.objects.filter((Q-
objects),obsolete=0).order_by('-version','docid') :

++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  1 | 1 |   1 | 2000-02-10   |
|  2 | 2 |   1 | 2000-02-11   |
|  3 | 3 |   1 | 2000-02-12   |
|  4 | 3 |   3 | 2000-02-13   |
|  5 | 2 |   3 | 2000-02-14   |
|  6 | 1 |   3 | 2000-02-15   |
++---+-+--+

Then I want to retrieve only these results, sorted on revisiondate:

++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  6 | 1 |   3 | 2000-02-15   |
|  5 | 2 |   3 | 2000-02-14   |
|  4 | 3 |   3 | 2000-02-13   |
++---+-+--+

My code does this, but the loop that selects the distinct docid's is
what makes it terribly slow...

Hope this clarifies it.

-- 
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: speeding up iterating over query set

2011-07-12 Thread Michel30
Hi guys,

I've been trying your suggestions but I'm afraid I'm stretching the
limits of my Python/Django abilities ;-)

Bruno got it right: what I want is a queryset of "model" with distinct
docid having the highest version number, sorted by revisiondate.

If have the following result of my
found_entries = model.objects.filter((Q-
objects),obsolete=0).order_by('-version','docid') :

++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  1 | 1 |   1 | 2000-02-10   |
|  2 | 2 |   1 | 2000-02-11   |
|  3 | 3 |   1 | 2000-02-12   |
|  4 | 3 |   3 | 2000-02-13   |
|  5 | 2 |   3 | 2000-02-14   |
|  6 | 1 |   3 | 2000-02-15   |
++---+-+--+

Then I want to retrieve only these results, sorted on revisiondate:

++---+-+--+
| pk | docid | version | revisiondate |
++---+-+--+
|  6 | 1 |   3 | 2000-02-15   |
|  5 | 2 |   3 | 2000-02-14   |
|  4 | 3 |   3 | 2000-02-13   |
++---+-+--+

My code does this, but the loop that selects the distinct docid's is
what makes it terribly slow...

Hope this clarifies it.

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



Problem with user.username

2011-07-12 Thread Suprnaturall
Hi,

First of all, apologize me for my poor, poor english.

I m new with django and i m stuck with a odd thing.

I created a login form and use the default django login handlet like
this :

base.html :
(...)   {% if user.is_authenticated %}
{{user.username }}
{% else %}
Login
{% endif %}
log outYour username and password didn't match. Please try again.
{% endif %}


{% csrf_token %}


{{ form.username.label_tag }}
{{ form.username }}


{{ form.password.label_tag }}
{{ form.password }}






{% endblock %}


The problem is : when i m in login.html i see my user.username, but
when i submit the login form and being redirect to index i don t
retrieve the user.username.
I add in my views.py this import :
from django.template import Context, loader, RequestContext
from empireFront.models import Video
from django.http import HttpResponse
from django.contrib import auth
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User
from django.http import HttpResponseRedirect
from django.contrib.sessions.models import Session

I heard something about use render_to_response but when, where and
how ?

Thx for your help !



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



Info Needed: Sprints at DjangoCon 2011

2011-07-12 Thread Shubhanan Bakre
Hi,

This will be my first year at DjangoCon and I wanted to know regarding
activities that happen during sprints.
Thanks and Regards,
Shubhanan Bakre

-- 
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: Using the mailing list

2011-07-12 Thread Kenneth Gonsalves
On Tue, 2011-07-12 at 08:42 +0100, Cal Leeming [Simplicity Media Ltd]
wrote:
> Oh, that's a good idea. I can probably do a write up about CodeIgniter
> and
> PHP. Also, perhaps this deserves a wiki page of its own..? 

let's see how it goes - if it gets big enough we can separate it. 
-- 
regards
KG
http://lawgon.livejournal.com
Coimbatore LUG rox
http://ilugcbe.techstud.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: block bots and spiders

2011-07-12 Thread Phang Mulianto
hi..

why not block the spiders in the web server environtment .
i think it is better than has to put the code in the apps.

is it possible ? because i had read that some web server can block
unnecesary request before reach the real web server..like nginx, lighttpd,
etc..



On Tue, Jul 12, 2011 at 5:38 PM, Jonas Geiregat  wrote:

>
>
> > Hi all,
> >
> > has someone an effective way to block away bots and spiders?
> > There are so many ignoring robots.txt - besides facebook and tons of
> > Java/xyz clients there are many more illegal spiders around.
> >
> > So does anyone have a performance effective way to block them out?
> > Or do you think - if performance matters, leave them crawling...
> >
> > regards
> >
> > Henrik
>
> The only thing I can think of is checking the request.META dictionary. It
> contains the HTTP_HOST and HTTP_USER_AGENT settings by the client. You could
> check if those are valid but of course a spider could fake those values. But
> I'm guessing not all spiders fake them.
> You could at least filter out those that don't set these values.
>
> It would probably require lot's of heavy regular expression code (since
> there are so many valid client headers) which would be best implemented as a
> decorator on each view method.  Or you could probably put the code in a
> middleware.
> Eventually taking out those spiders would slow down your request.
>
> Again I have no experience on this field, it's just an idea that might be
> possible.
>
> Regards,
>
> Jonas.
>
> --
> 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: request.method GET or POST

2011-07-12 Thread Masklinn
On 2011-07-12, at 07:04 , Venkatraman S wrote:
> Comments? (note that i am not passing request object to individual doPOST or
> doGET).
You can trivially do that by using callable objects as views, with a common 
superclass for dispatching.

class MethodView(object):
def __call__(self, request, *args, **kwargs):
try:
return getattr(self, request.method)(request, *args, **kwargs)
except AttributeError:
# status 405: method not allowed

GET requests will call the GET method, POST request the POST method, etc…

Note that this behavior is implemented by Django's own 
`django.views.generic.base.View` in 1.3 (although it lowercases the method 
names before calling them, to better fit Python standards), so you can inherit 
from that class and get the same result without writing your own superclass. It 
also provides a default 405 METHOD NOT ALLOWED implementation which can be 
overridden.

A small difference is that request, args and kwargs are set as instance members 
of the view, they're not passed along.

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

2011-07-12 Thread Tom Evans
On Tue, Jul 12, 2011 at 10:23 AM, Jonas Geiregat  wrote:
> Hello,
>
> I really love django's documentation. It covers a lot of ground and is really 
> well written.
> I do have one problem with it. It might be best explained with an example.
>
> I want to see all methods and properties of the request parameter in the 
> view. Search the docs for "request" doesn't help me much. In fact searching 
> the docs for a particular method often doesn't point me to the correct page.
>
> What I sometimes need is a tree view of all django's modules, classes, 
> methods and properties. It also might help me better understand the structure 
> of how django was written.
>
> Is there something like that out there ?

Not really. You can run epydoc over the django source to generate such
a view if you want.

I believe that this is not offered by design; by offering internal API
docs, people will then start to use previously 'undocumented' APIs,
which then need to be supported. Basically, if you can find a
reference to a function/class/attribute in the django docs at the
moment, that function/class/attribute will be there in the next
version, or will be discussed in the change log.

This allows things like the internal SQL compiler to be changed
significantly between 1.2 and 1.3 without any noticeable effects on
users.

The easiest way to investigate what attributes/methods a class has is
to read the source. HttpRequest is here:
https://code.djangoproject.com/browser/django/tags/releases/1.3/django/http/__init__.py

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: block bots and spiders

2011-07-12 Thread Jonas Geiregat


> Hi all,
> 
> has someone an effective way to block away bots and spiders?
> There are so many ignoring robots.txt - besides facebook and tons of
> Java/xyz clients there are many more illegal spiders around.
> 
> So does anyone have a performance effective way to block them out?
> Or do you think - if performance matters, leave them crawling...
> 
> regards
> 
> Henrik

The only thing I can think of is checking the request.META dictionary. It 
contains the HTTP_HOST and HTTP_USER_AGENT settings by the client. You could 
check if those are valid but of course a spider could fake those values. But 
I'm guessing not all spiders fake them.
You could at least filter out those that don't set these values.

It would probably require lot's of heavy regular expression code (since there 
are so many valid client headers) which would be best implemented as a 
decorator on each view method.  Or you could probably put the code in a 
middleware.
Eventually taking out those spiders would slow down your request.

Again I have no experience on this field, it's just an idea that might be 
possible.

Regards,

Jonas.

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

2011-07-12 Thread Thomas Guettler


On 12.07.2011 11:23, Jonas Geiregat wrote:
> Hello,
> 
> I really love django's documentation. It covers a lot of ground and is really 
> well written. 
> I do have one problem with it. It might be best explained with an example.
> 
> I want to see all methods and properties of the request parameter in the 
> view. Search the docs for "request" doesn't help me much. In fact searching 
> the docs for a particular method often doesn't point me to the correct page.
> 
> What I sometimes need is a tree view of all django's modules, classes, 
> methods and properties. It also might help me better understand the structure 
> of how django was written.
> 
> Is there something like that out there ?

Hi,

sometimes I use this, to get all attributes of an object:
assert False, dir(object_to_debug)

and if you really want to know what's going on, you can read the source. In
your example django/http/__init__.py has the Request class. You are
free to add logging.info() or assert to the django code.

There was a ticket about automatically created API reference:

  https://code.djangoproject.com/ticket/1248

In my company some developer started to create api documentation with epydoc 
for django. AFAIK they
never used it much, I guess it took more time to configure epydoc, than time was
spent to read the created stuff.

  Thomas


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

-- 
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: request.method GET or POST

2011-07-12 Thread Jonas Geiregat

Op 12-jul-2011, om 07:04 heeft Venkatraman S het volgende geschreven:

> We have to check for request.method to suitably route the request to the 
> logic.
> 
> Would it be nice if we have something like doGet or doPost(similar to java 
> servlets) that we have in our views,
> so that the request gets automatically routed , and the code is structured 
> nicely?
> 
> So a view would look like:
> def funcname(request,itemid,..):
>   def doPOST():
> #.do things when the request is POST
>   def doGET():
> #.do things when the request is GET..
> 

How would that be different from doing something like

@require_http_methods(["GET", "POST"])
def funcname(request, itemid):
if request.method == 'POST':
# do something

 #We can savely assume it's a GET request since it's not a POST request and 
those are the only two allowed
# do something 


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



Django API

2011-07-12 Thread Jonas Geiregat
Hello,

I really love django's documentation. It covers a lot of ground and is really 
well written. 
I do have one problem with it. It might be best explained with an example.

I want to see all methods and properties of the request parameter in the view. 
Search the docs for "request" doesn't help me much. In fact searching the docs 
for a particular method often doesn't point me to the correct page.

What I sometimes need is a tree view of all django's modules, classes, methods 
and properties. It also might help me better understand the structure of how 
django was written.

Is there something like that out there ?

Regards,

Jonas Geiregat
jo...@geiregat.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: Django Knowledge Strorehouse

2011-07-12 Thread Derek
"""
On Jul 10, 5:34 pm, "Cal Leeming [Simplicity Media Ltd]"
 wrote:
 Sadly, with all the extra projects I'm working on atm, it would just
sit in
 my todo list for at least 3-6 months :(

 On Sun, Jul 10, 2011 at 3:59 PM, Jacob Kaplan-Moss
wrote:
 [If you want to add search to the community aggregator that'd make me
 very happy; it's been on my todo list for ages...]
"""

And, sadly, folks here we get to the real meat of the issue - the
really clever guys with really clever ideas are way too busy
implementing all the other clever ideas they have.  This is *not* in
any way a criticism of them - all of us are busy - but a Fact of Life
when it comes to open source projects: number of ideas >> number of
resources to implement them.   Conclusion - think big but start small;
as far as possible build on what is already there so as to leverage
the contribution you can make!

-- 
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: Emailing submitted forms

2011-07-12 Thread Derek
> >     As the form is quite long I don't want to maintain a
> >     field-after-field html template for the results.
>
> >     Is there any convenient way to do this?
>
> > Iterate over the fields in the form in an email template and send that
> > template over?
>
> Hmm, yes, that'll do. I was hoping for getting away without the iteration.
>
Hmm. I would have said iteration *is* the most convenient way of doing
this.  That adds one line to the code.  Any simpler and you'll need to
invoke magic ;)

-- 
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: get all objects that are related to current, reverse look up

2011-07-12 Thread Marc Aymerich
On Tue, Jul 12, 2011 at 4:32 AM, garagefan  wrote:
> simply put, here's my code
>
> class ContentBlock(Orderable, Displayable):
>  location = models.ManyToManyField(ContentBlockLocation, blank=True,
> null=True, help_text="list of locations to display content block")
>  page = models.ManyToManyField(Page, blank=True, null=True,
> help_text="list of pages to display content block")
>  height = models.IntegerField(blank=True, null=True)
>  width = models.IntegerField(blank=True, null=True)
>
>  def __unicode__(self):
>    return self.title
>
>
> class StaticContent(Displayable, RichText):
>  content_block =  models.ForeignKey(ContentBlock, blank=True,
> null=True)
>
> class StaticContent2(Displayable, RichText):
>  content_block =  models.ForeignKey(ContentBlock, blank=True,
> null=True)
>
> putting together a template tag that will return all the items
> associated with a given ContentBlock, but i would like to do so
> without knowing upfront all of the classes that have a foreign key to
> ContentBlock as i'll want to be able to add more content types at any
> time
>

Hi. I think something like this is what you need:

obj = ContentBlock(pk=1)
for related in obj._meta.get_all_related_objects():
model = related.model
field = related.field
if related.parent_model == ContentBlock:
for rel_object in model.objects.filter(**{'%s' % (field.name): obj}):
 #rel_object is what you want
-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django-variables

2011-07-12 Thread Derek
On Jul 9, 9:41 am, sandeep kaur  wrote:
> I want to make some of my data in django-templates, variable. And
> separate single file to define the variables. How can I do this?

This is a common occurrence for Django - start with the overview here:
http://www.djangobook.com/en/2.0/chapter04/

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread Venkatraman S
On Tue, Jul 12, 2011 at 1:23 PM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> On 12 Jul 2011 08:13, "bruno desthuilliers" 
> wrote:
> >
> > On Jul 12, 3:37 am, Venkatraman S  wrote:
> > >
> > > On the validation, yes, it is a little pesky. But, offlate, i am trying
> to
> > > *understand* it better and trying to move the logic
> > > to the client. For eg. jquery-validate does bulk of the stuff on client
> side
> > > - atleast for required fields. So, moving
> > > bulk of the validation to the client helps in avoiding a few http
> calls.
> >
> > Client-side validation may be fine from a UX POV, but you just CAN NOT
> > rely on it - I mean, unless you're happy with unvalidated user
> > inputs
>
> +1
>

True; the validation *should* be present in the server, but i am trying to
move the *same*
validation(as much as possible) to the client *too*, so that the http calls
be avoided.

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



block bots and spiders

2011-07-12 Thread Henrik Genssen
Hi all,

has someone an effective way to block away bots and spiders?
There are so many ignoring robots.txt - besides facebook and tons of
Java/xyz clients there are many more illegal spiders around.

So does anyone have a performance effective way to block them out?
Or do you think - if performance matters, leave them crawling...

regards

Henrik

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
On 12 Jul 2011 08:13, "bruno desthuilliers" 
wrote:
>
> On Jul 12, 3:37 am, Venkatraman S  wrote:
> >
> > On the validation, yes, it is a little pesky. But, offlate, i am trying
to
> > *understand* it better and trying to move the logic
> > to the client. For eg. jquery-validate does bulk of the stuff on client
side
> > - atleast for required fields. So, moving
> > bulk of the validation to the client helps in avoiding a few http calls.
>
> Client-side validation may be fine from a UX POV, but you just CAN NOT
> rely on it - I mean, unless you're happy with unvalidated user
> inputs

+1

>
> --
> 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: Using the mailing list

2011-07-12 Thread Cal Leeming [Simplicity Media Ltd]
Oh, that's a good idea. I can probably do a write up about CodeIgniter and
PHP. Also, perhaps this deserves a wiki page of its own..?
On 12 Jul 2011 04:08, "Kenneth Gonsalves"  wrote:
> hi,
>
> I think this deserves a thread of it's own. I have started a section on
> migrating from other frameworks - since I came from Zope, I have added a
> few points there. People from other frameworks/tools please pitch in.
>
>
https://code.djangoproject.com/wiki/UsingTheMailingList#Migratingfromotherframeworkstools
> --
> regards
> KG
> http://lawgon.livejournal.com
> Coimbatore LUG rox
> http://ilugcbe.techstud.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.
>

-- 
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: get all objects that are related to current, reverse look up

2011-07-12 Thread bruno desthuilliers
On Jul 12, 4:32 am, garagefan  wrote:
> simply put, here's my code
>
> class ContentBlock(Orderable, Displayable):
>   location = models.ManyToManyField(ContentBlockLocation, blank=True,
> null=True, help_text="list of locations to display content block")
>   page = models.ManyToManyField(Page, blank=True, null=True,
> help_text="list of pages to display content block")
>   height = models.IntegerField(blank=True, null=True)
>   width = models.IntegerField(blank=True, null=True)
>
>   def __unicode__(self):
>     return self.title
>
> class StaticContent(Displayable, RichText):
>  content_block =  models.ForeignKey(ContentBlock, blank=True,
> null=True)
>
> class StaticContent2(Displayable, RichText):
>  content_block =  models.ForeignKey(ContentBlock, blank=True,
> null=True)
>
> putting together a template tag that will return all the items
> associated with a given ContentBlock, but i would like to do so
> without knowing upfront all of the classes that have a foreign key to
> ContentBlock as i'll want to be able to add more content types at any
> time


Are you sure your data model is right ?

-- 
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 form validation.. does anyone else find it awkward??

2011-07-12 Thread bruno desthuilliers
On Jul 12, 3:37 am, Venkatraman S  wrote:
>
> On the validation, yes, it is a little pesky. But, offlate, i am trying to
> *understand* it better and trying to move the logic
> to the client. For eg. jquery-validate does bulk of the stuff on client side
> - atleast for required fields. So, moving
> bulk of the validation to the client helps in avoiding a few http calls.

Client-side validation may be fine from a UX POV, but you just CAN NOT
rely on it - I mean, unless you're happy with unvalidated user
inputs

-- 
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: request.method GET or POST

2011-07-12 Thread bruno desthuilliers
On Jul 12, 7:04 am, Venkatraman S  wrote:
> We have to check for request.method to suitably route the request to the
> logic.
>
> Would it be nice if we have something like doGet or doPost(similar to java
> servlets) that we have in our views,
> so that the request gets automatically routed , and the code is structured
> nicely?

Most often than not, there's common code before and after the
request.method specific branches, so handling both in a same
function / method makes sense. But if you want automatic
request.method-based dispatch, that quite easy to implement, using
either a class-based view and/or a custom decorator working the same
way as the Python builtin property type works for getter and setter.

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