Efficiently querying db

2011-07-13 Thread Amit Sethi
I have a db that looks something like this . { message : xyz parent : 23 id : 25 } or { message : abc parent : None id : 25 } { message : cde parent : 28 id : 32 } { message : lbq parent : 23 id : 35 } I want to make seperate the lists such that messages in same thread( The parent message a

Re: Simple example of custom user profile fields?

2011-07-13 Thread i...@webbricks.co.uk
if i can extend the user model, anybody should be able to. i followed james bennett example. in fact most of the clever stuff i do came from his tuts http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ at this point, i'd suggest a clean virtualenv, with a single app, single

Re: Simple example of custom user profile fields?

2011-07-13 Thread i...@webbricks.co.uk
read the paragraph on the AUTH_PROFILE_MODULE in james blog. especially understand you're pointing it at a modelname, but that it knows its a model caught me out once upon a time and might be your issue. Matt On Jul 13, 3:57 am, Brent wrote: > Unfortunately, no matter what kind of path I pu

failed to run PROJ/manage.py in zip file

2011-07-13 Thread Robert Nie
Hi, I would like to compress my DJANGO project into one zip file (all *.pyo files) and then do basic testing and deploy. Now I found PROJ/ manage.py in zip file can not be invoked. It seems it is caused by imp.find_module() failed to find the 'settings' module. The code looks like this, >>> impo

Re: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-13 Thread AlexH
> If you're interested, please reply on-list so others can see. Would be very interested in attending. Thanks! -- 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-user

Handling Efficiency issues

2011-07-13 Thread Amit Sethi
Hi all for some reason i am doing something like this for i in Message.objects.all(): i.read_at = datetime.now() i.save() now the number of Message instances are likely to increase by a lot with time . My question is is it likely that this code piece will become very slow over tim

Re: Possible interest in a webcast/presentation about Django site with 40mil+ rows of data??

2011-07-13 Thread Andre Terra
Unfortunately, I'm on GMT-0300 and none of those timezones work for me. Looking forward to the recorded version, though! Cheers, André On Tue, Jul 12, 2011 at 10:48 AM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: > Hi all, > > Great response to this, 45 regi

Re: Duplicate Key Error in Cache

2011-07-13 Thread Andre Terra
And memcached isn't hard to setup at all! Cheers, André On Tue, Jul 12, 2011 at 10:29 PM, Issac Kelly wrote: > 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.

Re: Handling Efficiency issues

2011-07-13 Thread Lucian Nicolescu
Did you try updating multiple rows at once? see https://docs.djangoproject.com/en/dev/topics/db/queries/#updating-multiple-objects-at-once It is possible that in time the database will become slower depending on your Message count but it will take some time. Lucian On Wed, Jul 13, 2011 at 1:11 PM

AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
I do have a views that are basically just proxies for the author views, but I was under the impression that if I just wanted to replace the registration templates then all I needed was a registration directory in my templates directory with the right file names. From there it should just take th

Re: AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Sorry, auto correct strikes again. I was trying to reply quickly from my phone. I meant auth, not author views. -- 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-us

Re: Inspecting objects

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
You know, I think that this subject deserves it own page on the wiki. I'll get something started later :) On Wed, Jul 13, 2011 at 7:33 AM, Jonas Geiregat wrote: > > Op 13-jul-2011, om 08:25 heeft Jirka Vejrazka het volgende geschreven: > > >> Thank you all for your help!!! > > > > I know I'm a b

session and caching

2011-07-13 Thread het.oosten
I have site with with a lay-out depending on a session, set in my view. I first tried site-wide caching, and this obviously didn't work. The caching is not session aware, and the lay-out changes almost randomly. Therefore I tried my luck with the @vary_on_headers decorator, using my session variab

Re: failed to run PROJ/manage.py in zip file

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Hi Robert, You might be interested to know that some of us are currently working on something similar. See following: http://groups.google.com/group/django-users/browse_thread/thread/38525319cd44263c?hl=en# Cal On Wed, Jul 13, 2011 at 10:41 AM, Robert Nie wrote: > Hi, > > I would like to comp

Re: session and caching

2011-07-13 Thread Jonas Geiregat
> I have site with with a lay-out depending on a session, set in my > view. I first tried site-wide caching, and this obviously didn't work. > The caching is not session aware, and the lay-out changes almost > randomly. Are you sure because in the docs I find the opposite. https://docs.djangopr

VirtualServer definition

2011-07-13 Thread kyosa
Hi, I'm new to Ubuntu, Python and Django. To learn Python and Django I following a case in Pro Python System Administration book. I have done all what the book say, but I cant find out how to change config for "The VirtualServer definition for the Django web application" The book say that I need

Re: session and caching

2011-07-13 Thread het.oosten
> Are you sure because in the docs I find the opposite. > When I read it correct this is about caching the session. I was referring to (or trying to) caching the entire webpage using a custom session key for the lay-out (I use memcached) When I look at the request headers my custom session key,

Re: VirtualServer definition

2011-07-13 Thread Sergiy Khohlov
Could you please provide some detail about your target ? If you are novice then django is started at 127.0.0.1:8080 What do you what to do ? Thsnks, Serge 2011/7/13 kyosa : > Hi, > I'm new to Ubuntu, Python and Django. To learn Python and Django I > following a case in Pro Python System Adminis

Re: VirtualServer definition

2011-07-13 Thread Shawn Milochik
It sounds like that part of the tutorial you're following is regarding configuring Apache. You don't need to worry about that yet. If you start with the Django tutorial it'll show you how to get started using the development server. The tutorial doesn't take too long to do. https://docs.djangoproj

RE: [] Re: session and caching

2011-07-13 Thread Henrik Genssen
you can inherit the cache system (UpdateCacheMiddleware, FetchFromCacheMiddleware) with your own get_Cache_Key function that you extend by layout (as you hopefully do not want to cache every single user, but all user using the same layout) Then create a new middleware, that uses your both new cre

Re: session and caching

2011-07-13 Thread het.oosten
I want indeed cache all users using the same lay-out. I haven't considered writing my own middleware for this yet. I will look into it. Thanks! Rob On 13 jul, 15:24, "Henrik Genssen" wrote: > you can inherit the cache system (UpdateCacheMiddleware, > FetchFromCacheMiddleware) with your own get

Re: session and caching

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Nice, i didnt' even realise there was built in support for having sessions in cache. :) On Wed, Jul 13, 2011 at 2:36 PM, het.oosten wrote: > I want indeed cache all users using the same lay-out. I haven't > considered writing my own middleware for this yet. I will look into > it. > > Thanks! > >

Re: Duplicate Key Error in Cache

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
May I ask why you are using a database cache, rather than something like memcache?? Cal On Tue, Jul 12, 2011 at 5: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

Re: Efficiently querying db

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
On Wed, Jul 13, 2011 at 9:36 AM, Amit Sethi wrote: > I have a db that looks something like this . > > { message : xyz > parent : 23 > id : 25 > } > or > { message : abc > parent : None > id : 25 > } > > { message : cde > parent : 28 > id : 32 > } > > { message : lbq > parent : 23 > id : 35 > }

Re: Duplicate Key Error in Cache

2011-07-13 Thread gamingdroid
I'm memory constrained and therefore memcache is not an option. The pages makes a lot of independent SQL queries that is better handled through one sql call via the db cache backend. I suppose I could roll my own, but find it odd that somebody hasn't fixed it. I would fix it myself, if I knew what

exclude field from SQL insert

2011-07-13 Thread Slafs
Hello. I have a model in Django that is based on database view. One of the fields is "virtual" (computed in the view) . I would like to exclude this field in my model from being used in SQL Insert and Update statements. Do You know maybe how can I do that ? Regards -- You received this mes

Re: exclude field from SQL insert

2011-07-13 Thread Tom Evans
On Wed, Jul 13, 2011 at 4:05 PM, Slafs wrote: > Hello. > > I have a model in Django that is based on database view. One of the fields > is "virtual" (computed in the view) . > I would like to exclude this field in my model from being used in SQL Insert > and Update statements. > > Do You know mayb

Re: AW: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Am I wrong about how templates work? -- 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/-/FVBKI9qS2PQJ. To post to this group, send email to django-users@googleg

Re: Trouble overriding registration templates

2011-07-13 Thread Andre Terra
Or render() which is the recommended shortcut since 1.3. https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#render Cheers, André On Wed, Jul 13, 2011 at 3:28 AM, Szabo, Patrick (LNG-VIE) < patrick.sz...@lexisnexis.at> wrote: > Did you write your own view for that purpose ?! > >

Django Internals

2011-07-13 Thread Venkatraman S
Except for the code, is there any good place to start with to better understand the django structure. As in, i am trying to figure out a way by which django can be much leaner, so that the actual footprint is much smaller. Say, if i just want to have a simple website with a handful of models, with

Re: exclude field from SQL insert

2011-07-13 Thread Venkatraman S
On Wed, Jul 13, 2011 at 8:57 PM, Tom Evans wrote: > Models based on views are not explicitly supported, but should work > well in practice (use managed=False in the meta class). Virtual > computed 'fields' are definitely not supported for update/insert. > Nice, i didnt know this. -- You receiv

Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
That's fine, but I was under the impression that the templates could be overridden just by creating the proper path in my template directories. Is that not true? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the we

Re: Trouble overriding registration templates

2011-07-13 Thread Shawn Milochik
On 07/13/2011 12:46 PM, Joshua Russo wrote: That's fine, but I was under the impression that the templates could be overridden just by creating the proper path in my template directories. Is that not true? It's true. Check the order of your TEMPLATE_DIRS in settings.py. If you don't have t

old app fails tests, runs ok

2011-07-13 Thread Javier Guerra Giraldez
Hi, I'm having a very weird problem, hope somebody can shed some light. some time ago, I developed an internal app at my officeIt using Django 1.1 (final), and it has been running with very few issues, on a small virtual machine. Now i have to do some non-trivial changes, so i set up a Virtualen

Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Cool, thanks for the confirmation. I do have my template directories explicitly listed in TEMPLATE_DIRS. I even made sure that my app's templates came before the admin templates, but for some reason it's not picking up my /registration/logged_out.html and the others that show up in the admin's

Re: Trouble overriding registration templates

2011-07-13 Thread Shawn Milochik
To be clear, when you say registration/login, you mean templates/registration/login, correct? Your 'registration' directory should be in a 'templates' dir. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dja

Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
*light bulb* I forgot about my development vs production settings. I was only changing the TEMPLATE_DIRS in the main settings.py that represents my production settings. I'm not in a place where I can test this but I'm almost certain that's what the problem is. -- You received this message beca

Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello, I know about assigning attributes to widgets, like shown here: or here: However, I want to assign an additional attribute t

Re: Trouble overriding registration templates

2011-07-13 Thread Joshua Russo
Correct -- 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/-/K5yKllF_gPcJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe fro

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Shawn Milochik
Following this as a sample (from the docs you linked to): widget=forms.TextInput(attrs={'class':'special'})) You'd do this: widget=forms.TextInput(attrs={'div_css':'test'})) Or, to not clobber other things set in the form, you could do it in the __init__: #working example I just

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello Shawn, thanks for your answer, however that's not exactly what I wanted. Now the html renders to: No. of properties However, I would want: No. of properties Additionally, I can't access {{ field.widget.attrs.div_css }} to get the class directly, I get an

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andre Terra
Write a wrapper function and make it even shorter (ok, go ahead and call it syntax sugar): def css(field, **kwargs): field.attrs.update(**kwargs) use as: css(self.fields['release_date'], div_css="test") DISCLAIMER: not tested on a real Field, but I tested it on a simple class in a python sh

Re: Django Internals

2011-07-13 Thread Daniel Roseman
On Wednesday, 13 July 2011 17:36:44 UTC+1, Venkatraman.S. wrote: > > Except for the code, is there any good place to start with to better > understand the django structure. > As in, i am trying to figure out a way by which django can be much leaner, > so that the actual footprint > is much small

Django piston

2011-07-13 Thread Dipo Elegbede
I'm about to start using django piston. Can anyone please point me to any example? I've looked through the documentation but can't get a hang of it. Regards. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to dj

Re: Django piston

2011-07-13 Thread Shawn Milochik
Try going to github and doing a search for 'django-piston.' That will show you a list of open-source projects that have implemented django-piston. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-user

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Shawn Milochik
On 07/13/2011 02:00 PM, Andreas Pfrengle wrote: Hello Shawn, thanks for your answer, however that's not exactly what I wanted. Now the html renders to: No. of properties However, I would want: No. of properties Additionally, I can't access {{ field.wid

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andre Terra
Shawn, He wants the form attribute to be applied to the div, not the field. Andreas, You can't pass an attribute to a field and expect it to show up in a different object altogether. I assume your div isn't handled by django, so you need to fix that first in order to be able to pass extra attri

Model "created_by"

2011-07-13 Thread Petey
Hi! I've made a model in news application: http://pastebin.com/49VkFT14 I want it to save user who created a message, however I get this message: OperationalError at /admin/news/news/add/(1054, "Unknown column 'user_id' in 'field list'") -- You received this message because you are subscribed

Re: session and caching

2011-07-13 Thread het.oosten
As always afterwards everything is very logical :-) Never used caching before. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to dja

Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Most of you will probably read this and say "duh", so this is aimed more at people who haven't had experience with using large data sets in Django. This isn't necessarily a bug or a problem with the ORM (although it would be nice if it could try and utilize little gotcha's like this), it just show

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Andre Terra
On Wed, Jul 13, 2011 at 4:37 PM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: (...) > ** > *This original query took 4 seconds to complete:* > > # return sessions for all subscriptions under this username > _users = Members.objects.filter( >

Re: Model "created_by"

2011-07-13 Thread Nick Serra
That error just means you didn't add that field to the database and it can't find it. Verify the user_id field is on that table. On Jul 13, 2:40 pm, Petey wrote: > Hi! > > I've made a model in news application:http://pastebin.com/49VkFT14 > > I want it to save user who created a message, however

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
The first query took around 4 seconds, the latter took around 0.2s. :) On 13 Jul 2011 21:15, "Andre Terra" wrote: > On Wed, Jul 13, 2011 at 4:37 PM, Cal Leeming [Simplicity Media Ltd] < > cal.leem...@simplicitymedialtd.co.uk> wrote: > > (...) > > >> ** >> *This original query took 4 seconds to com

Re: Add attributes (css-class) to formfield

2011-07-13 Thread Andreas Pfrengle
Hello Andre, it took me some time, but since I couldn't get insight in suggestion 1) and 2) really seemed too ugly, I've discovered an intermediate solution. I came around it when trying to make suggestion 2) a little less ugly, and after all it's still quite easy ;-) 3) Write a template-filter t

Re: Django piston

2011-07-13 Thread Dipo Elegbede
Thanks. On 13 Jul 2011 19:24, "Shawn Milochik" wrote: > Try going to github and doing a search for 'django-piston.' That will > show you a list of open-source projects that have implemented django-piston. > > > -- > You received this message because you are subscribed to the Google Groups "Django

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
Sorry, let me rephrase to avoid confusion. The original query I showed took about 4 seconds in total. The modified query underneath took around 0.2s in total. Cal On Wed, Jul 13, 2011 at 11:08 PM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: > The first que

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread bruno desthuilliers
On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]" wrote: >         _users = map(lambda x: x.get('memberid'), Members.objects.filter( >             username = self.username >         ).values('memberid')) What's wrong with values_list ? member_ids = Members.objects.filter(

Re: Digest for django-users@googlegroups.com - 25 Messages in 8 Topics

2011-07-13 Thread Alistair Cohen
Sent via BlackBerry® from Telstra -Original Message- From: django-users+nore...@googlegroups.com Sender: django-users@googlegroups.com Date: Wed, 13 Jul 2011 18:37:47 To: Digest Recipients Reply-To: django-users@googlegroups.com Subject: Digest for django-users@googlegroups.com - 25 Mess

Django Cache - how to clear per-site cache?

2011-07-13 Thread galgal
I use per-site cache. In my admin actions I want to add some commnad to clear cache every time content is changed. How can I clear per-site cache from admin? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web vis

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Cal Leeming [Simplicity Media Ltd]
On 14 Jul 2011 00:13, "bruno desthuilliers" wrote: > > On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]" > wrote: > > > _users = map(lambda x: x.get('memberid'), Members.objects.filter( > > username = self.username > > ).values('memberid')) > > What's wrong with

Re: Some more curious performance issues between MySQL and Django ORM

2011-07-13 Thread Andre Terra
PostgreSQL or bust. On Wed, Jul 13, 2011 at 9:24 PM, Cal Leeming [Simplicity Media Ltd] < cal.leem...@simplicitymedialtd.co.uk> wrote: > > On 14 Jul 2011 00:13, "bruno desthuilliers" > wrote: > > > > On 13 juil, 21:37, "Cal Leeming [Simplicity Media Ltd]" > > wrote: > > > > > _users =

Re: something about django mysql database long connection

2011-07-13 Thread Jian Chang
Try DBUtils http://www.webwareforpython.org/DBUtils/Docs/UsersGuide.html 2011/7/13 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

Re: Django form validation.. does anyone else find it awkward??

2011-07-13 Thread Matteius
""" Devs: ALWAYS call model.full_clean() OR form.is_valid() to protect Database from radical or duplicate DB entries! * Calling model.full_clean() OR form.is_valid() calls 3 underlying methods (clean, clean_fields, validate_unique) """ I haven't had to do much with form validation beyond w

can you use the Form Wizard with Model Forms?

2011-07-13 Thread sq1020
Hi everyone! I have one model and I've created a form out of the model using ModelForm. Now, I want to spread the form across two pages. For example, the first three fields will appear on the first page then the user clicks next and fills out the last three fields then he clicks submit and the u

middleware

2011-07-13 Thread NISA BALAKRISHNAN
how to write a middleware that that stores all database requests. How can i store all database requests? pls 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

creating a simple mailbox

2011-07-13 Thread bahare hoseini
hi there, as my first project i'm going to create a simple mail box to recieve or delete Emails, i made my models in my application, could you please tell me the next steps? thanks. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to thi

Re: Django Internals

2011-07-13 Thread Gath
There was a long talk by James Bannett called "Django In Depth" during pycon 2010, it would be good to check it out http://djangocon.blip.tv/file/3322277/ Gath On Jul 13, 7:36 pm, Venkatraman S wrote: > Except for the code, is there any good place to start with to better > understand the djang

database requests

2011-07-13 Thread NISA BALAKRISHNAN
how can i get the queries being passed while a page is being requested? i mean when a view is requested the database queries being sent. -- 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@googlegrou