Re: Multiple file upload crashes dev server
Hi Lorenzo I suspect its not that you are uploading 2 files, but which files u upload. The line print "%s %s %s %s" % (k, new_data[k]["filename"],new_data[k]["content- type"], new_data[k]["content"]) Will print the actual content of the file you are uploading. Now if thats an image or binary file the char \x07 will appear in it. Which is system beep.(Printing char \x07 will make windows beep, Dell does not play nicely with system beep, no way to mute it, I know, I have one.) So with many \x07 chars in the content you system is going to look like its hanging beeping like crazy until its beeped its way through the files you are uploading. Caz On Mar 18, 5:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi everybody, > > the following script running on the dev server with Py2.4/Win2k3 > (tested on both IE7 and FF2) crashes the dev server. The funny thing > is that the files get actually written to the filesystem and CPU usage > is normal. > > What i'm trying to do is allow uploading of an undeterminate number N > of files, just as GMail does. > > The javascript part uses jquery. > > Thanks, > Lorenzo > > template### > {%extends "base_template.html"%} > > {%block content%} > > > function addImageField() > { > var rndName = Math.ceil(Math.abs(Math.random() * 10)); > var chunk = "Description
"; > > $("#imagefields").append(chunk);} > > > > {%if error_msg%} > {{error_msg}} > {%endif%} > > {%if info_msg%} > {{info_msg}} > {%endif%} > > {{form.errors.as_ul}} > > > > Description {{form.description}} > {{form.myfile}} > > > > > > > > > Attach another file > > > > > > > {%endblock%} > > view### > class FileUploadForm(Form): > description = CharField(required=False) > myfile = CharField(widget=FileInput(), required=False) > > def file_upload(request): > if request.method == "POST": > new_data = request.POST.copy() > new_data.update(request.FILES) > form = FileUploadForm(new_data) > > if form.is_valid(): > for k in request.FILES.keys(): > print "%s %s %s %s" % (k, new_data[k]["filename"], > new_data[k]["content-type"], new_data[k]["content"]) > f = file("C:\\temp\\%s" % k, "wb") > try: > f.write(new_data[k]["content"]) > f.close() > except: pass > > return HttpResponse("Success") > else: > context = dict(form=form, error_msg="Upload went > bananas!") > else: > form = FileUploadForm() > context = dict(form=form) > > return render_to_response("fileupload.html", context) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: svn 400 bad request
Once I work out how to install pysvn on Dreamhost, I'll make some sort of "nightlies" available for Django. In fact, I wrote an app. [1] to do just that (although it will work for any svn. repo), but should have checked that my host support pysvn first :) [1] http://code.google.com/p/django-nightly/ --Simon G. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
models.ManyToManyField: Multi-relationship in one table
i have no idea about keywords of this question, so i can't search the answer of this question or the django document. my question is i have three models: Trainee, Company, Course. and their relation table is below: Course|Trainee|Company C1| T1 | Com1 C1| T2 | Com1 C1| T3 | Com1 C2| T1 | Com2 C2| T3 | Com1 C2| T4 | Com2 C3| T1 | Com2 one course has many trainees, and one trainee mayby belongs to two Companies. for example: T1 belongs to two companies, when T1 go to C1 course, he belongs to Com1, but belongs to Com2 when he go to C2,C3. how can i implement this relation in Couse Model, i cann't use the syntax like trainee = models.ManyToManyField(Trainee) company = models.ManyToManyField(Company) that makes two relation tables not one. thank you for your patience. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Adding data to Many-to-Many relationship
On 3/20/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I have an unusual data modeling situation I am trying to see if I can > tackle using Django. I have a class "Person", which has a self- > referential M2M relationship (a person is related to another person). > I would like to capture what that relationship is. Is there a way to > add more fields to the intermediate table in the M2M? If not, am I > going about this entirely incorrectly? There's no way to attach data to an m2m definition. However, there is another way to represent the problem: http://www.djangoproject.com/documentation/models/m2m_intermediary/ 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: IRC
what happens when you try to join #django the command would be /join #django ~ Anders On 3/19/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > > I'm trying to use XChat to connect to the IRC channel, but I can only > find #django-br and #django-fr on FreeNode. > > What am I stupidly doing? > > Todd > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Adding data to Many-to-Many relationship
I have an unusual data modeling situation I am trying to see if I can tackle using Django. I have a class "Person", which has a self- referential M2M relationship (a person is related to another person). I would like to capture what that relationship is. Is there a way to add more fields to the intermediate table in the M2M? If not, am I going about this entirely incorrectly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
IRC
I'm trying to use XChat to connect to the IRC channel, but I can only find #django-br and #django-fr on FreeNode. What am I stupidly doing? Todd --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django & Web Services Api
ElementTree is great, and included with Python 2.5; lxml (http://codespeak.net/lxml) is a super-fast ElementTree + xpath + xslt + lots library implemented on top of libxml2. On 3/19/07, johnny <[EMAIL PROTECTED]> wrote: > > I need to create a simple web api for my project. Basically they make > a request, I send response back in XML. Or they send me XML docs to > upload to my site. Any good python XML out there for this kind of > service? I am looking at ElemenTtree. Any other ideas welcome. > > Thank you > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django & Web Services Api
I need to create a simple web api for my project. Basically they make a request, I send response back in XML. Or they send me XML docs to upload to my site. Any good python XML out there for this kind of service? I am looking at ElemenTtree. Any other ideas welcome. Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sandbox/Staging/Production Environments with Django (imports work how?)
OK, my setup before put both all the different ones in the same path I had: /home/user/django_projects/project_sandbox /home/user/django_projects/project_staging etc. Now: /home/user/production/project_name /home/user/staging/project_name etc. Before, I would add /home/user/django_projects to the PythonPath in Apache and so I would have to declare my imports as [from project_sandbox.app.models import blah] because all three environments were available to Apache. Now, with each having the same name, but different parent directory I can add /home/user/sandbox to my PythonPath for Apache and then the project_name is the same for each project and so the imports are the same. Thanks for clearing that up for me! Sean. On Mar 19, 8:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2007-03-19 at 23:54 +, sphogan wrote: > > Hi! I've started to use Django and it's wonderful. I'm about ready > > to launch my first production site (around 4,000 visitors daily) and I > > found that I was unable to setup the sandbox/staging/production setup > > I'm used to having. > > > Basically, the problem is that files will have imports in them that > > clearly don't change themselves for each environment. I can get > > around this while in the same app by just doing a [from models import > > blah], but that doesn't work if you're trying to do a [from > > project.salt.models import blah] in project.pepper.views. > > > Is there any way to make these paths relative to the project they're > > in? That way I can hack around on sandbox and just stick it in SVN to > > move it to staging without having to change anything and then on to > > production likewise. > > Your description doesn't make it entirely clear what you're particular > staging set up looks like. Traditionally a staging setup is completely > separate from the production one; let's assume that is the case here > (although I don't quite understand your query about import paths in > views). You can set the Python path for each installation > (sandbox/staging/production) to point to their particular import root. > You don't need to include the project directory in the import path (see > [1]) -- this is partly because there may not even be a "project > directory" -- so you could have the two installations side-by-side under > differently named project directories. Or you could have the same > project directory name under different parent directories. > > [1]http://groups.google.com/group/django-users/browse_frm/thread/2309bb7... > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: __search works in mysterious ways.
On Mar 19, 11:41 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 3/19/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > > That's not what I would have expected to see. Have a look at the SQL > > that Django is generating and see if there are any clues there. To do > > that, make sure you have DEBUG=True in your settings file (which you > > will have by default) and then do this: > > That's actually the correct behavior on MySQL -- it defaults to > ignoring words of less than four characters in full-text searches (it > also ignores "stop words"). > > These are configurable in MySQL via the 'ft_min_word_len' and > 'ft_stopword_file' options. hmm, I see, thanks. setting 'ft_min_word_len=2 solved it. still pretty annoying. could django take care of changing this setting? (assuming that this is not how __search is supposed to work). thanks -abe > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: __search works in mysterious ways.
On Mar 19, 11:15 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2007-03-19 at 14:09 +, abe wrote: > > I'm getting unexpected (missing) results from the __search field > > lookup > > it looks like it can only finds whole words, but only if they're > > larger than > > 3 chars. is this correct? and is it supposed to work like this? > > > In [65]: c.choice='ABC123\ncde456' > > > In [66]: c.save() > > > In [67]: Choice.objects.filter(choice__search='abc123') > > Out[67]: > > [ABC123 > > cde456] > > > In [68]: c.choice='ABC\ncde' > > > In [69]: c.save() > > > In [70]: Choice.objects.filter(choice__search='abc') > > Out[70]: [] > > That's not what I would have expected to see. me neither. > Have a look at the SQL > that Django is generating and see if there are any clues there. To do > that, make sure you have DEBUG=True in your settings file (which you > will have by default) and then do this: > > from django.db import connection > connection.query[-1]['sql'] nothing strange in the SQL I guess. In [16]: Choice.objects.filter(choice__search='ABC') Out[16]: [] In [17]: Choice.objects.filter(choice__search='efgh') Out[17]: [ABC efgh] In[18]: connection.queries[-2]['sql'] Out[18]: 'SELECT `polls_choice`.`id`,`polls_choice`.`poll_id`,`polls_choice`.`choice`,`polls_choice`.`votes` FROM `polls_choice` WHERE (MATCH (`polls_choice`.`choice`) AGAINST (ABC IN BOOLEAN MODE))' In [19]: connection.queries[-1]['sql'] Out[19]: 'SELECT `polls_choice`.`id`,`polls_choice`.`poll_id`,`polls_choice`.`choice`,`polls_choice`.`votes` FROM `polls_choice` WHERE (MATCH (`polls_choice`.`choice`) AGAINST (efgh IN BOOLEAN MODE))' -abe > > (from the interactive prompt). The connection.query object is a list of > all the SQL queries from the session -- or a single request if you are > using it in webserver mode. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Sandbox/Staging/Production Environments with Django (imports work how?)
On Mon, 2007-03-19 at 23:54 +, sphogan wrote: > Hi! I've started to use Django and it's wonderful. I'm about ready > to launch my first production site (around 4,000 visitors daily) and I > found that I was unable to setup the sandbox/staging/production setup > I'm used to having. > > Basically, the problem is that files will have imports in them that > clearly don't change themselves for each environment. I can get > around this while in the same app by just doing a [from models import > blah], but that doesn't work if you're trying to do a [from > project.salt.models import blah] in project.pepper.views. > > Is there any way to make these paths relative to the project they're > in? That way I can hack around on sandbox and just stick it in SVN to > move it to staging without having to change anything and then on to > production likewise. Your description doesn't make it entirely clear what you're particular staging set up looks like. Traditionally a staging setup is completely separate from the production one; let's assume that is the case here (although I don't quite understand your query about import paths in views). You can set the Python path for each installation (sandbox/staging/production) to point to their particular import root. You don't need to include the project directory in the import path (see [1]) -- this is partly because there may not even be a "project directory" -- so you could have the two installations side-by-side under differently named project directories. Or you could have the same project directory name under different parent directories. [1] http://groups.google.com/group/django-users/browse_frm/thread/2309bb788fd89b0c/c1347b46d9e1445f?lnk=gst&q=Python+path&rnum=1#c1347b46d9e1445f Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Sandbox/Staging/Production Environments with Django (imports work how?)
Hi! I've started to use Django and it's wonderful. I'm about ready to launch my first production site (around 4,000 visitors daily) and I found that I was unable to setup the sandbox/staging/production setup I'm used to having. Basically, the problem is that files will have imports in them that clearly don't change themselves for each environment. I can get around this while in the same app by just doing a [from models import blah], but that doesn't work if you're trying to do a [from project.salt.models import blah] in project.pepper.views. Is there any way to make these paths relative to the project they're in? That way I can hack around on sandbox and just stick it in SVN to move it to staging without having to change anything and then on to production likewise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: __search works in mysterious ways.
On 3/19/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > That's not what I would have expected to see. Have a look at the SQL > that Django is generating and see if there are any clues there. To do > that, make sure you have DEBUG=True in your settings file (which you > will have by default) and then do this: That's actually the correct behavior on MySQL -- it defaults to ignoring words of less than four characters in full-text searches (it also ignores "stop words"). These are configurable in MySQL via the 'ft_min_word_len' and 'ft_stopword_file' options. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: __search works in mysterious ways.
On Mon, 2007-03-19 at 14:09 +, abe wrote: > I'm getting unexpected (missing) results from the __search field > lookup > it looks like it can only finds whole words, but only if they're > larger than > 3 chars. is this correct? and is it supposed to work like this? > > > In [65]: c.choice='ABC123\ncde456' > > In [66]: c.save() > > In [67]: Choice.objects.filter(choice__search='abc123') > Out[67]: > [ABC123 > cde456] > > In [68]: c.choice='ABC\ncde' > > In [69]: c.save() > > In [70]: Choice.objects.filter(choice__search='abc') > Out[70]: [] That's not what I would have expected to see. Have a look at the SQL that Django is generating and see if there are any clues there. To do that, make sure you have DEBUG=True in your settings file (which you will have by default) and then do this: from django.db import connection connection.query[-1]['sql'] (from the interactive prompt). The connection.query object is a list of all the SQL queries from the session -- or a single request if you are using it in webserver mode. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple Forms and/or Models from one template (newforms)
I don't know if it would be of any use to you, but when faced with this problem I ended up making subclass of forms.Form that handled one to one relations. It works a little like form_for_model/instance in that it generates the form based on the model definition rather than fields you define. Instead you can define the exceptions when you subclass the form (like specifying choices, widgets, or fields to exclude). The usage is pretty simple and I tried to document it. It's fairly complicated internally, only a week or so old, and I'm new to both Django and Python. That probably means one of the regulars will pop in an explain how to do it in 3 lines of code. It seems to work ok for me so far though, so if you like living dangerously... http://dpaste.com/hold/7108/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: svn 400 bad request
Thanks... Probably has to 'appeal' to the key persons ;-) On Mar 19, 5:40 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 3/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > In my case, the problem is due to the firewall setting which I have no > > power to alter. But if the subversion repository can support the https > > protocol, svn can connect to it with no problem. > > > I wonder if Django team can add the https to the repository? > > This has come up a couple of times[1], and as far as I know no > official response has been issued (other than the fact that there's > still no HTTPS access to the repo). > > [1]http://groups.google.com/group/django-users/search?group=django-users... > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
As noted in another thread there is a hack way of adding search to a model detailed on teh django snippits site: http://www.djangosnippets.org/snippets/31/ http://www.djangosnippets.org/snippets/32/ It is no where near as nice nor as comprehensive as the old django stuff abstract search interface, but it does get the job done in a pinch. -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
On Mar 19, 5:15 pm, "Mary" <[EMAIL PROTECTED]> wrote: > I want anybody to help me and tell me where to > findhttps://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/AbstractS... > that can work with Django stable version 0.95.1 > cause i want to use Abstarct search module Unfortunately there is no such beast.There has been talk of adding generic search support, and I overheard Jacob and someone else having long protracted discussions on this subject at PyCon. I don't believe you will find any code to do this anytime soon (but I could be wrong). I have searched all over the internet for this myself and found nothing. The DjangoStuff Code would need to be completely re-written to hook into the new generic relation framework. I was thinking of doing this, but the djangostuff svn archive has been offline for a while, and development seems to have stopped some time back in January 06. I mis-pasted in my last post. The maintainer is Georg "Hugo" Bauer. I have e-mailed him about the status of the project, but heard nothing back. Here is his information: Georg Bauer Weseler Strasse 48 48151 Münster eMail: gb at rfc1437.de Telefon: +49 251 531136 Sorry, wish I had better information. -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
Hi Mary, Attached is a patch to get stuff.search and stuff testing framework (not unlike the new django one) working. I've been using this in a production django site for around a year. On 3/20/07, Mary <[EMAIL PROTECTED]> wrote: > > I want anybody to help me and tell me where to find > https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/AbstractSearching > that can work with Django stable version 0.95.1 > cause i want to use Abstarct search module > > May be this is not the right place for this question but i really > don't know where i can ask this question > > Thank you in advance > Mary Adel > > On Mar 19, 9:41 pm, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > > DjangoStuff:https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoStuff > > > > Is not part of the core Django system and is third party. > > It is developed by D. Joseph Creighton, and all questions on his code > > should be directed to him:https://simon.bofh.ms/ > > > > In direct answer to your question: no. Not all of the djangostuff code > > works with 0.95.1, some of it has been migrated, some of it has not, > > and the testing framework has been deprecated in favor of the testing > > framework in django. You will need to read up on the documentation on > > each individual project or app. > > > > You just need to put the code somewhere on your PYTHONPATH. There are > > complete instructions on the DjangoStuff track wiki, and in the code > > its self. You may need to modify some of the code in order to get it > > to work with your site. > > > > -Doug > > > > > -- matthew http://wadofstuff.blogspot.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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~--- Index: utils.py === --- utils.py (revision 1016) +++ utils.py (working copy) @@ -2,7 +2,7 @@ Simple and handy utility functions. """ -from django.models.core import sites +from django.contrib.sites.models import Site from django.core.template.defaultfilters import slugify from stuff.latin1 import latin1_to_ascii @@ -30,7 +30,7 @@ slug = _slug(slugify(latin1_to_ascii(title))) if sitesfield is not None: -current = sites.get_current() +current = Site.objects.get_current() i = 1 pslug = slug while True: @@ -38,7 +38,7 @@ kw.update(extra_kwargs) if sitesfield is not None: kw.update({'%s__id__exact' % sitesfield: current.id}) -t = table.get_list(**kw) +t = table.objects.filter(**kw) if not t: return pslug i += 1 @@ -53,6 +53,6 @@ global current_site if current_site is not None: return current_site -current_site = sites.get_current() +current_site = Site.objects.get_current() return current_site Index: json.py === --- json.py (revision 1016) +++ json.py (working copy) @@ -2,7 +2,7 @@ import types import re -from django.conf.settings import DEFAULT_CHARSET +from django.conf import settings ##json.py implements a JSON (http://json.org) reader and writer. ##Copyright (C) 2005 Patrick D. Logan @@ -301,7 +301,7 @@ obj = obj.replace('\r', r'\r') obj = obj.replace('\t', r'\t') if ty is types.StringType: -obj = obj.decode(DEFAULT_CHARSET) +obj = obj.decode(settings.DEFAULT_CHARSET) obj = str(ustring_quote(obj)) self._append(obj) self._append('"') Index: testing.py === --- testing.py (revision 1016) +++ testing.py (working copy) @@ -110,19 +110,15 @@ if hasattr(fixture_mod, '_fixtures'): return fixture_mod._fixtures -app_label = getattr(fixture_mod, 'app_label', None) -module_name = getattr(fixture_mod, 'module_name', None) +model_name = getattr(fixture_mod, 'model_name', None) fixtures = [] for name, obj in fixture_mod.__dict__.items(): if type(obj) == type and hasattr(obj, 'DATA'): -my_app_label = getattr(obj, 'app_label', app_label) -my_module_name = getattr(obj, 'module_name', module_name) -if not my_app_label or not my_module_name: +my_model_name = getattr(obj, 'model_name', model_name) +if not my_model_name: raise FixtureFileBroken, module -model_mod = __import__('django.models.%s' % my_app_label, {}, {}, [my_module_name]) -model_mod = getattr(model_mod, my_module_name) -
Re: Django Stuff
I want anybody to help me and tell me where to find https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/AbstractSearching that can work with Django stable version 0.95.1 cause i want to use Abstarct search module May be this is not the right place for this question but i really don't know where i can ask this question Thank you in advance Mary Adel On Mar 19, 9:41 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > DjangoStuff:https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoStuff > > Is not part of the core Django system and is third party. > It is developed by D. Joseph Creighton, and all questions on his code > should be directed to him:https://simon.bofh.ms/ > > In direct answer to your question: no. Not all of the djangostuff code > works with 0.95.1, some of it has been migrated, some of it has not, > and the testing framework has been deprecated in favor of the testing > framework in django. You will need to read up on the documentation on > each individual project or app. > > You just need to put the code somewhere on your PYTHONPATH. There are > complete instructions on the DjangoStuff track wiki, and in the code > its self. You may need to modify some of the code in order to get it > to work with your site. > > -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: use default value for an unavailable variable on a tag
Michel Thadeu Sabchuk wrote: > I've done a custom tag to use on my templates and I ned to pass a > variable to it, but this variable can or cannot exists. If the > variable doesn't exists, I get an error telling that form.data doesn't > have the key "city". In your tag you can catch the exception template.VariableDoesNotExist that is raised by the template.resolve_variable() function. Something like this: try: city = template.resolve_variable(variable_name, context) except template.VariableDoesNotExist: city = 'London' -- Jon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: problem with template {% url string %}
Paul Rauch wrote: > Template: > {% url cvh.view.login %} Here you have "view". > urlpatterns = patterns('mysite.cvh.views', > (r'^$','index'), > (r'^login/$','login'), > ) And here you have "views". {% url %} doesn't find your pattern and returns '' (empty string) that browser translates to a current URL. {% url cvh.views.login %} should do. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple Forms and/or Models from one template (newforms)
Brooks, Just saw your note and, no, I haven't gotten it to work the way I wanted. I'm having the same problem and just made another post on the subject. I've tried a bunch of different things, to no avail. I'll keep hacking away at it until it works and if I come up with something I'll drop you a note. Keep an eye on the new post and see if it helps. Conversely, if you've had some success I'd like to hear about it. Thanks, Jim On Feb 19, 6:16 pm, "brooks" <[EMAIL PROTECTED]> wrote: > Have you had any luck so far, Jim? I'm in a similar boat, and haven't > been able to get it to work. My problem seems to be adding the 'id' > to the clean_data and getting it to validate. Anything you've managed > to figure out would be very helpful. At this point, I'm stuck. > > On Jan 24, 11:33 am, "JimR" <[EMAIL PROTECTED]> wrote: > > > Thanks SmileyChris and ashwoods for the guidance, it definitely > > helped...I'm making progress. Once I've gotten to a point where I've > > got theformworking and validating, I'll post it for comment. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
use default value for an unavailable variable on a tag
Hi guys! I've done a custom tag to use on my templates and I ned to pass a variable to it, but this variable can or cannot exists. If the variable doesn't exists, I get an error telling that form.data doesn't have the key "city". To avoid this error I've done: {% block body_onload %} {% if form.data.city %} {% cidades_bodyonload form.data.city %} {% else %} {% cidades_bodyonload %} {% endif %} {% endblock %} I looking for a way to contract this, I try: {% block body_onload %}{% cidades_bodyonload form.data.city|default:'' %}{% endblock %} But I couldn't use filters here. Do you have any suggestion? Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
New Forms/Newbie Question
Alright, I've been struggling with this for a while, so I hope someone can help me. I'm not even sure if I can ask the question intelligently enough for a reply. I'll paraphrase the problem using a subset of my model. I'm familiar with DB programming but not good at it right now! I'm developing a membership registration form that is collecting data for several tables. I also have tables set up to store attributes about the data I'm collecting (e.g., telephone information can be "home," "business," "mobile," etc.). In essence, I have foreign keys set up within several tables. I want to create entries in each of the tables (user id, person inform, address, contact info, ...) for new data, and reference the attribute id for the appropriate foreign keys. The collecting and storing of the new data is straightforward enough. However, how do I retrieve/store the correct key/id for the attribute information? I generate a drop-down with the valid selections "home," "mobile," etc.) and then want to store it's associated id: Any help/suggestions would be greatly appreciated. Here's and abridged example: class Userid(models.Model): user_id = models.CharField(verbose_name="User ID", maxlength=15, primary_key=True) password = models.CharField(verbose_name="Password", maxlength=15) password_verify = models.CharField(verbose_name="Verify Password", maxlength=15) email = models.EmailField(verbose_name="e-mail") email_verify = models.EmailField(verbose_name="Re-enter e-mail") class Person(models.Model): user_id = models.ForeignKey(Userid) first_name = models.CharField(verbose_name="First Name", maxlength=50) middle_name = models.CharField(verbose_name="Middle Initial/ Name",maxlength=50) last_name = models.CharField(verbose_name="Last Name",maxlength=75) dob = models.DateField(verbose_name="Birth Date") ssn = models.CharField(verbose_name="Social Security #", maxlength=9, blank=True) gender = models.ForeignKey(GenderType, verbose_name="Gender") created_at = models.DateTimeField(default=datetime.now) updated_at = models.DateTimeField(default=datetime.now) class TelecommunicationNumber(models.Model): area_code = models.CharField(maxlength=10) contact_number = models.CharField(maxlength=40) extension = models.CharField(maxlength=10) country = models.ForeignKey(Country) type = models.ForeignKey(TelecommuncationType) unformatted_number = models.CharField(maxlength=70,editable=False) created_at = models.DateTimeField(default=datetime.now) updated_at = models.DateTimeField(default=datetime.now) class TelecommuncationType(models.Model): name = models.CharField(maxlength=50) description = models.CharField(maxlength=100, blank=True) created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_at = models.DateTimeField(auto_now=True, editable=False) class Country(models.Model): name = models.CharField(maxlength=100) internet_code = models.CharField(maxlength=2, blank=True) tele_code = models.CharField(maxlength=10, blank=True) abbr = models.CharField(maxlength=10, blank=True) number = models.IntegerField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True, editable=False) updated_at = models.DateTimeField(auto_now=True, editable=False) FORM: class RegistrationForm(forms.Form): ... phone_type = forms.ChoiceField(choices=[(c.description, c.name) for c in TelecommuncationType.objects.all()]) ... gender_type = forms.ChoiceField(choices=[(c.description, c.name) for c in GenderType.objects.all()]) ... country_id = forms.ChoiceField(choices=[(c.abbr, c.name) for c in Country.objects.all()]) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and referential integrity.
Thank you very much both of you! On 19 mar, 20:32, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 3/19/07, Grupo Django <[EMAIL PROTECTED]> wrote: > > > > > Does Django support referential integrity? > > Django does its best to emulate integrity features when they are not > present in the underlying database (for example, if you delete an > object to which other objects were related via foreign keys, Django > will work out what those objects are and delete them as well, > effectively emulating "ON DELETE CASCADE"), but it is preferred to use > a database -- such as PostgreSQL -- which has strong integrity support > by default. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
DjangoStuff: https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoStuff Is not part of the core Django system and is third party. It is developed by D. Joseph Creighton, and all questions on his code should be directed to him: https://simon.bofh.ms/ In direct answer to your question: no. Not all of the djangostuff code works with 0.95.1, some of it has been migrated, some of it has not, and the testing framework has been deprecated in favor of the testing framework in django. You will need to read up on the documentation on each individual project or app. You just need to put the code somewhere on your PYTHONPATH. There are complete instructions on the DjangoStuff track wiki, and in the code its self. You may need to modify some of the code in order to get it to work with your site. -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: defecting to django from rails
On Mar 17, 5:09 pm, "rubdabadub" <[EMAIL PROTECTED]> wrote > Now I also need to learn Python from scratch! Man! Python is a rather easy language to pick up. I suggest you start here: http://www.python.org/moin/BeginnersGuide Learning python through Django is kind of like learning C++ via MFC. Well that over stating things a bit. Django uses some advanced features of the language to get some of its work done. The end result is some of it appears to work by magic. This is not that big a deal, but I have seen it trip a few people up. Don't get too bogged down in trying to do things the 'python' or 'Django' way. > 1. How about deployment? Capistrano works with django i mean you can > make so called recipe but is there anything like that in python > world.. NOTE: don't get overwhelmed reading these sites, they are best used as reference or for when you are interested in solving a specific problem. Python has the cheezeshop for python modules, and packages called eggs (think RedHat RPM). http://cheeseshop.python.org/ There is also the ActiveState python cookbook repository: http://aspn.activestate.com/ASPN/Cookbook/Python/ As you noted Capistrano works with django, and the djangosnippet people are working on getting something integrated: http://www.djangosnippets.org/snippets/ The main django wiki site also has many many many pages and links to different django apps ready to plug in. > 2. How about "consuming XML" i didn't find much docs about it. I would > like to edit OPML files via the django-admin. My apps has some > database stuff but mostly I am playing 90% of the time with XML files > and 10% with a db. The best XML processing library in python is ElementTree. It comes with Python2.5 and can be downloaded seperatly for older python releases. You wont find much about consuming XML, generating PDF's, working with images, etc. in the Django docs, because there are standard python modules for dealing with those problems. The python standard library is extensive and so is the cheeseshop. There is a firefox sidebar for the python docs which I use regularly: http://www.edgewall.org/python-sidebar/html/toc-tutorial.html Unfortunately Ruby is becoming synonymous with RoR which is a huge injustice to the language. It means that there is allot of language documentation in the RoR docs (what there are of them). That isn't the case with Django so sometimes it can be confusing to people who have never seen Python before. It can be hard to discern which things are part of the language, the standard libraries, and what is part of Django. Luckily the documentation for all of these is fantastic and the community help is incredible. > 3. There are plenty of python programs out there that is off my > interest is there any "blog post" or anything that could guide me how > to djangofiy these scripts/apps. * Probably a dumb question due to > lack of python knowledge * James posts cover the links you need here. If there are pages dedicated to answering a question, it's defiantly not dumb. > 4. What about migrations i.e Schema Evolution is it in the trunk? Schema migration is a hot topic in general. There is work being done to make it easier to migrate your existing django code to a new schema. Currently you need to do this by hand. There is a wiki page for the progress of this feature: http://code.djangoproject.com/wiki/SchemaEvolution Django has schema introspection to create django code from an existing DB. http://www.djangoproject.com/documentation/legacy_databases/ > 5. Can I hook on to django SVN for production servers? is it a good > idea or should I go with released version? I prefer to use the svn trunk via svn:externals in my own svn project. This way I revision control the version of django I am using with the version of my code. It can also make it easier to upgrade a large number of production machines at once. I use buildbot for this, but there are a number of tools for doing an svn update on N networked machines. I have found the SVN trunk to be exceptionally stable. Django has a good set of standard tests which get run regularly, and I have my own tests for my sites. I recommend going this route. If you want to stick with a specific release of django you can. just set the svn:externals property to that release revision. The new features in django are too good to stick with the older releases. This will may change once 1.0 is released. > More ideas, pointers that will help me forget my loss (last 4 months) > are also welcome :-) Django has a very gradual learning curve over all. It is best to take it one step at a time and try not to do everything all at once. Start with something small and then build, adding features as you need. Start off with a basic model and get used to the django admin and the power of that interface. Then create some simple views of your data. Then add some custom forms. Then move on to login accounts, etc. Building, one step at a time will keep you from being overwhelmed by
Re: Django and referential integrity.
On 3/19/07, Grupo Django <[EMAIL PROTECTED]> wrote: > > Does Django support referential integrity? Django does its best to emulate integrity features when they are not present in the underlying database (for example, if you delete an object to which other objects were related via foreign keys, Django will work out what those objects are and delete them as well, effectively emulating "ON DELETE CASCADE"), but it is preferred to use a database -- such as PostgreSQL -- which has strong integrity support by default. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
On 3/19/07, Mary <[EMAIL PROTECTED]> wrote: > Does Django Stuff works with latest stable version for Django which is > 0.95.1 ?? What is "Django Stuff"? -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django and referential integrity.
On 3/19/07, Grupo Django <[EMAIL PROTECTED]> wrote: > > Does Django support referential integrity? Databases support referential integrity. Django supports databases. :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
What is "Django Stuff"? On 3/19/07, Mary <[EMAIL PROTECTED]> wrote: > > Does Django Stuff works with latest stable version for Django which is > 0.95.1 ?? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Stuff
Also jone more question where shall i put stuff when i download it ?? On Mar 19, 9:12 pm, "Mary" <[EMAIL PROTECTED]> wrote: > Does Django Stuff works with latest stable version for Django which is > 0.95.1 ?? > > Thank you in advance; > Mary Adel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django and referential integrity.
Does Django support referential integrity? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
problem with template {% url string %}
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 hello users, I've a problem with the template"function" url: http://www.djangoproject.com/documentation/templates/#url Template: {% url cvh.view.login %} mysite.urls: from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^test/polls/',include('mysite.polls.urls')), (r'^test/cvh/',include('mysite.cvh.urls')), # Uncomment this for admin: (r'^test/admin/', include('django.contrib.admin.urls')), ) mysite.cvh.urls: from django.conf.urls.defaults import * urlpatterns = patterns('mysite.cvh.views', (r'^$','index'), (r'^login/$','login'), ) according to the documentation {% url cvh.view.login %} should render to /test/cvh/login/ but it renders to /test/cvh/ even {% url blablupp %} renders to /test/cvh/ what am I doing wrong?.. mfg Paul Rauch -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iQIVAwUBRf7jIRG67lyyQrltAQJg2hAAlZfrsyedgnwfrl1DGvyaMGwtO9gi9X63 3seW4H0xQJpAPzfZzdFR+AEnConM3cgWXuSle/HOJ7jzHrjNhNgp/+/M2xZNnnCo iG5aDMLpxjMdJaobA4OwAGFDlFKviD62MzEgQNSV0wGXJSfZJB15vJFbofNcM5lT HpCtTDDHFwhqys6O2uy8I/SHe/KosqigjXCxaTLxvymIuyftQYH70zEFRfEQz8Cz G+0aYI6kGuScDvoIWxaEZy5DUI6vDj+hoM+0YopnRPsqjmml74Ik6sBTFEDdc3LU ZdZuQD72xCe+ARdqTmPmYf4G3d8vkjb99Eco4+HpznhTyJU2Qt41uM+8SJfsu2F2 gNTgeE0F5CyiI/qIcpLGV8x2dtfaW7+AL3BKcCHl1KVfnO1iwvUbctG0TltCTDrn a5mXpYlOIIFpwDKx4OGUVR2B5u6rFiRRyd2tidj/DRlSmFNzTTzVsTt0mLFtPuHU ij+itGS8TGlmJu2nqSl+F03Z1V40HyRaIiNdwR43G83TLHQNzCZhX1QeAJRlgttm A8YY+uJ1r5GGmfDtXwvHISWv19oMf7BwfaKgvbR6hnghdBz8zXMPU0m6JpE8gd9U 9LlPtV+QM95uxBfsQ7u5ztGiXh9a5+BBh4JmdItNp7+QypE/MC7Lbi4DCAdg9dQF v25lYo9ZLMQ= =Cpw1 -END PGP SIGNATURE- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A custom label on a newforms Field doesn't get passed trought pretty_name
Ok, and I think this is the right approach ;) I have just one note: the admin interface turns the first character of a custom label to uppercase. Should the admin interface follow the same pattern and keep the custom label as is? I only get confused in this question because of the different way that the admin interface and the newforms work. But this is not even a real problem, this is just to keep the logic. Thanks for help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django Stuff
Does Django Stuff works with latest stable version for Django which is 0.95.1 ?? Thank you in advance; Mary Adel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SESSION_EXPIRE
Two things, that might be the cause of your problem: a) Have you restarted your browser or at least removed settings.pyc after the changes? b) If you use Mac OS and you close the window of your browser, the browser itself isn't closed. Press Cmd+Q to close the browser completely. Regards, Aidas Bendoraitis [aka Archatas] On 3/19/07, tyman26 <[EMAIL PROTECTED]> wrote: > > Where do I set the 'SESSION_EXPIRE_AT_BROWSER_CLOSE = True'? I added > this to the "settings" file and sync'd the database, but when I close > the browser the session still stays intact. Do I have to add this > when the session is created? > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using custom tags inside custom tags
I think the ideal would be to keep the two tags decoupled, so I think I'll instead use another approach. Instead of using the "list_limit" tag I'll just pass the value from the view to the template (inside the "context"). thanks, Filipe On Mar 19, 4:08 pm, Georgi Stanojevski <[EMAIL PROTECTED]> wrote: > Filipe Correia напиша: > > > {% ifgreaterthan items|length list_limit %} > > See all the records. > > {% endifgreaterthan %} > > > Using {% list_limit %} prints it's value fine but somehow, when used > > in the context of another tag, it's value isn't resolved. > > Prehaps you could try setting a context variable in list_limit and pass > that as an argument to ifgreaterthan? > > http://www.djangoproject.com/documentation/templates_python/#setting-... > > -- > Glisha > The perfect OS, MS-DOS! > No patches, no root exploits for 21 years. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
problems with many to many relations.
I have started to use django to develop an application , i use the Object-relational mapper from django because i develop a python-qt application i had a problem with many to many relation. My models: RoutePointLog: -- from django.db import models from client import Client from driver import Driver from task import Task from routelog import RouteLog class BaseMeta: app_label = 'main' class RoutePointLog( models.Model ): route = models.ForeignKey( RouteLog ) client = models.ForeignKey( Client ) comment = models.CharField( maxlength=100 ) tasks = models.ManyToManyField( Task ) Meta=BaseMeta RouteLog: - from django.db import models from client import Client from driver import Driver from task import Task class BaseMeta: app_label = 'main' class RouteLog( models.Model ): date = models.DateTimeField( ) Meta=BaseMeta tasks - from django.db import models from enterprise import * class BaseMeta: app_label = 'main' class Task( models.Model ): name = models.CharField(maxlength=200,unique=True) enterprise = models.ForeignKey( Enterprise ) Meta=BaseMeta Code i have problems: for rp in self.routeLog.routepointlog_set.all(): print rp html=html+""+ rp.client.code +" " html=html+""+ rp.client.name +" " html=html+""+ rp.client.name +" " html=html+""+ rp.client.city +" " html=html+""+ rp.client.locality +"" for task in rp.tasks.all(): print task html=html+""+ task.name +"" html = html + "" and the output: Traceback (most recent call last): File "/home/angel/prog/track/main/routeadminui.py", line 165, in slotPrint html = self.getHtml( ) File "/home/angel/prog/track/main/routeadminui.py", line 152, in getHtml for task in rp.tasks.all(): File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 103, in __iter__ return iter(self._get_data()) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 430, in _get_data self._result_cache = list(self.iterator()) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 171, in iterator select, sql, params = self._get_sql_clause() File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 444, in _get_sql_clause joins2, where2, params2 = self._filters.get_sql(opts) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 574, in get_sql joins2, where2, params2 = val.get_sql(opts) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 622, in get_sql return parse_lookup(self.kwargs.items(), opts) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 734, in parse_lookup joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/q uery.py", line 835, in lookup_inner raise TypeError, "Cannot resolve keyword '%s' into field" % name TypeError: Cannot resolve keyword 'routepointlog' into field any idea? thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
SESSION_EXPIRE
Where do I set the 'SESSION_EXPIRE_AT_BROWSER_CLOSE = True'? I added this to the "settings" file and sync'd the database, but when I close the browser the session still stays intact. Do I have to add this when the session is created? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Schema evolution
Hi all, Does anyone know what the plans for the schema evolution branch are? Can we expect to see its ideas and code in 1.0? I ask as having to write a patch runner to update live schemas is the only part of working with Django that is an annoyance :) Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A custom label on a newforms Field doesn't get passed trought pretty_name
> class MyForm(forms.Form): > field1 = forms.CharField(max_length=100) > field2 = forms.Charfield(max_length=100, label='custom field') > > When I render the field, the label for field1 get his first character > uppercased and becomes "Field1", the label for field2 was set by the > label keyword and this value doesn't get passed through pretty_name > function and keeps "custom field" (without the first letter > uppercase). > > I couldn't figure out if this is a bug or a design decision. I'd say it's a design decision: Django makes a smart guess as to what to make the default, but if you specify "this is my label", it should use it verbatim. So if you have x = forms.CharField(max_length=10, label='mY l33t f13Ld') It should assume you know what you're rambling about and just use it. If you need it, you can always do something like label=pretty_name('custom field') -tkc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Subversion: How do you set up multiple branches of the same project on the same machine?
How can you import from a package if it is not under python path? Is there another way to do that than just to create a symlink in site-packages? PYTHON_PATH environment variable? The relation between someproject and someproject2 in my case is similar to django trunk and django per-object-permission branch. They are like one project at different statuses and at some point they'll need to be merged (at least some parts of them). Both someproject and someproject2 are self-contained projects. No other project uses any part of them. Regards, Aidas Bendoraitis [aka Archatas] On 3/19/07, ScottB <[EMAIL PROTECTED]> wrote: > > Hi Aidas. > > On Mar 19, 2:18 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]> > wrote: > > I have a symlink from trunk/someproject to site-packages/someproject > > on my machine. > > > > I need to launch the branched version of the project at the same time. > > So intuitively I create a symlink from branches/somebranch/someproject > > to site-packages/someproject2 to get it to the python path. > > Do your projects really need to be in site-packages? Are they normal > self-contained projects, or does something else import them? > > I'm thinking you could have: > > /home/me/dev/someproject/ > /home/me/dev/someproject2/ > > Then either use manage.py runserver for each one (with different > ports), or configure Apache/Lighty/whatever to access those two > projects under different urls. That way, both can run simultaneously. > > Scott > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A custom label on a newforms Field doesn't get passed trought pretty_name
On Mon, 19 Mar 2007 12:47:23 -0400, Michel Thadeu Sabchuk <[EMAIL PROTECTED]> wrote: > > Hi guys, > > If I have a form defined on newforms as: > > class MyForm(forms.Form): > field1 = forms.CharField(max_length=100) > field2 = forms.Charfield(max_length=100, label='custom field') > > When I render the field, the label for field1 get his first character > uppercased and becomes "Field1", the label for field2 was set by the > label keyword and this value doesn't get passed through pretty_name > function and keeps "custom field" (without the first letter > uppercase). > > I couldn't figure out if this is a bug or a design decision. > I it is a bug I can fix and send a patch. > Is it a bug? > That is by design. A custom label is just that. If you wnat your label in all lowercase, then that is possable. Whatever you type in your code is exactly how it will appear. That is complete customization. Pretty-name is just a shortcut for lazy programmers (we all are) when the default behavior is good enough. -- Waylan Limberg [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyField, limit_choices_to and properties of the request object
Brilliant - thanks, Sam. Is this in the docs anywhere, I wonder? I've seen a few queries along these lines. Might be an FAQ Q --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Subversion: How do you set up multiple branches of the same project on the same machine?
Hi Aidas. On Mar 19, 2:18 pm, "Aidas Bendoraitis" <[EMAIL PROTECTED]> wrote: > I have a symlink from trunk/someproject to site-packages/someproject > on my machine. > > I need to launch the branched version of the project at the same time. > So intuitively I create a symlink from branches/somebranch/someproject > to site-packages/someproject2 to get it to the python path. Do your projects really need to be in site-packages? Are they normal self-contained projects, or does something else import them? I'm thinking you could have: /home/me/dev/someproject/ /home/me/dev/someproject2/ Then either use manage.py runserver for each one (with different ports), or configure Apache/Lighty/whatever to access those two projects under different urls. That way, both can run simultaneously. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
A custom label on a newforms Field doesn't get passed trought pretty_name
Hi guys, If I have a form defined on newforms as: class MyForm(forms.Form): field1 = forms.CharField(max_length=100) field2 = forms.Charfield(max_length=100, label='custom field') When I render the field, the label for field1 get his first character uppercased and becomes "Field1", the label for field2 was set by the label keyword and this value doesn't get passed through pretty_name function and keeps "custom field" (without the first letter uppercase). I couldn't figure out if this is a bug or a design decision. I it is a bug I can fix and send a patch. Is it a bug? Thanks in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyField, limit_choices_to and properties of the request object
On Mon, 19 Mar 2007 09:29:08 -0700, quentinsf wrote: > I need to do something similar. In a form I want to limit the options > in a ForeignKey's pull-down select field to objects owned by an > organisation of which the user is a member. > > I've been trying to work out where this would fit. Any help much > appreciated. It turns out that you can just set the field's choices after the manipulator has been created: m = Post.AddManipulator () m['images'].choices = [(i.id, i) for i in Image.objects.filter (author = request.user)] -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Authentication Issues...
On 3/19/07, mediumgrade <[EMAIL PROTECTED]> wrote: > I am not sure what the difference is between RequestContext and > Context (I am still fairly new to Django and Python). RequestContext automatically adds some extra variables to the context of every template that uses it; exactly which variables depends on the TEMPLATE_CONTEXT_PROCESSORS setting, but the default set includes a variable called 'user', which lets you do things like '{% if user.is_authenticated %}' in a template. To use it you'd want to do something like this: from django.template import RequestContext def home(request): if not request.user.is_authenticated(): return render_to_response('login_error.html', {}, context_instance=RequestContext(request)) else: return render_to_response('index.html', {}, context_instance=RequestContext(request)) And also note that Django will happily help you out with forcing login; you could write the view like this: from django.template import RequestContext from django.contrib.auth.decorators import login_required def home(request): return render_to_response('index.html', {}, context_instance=RequestContext(request)) home = login_required(home) The 'login_required' decorator will accomplish the same thing as your manual authentication check -- if the user isn't logged in, it will force them to log in and then go on to your view. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyField, limit_choices_to and properties of the request object
I need to do something similar. In a form I want to limit the options in a ForeignKey's pull-down select field to objects owned by an organisation of which the user is a member. I've been trying to work out where this would fit. Any help much appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using custom methods in queryset lookups
> Now, I want to select all records whose duration (end_time - > start_time) is more than 2 hours. > > I tried a custom method in the model like this which returns the > duration but cannot figure out how to use it in queryset filters. Filtering by calculated fields is best done on the server side so you don't bring all the data across the pipe, just to throw it away. This may not matter if you only have a handful of records, but if your data collection will grow indefinitely, you certainly don't want to be pulling bajillions of records across the connection, just to skim through them and toss the uninteresting ones. If it's to be done on the DB-server side of things, the syntax is a bit dependant on the DB engine you're using. However, the basics: # sqlite would be something like items = items.extra(where=""" julianday(end_time) - julianday(start_time) > 2 * 60 * 60 * 100 """) # 60 minutes * 60 seconds * 100ths of a second # I don't know if the precision of julianday() varies by machine # postgresql's much cleaner syntax items = items.extra(where=""" start_time + interval '2 hours' > end_time """) Those are the two DBs I have at hand. If you're using a different DB back end, you'll have to look into its date-math syntax. It looks like the MySQL syntax might be something like items = items.extra(where=""" date_add(start_time, interval 2 hour) > end_time """) #close to PostgreSQL syntax, but with quotes and "hour" and on SQLServer, there's a DateDiff() function that one would want to use. I know it's a bear to deal with differing syntax...perhaps something like this might be a helpful wrapper function to include in the DB abstraction layer, much like the quote_name function, a "date-arithmetic" function that returns the DB-specific SQL clause for the difference between two dates/times/datetimes. Or perhaps there already is one, and I missed it? -tkc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Authentication Issues...
I am getting exactly this same issue when i don't use the built in login short cuts. I too would be interested in the answer. On Mon, 19 Mar 2007 08:11:08 -, mediumgrade <[EMAIL PROTECTED]> wrote: > > So, I am writing my first Django app that requires some form of > authentication, and I have run into a bit of a snag: > > I authenticate the user via the 'django.contrib.auth.views.login' view > using a login template like this: > > > {% block main_section %} > > > {% if form.has_errors %} > Your username and password didn't match. Please try again. > {% endif %} > LoanCRM > > > Username: td>{{ form.username }} > Password: td>{{ form.password }} > > > > > > > > {% endblock %} > > > As you can see, this redirects the user to the URL "/home". > > "Home" is rendered using a template like this: > > > > > {% block contentbody %} > {% if is_logged_in %}Thanks for logging in!{% else %}Please log in.{% > endif %} > {% endblock %} > > > > > The login process seems to work just fine. If the password is > incorrect, the login page will warn them. If the password is correct, > the user proceeds to the "/home" URL. > > The problem is that once they are at the "/home" URL, the template > does not show that the user is logged in. The "if is_logged_in" test > fails. > > What could I be doing wrong? > > > > -- http://belfast.no-ip.info/ Get http://www.ubuntu.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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using custom tags inside custom tags
Filipe Correia напиша: > {% ifgreaterthan items|length list_limit %} > See all the records. > {% endifgreaterthan %} > > Using {% list_limit %} prints it's value fine but somehow, when used > in the context of another tag, it's value isn't resolved. Prehaps you could try setting a context variable in list_limit and pass that as an argument to ifgreaterthan? http://www.djangoproject.com/documentation/templates_python/#setting-a-variable-in-the-context -- Glisha The perfect OS, MS-DOS! No patches, no root exploits for 21 years. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How much is Django memory footprint?
Hi, Anyone can say how much memory an apache process wastes in a django app, in your servers? I can't understand why the 2 servers that I have, one dedicated and other in a slicehost, with the same distro and apps installed. Have diferent memory stats. In my slice I have something like: PID USER PR NI VIRT RES SHR S %CPU %MEMTIME+ DATA COMMAND 14611 www-data 16 0 105m 33m 4096 S0 6.6 0:01.95 29m apache2 2010 mysql 15 0 148m 29m 5220 S0 5.8 0:16.78 124m mysqld 14608 www-data 15 0 99136 27m 3776 S0 5.3 0:01.65 23m apache2 14609 www-data 16 0 98620 26m 3776 S0 5.2 0:01.63 22m apache2 30782 www-data 15 0 98020 25m 3744 S0 5.1 0:00.82 22m apache2 30781 www-data 15 0 97956 25m 3748 S0 5.1 0:00.80 22m apache2 30648 www-data 15 0 97.8m 25m 4032 S0 5.0 0:01.00 22m apache2 20138 www-data 15 0 97368 25m 3760 S0 4.9 0:01.07 21m apache2 30638 www-data 15 0 96876 24m 3748 S0 4.9 0:00.96 21m apache2 30663 www-data 16 0 96820 24m 3748 S0 4.8 0:00.84 21m apache2 30795 www-data 16 0 96728 24m 3744 S0 4.8 0:00.74 21m apache2 [...] In the dedicate server(that have more traffic than the slice): PID USER PR NI VIRT RES SHR S %CPU %MEMTIME+ DATA COMMAND 3878 mysql 15 0 126m 21m 4884 S0 2.1 0:54.72 118m mysqld 25271 www-data 15 0 24824 18m 4084 S0 1.8 0:00.68 14m apache2 16845 www-data 15 0 24176 18m 4080 S0 1.8 0:01.00 14m apache2 26070 www-data 15 0 24764 17m 3524 S0 1.8 0:00.63 14m apache2 26137 www-data 15 0 24700 17m 3528 S0 1.8 0:00.54 14m apache2 26100 www-data 15 0 24120 17m 3528 S0 1.7 0:00.59 14m apache2 26069 www-data 16 0 23972 17m 3536 S0 1.7 0:00.65 14m apache2 26141 www-data 16 0 23612 17m 3528 S0 1.7 0:00.64 13m apache2 25660 www-data 15 0 19500 13m 4088 S0 1.4 0:00.41 9912 apache2 26489 www-data 16 0 19524 13m 3528 S0 1.3 0:00.38 9936 apache2 24899 www-data 16 0 19040 12m 4076 S0 1.3 0:00.44 9452 apache2 [...] Some times I have apache processes with 49mb in the slice, I think is too much. By the way I'm using Ubuntu 6.06LTS with apache prefork MPM in both servers. The slice have 512Mb and with this in apache: StartServers 5 MinSpareServers 5 MaxSpareServers 10 MaxClients 20 MaxRequestsPerChild 0 I have DEBUG=False in all apps. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Authentication Issues...
I am not sure what the difference is between RequestContext and Context (I am still fairly new to Django and Python). Here is my view code: def home(request): if not request.user.is_authenticated(): return render_to_response('login_error.html') else: return render_to_response('index.html') This is just a basic place holder for now as I am developing the application. Is there something wrong with this method? On Mar 19, 5:29 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Mar 19, 4:11 am, "mediumgrade" <[EMAIL PROTECTED]> wrote: > > > The problem is that once they are at the "/home" URL, the template > > does not show that the user is logged in. The "if is_logged_in" test > > fails. > > > What could I be doing wrong? > > 1. where is your view code? > 2. where does the 'is_logged_in' variable come from? That is not > standard django. > 3. {% if user.is_authenticated %} is standard. > 4. Are you using RequestContext or Context in your view? (you need > RequestContext to get the user object) > > Seehttp://www.djangoproject.com/documentation/authentication/#authentica... > for more details. > > -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ManyToManyField, limit_choices_to and properties of the request object
Is it possible to use a ManyToManyField's limit_choices_to attribute to limit a user to picking only from related objects that have author = request.user? Given that request has no place in the model definition, would it be necessary to write a custom manipulator? -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 signature.asc Description: This is a digitally signed message part
Re: creating a website log
2007/3/6, limodou <[EMAIL PROTECTED]>: > > I think signals will be easier, if you also want to record delete > information of a record, you can also hook pre_delete, the pseudo code > is: > > from django.db.models import signals > > def pre_save(sender, instance, signal, *args, **kwargs): > if instance.id:#update > state = 'change' > old_record = serder.objects.get(id=instance.id) #because the > instance has been changed, so you should get the unchanged record > first > result = #compre old_record and instance > else: > state = 'add' > result = #format instance > WriteLog(state, result) > > def pre_delete(sender, instance, signal, *args, **kwargs): > state = 'delete' > result = #format instance > WriteLog(state, result) > > dispatcher.connect(pre_save , signal=signals.pre_save) > dispatcher.connect(pre_delete , signal=signals.pre_delete) > I'm really interested in this elegant solution. I want to log actions in database from many objects and many applications in my project and I don't know if it's feasible easily with signals. If yes, where did I have to put this code? Documentation on signals is a bit short... even if mercurityde whitepaper is a great help (http://www.mercurytide.com/whitepapers/django-signals/). Thanks, David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using custom methods in queryset lookups
Hi everyone, A simplified version of my model looks like this: class Schedule(models.Model): start_time = models.DateTimeField('Start Time') end_time = models.DateTimeField('End Time') event = models.CharField(maxlength=100) Now, I want to select all records whose duration (end_time - start_time) is more than 2 hours. I tried a custom method in the model like this which returns the duration but cannot figure out how to use it in queryset filters. class Schedule(models.Model): start_time = models.DateTimeField('Start Time') end_time = models.DateTimeField('End Time') event = models.CharField(maxlength=100) def event_duration(self): return self.end_time-self.start_time Could anyone suggest the best way to do this? Thanks, Sambhav --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: update_object and duplication of inline objects on save
Hello all, I'm still really stuck with this problem. I could write a custom manipulator, although then I loose lots of the useful admin-related functionality e.g. num_in_admin, num_extra_on_change etc. I suspect I should really update my version of django and swap everything to the newforms library, and sort it out after that if there's still a problem, but unfortunately I really don't have time at the moment and just need it to work! If there's a bugfix that I've missed (I have searched long and hard) then I would be really grateful for a pointer. Many thanks Martin On 3/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Hi, > > I have the same or similar problem. I'm using update_object to > reproduce the inline editing of a foreignkey join table that works > very well in the admin interface. When editing a publication, I need > to be able to add authors to the publication, who are linked to > publications by an explicit join table (authorships - to allow > ordering of authors on the publication). > > > > Models are as follows: > > class Publication(models.Model): > many fields (none relevant to this problem) > > class Author(models.Model): > some fields - name, email address etc - again not relevant > > class Authorship(models.Model): > # an explicit join table between authors and publications to > enable ordered authorship > publication = models.ForeignKey(Publication, > edit_inline=models.TABULAR, > num_in_admin=10, num_extra_on_change=3) > author = models.ForeignKey(Author, core=True) > > > There is a very simple view which gets some info about where this > editing is being done and passes appropriate extra_context and model > kwargs to the update_object generic view (object_id is resolved from > urls.py) > > def edit_publication(request, **kwargs): > group = kwargs.get("group", False) > if group: > g = Group.objects.get(acronym=group) > if request.user.is_anonymous(): > return HttpResponseRedirect(settings.URLBASE +'/accouns/ > login/') > person = request.user.person > membership = person.membership_set.all() > if group: > css = g.defaultcss > logo = g.get_logo_url() > del kwargs['group'] > redirect = g.get_absolute_url() + '/publications/' > else: > css = settings.DEFAULT_CSS > logo = settings.DEFAULT_LOGO > redirect = settings.URLBASE + '/publications' > kwargs['model'] = Publication > kwargs['extra_context'] = {'css':css, 'logo':logo, > 'membership':membership, > 'add':False, 'post_save_redirect':redirect} > return update_object(request, **kwargs) > > > The bit of the publication_form template for the inline editing of > authors(hips) is as follows: > > > {% for authorship in form.authorship %} > Author > {{forloop.counter0}} > {{ authorship.author }} > {% endfor %} > > > > > This produces html form code exactly the same as appears in the admin > interface for doing the same thing: > ... > Author 0 > name="authorship.0.author" size="1"> > > > > Author 1. > name="authorship.1.author" size="1">... etc > > These show the correct authors auto-selected in the form rendered by > update_object, and the form works fine when the exact same template is > used for the create_object generic view. However, when editing objects > using the update_object view as described above, authors are re-added > (i.e. new authorships are created) for each of the authors on the > publication on save. If one 'blanks' each of the auto-filled author > fields i.e. select "---" for each of id_authorship.0.author > etc before editing other fields, then save, the original authorships > are preserved and no new ones are added. > > This is all very strange as I'm sure I'm reproducing admin > functionality exactly, and it all works perfectly well there - > probably just me not seeing the wood for the trees. > > Any help would be most gratefully appreciated > > Best regards > > Martin > > > > On Feb 22, 2:27 pm, Antonio <[EMAIL PROTECTED]> wrote: > > hi all, > > > > I've used thegenericview 'update_object' to modify a class with a > > ForeignKey() ... the urls.py: > > > > (r'^confs/(?P\d+)/$', \ > > 'django.views.generic.create_update.update_object', \ > > { 'model': Conferma, 'login_required': True }), > > > > the models.py: > > > > class DatiConf(models.Model): > > fk_conf = models.ForeignKey(Conferma, edit_inline = > models.TABULAR) > > > > > > in conferma_form.html > > > > {% if form.daticonf %} > > > > Dati Conferma > > > > > > Comandante > > Ora disormeggio > > > > {% for x in form.daticonf %} > > > > > > {{ x.com }} > > {% if x.com.errors %} > > {{ x.com.errors|join:", " }}
problems with many to many relations.
I have started to use django to develop an application , i use the Object-relational mapper from django because i develop a python-qt application i had a problem with many to many relation. My models: RoutePointLog: -- from django.db import models from client import Client from driver import Driver from task import Task from routelog import RouteLog class BaseMeta: app_label = 'main' class RoutePointLog( models.Model ): route = models.ForeignKey( RouteLog ) client = models.ForeignKey( Client ) comment = models.CharField( maxlength=100 ) tasks = models.ManyToManyField( Task ) Meta=BaseMeta RouteLog: - from django.db import models from client import Client from driver import Driver from task import Task class BaseMeta: app_label = 'main' class RouteLog( models.Model ): date = models.DateTimeField( ) Meta=BaseMeta tasks - from django.db import models from enterprise import * class BaseMeta: app_label = 'main' class Task( models.Model ): name = models.CharField(maxlength=200,unique=True) enterprise = models.ForeignKey( Enterprise ) Meta=BaseMeta Code i have problems: for rp in self.routeLog.routepointlog_set.all(): print rp html=html+""+ rp.client.code +" " html=html+""+ rp.client.name +" " html=html+""+ rp.client.name +" " html=html+""+ rp.client.city +" " html=html+""+ rp.client.locality +"" for task in rp.tasks.all(): print task html=html+""+ task.name +"" html = html + "" and the output: Traceback (most recent call last): File "/home/angel/prog/track/main/routeadminui.py", line 165, in slotPrint html = self.getHtml( ) File "/home/angel/prog/track/main/routeadminui.py", line 152, in getHtml for task in rp.tasks.all(): File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 103, in __iter__ return iter(self._get_data()) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 430, in _get_data self._result_cache = list(self.iterator()) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 171, in iterator select, sql, params = self._get_sql_clause() File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 444, in _get_sql_clause joins2, where2, params2 = self._filters.get_sql(opts) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 574, in get_sql joins2, where2, params2 = val.get_sql(opts) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 622, in get_sql return parse_lookup(self.kwargs.items(), opts) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 734, in parse_lookup joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, opts.db_table, None) File "/usr/lib/python2.4/site-packages/Django-0.95.1-py2.4.egg/django/db/models/query.py", line 835, in lookup_inner raise TypeError, "Cannot resolve keyword '%s' into field" % name TypeError: Cannot resolve keyword 'routepointlog' into field any idea? thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using custom tags inside custom tags
Hi, I'm trying to write a custom tag which would accept as a parameter a value from another custom tag. The usage would be something like the following (trunclist_legth is a custom template tag which simply returns an int value): {% ifgreaterthan items|length list_limit %} See all the records. {% endifgreaterthan %} Using {% list_limit %} prints it's value fine but somehow, when used in the context of another tag, it's value isn't resolved. Inside the "render" method of "ifgreaterthan" I'm using: val2 = self.param2.resolve(context) self.param2.var does contain the string "list_limit", but resolve() returns an empty string instead of the int value I was expecting. I must be doing something wrong... any thoughts? thanks in advance, Filipe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Subversion: How do you set up multiple branches of the same project on the same machine?
We have the following structure for development files under subversion: trunk |_ someproject |_ media branches |_ somebranch |_ someproject |_ media I have a symlink from trunk/someproject to site-packages/someproject on my machine. I need to launch the branched version of the project at the same time. So intuitively I create a symlink from branches/somebranch/someproject to site-packages/someproject2 to get it to the python path. When I try to run the shell for the project, the settings file from someproject is taken instead of someproject2: the symlink is followed and the real name of the linked directory is used instead of the name of the symlink. The only solution that I came up with was to rename someproject to someproject2 in the somebranch and then to create a symlink from branches/somebranch/someproject2 to site-packages/someproject2 (notice the matching names). But in that case I won't be able to merge the branch back to the project, will I? How do you solve problems like that, or how could I deal with it instead of renaming the project? Regards, Aidas Bendoraitis [aka Archatas] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
__search works in mysterious ways.
I'm getting unexpected (missing) results from the __search field lookup it looks like it can only finds whole words, but only if they're larger than 3 chars. is this correct? and is it supposed to work like this? In [65]: c.choice='ABC123\ncde456' In [66]: c.save() In [67]: Choice.objects.filter(choice__search='abc123') Out[67]: [ABC123 cde456] In [68]: c.choice='ABC\ncde' In [69]: c.save() In [70]: Choice.objects.filter(choice__search='abc') Out[70]: [] abe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple file upload crashes dev server
You might want to throw some logging into your application (Python's logging module). [0] If you use logging, you'll be able to get a better handle on where the problem is actually happening. I've heard of the dev server crashing ungracefully when it encounters an error, but have never seen it myself. The reports I've heard all end up being programmer error, not problems with Django. Also, I've never heard of it taking down the whole machine. - Ben [0] http://docs.python.org/lib/node407.html -- the second example writes to a file On 3/19/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Mar 19, 1:56 am, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > > > The PC literally starts beeping like mad (it's a hardware beep that > > > you can hear even if the speakers are off). > > > > I know this is going to sound like a cop-out, but it really sounds > > like a hardware problem. There is no reason why a python script of ANY > > kind would cause a hardware lockup as you are describing. It sounds > > more like a memory fault. If it happens with more than one machine I > > would be extremely impressed. > > It _does_ happen on more than one machine and on both WinXp and > Win2k3. They're both Dell machines though with different hardware > > L. > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Search feature
On Feb 22, 11:07 pm, "Mary" <[EMAIL PROTECTED]> wrote: > How can i add a search feature to my website? > > Can anybody help me in this Hi Mary, have a look at these two snippets: http://www.djangosnippets.org/snippets/31/ (long version, easier to understand the principle) http://www.djangosnippets.org/snippets/32/ (compact version) L. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: referrers: to django or not?
Hi Bram. On Mar 17, 2:17 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > "in the last 7 days your blog/item/whatever has been visited from: > 7 xhttp://somewebsite.com > 5 xhttp://someotherwebsite.com Beware of opening yourself up to referrer spam. Spam bots can request pages on your site and pass their own website as the referrer. This gets you to list a link to their site. http://en.wikipedia.org/wiki/Referer_spam > Should I be thinking Django (and perhaps middleware) or should I be > thinking about parsing apache logs via a cron? I suppose it depends how concerned you are about performance. Apache is logging the information anyway, so it saves you a write to the database. If you are updating stats every day or hour instead of every request, you could use cron to parse the logs and generate some static info for your templates to include. It's probably also a good candidate for caching. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Authentication Issues...
On Mar 19, 4:11 am, "mediumgrade" <[EMAIL PROTECTED]> wrote: > The problem is that once they are at the "/home" URL, the template > does not show that the user is logged in. The "if is_logged_in" test > fails. > > What could I be doing wrong? 1. where is your view code? 2. where does the 'is_logged_in' variable come from? That is not standard django. 3. {% if user.is_authenticated %} is standard. 4. Are you using RequestContext or Context in your view? (you need RequestContext to get the user object) See http://www.djangoproject.com/documentation/authentication/#authentication-data-in-templates for more details. -Doug --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: model relationship filtering
Hello, > If a gallery is unique to a rantal, why use a n:m relationship? You > should be able to use a 1:m if each photo is associated with exactly one > rental. As to putting the images in rental-specific sub-directories, can > you make the association from photo to rental explicit and do this? I have switched to ForeignKey with edit_inline, and everything works now nicely. Thank you ! Robbin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Authentication Issues...
So, I am writing my first Django app that requires some form of authentication, and I have run into a bit of a snag: I authenticate the user via the 'django.contrib.auth.views.login' view using a login template like this: {% block main_section %} {% if form.has_errors %} Your username and password didn't match. Please try again. {% endif %} LoanCRM Username:{{ form.username }} Password:{{ form.password }} {% endblock %} As you can see, this redirects the user to the URL "/home". "Home" is rendered using a template like this: {% block contentbody %} {% if is_logged_in %}Thanks for logging in!{% else %}Please log in.{% endif %} {% endblock %} The login process seems to work just fine. If the password is incorrect, the login page will warn them. If the password is correct, the user proceeds to the "/home" URL. The problem is that once they are at the "/home" URL, the template does not show that the user is logged in. The "if is_logged_in" test fails. What could I be doing wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---