Re: django-admin tab completion not working
Thanks, at least I know that it should work. Could it be that I don't have bash-completion installed on osx? I've tried to install it with brew and it seemed to work but I'm not sure if it is in fact installed and working and I'm not sure how to test if it is. -Martin On Fri, Apr 30, 2010 at 2:39 AM, Xavier Ordoquy wrote: > Hi, > > I'm on OSX (snow leopard) with default shell, python but django 1.2 beta > within a virtual env. Having the django_bash_completion sourced, the > django-admin.py he completes correctly to "help". > > Regards, > Xavier. > > Le 29 avr. 2010 à 19:41, Martin Lundberg a écrit : > > Anyone on OSX who has had this same problem? I'm going crazy here. Would > really want it to work since it would make it much easier to use > django-admin. > > On Thu, Apr 29, 2010 at 12:01 AM, Martin Lundberg < > martin.lundb...@gmail.com> wrote: > >> Hello, >> >> I've source the django_bash_completion script but when I try to use it >> by hitting TAB I get this: >> >> $ django-admin.py heType 'django-admin.py help' for usage. >> >> I hit tab after 'he' but it is not working and I get the above message >> instead. >> >> Any idea what I'm doing wrong? >> >> Thanks, >> >> -Martin >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with letters like ÄÖÕÜ in django adm in
I dont use any cms. I use few third party plugins like django-tinymce, sorl-thumbnail, django-tagging and django-tagging-autocomplete and thats it. I checked how the stuff is stored in the database and its exactly the same html it prints out on the pages. Letters like äöõü are all ä ö õ ü in the database. No idea if this is relevant info to you... :P Alan On Apr 30, 1:22 am, Bill Freeman wrote: > I don't have time to look in detail right now, but if you're using > pages cms, try > putting: > > PAGE_SANITIZE_USER_INPUT = False > > in your settings.py (after or in place of anywhere you set it True). > The last time > I got this it was due to a bug in the sanitize stuff in that it > converted perfectly > valid unicode into a UTF-8 bytestring and left that as the value to render, so > when you call unicode on it, the default codec being 'ascii', it blows > up if there > was anything requiring extended coding in UTF-8, such as a nbsp (in my case, > the entity was being converted by sanitize to the unicode, but in UTF-8. > > If that turns out to fix your issue, we should do a real fix, which is simply > to > decode the return value from sanitize using the 'utf-8' codec, giving us a > unicode string, which the safe_unicode function will be happy with. One of > us should produce a patch to send to the pages cms folks. > > Bill > > > > On Thu, Apr 29, 2010 at 3:28 PM, zayatzz wrote: > > Buh... took me a while to get around to do it. After first installing > > the django trunk it revealed another problem first though. Not sure if > > this can be the cause or not? > > > The problem was django tinymce import error. In django tinymce widgets > > line 14 there was > > from django.forms.util import smart_unicode > > But that did not work. I changed it to: > > from django.utils.encoding import smart_unicode > > > After that i got this error: > > >http://pastebin.com/QaF6HQbg > > > Alan > > > On Apr 16, 4:37 pm, Bill Freeman wrote: > >> I like the idea of getting a full stack trace using python 2.5 > > >> I don't know what you platform is, but at least on linux (and similar > >> systems) > >> you can easily install multiple versions of python without causing > >> trouble*. > >> You grab the sources, do a make, and then, instead of doing make install, > >> you do make altinstall. Then "python" still refers to your original > >> version, but > >> your additional version is available as, say "python2.5". Then use > >> virtualenv > >> to make an environment for django tied to python2.5, and do a > >> checkout/clone/ > >> whatever (assuming that your project is under revision control) of your > >> project > >> into the virtual environment (saves trouble with wrong version .pyc > >> files). Activate > >> the virutal environment, pip install django and your requirements, and > >> fire up > >> manage.py runserver. The whole process shouldn't take more than an hour > >> if you know what you're doing, or a couple of hours if you need to read a > >> bunch > >> of documentation. > > >> [ * I've got 2.4 (for zope/plone), 2.5, 2.6, 2.7, 3.0, and 3.1 on my > >> laptop. ] > > >> Bill > > >> On Fri, Apr 16, 2010 at 2:29 AM, zayatzz wrote: > >> > Okay. I will try to test it in the way suggested by Bill and Karen. > > >> > This will take me some time though. Hopefully you will be able to keep > >> > track of this thread even though it will get pushed to later pages > >> > when new threads are created. > > >> > Alan > > >> > On Apr 15, 10:52 pm, Karen Tracey wrote: > >> >> On Thu, Apr 15, 2010 at 3:48 PM, Bill Freeman wrote: > >> >> > Sadly, the problem string doesn't occur at the top level of any of > >> >> > those > >> >> > local > >> >> > vars. It was worth a shot. It's probably in the context. > > >> >> > If I were you, I'd go find the raise wrapped... in debug.py down at > >> >> > the > >> >> > bottom > >> >> > of the stack trace, and stick a pdb.set_trace() there. Then > >> >> > (assuming you > >> >> > do this under manage.py runserver) you can poke around to see what was > >> >> > being rendered and what's in the context. The exception being > >> >> > wrapped may > >> >> > have useful information that isn't showing in the stacktrace. If you > >> >> > can > >> >> > find > >> >> > the actuall line of code that is getting the exception, you may be > >> >> > able to figure > >> >> > out why it thinks it has to convert something to ascii (which is > >> >> > probably > >> >> > the > >> >> > default string encoding, use sys.getdefaultencoding() to find out). > >> >> > Probably > >> >> > something is applying str() to a unicode object. > > >> >> > I'm sorry that I can't provide a shortcut. Perhaps someone else will. > > >> >> If there is a way to run the app using Python 2.5 instead of 2.6 then > >> >> the > >> >> debug information would include the original traceback. Alternatively > >> >> if it > >> >> could be run with a recent checkout of either the 1.1.X branch or trunk > >> >> then > >> >>
Re: contrib.auth: Email address instead of username as identifier
On Thu, Apr 29, 2010 at 11:08 PM, Russell Keith-Magee < freakboy3...@gmail.com> wrote: > On Fri, Apr 30, 2010 at 5:03 AM, Felippe Bueno > wrote: > > django-1.2 will support this. > > I'm sorry - what is this based on? There haven't been any substantive > changes to contrib.auth in 1.2. It's not on the official "new > features" list. There have been some discussions about some potential > changes, but a design hasn't even been settled on yet. > Possibly http://code.djangoproject.com/changeset/12634, which I think allows storing an email address in the username field? So perhaps some of the hacks can be avoided, if you adopt the convention having the username field be an email address. Though some special code would be needed to enforce that conventionand there is that other email address field hanging around. So no, not exactly what the original question asked for but maybe a bit better than it used to be. Karen -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: contrib.auth: Email address instead of username as identifier
On Fri, Apr 30, 2010 at 5:03 AM, Felippe Bueno wrote: > django-1.2 will support this. I'm sorry - what is this based on? There haven't been any substantive changes to contrib.auth in 1.2. It's not on the official "new features" list. There have been some discussions about some potential changes, but a design hasn't even been settled on yet. Answering the orignal poster - the hacks you've found are, at present, the only way to do it. This is something we hope to address in the near future. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem logging into admin site
I know this is way delayed, but in the hopes it helps someone else out there... if you have, SESSION_COOKIE_SECURE = True then the browser may not be sending the cookie back to your view on an http (i.e. not https) page. The behavior is as you described. The admin login complains that the browser does not have cookies enabled. And you can see that a cookie was created corresponding to the domain. I most often develop using the django dev server, without https obviously, and sometimes forget to switch off SESSION_COOKIE_SECURE. On Mar 25, 1:04 pm, Tim wrote: > On Mar 25, 4:44 pm, Genghisu wrote: > > > Have you set SESSION_COOKIE_DOMAIN in settings.py? Without that being > > set correctly, you'll run into the problem you've described above. In > >yourcase, > > > SESSION_COOKIE_DOMAIN = 'dev.mydomain.com'. > > >http://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-domain > > Hi Genghisu, > > Yes I've tried that and it made no difference at all. > > I've delved much deeper into the Django session code, in an attempt to > debug my problem. I added the following line of code to the > django.contrib.sessions.backends.base file: > > def test_cookie_worked(self): > ++ print "%s == %s" % (self.get(self.TEST_COOKIE_NAME), > self.TEST_COOKIE_VALUE) > return self.get(self.TEST_COOKIE_NAME) == > self.TEST_COOKIE_VALUE > > That outputs the following when I attempt to log in: > > [25/Mar/2010 16:55:09] "GET /admin/ HTTP/1.1" 200 1680 > None == worked > [25/Mar/2010 16:55:14] "POST /admin/ HTTP/1.1" 200 1826 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-admin tab completion not working
Hi, I'm on OSX (snow leopard) with default shell, python but django 1.2 beta within a virtual env. Having the django_bash_completion sourced, the django-admin.py he completes correctly to "help". Regards, Xavier. Le 29 avr. 2010 à 19:41, Martin Lundberg a écrit : > Anyone on OSX who has had this same problem? I'm going crazy here. Would > really want it to work since it would make it much easier to use django-admin. > > On Thu, Apr 29, 2010 at 12:01 AM, Martin Lundberg > wrote: > Hello, > > I've source the django_bash_completion script but when I try to use it > by hitting TAB I get this: > > $ django-admin.py heType 'django-admin.py help' for usage. > > I hit tab after 'he' but it is not working and I get the above message > instead. > > Any idea what I'm doing wrong? > > Thanks, > > -Martin > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Refresh django settings without restarting apache
On Apr 30, 2:57 am, "ge...@aquarianhouse.com" wrote: > Sure, with WSGI script reload In respect of what? You can't just say WSGI as a generalised concept in this case, you have to refer to the specific WSGI hosting mechanism. Many WSGI hosting mechanisms don't provide a way of doing automatic reloading. How one achieves reloading for those that do differs. For Apache/mod_wsgi in daemon mode (not embedded mode), one can touch the WSGI script file to force a reload as documented in: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode For some (but not all) FASTCGI hosting solutions, it is possible to touch the .fcgi script file. So, not that simple. Graham > On Apr 29, 6:51 pm, Kashif Ali wrote: > > > > > > > Hi, > > > Is it possible to refresh changes to apache (webserver) without restart it? > > Actually i have multiple databases that i need to change while the webserver > > is running. Is it possible? > > > Or any other way to accomplish this task? i.e. use multiple databases for > > django application. > > > Regards, > > Kashif > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Refresh django settings without restarting apache
On Apr 30, 4:01 am, "ge...@aquarianhouse.com" wrote: > it should be already switched on > > http://www.modpython.org/live/current/doc-html/dir-other-par.html That has zero effect in the case of Django. The automatic reloading in mod_python only applies to handler code files directly under the control of mod_python. It does not apply to standard Python module imports taken from sys.path. Read about the import_module() function in mod_python which implements its reloading in: http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html Graham > On Apr 29, 7:14 pm, Kashif Ali wrote: > > > > > > > Thanks for your response. > > > One more question: Is it possible with mod_python?. This is because i am > > using mod_python currently not WSGI. > > > On Thu, Apr 29, 2010 at 9:57 PM, ge...@aquarianhouse.com < > > > ge...@aquarianhouse.com> wrote: > > > Sure, with WSGI script reload > > > > On Apr 29, 6:51 pm, Kashif Ali wrote: > > > > Hi, > > > > > Is it possible to refresh changes to apache (webserver) without restart > > > it? > > > > Actually i have multiple databases that i need to change while the > > > webserver > > > > is running. Is it possible? > > > > > Or any other way to accomplish this task? i.e. use multiple databases > > > > for > > > > django application. > > > > > Regards, > > > > Kashif > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups > > > "Django users" group. > > > > To post to this group, send email to django-us...@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > groups.com> > > > . > > > > For more options, visit this group athttp:// > > > groups.google.com/group/django-users?hl=en. > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > groups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > -Kashif > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Trouble constructing raw SQL requiring multiple LIKE statements
I think that there's an extra "samples.description LIKE" in there (occurs twice). But, should you want to do this with the ORM, assuming that samples is a model (or could be made one, see the legacy database stuff in the docs), I think that it could be done with Q objects using description__contains='ultraviolet' and title__contains='ultraviolet'. filter(description__contains= On Thu, Apr 29, 2010 at 6:12 PM, Daniel wrote: > Hi guys, > > I am having trouble getting multiple LIKE statements to work using > cursor.execute(SQL, [params]). > > Here is my raw SQL query which I have confirmed is working directly at > the mysql command line: > > "SELECT samples.number from samples WHERE samples.description LIKE > samples.description LIKE %ultraviolet% OR samples.title LIKE > %ultraviolet%" > > When I try to use cursor.execute() I am getting no matches. > > I am trying to construct the query above programmatically. Must I use > the query param? I know in the docs it states that it expects a > placeholder, but I don't want to use one. I have successfully > constructed the full query programmatically but that apparently > doesn't work and I don't know why. I use: > > cursor.execute("SELECT samples.number FROM samples WHERE %s",[query]) > > query = "samples.description LIKE samples.description LIKE %ultraviolet > % OR samples.title LIKE %ultraviolet%" > > I'd really appreciate some help. Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with letters like ÄÖÕÜ in django adm in
I don't have time to look in detail right now, but if you're using pages cms, try putting: PAGE_SANITIZE_USER_INPUT = False in your settings.py (after or in place of anywhere you set it True). The last time I got this it was due to a bug in the sanitize stuff in that it converted perfectly valid unicode into a UTF-8 bytestring and left that as the value to render, so when you call unicode on it, the default codec being 'ascii', it blows up if there was anything requiring extended coding in UTF-8, such as a nbsp (in my case, the entity was being converted by sanitize to the unicode, but in UTF-8. If that turns out to fix your issue, we should do a real fix, which is simply to decode the return value from sanitize using the 'utf-8' codec, giving us a unicode string, which the safe_unicode function will be happy with. One of us should produce a patch to send to the pages cms folks. Bill On Thu, Apr 29, 2010 at 3:28 PM, zayatzz wrote: > Buh... took me a while to get around to do it. After first installing > the django trunk it revealed another problem first though. Not sure if > this can be the cause or not? > > The problem was django tinymce import error. In django tinymce widgets > line 14 there was > from django.forms.util import smart_unicode > But that did not work. I changed it to: > from django.utils.encoding import smart_unicode > > After that i got this error: > > http://pastebin.com/QaF6HQbg > > Alan > > On Apr 16, 4:37 pm, Bill Freeman wrote: >> I like the idea of getting a full stack trace using python 2.5 >> >> I don't know what you platform is, but at least on linux (and similar >> systems) >> you can easily install multiple versions of python without causing trouble*. >> You grab the sources, do a make, and then, instead of doing make install, >> you do make altinstall. Then "python" still refers to your original >> version, but >> your additional version is available as, say "python2.5". Then use >> virtualenv >> to make an environment for django tied to python2.5, and do a checkout/clone/ >> whatever (assuming that your project is under revision control) of your >> project >> into the virtual environment (saves trouble with wrong version .pyc >> files). Activate >> the virutal environment, pip install django and your requirements, and fire >> up >> manage.py runserver. The whole process shouldn't take more than an hour >> if you know what you're doing, or a couple of hours if you need to read a >> bunch >> of documentation. >> >> [ * I've got 2.4 (for zope/plone), 2.5, 2.6, 2.7, 3.0, and 3.1 on my laptop. >> ] >> >> Bill >> >> >> >> >> >> On Fri, Apr 16, 2010 at 2:29 AM, zayatzz wrote: >> > Okay. I will try to test it in the way suggested by Bill and Karen. >> >> > This will take me some time though. Hopefully you will be able to keep >> > track of this thread even though it will get pushed to later pages >> > when new threads are created. >> >> > Alan >> >> > On Apr 15, 10:52 pm, Karen Tracey wrote: >> >> On Thu, Apr 15, 2010 at 3:48 PM, Bill Freeman wrote: >> >> > Sadly, the problem string doesn't occur at the top level of any of those >> >> > local >> >> > vars. It was worth a shot. It's probably in the context. >> >> >> > If I were you, I'd go find the raise wrapped... in debug.py down at the >> >> > bottom >> >> > of the stack trace, and stick a pdb.set_trace() there. Then (assuming >> >> > you >> >> > do this under manage.py runserver) you can poke around to see what was >> >> > being rendered and what's in the context. The exception being wrapped >> >> > may >> >> > have useful information that isn't showing in the stacktrace. If you >> >> > can >> >> > find >> >> > the actuall line of code that is getting the exception, you may be >> >> > able to figure >> >> > out why it thinks it has to convert something to ascii (which is >> >> > probably >> >> > the >> >> > default string encoding, use sys.getdefaultencoding() to find out). >> >> > Probably >> >> > something is applying str() to a unicode object. >> >> >> > I'm sorry that I can't provide a shortcut. Perhaps someone else will. >> >> >> If there is a way to run the app using Python 2.5 instead of 2.6 then the >> >> debug information would include the original traceback. Alternatively if >> >> it >> >> could be run with a recent checkout of either the 1.1.X branch or trunk >> >> then >> >> the full traceback would appearing, instead of it getting cut off at >> >> "raise >> >> wrapped". >> >> >> Karen >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Django users" group. >> > To post to this group, send email to django-us...@googlegroups.com. >> > To unsubscribe from this group, send email to >> > django-users+unsubscr...@googlegroups.com. >> > For more options, visit this group >> > athttp://groups.google.com/group/django-users?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" grou
Trouble constructing raw SQL requiring multiple LIKE statements
Hi guys, I am having trouble getting multiple LIKE statements to work using cursor.execute(SQL, [params]). Here is my raw SQL query which I have confirmed is working directly at the mysql command line: "SELECT samples.number from samples WHERE samples.description LIKE samples.description LIKE %ultraviolet% OR samples.title LIKE %ultraviolet%" When I try to use cursor.execute() I am getting no matches. I am trying to construct the query above programmatically. Must I use the query param? I know in the docs it states that it expects a placeholder, but I don't want to use one. I have successfully constructed the full query programmatically but that apparently doesn't work and I don't know why. I use: cursor.execute("SELECT samples.number FROM samples WHERE %s",[query]) query = "samples.description LIKE samples.description LIKE %ultraviolet % OR samples.title LIKE %ultraviolet%" I'd really appreciate some help. Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: contrib.auth: Email address instead of username as identifier
django-1.2 will support this. for now, I think the only way to do this is using some hacks like: http://www.djangosnippets.org/snippets/74/ On Thu, Apr 29, 2010 at 5:01 PM, Thomas Allen wrote: > Hi everyone, > > I am looking for a way to replace the username with the email address > as the unique key for user accounts. Is there a setting in > contrib.auth to allow this? The solutions I've seen so far are hacks, > validating email uniqueness via a form rather than as a model field, > etc. In my mind a clean, acceptable way to do this would result in no > username field at all in the User model. > > Thanks, > Thomas > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django app svn management
This was not really a feature request or how its really setup. But I wanted to know how the community thinks of this kind of development setup. I'm looking forward to your responses. Grtz, Dexter On Thu, Apr 29, 2010 at 4:10 PM, Dexter wrote: > Hi there, > > I was wondering if there is a solution to manage a django deployment with > svn like revision tool. > What I would like to have my main django deployment to be a trunk like > folder. > When I want to test something, or make a new app, I want to make a branch > oid. which should be visible under some sort of url structure (ie. > www.example.org/svn/branchname/normal_folder_structure) > > I wouldn't know if this is the best way to develop app's, but I guess it > would be nice to commit something when it's solid, and not having to > compromise the general site preformance/stability. > > What do you think of this? > > Grtz, Dexter > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
[Ann] django_audit 0.0.2
https://code.google.com/p/django-audit/ This is a fairly comprehensive Audit Trail App that uses regular django models and is not tied to a "NoSQL" solution Disclaimer: The nature of Audit requirements makes it impossible for a one size fits all solution. This solution fits my requirements very well, if it does not fit yours I may or may not be willing to modify it so it does. Dj Gilcrease -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
contrib.auth: Email address instead of username as identifier
Hi everyone, I am looking for a way to replace the username with the email address as the unique key for user accounts. Is there a setting in contrib.auth to allow this? The solutions I've seen so far are hacks, validating email uniqueness via a form rather than as a model field, etc. In my mind a clean, acceptable way to do this would result in no username field at all in the User model. Thanks, Thomas -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with letters like ÄÖÕÜ in django adm in
Buh... took me a while to get around to do it. After first installing the django trunk it revealed another problem first though. Not sure if this can be the cause or not? The problem was django tinymce import error. In django tinymce widgets line 14 there was from django.forms.util import smart_unicode But that did not work. I changed it to: from django.utils.encoding import smart_unicode After that i got this error: http://pastebin.com/QaF6HQbg Alan On Apr 16, 4:37 pm, Bill Freeman wrote: > I like the idea of getting a full stack trace using python 2.5 > > I don't know what you platform is, but at least on linux (and similar systems) > you can easily install multiple versions of python without causing trouble*. > You grab the sources, do a make, and then, instead of doing make install, > you do make altinstall. Then "python" still refers to your original > version, but > your additional version is available as, say "python2.5". Then use virtualenv > to make an environment for django tied to python2.5, and do a checkout/clone/ > whatever (assuming that your project is under revision control) of your > project > into the virtual environment (saves trouble with wrong version .pyc > files). Activate > the virutal environment, pip install django and your requirements, and fire up > manage.py runserver. The whole process shouldn't take more than an hour > if you know what you're doing, or a couple of hours if you need to read a > bunch > of documentation. > > [ * I've got 2.4 (for zope/plone), 2.5, 2.6, 2.7, 3.0, and 3.1 on my laptop. ] > > Bill > > > > > > On Fri, Apr 16, 2010 at 2:29 AM, zayatzz wrote: > > Okay. I will try to test it in the way suggested by Bill and Karen. > > > This will take me some time though. Hopefully you will be able to keep > > track of this thread even though it will get pushed to later pages > > when new threads are created. > > > Alan > > > On Apr 15, 10:52 pm, Karen Tracey wrote: > >> On Thu, Apr 15, 2010 at 3:48 PM, Bill Freeman wrote: > >> > Sadly, the problem string doesn't occur at the top level of any of those > >> > local > >> > vars. It was worth a shot. It's probably in the context. > > >> > If I were you, I'd go find the raise wrapped... in debug.py down at the > >> > bottom > >> > of the stack trace, and stick a pdb.set_trace() there. Then (assuming > >> > you > >> > do this under manage.py runserver) you can poke around to see what was > >> > being rendered and what's in the context. The exception being wrapped > >> > may > >> > have useful information that isn't showing in the stacktrace. If you can > >> > find > >> > the actuall line of code that is getting the exception, you may be > >> > able to figure > >> > out why it thinks it has to convert something to ascii (which is probably > >> > the > >> > default string encoding, use sys.getdefaultencoding() to find out). > >> > Probably > >> > something is applying str() to a unicode object. > > >> > I'm sorry that I can't provide a shortcut. Perhaps someone else will. > > >> If there is a way to run the app using Python 2.5 instead of 2.6 then the > >> debug information would include the original traceback. Alternatively if it > >> could be run with a recent checkout of either the 1.1.X branch or trunk > >> then > >> the full traceback would appearing, instead of it getting cut off at "raise > >> wrapped". > > >> Karen > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Oracle cursor.execute problem
Excellent, I'll give trunk a go. Thanks Ian. Tim. Ian wrote: On Apr 27, 2:36 pm, Tim Sawyer wrote: Hmm, nearly. That gets around the error, but the return value isn't populated. >>> import cx_Oracle >>> from django.db import connection >>> cursor = connection.cursor() >>> lOutput = cursor.var(cx_Oracle.STRING) >>> cursor.execute("BEGIN %s := 'N'; END; ", [lOutput]) >>> print lOutput >>> print lOutput.getvalue() None >>> Any more clues, or am I just going to have to stick with creating a specific Oracle connection to do this? That would be a bug. I've just checked in a fix, which will be included in Django 1.2 and the next 1.1.X release. If you're not willing to use trunk or wait for the release, my recommendation would be to use cursor.callfunc if possible. Otherwise, you can get the cx_Oracle cursor from cursor.cursor and use that directly. Ian -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Refresh django settings without restarting apache
Thank you Georg i am checking into it. On Thu, Apr 29, 2010 at 11:01 PM, ge...@aquarianhouse.com < ge...@aquarianhouse.com> wrote: > it should be already switched on > > http://www.modpython.org/live/current/doc-html/dir-other-par.html > > On Apr 29, 7:14 pm, Kashif Ali wrote: > > Thanks for your response. > > > > One more question: Is it possible with mod_python?. This is because i am > > using mod_python currently not WSGI. > > > > On Thu, Apr 29, 2010 at 9:57 PM, ge...@aquarianhouse.com < > > > > > > > > ge...@aquarianhouse.com> wrote: > > > Sure, with WSGI script reload > > > > > On Apr 29, 6:51 pm, Kashif Ali wrote: > > > > Hi, > > > > > > Is it possible to refresh changes to apache (webserver) without > restart > > > it? > > > > Actually i have multiple databases that i need to change while the > > > webserver > > > > is running. Is it possible? > > > > > > Or any other way to accomplish this task? i.e. use multiple databases > for > > > > django application. > > > > > > Regards, > > > > Kashif > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > > To post to this group, send email to django-us...@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > > > > > . > > > > For more options, visit this group athttp:// > > > groups.google.com/group/django-users?hl=en. > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com > > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > > -- > > -Kashif > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- -Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Refresh django settings without restarting apache
it should be already switched on http://www.modpython.org/live/current/doc-html/dir-other-par.html On Apr 29, 7:14 pm, Kashif Ali wrote: > Thanks for your response. > > One more question: Is it possible with mod_python?. This is because i am > using mod_python currently not WSGI. > > On Thu, Apr 29, 2010 at 9:57 PM, ge...@aquarianhouse.com < > > > > ge...@aquarianhouse.com> wrote: > > Sure, with WSGI script reload > > > On Apr 29, 6:51 pm, Kashif Ali wrote: > > > Hi, > > > > Is it possible to refresh changes to apache (webserver) without restart > > it? > > > Actually i have multiple databases that i need to change while the > > webserver > > > is running. Is it possible? > > > > Or any other way to accomplish this task? i.e. use multiple databases for > > > django application. > > > > Regards, > > > Kashif > > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > > For more options, visit this group athttp:// > > groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > -Kashif > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is it safe to alter Django generated tables in MySQL to have composite PK?
Hi Continuation, In Django, at this time, the best you can do is: class AuctionBid(models.Model): class Meta: unique_together = ( ( ' On Apr 29, 12:09 pm, Continuation wrote: > I'm using MySQL with Django. > > MySQL uses clustered index. I have a class AuctionBid for which the > "natural" PK is (user_id, auction_id). > > I'd like to set (user_id, aucton_id) as the PK so that it'll be the > clustered index. I understand that Django doesn't support composite > PK. But what if after syncdb I just ALTER TABLE to make (user_id, > aucton_id) the PK. Would that work with Django or would that introduce > some unwanted behavior under the hood? > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is it safe to alter Django generated tables in MySQL to have composite PK?
In Django, the best current option I know of is: from django.db import models class AuctionBid(models.Model): On Apr 29, 12:09 pm, Continuation wrote: > I'm using MySQL with Django. > > MySQL uses clustered index. I have a class AuctionBid for which the > "natural" PK is (user_id, auction_id). > > I'd like to set (user_id, aucton_id) as the PK so that it'll be the > clustered index. I understand that Django doesn't support composite > PK. But what if after syncdb I just ALTER TABLE to make (user_id, > aucton_id) the PK. Would that work with Django or would that introduce > some unwanted behavior under the hood? > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Is it safe to alter Django generated tables in MySQL to have composite PK?
Hi Continuation, In Django, at this time, the best you can do is: class AuctionBid(models.Model): class On Apr 29, 12:09 pm, Continuation wrote: > I'm using MySQL with Django. > > MySQL uses clustered index. I have a class AuctionBid for which the > "natural" PK is (user_id, auction_id). > > I'd like to set (user_id, aucton_id) as the PK so that it'll be the > clustered index. I understand that Django doesn't support composite > PK. But what if after syncdb I just ALTER TABLE to make (user_id, > aucton_id) the PK. Would that work with Django or would that introduce > some unwanted behavior under the hood? > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-admin tab completion not working
Anyone on OSX who has had this same problem? I'm going crazy here. Would really want it to work since it would make it much easier to use django-admin. On Thu, Apr 29, 2010 at 12:01 AM, Martin Lundberg wrote: > Hello, > > I've source the django_bash_completion script but when I try to use it > by hitting TAB I get this: > > $ django-admin.py heType 'django-admin.py help' for usage. > > I hit tab after 'he' but it is not working and I get the above message > instead. > > Any idea what I'm doing wrong? > > Thanks, > > -Martin > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Refresh django settings without restarting apache
Thanks for your response. One more question: Is it possible with mod_python?. This is because i am using mod_python currently not WSGI. On Thu, Apr 29, 2010 at 9:57 PM, ge...@aquarianhouse.com < ge...@aquarianhouse.com> wrote: > Sure, with WSGI script reload > > On Apr 29, 6:51 pm, Kashif Ali wrote: > > Hi, > > > > Is it possible to refresh changes to apache (webserver) without restart > it? > > Actually i have multiple databases that i need to change while the > webserver > > is running. Is it possible? > > > > Or any other way to accomplish this task? i.e. use multiple databases for > > django application. > > > > Regards, > > Kashif > > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- -Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sorl-thumbnail: random name in Thumbnail field
thanks but now I prefer to tweak sorl-thumbnail ;) --- On 29 Apr, 18:51, "ge...@aquarianhouse.com" wrote: > http://docs.djangoproject.com/en/dev/howto/custom-file-storage/ > > On Apr 29, 6:48 pm, xRobot wrote: > > > > > > > No I am newbie and I don't know how to overwrite storage... could you > > help me ^_^ ? > > > > > > On 29 Apr, 12:46, "ge...@aquarianhouse.com" > > wrote: > > > > Did you try to overwrite the storage? > > > > On Apr 29, 6:16 pm, xRobot wrote: > > > > > I want to use str(uuid.uuid4()) instead of the name uploaded. > > > > > For instance: I have this model: > > > > > class foo(models.Model): > > > > pic = ThumbnailField(upload_to='pics', size=(200, 200)) > > > > > I am uploading hello_world.jpg and I should save these named versions > > > > should be saved for example in: > > > > > 4ba9b397-da69-4307-9bce-e92887e84d2f.jpg > > > > > How can I do that ? > > > > Thanks ^_^ > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Django users" group. > > > > To post to this group, send email to django-us...@googlegroups.com. > > > > To unsubscribe from this group, send email to > > > > django-users+unsubscr...@googlegroups.com. > > > > For more options, visit this group > > > > athttp://groups.google.com/group/django-users?hl=en. > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com. > > > For more options, visit this group > > > athttp://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Refresh django settings without restarting apache
Sure, with WSGI script reload On Apr 29, 6:51 pm, Kashif Ali wrote: > Hi, > > Is it possible to refresh changes to apache (webserver) without restart it? > Actually i have multiple databases that i need to change while the webserver > is running. Is it possible? > > Or any other way to accomplish this task? i.e. use multiple databases for > django application. > > Regards, > Kashif > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sorl-thumbnail: random name in Thumbnail field
http://docs.djangoproject.com/en/dev/howto/custom-file-storage/ On Apr 29, 6:48 pm, xRobot wrote: > No I am newbie and I don't know how to overwrite storage... could you > help me ^_^ ? > > > > On 29 Apr, 12:46, "ge...@aquarianhouse.com" > wrote: > > > > > Did you try to overwrite the storage? > > > On Apr 29, 6:16 pm, xRobot wrote: > > > > I want to use str(uuid.uuid4()) instead of the name uploaded. > > > > For instance: I have this model: > > > > class foo(models.Model): > > > pic = ThumbnailField(upload_to='pics', size=(200, 200)) > > > > I am uploading hello_world.jpg and I should save these named versions > > > should be saved for example in: > > > > 4ba9b397-da69-4307-9bce-e92887e84d2f.jpg > > > > How can I do that ? > > > Thanks ^_^ > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com. > > > For more options, visit this group > > > athttp://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Refresh django settings without restarting apache
Hi, Is it possible to refresh changes to apache (webserver) without restart it? Actually i have multiple databases that i need to change while the webserver is running. Is it possible? Or any other way to accomplish this task? i.e. use multiple databases for django application. Regards, Kashif -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sorl-thumbnail: random name in Thumbnail field
No I am newbie and I don't know how to overwrite storage... could you help me ^_^ ? On 29 Apr, 12:46, "ge...@aquarianhouse.com" wrote: > Did you try to overwrite the storage? > > On Apr 29, 6:16 pm, xRobot wrote: > > > > > > > I want to use str(uuid.uuid4()) instead of the name uploaded. > > > For instance: I have this model: > > > class foo(models.Model): > > pic = ThumbnailField(upload_to='pics', size=(200, 200)) > > > I am uploading hello_world.jpg and I should save these named versions > > should be saved for example in: > > > 4ba9b397-da69-4307-9bce-e92887e84d2f.jpg > > > How can I do that ? > > Thanks ^_^ > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sorl-thumbnail: random name in Thumbnail field
Did you try to overwrite the storage? On Apr 29, 6:16 pm, xRobot wrote: > I want to use str(uuid.uuid4()) instead of the name uploaded. > > For instance: I have this model: > > class foo(models.Model): > pic = ThumbnailField(upload_to='pics', size=(200, 200)) > > I am uploading hello_world.jpg and I should save these named versions > should be saved for example in: > > 4ba9b397-da69-4307-9bce-e92887e84d2f.jpg > > How can I do that ? > Thanks ^_^ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
sorl-thumbnail: random name in Thumbnail field
I want to use str(uuid.uuid4()) instead of the name uploaded. For instance: I have this model: class foo(models.Model): pic = ThumbnailField(upload_to='pics', size=(200, 200)) I am uploading hello_world.jpg and I should save these named versions should be saved for example in: 4ba9b397-da69-4307-9bce-e92887e84d2f.jpg How can I do that ? Thanks ^_^ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setting readonly_fields dynamically
Yes that works, totally missed the get_readonly_fields method - thanks! Nick On Apr 29, 4:40 pm, Daniel Roseman wrote: > On Apr 29, 3:43 pm, Nick wrote: > > > > > > > Hi, > > > I would like to set some fields to be readonly in the Admin app based > > on some logic, and would like to use the new readonly_fields attribute > > of ModelAdmin if possible (rather than some other sort of hack). > > > I'm trying to access readonly_fields, but get the error "'GalleryForm' > > object has no attribute 'readonly_fields'" > > > My code is currently as follows: > > > class GalleryAdminForm(forms.ModelForm): > > class Meta: > > model = Gallery > > def __init__(self, *args, **kwargs): > > super(GalleryAdminForm, self).__init__(*args, **kwargs) > > print self.readonly_fields > > > Any help on how I can access readonly_fields from the ModelForm to > > override it would be really helpful! > > > Thanks, > > Nick > > I haven't played with it myself, but surely readonly_fields is an > attribute of the ModelAdmin subclass, not the form? > > It looks like there's a get_readonly_fields method on the base > ModelAdmin class, which takes the request as a parameter, so you > should be able to override that and return a customised tuple as > required. > -- > DR. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Saving the query object for later
cleaned_data is just a dictionary. Every time you accept a form in order to do a search, you write code to take the form data from cleaned_data, plus, perhaps, request.user and/or things you can pull from request.user, and build a queryset. That code can clearly be refactored into a separate function. As far as serializing the function's arguments goes, if the user object is needed, you would instead serialize user.id. The function could easily test whether the user argument is an instance of User, or an int, and optionally perform the query to get the user object. Or the code that re-calls it later could fetch the user object, simplifying the function (a matter of taste, mostly, since an isinstance check is pretty cheap in the context of running a query). On Thu, Apr 29, 2010 at 10:30 AM, derek wrote: > On Apr 28, 7:45 pm, Peter Landry wrote: >> +1 to this. I had similar requirements, and initially went down the road of >> pickling a queryset. It became clear quickly that (at least in my case) a >> better solution was to have a function that translates a Form instance into >> a Queryset. Then serialize the form (or form data) and regenerate the >> Queryset that way. >> >> Peter >> >> On 4/28/10 12:28 PM, "Bill Freeman" wrote: >> >> >> >> > The request may have references to objects that will no longer >> > exist, or may be inappropriate when rerun later. I can't promise >> > that it won't work, but I believe that pickling the request is at >> > best a fragile solution. >> >> > To save just the required parameters won't take much code, >> > especially if you refactor the code that turns the parameters into >> > a the search operation into a function (or method) that you can >> > use both initially and when you rerun the search. >> >> > Having to do some preparation again probably isn't going to be >> > as big a performance drain as unpickling enough context to >> > make it work without extra code. >> >> > On Wed, Apr 28, 2010 at 11:56 AM, Mark Jones wrote: >> >> I was thinking I could pickle/unpickle the request then run it thru >> >> with an extra flag of (send email) thru the same code that wsgi uses. >> >> If I jsonify the data, how would I get that back into a python object? >> >> >> Is it really as simple as str=json.dumps(request) and request = >> >> json.loads(str) >> >> >> I don't see how json keeps track of the object it is dumping, and not >> >> sure how to construct a request object from the json return value. >> >> >> I can see how easy that part would be in C++, but my python skills are >> >> a good deal weaker I guess I'm hunting for "how to do this in >> >> python" >> > > Peter > > This sounds intriguing: "a function that translates a Form instance > into a Queryset". Is this a generic solution? Even if not, would you > mind sharing the code here? > > Thanks! > Derek > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
ANN: django-currencies 0.2.1
Description: django-currencies allows you to define different currencies, and includes template tags/filters to allow easy conversion between them. Download: http://pypi.python.org/pypi/django-currencies/0.2.1 Documentation: http://packages.python.org/django-currencies/ Source Code: https://launchpad.net/django-currencies -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Setting readonly_fields dynamically
On Apr 29, 3:43 pm, Nick wrote: > Hi, > > I would like to set some fields to be readonly in the Admin app based > on some logic, and would like to use the new readonly_fields attribute > of ModelAdmin if possible (rather than some other sort of hack). > > I'm trying to access readonly_fields, but get the error "'GalleryForm' > object has no attribute 'readonly_fields'" > > My code is currently as follows: > > class GalleryAdminForm(forms.ModelForm): > class Meta: > model = Gallery > def __init__(self, *args, **kwargs): > super(GalleryAdminForm, self).__init__(*args, **kwargs) > print self.readonly_fields > > Any help on how I can access readonly_fields from the ModelForm to > override it would be really helpful! > > Thanks, > Nick > I haven't played with it myself, but surely readonly_fields is an attribute of the ModelAdmin subclass, not the form? It looks like there's a get_readonly_fields method on the base ModelAdmin class, which takes the request as a parameter, so you should be able to override that and return a customised tuple as required. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Setting readonly_fields dynamically
Hi, I would like to set some fields to be readonly in the Admin app based on some logic, and would like to use the new readonly_fields attribute of ModelAdmin if possible (rather than some other sort of hack). I'm trying to access readonly_fields, but get the error "'GalleryForm' object has no attribute 'readonly_fields'" My code is currently as follows: class GalleryAdminForm(forms.ModelForm): class Meta: model = Gallery def __init__(self, *args, **kwargs): super(GalleryAdminForm, self).__init__(*args, **kwargs) print self.readonly_fields Any help on how I can access readonly_fields from the ModelForm to override it would be really helpful! Thanks, Nick -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Saving the query object for later
On Apr 28, 7:45 pm, Peter Landry wrote: > +1 to this. I had similar requirements, and initially went down the road of > pickling a queryset. It became clear quickly that (at least in my case) a > better solution was to have a function that translates a Form instance into > a Queryset. Then serialize the form (or form data) and regenerate the > Queryset that way. > > Peter > > On 4/28/10 12:28 PM, "Bill Freeman" wrote: > > > > > The request may have references to objects that will no longer > > exist, or may be inappropriate when rerun later. I can't promise > > that it won't work, but I believe that pickling the request is at > > best a fragile solution. > > > To save just the required parameters won't take much code, > > especially if you refactor the code that turns the parameters into > > a the search operation into a function (or method) that you can > > use both initially and when you rerun the search. > > > Having to do some preparation again probably isn't going to be > > as big a performance drain as unpickling enough context to > > make it work without extra code. > > > On Wed, Apr 28, 2010 at 11:56 AM, Mark Jones wrote: > >> I was thinking I could pickle/unpickle the request then run it thru > >> with an extra flag of (send email) thru the same code that wsgi uses. > >> If I jsonify the data, how would I get that back into a python object? > > >> Is it really as simple as str=json.dumps(request) and request = > >> json.loads(str) > > >> I don't see how json keeps track of the object it is dumping, and not > >> sure how to construct a request object from the json return value. > > >> I can see how easy that part would be in C++, but my python skills are > >> a good deal weaker I guess I'm hunting for "how to do this in > >> python" > Peter This sounds intriguing: "a function that translates a Form instance into a Queryset". Is this a generic solution? Even if not, would you mind sharing the code here? Thanks! Derek -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Admin limits
On Apr 29, 12:47 pm, Martin Tiršel wrote: > Hello, > > I am still a newbie exploring possibilities of Django but you learn > advanced techniques often on really big applications. I have here my two > projects I want to do in Django (1. advanced eshop system and 2. > webhosting management [customer database, invoicing, webhosting settings, > trouble tickets, ...]). Django Admin can be very customized but I don't > know if it can handle such projects. I am asking this because I don't know > if I have first to go deep into Django Admin and spend some weeks > exploring and testing all of the functionality first or I should begin > with building the application from scratch the old classic way. > > Here are some examples I will need to do: > > * combine Admin pages (CRUD) with normal pages (e.g. listing of sales > summaries or another overviews [with linking to details page for example], > displaying an amount of mixed informations [combined from multiple > models], ...) > > * dynamic edit forms - e.g. customer has a product which consist from > multiple parts which can be combined. So, one customer has fieldsets A, B, > C another A, C, D . Every fieldset has some editable and some static > fields (read only). > > * advanced permissions - some employees have editing access only to some > fields in a fieldset and these not editable without permissions are > displayed only as text instead of a textfield > > I don't think that such things will be possible, but as I found yesterday, > Django Admin has wider possibilities than I expected :) Indeed it has. The "standard" reply is "don't use the Admin." My view is "use the Admin to learn Django." E.g. you say "combine Admin pages (CRUD) with normal pages" - I am not sure exactly what you mean by "combine" but its very easy to add many other kinds of views to a Django site, happily running alongside the CUD pages [sorry, no "R" without some effort :( - I'll blog on this shortly], such as ones "displaying an amount of mixed information". Re "* dynamic edit forms" => there had just been a thread on that http://groups.google.com/group/django-users/browse_thread/thread/48f243a020b244e9 . [Sidebar - wait for version 1.2 for read-only field]. Re "* advanced permissions - some employees have editing access only to some fields" => I have not done this, but would think you can do this as part of the "dynamic edit forms" (certainly permissions can be fine-grained at a row level - many topics discussing this). In short - push the limits on the Admin - it can do far more than I thought after a read through of the Django book and similar documents (you must read these first, of course!). My 2c Derek (recent Django convert) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
add custom sidebar to admin site
I need to add some custom links to sidebar in admin section. What's the cleaner way to make that? I can only override the index.html template? -- Alessandro Ronchi http://www.soasi.com SOASI - Sviluppo Software e Sistemi Open Source Hobby & Giochi, l'e-commerce del divertimento http://hobbygiochi.com http://www.facebook.com/pages/Forli/Hobby-Giochi/185311523755 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django app svn management
Hi there, I was wondering if there is a solution to manage a django deployment with svn like revision tool. What I would like to have my main django deployment to be a trunk like folder. When I want to test something, or make a new app, I want to make a branch oid. which should be visible under some sort of url structure (ie. www.example.org/svn/branchname/normal_folder_structure) I wouldn't know if this is the best way to develop app's, but I guess it would be nice to commit something when it's solid, and not having to compromise the general site preformance/stability. What do you think of this? Grtz, Dexter -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Distributing application
On Thu, Apr 29, 2010 at 04:37:09AM -0700, Mag wrote: > I was wondering what is the best way to distribute my application? IMHO, the best way is the native way of your target platform. I.e., MSI for Windows, rpm for RedHat, etc. I'd also bundle dependencies together with the app. With kind regards, -- Baurzhan Ismagulov http://www.kz-easy.com/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Distributing application
What do you mean by distributing your app? getting people to view it?, or having your clients running their own server. If you want people to view it, you have to deploy a django installation somewhere with your app. Else, if you want you clients to have each their own app, theyll have to have their own django installation, and with that a python installation Grtz, Dexter On Thu, Apr 29, 2010 at 1:37 PM, Mag wrote: > I have been using Django and I like it a lot. > > I was wondering what is the best way to distribute my application? > Previously, with Apache tomcat it was very easy to distribute it. I > provided the tomcat server and the war file and everything was done. > > Is there a tool or a preferred way to do this? I am not sure if my > clients all have python installed. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Distributing application
I have been using Django and I like it a lot. I was wondering what is the best way to distribute my application? Previously, with Apache tomcat it was very easy to distribute it. I provided the tomcat server and the war file and everything was done. Is there a tool or a preferred way to do this? I am not sure if my clients all have python installed. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Admin limits
Hello Martin, Django admin has its limitations and this quote from djangobook.com http://djangobook.com/en/2.0/chapter06/ will clarify your comment. "One final point we want to make clear is: the admin site is not an end-all-be-all. Over the years, we’ve seen it hacked and chopped up to serve a variety of functions it wasn’t intended to serve. It’s not intended to be a public interface to data, nor is it intended to allow for sophisticated sorting and searching of your data. As we said early in this chapter, it’s for trusted site administrators. Keeping this sweet spot in mind is the key to effective admin-site usage." So if you want a customizable option i would suggest to do it from the ground up to your needs. Joao da silva @codedefinition On Apr 29, 12:47 pm, Martin Tiršel wrote: > Hello, > > I am still a newbie exploring possibilities of Django but you learn > advanced techniques often on really big applications. I have here my two > projects I want to do in Django (1. advanced eshop system and 2. > webhosting management [customer database, invoicing, webhosting settings, > trouble tickets, ...]). Django Admin can be very customized but I don't > know if it can handle such projects. I am asking this because I don't know > if I have first to go deep into Django Admin and spend some weeks > exploring and testing all of the functionality first or I should begin > with building the application from scratch the old classic way. > > Here are some examples I will need to do: > > * combine Admin pages (CRUD) with normal pages (e.g. listing of sales > summaries or another overviews [with linking to details page for example], > displaying an amount of mixed informations [combined from multiple > models], ...) > > * dynamic edit forms - e.g. customer has a product which consist from > multiple parts which can be combined. So, one customer has fieldsets A, B, > C another A, C, D . Every fieldset has some editable and some static > fields (read only). > > * advanced permissions - some employees have editing access only to some > fields in a fieldset and these not editable without permissions are > displayed only as text instead of a textfield > > I don't think that such things will be possible, but as I found yesterday, > Django Admin has wider possibilities than I expected :) > > Thank your for your answers, > Martin > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django Admin limits
Hello, I am still a newbie exploring possibilities of Django but you learn advanced techniques often on really big applications. I have here my two projects I want to do in Django (1. advanced eshop system and 2. webhosting management [customer database, invoicing, webhosting settings, trouble tickets, ...]). Django Admin can be very customized but I don't know if it can handle such projects. I am asking this because I don't know if I have first to go deep into Django Admin and spend some weeks exploring and testing all of the functionality first or I should begin with building the application from scratch the old classic way. Here are some examples I will need to do: * combine Admin pages (CRUD) with normal pages (e.g. listing of sales summaries or another overviews [with linking to details page for example], displaying an amount of mixed informations [combined from multiple models], ...) * dynamic edit forms - e.g. customer has a product which consist from multiple parts which can be combined. So, one customer has fieldsets A, B, C another A, C, D . Every fieldset has some editable and some static fields (read only). * advanced permissions - some employees have editing access only to some fields in a fieldset and these not editable without permissions are displayed only as text instead of a textfield I don't think that such things will be possible, but as I found yesterday, Django Admin has wider possibilities than I expected :) Thank your for your answers, Martin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Saving Child Records via ForeignKeyField
You initialize (__init__) your ZoneType model instead of create()'ing. When you save an initialized it doesn't get an id magically. I suggest you to use ZoneType.objects.create() whenever possible. But if you must init your model first; make sure you get() it again to retrieve its id. Remember that id's are created on database and they're non-existent before save. -- Saygılarımla, Atamert Ölçgen -+- --+ +++ www.muhuk.com mu...@jabber.org A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Saving Child Records via ForeignKeyField
Here are the models: class ZoneType(models.Model): name = models.CharField(max_length=50) color = models.CharField(max_length=7) class Meta: app_label = 'maps' class Zone(models.Model): name = models.CharField(max_length=50) type = models.ForeignKey(ZoneType) code = models.CharField(max_length=10) description = models.CharField(max_length=255) uri = models.CharField(max_length=200) class Meta: app_label = 'maps' My problem with using the QuerySet.add example is that I am importing this data from a file that may have data scattered throughout it. Here is the order I have to do things: create the parent record, create the child record, associate it to the parent, set attributes of child and parent, then save. Perhaps I have to associate it with a separate data structure and then use QuerySet.add(). I am doing all this using getattr(), ReverseSingleRelatedObjectDescriptor, etc, so it ends up being a more complicated. The code below works and is more like the real code: #Definition would be loaded from file parent_model = ZoningType child_model = Zoning rel_field = 'type' parent_attributes = {'name':'ABC', 'color':'#123123'} child_attributes = [{'name':'ABC-1', 'code':'ABA', 'description':'my description', 'uri':'http://abc.com/abc'}, {'name':'ABC-2', 'code':'ABA', 'description':'my description', 'uri':'http://abc.com/ abc'}] #Definition would be loaded from file save_packages = [] #Setup Parent parent_object = parent_model() save_package = [parent_object, {}] for attr, val in parent_attributes.items(): setattr(parent_object, attr, val) #Setup Child for child in child_attributes: child_object = child_model() rel_descriptor = getattr(child_model, rel_field) if not save_package[1].has_key(rel_descriptor) : save_package[1][rel_descriptor] = [] save_package[1][rel_descriptor].append(child_object) for attr, value in child.items(): setattr(child_object, attr, value) save_packages.append(save_package) #Save Packages for r in save_packages: r[0].save() for rd in r[1]: query_set = getattr(parent_object, rel_descriptor.field.related.get_accessor_name()) for child_object in r[1][rd]: query_set.add(child_object) Thanks for pointing me in the right direction with the query set. It still seems like the models could do this for me when it looks up the values from ForeignKeyField objects. If they don't have a key, save them and update the key. In addition, it would always be in the same transaction as well. I'll have to manually ad that logic as well. If there is no easier way, I'll have to go with this. On Apr 29, 1:40 am, akonsu wrote: > hello, > > it would be easier to help if you provided your modes. are you missing > this:http://docs.djangoproject.com/en/dev/ref/models/relations/#ref-models... > > for example: > > >>> b = Blog.objects.get(id=1) > >>> e = b.entry_set.create( > > ... headline='Hello', > ... body_text='Hi', > ... pub_date=datetime.date(2005, 1, 1) > ... ) > > On Apr 29, 2:16 am, "Robinson B. Heath" > wrote: > > > > > > > I believe I have done my due diligence, but point me in the right direction > > if I am missing something. > > > I am working on a generic importing engine to import various file > > formats(csv, fixed length, etc) into django models based on json formatted > > file definitions. It needs to do something like the following, which I > > have actually tried in the shell. > > > zone_type = ZoneType() > > zone_type.name = 'GrowthArea' > > … > > zone = Zone() > > zone.type = zone_type > > zone.name = 'TX-Region12' > > > #-save starts here > > zone.save() > > #-save ends here > > > Is this supposed to work? > > > I have also tried: > > > #-save starts here > > zone_type.save() > > zone.save() > > #-save ends here > > > Both report that the foreign key field is null such as: " null value in > > column "type_id" violates not-null constraint". > > > This does work: > > > #-save starts here > > zone_type.save() > > zone.type = zone_type > > zone.save() > > #-save ends here > > > as does this: > > > #-save starts here > > z.type.save() > > z.type = z.type > > z.save() > > #-save ends here > > > I could do something like the last example in my code, but I'd rather not. > > It seems like this would be simple to do inside the model save logic. Am I > > missing something? > > > Thanks. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com.
Re: Deleting parent object when many related objects exist is to slow
I found this quite interestine discussion: http://groups.google.com/group/django-developers/browse_thread/thread/166752daf5c96499/007ff42d83ac60c0 my opinion is close to Russell Keith-Magee opinion there. It looks like a lot of effort was done just to conform django with small number of databases. This is not so but idea from some point of view, but losing efficient, tested methods of handling deletes by db backends seems to be a great loss for me. Isn't possible to implement this as a sort of fallback mechanism 'if I can relay on DB deleteing policy then I use it, otherwise Django machinery created for that is enabled'? Or amybe there is some workaround to make this work more efficient I'm missing at the momment? Regards, Lukasz On 29 Kwi, 02:17, Christophe Pettus wrote: > On Apr 28, 2010, at 4:36 PM, dzida wrote: > > > "When Django deletes an object, it emulates the behavior of the SQL > > constraint ON DELETE CASCADE -- > > in other words, any objects which had foreign keys pointing at the > > object to be deleted will be deleted along with it. ", > > which is something I really want - but performed in shorter time. > > I'm a bit surprised Django does this. Is there a reason that Django > re-implements ON DELETE CASCADE for databases that support it? > > -- > -- Christophe Pettus > x...@thebuild.com > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: "dynamically" setting ModelAdmin properties?
On Apr 29, 6:10 am, akonsu wrote: > hello, > > in my custom admin class that inherits ModelAdmin i need to set > ModelAdmin.exclude, ModelAdmin.list_display, etc based on whether the > logged in user is a superuser or not. > > is this possible? > > thanks > konstantin > ModelAdmin provides a get_form method that you can override to return a different form class depending on the user - it is passed the request object, so you can access the user from there. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Transaction commit with cursor.execute
> When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. So it is, my bad, thank you againg. You see, it seemed a little weird, that first (with the decorator) we force transaction to commit manually to use 'test' for all that would happen in our view (suppose that all commits in view should share that 'using' from the decorator), and then explicitly tell the transaction to commit again with 'using'. But if we have transactions to different DBs in one view that seems logical. On 29 апр, 13:16, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 12:20 PM, idle sign wrote: > > I'm using the latest trunk fromhttp://github.com/django/django. > > A complete test project you can grab > > athttp://idlesign.narod.ru/django/django-tests.tar.gz > > There is a little bootstrap.sh to run to create DBs. > > > Thank you, Russ. > > Ok - using your test application as provided, I see the "This code > isn't under transaction management" error. That's because line 7 of > views.py (the decorator that enables transaction management) is > commented out. When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. > > I take it you seeing something different? > > Yours, > Russ Magee %-) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Transaction commit with cursor.execute
> When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. So it is, my bad, thank you againg. You see, it seemed a little weird, that first (with the decorator) we force transaction to commit manually to 'test' all that would happen in our view (suppose that all commits in view should share that 'using' from the decorator), and then explicitly tell the transaction to commit again with 'using'. But if we have transactions to different DBs in one view that seems logical. On 29 апр, 13:16, Russell Keith-Magee wrote: > On Thu, Apr 29, 2010 at 12:20 PM, idle sign wrote: > > I'm using the latest trunk fromhttp://github.com/django/django. > > A complete test project you can grab > > athttp://idlesign.narod.ru/django/django-tests.tar.gz > > There is a little bootstrap.sh to run to create DBs. > > > Thank you, Russ. > > Ok - using your test application as provided, I see the "This code > isn't under transaction management" error. That's because line 7 of > views.py (the decorator that enables transaction management) is > commented out. When line 7 is uncommented, transaction management is > enabled, and the view works as I would expect. > > I take it you seeing something different? > > Yours, > Russ Magee %-) > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.