Django TCP socket communication
I am new to TCP socket programming. I have a django based server communicating with a microcontroller. Now, I want to implement TCP based socket on the server side in order to communicate with the TCP socket on the microcontroller. Can anyone give me an idea on how to do this ? What libraries should I use on my django server The microprocessor basically opens the socket every 5 seconds and sends a notification to the server. I on the server side should be able to read this and pump data back to the microprocessor using this socket which was opened by the microprocessor. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ea5bf85-0163-40cf-a4da-ec9edb27f3ac%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Adding context data to a TemplateView?
An additional point, if you want to be able to use the view more generically (be able to pass in custom context from your urls.py), I've done the following: class StaticPageView(TemplateView): context = None def get_context_data(self, **kwargs): context = super(StaticPageView, self).get_context_data(**kwargs) context.update(self.context or {}) return context -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cc05af47-b6ae-4050-bbd9-6a8958db502e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
python list to string conversion
Hi all. I have a simple list such as: ['1','2','3','4'] I need to convert this to a string such as: 1,2,3,4 so that I can use that in a sql function. any help is 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: python list to string conversion
On Sep 1, 9:34 am, "Valts Mazurs" <[EMAIL PROTECTED]> wrote: > yourList = ['1','2','3','4'] > stringForQuery = ','.join(yourList) > > Regards, > Valts. Thanks for the quick reply. here's what I have: selchecks=ctx.request.field_value("selItems") myselchecks=','.join(selchecks) assert False, myselchecks #print the value to the screen and stop This bit of code raises a key error as follows: KeyError: 'selItems' The value of selitems is ['1', '2', '3', '4', '5'] --~--~-~--~~~---~--~~ 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: python list to string conversion
On Sep 1, 9:47 am, "Valts Mazurs" <[EMAIL PROTECTED]> wrote: > Hello, > > "selItems" is not the same as "selitems". Probably you have mixed the name > of the field that you are looking for in the forst row. the variable name is selltems (with a capital i) --~--~-~--~~~---~--~~ 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: python list to string conversion
On Sep 1, 9:57 am, "Valts Mazurs" <[EMAIL PROTECTED]> wrote: > Hello, > > So, which exact line raises the error? > > Valts. very very strange seems to be working beautifully now. Thanks for your help! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
python list issue
interesting situation. I've got a form where i can check off items to manipulate in the database, each checkbox containing the recordID to manipulate if i check one box, (recordID # 66) then the length of that value is 2 If i check two boxes (record id # 66,67) then the length of the list is 2 What command should I be using to give me the number of elements in the list. I'm currently using len(listnamehere) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
webfaction django installation
hi. I'm setting up a small django project on webfaction and i'm havnig some issues getting my settings.py file correct in regards to media files for both the front end and admin. Can someone please help me --~--~-~--~~~---~--~~ 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: webfaction django installation
> The "Getting started with Django at WebFaction" article should solve > Bobby's > problem:https://help.webfaction.com/index.php?_m=knowledgebase&_a=viewarticle... > Setting up a static application was easy and worked perfectly. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
Comments
the Django docs state that "Django's comments are all "attached" to some parent object"... I'm building a very simple django powered website with auth, flatpages, and comments currently installed. I want to use the comments so people can post testimonials which can then be displayed on the site. What would I attach to using this form statement as a starting point: {% render_comment_form for [object] %} ie what should the object be? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
OS path in python
i've got a setup like most people where i have directory structure such as: home/sites/xxx/whatever where xxx is the domain name If I have a file sitting in the "whatever" directory, how can i find the domain name under which the file resides? Thanks for helping a noob. --~--~-~--~~~---~--~~ 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: OS path in python
On Sep 22, 5:05 pm, Jarek Zgoda <[EMAIL PROTECTED]> wrote: > os.path.dirname() Thanks. The main problem is that i have to dynamically get the url i'm at so i can pass to that function ( Python returns that i'm missing 1 argument and I don't know how to dynamically pass that in.) --~--~-~--~~~---~--~~ 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: OS path in python
On Sep 22, 6:11 pm, Erik Allik <[EMAIL PROTECTED]> wrote: > Shouldn't that be os.path.abspath(os.path.dirname(__file__)) instead > just in case the .py file is executed with a relative path? > > And Bobby, I would instead use the Sites framework to compute the URL > of the site, not rely on a local folder name. > Hi all - let me clarify things. this is a straight python platform at the moment. We plan on moving it to django but for now we just have python running on an in-house framework. there is a point in the code where i need to write a file... let's call it "myfile.txt". The directory i'm writing to most likely will not have any existing files inside. Therefore the dirname function won't work because I have no file to base it off of. the only known in this situation is the file should be written to home/sites/x/library where x is the domain name which also happens to be dynamic. I need to find the x part of the path which is the domain name (whatever.com, ie). I'm thinking that the only way to do this is to get the current URL being viewed but I can't figure that out. I think it has to be with os or urllib but I can't seem to find the answer. any help is greatly 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: OS path in python
> import os > os.environ['SERVER_NAME'] > > See how that goes. I get: KeyError: 'SERVER_NAME' So i'm assuming we aren't --~--~-~--~~~---~--~~ 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: OS path in python
I wasn't aware of that group. Thanks for posting the info. On Sep 23, 5:08 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 23 sep, 02:01, Bobby Roberts <[EMAIL PROTECTED]> wrote: > > > On Sep 22, 6:11 pm, Erik Allik <[EMAIL PROTECTED]> wrote: > > > > Shouldn't that be os.path.abspath(os.path.dirname(__file__)) instead > > > just in case the .py file is executed with a relative path? > > > > And Bobby, I would instead use the Sites framework to compute the URL > > > of the site, not rely on a local folder name. > > > Hi all - > > > let me clarify things. this is a straight python platform at the > > moment. > > Err... Then why are you asking on the Django's newsgroup ??? > comp.lang.py is the place for general Python questions, you know ? > > (snip OT question) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
installing tiny mce for flatpages
hi group. I need some help getting tinymce installed for flatpages in admin. I'm serving static content from an application called /static/ with tinymce located in /static/js/tiny_mce/. I have read the docs on creating an admin.py file and have done that as well but it's not showing the richtext box... just the textarea. Is there anyone out there that can 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 -~--~~~~--~~--~--~---
Re: installing tiny mce for flatpages
> Did you see this: > > http://code.djangoproject.com/wiki/AddWYSIWYGEditor yeah i saw that and tried to follow it. Here's what i did: 1. d/l tinymce 2. uploaded to /static/admin/js/tiny_mce (i have static setup as an app to serve static files) 3. I created a textarea.js file as instructed an put it in that dir 4. I created the admin.py file in /www/myproject i'm using newforms in the admin --~--~-~--~~~---~--~~ 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: installing tiny mce for flatpages
> So you did this > part?http://code.djangoproject.com/wiki/AddWYSIWYGEditor#UsingTinyMCEwithf... > > Do you have MEDIA_URL and MEDIA_ROOT setup correctly in settings.py? > Are you using the development server? Do you have that setup to server > static content? yeah see my previous post. This is on a live server not a dev. I've got an admin.py file setup per the django doc and have /static setup as an application to serve static content. MEDIA_URL is setup correctly and is serving static content. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
perplexing form issue
Hi group. I have form on the right side of my website. It's a simple site consisting of a single template and utlizes flat pages. Now i can create content just fine and that is all working. The issue is that the form is not showing up when I view the site. I'm assuming that it is because something is awry with the urls or views. I think i've narrowed it down to the following question. How can I specify that the form show and work on each page in the website? I've tried the following in my urls.py file: (r'/$', 'myForm'), where myForm is my view what am I missing? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
html inserted into csv file
HI group. I'm using the python csv writer to drop a csv file available for download/opening when a button is clicked on my site. The code is shown here myselchecks=selchecks sql="select * from inquiries where inquiry_id = (%s)" %myselchecks ctx.request.write_header('Content-Type', 'text/csv') ctx.request.write_header('Content-Disposition','attachment; filename=contacts.csv') ctx.request.write = ctx.request.write_content writer = csv.writer(ctx.request) c = ctx.request.db.cursor() c.execute(sql) writer.writerow([x[0] for x in c.description]) writer.writerows(c.fetchall()) This code drops all selected fields into a temporary csv file named "contact.csv" so that it can be downloaded. However, the template HTML is being appended after the last record in the csv file. Is there any way to prevent this from happening? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
random quote help
Hi. I have a project with one template only. I am trying to get a random quote from the database pushed up to the template so that a new quote is shown with each new page url or each page refresh. Can someone point out in the docs where this is covered or help me understand the urls.py structure to do this? --~--~-~--~~~---~--~~ 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: random quote help
> Is your problem the mechanics of *making* the random choice, or are you > uncertain how to get it into your output? Hi Steve - Yeah i know the randomization needs to be in the view and then pushed back to the template. How would I call the view on each page in the website? 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 flat pages and sites
hi. I am needing advice as a django noob. I am hosting at webfaction and want to use django to power about 11 sites. I have my django app installed with a current project in its own directory with its own settings etc. My question is what is the best way to proceed from this point? Do I just setup more projects with their own settings etc and change the site id ref (and other appropriate settings) in each settings file? Is there anything else to configure? What is the best practice for this? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
multiple sites on webfaction (need help with installation)
hi. I am trying to setup 11 websites sharing a common admin and database using the sites framework. can someone help me out and tell me how to get this installed over at webfaction. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
multiple sites help needed
hi all. A friend of mine is hosting a number of websites over at webfaction. I've got them setup as follows. /staticserves static content /www django install serving 5 sites /www2 django install serving 5 sites /www3 django install serving 3 sites all of the sites seem to be pointing to one domain, or at least pulling in the content from a single domain.has anyone gotten the sites framwork for django working properly at webfaction? Please help if you can. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
tinymce help
hi. I'm using django 1.0 over at webfaction. I have the following setup /static (serves js, css, flash, images etc) /www (my django app) I have tiny_mce loaded to /static/js/tiny_mce/ I have followed the steps at this page: http://code.djangoproject.com/wiki/AddWYSIWYGEditor in this order: 1. Install tiny_mce on your server some where 2. create a textareas.js file (placed in /static/js/tiny_mce/) 3. created an admin.py file in my website located at www/learn/ as follows: from django.contrib.flatpages.models import FlatPage from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld class FlatPageAdmin(FlatPageAdminOld): class Media: js = ('js/tiny_mce/tiny_mce.js', 'js/tiny_mce/textareas.js',) # We have to unregister it, and then reregister admin.site.unregister(FlatPage) admin.site.register(FlatPage, FlatPageAdmin) step3 i'm confused on. This is for newforms with flatpages per the documentation. It is my understanding that django 1 uses newforms. Why won't the admin show the tinymce in place of text areas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
passing css classes in forms
how can I assign form fields to certain css classes in django? --~--~-~--~~~---~--~~ 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: passing css classes in forms
> Seehttp://docs.djangoproject.com/en/dev/ref/forms/widgets/#customizing-w... > > -- > DR Man i'm glad that wasn't a snake. Many thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
widget attribute help needed
hi. I have the following code in my forms.py Anonymous = forms.ChoiceField (choices=Anonymous_Choices, widget=forms.RadioSelect(attrs={'class':'anonymous'})) which sets up a radio button UL on my form. This part is working great. however, i've got a problem. When viewing the source below: Yes No (Check for yes) You can see the class is added to the LI element, not the UL. How do i stick a class on the UL itself so I can format that list? I have several like this on my form and they each need to be edited independently in regard to their style. many thanks for help 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 -~--~~~~--~~--~--~---
required checkboxes issue
I have a problem with one of my forms in regard to a series of checkboxes. They are displaying properly on the page with the right values in the checkboxes. I have this set to REQUIRED in my form. However, whether I check one box, or check them all, I still get this message: "Select a valid choice. That choice is not one of the available choices." My forms.py code for this form field is as follows: Designations_Choices = ( ('1','1'), ('2','2'), ('3','3'), ('4','4'), ) Designations = forms.ChoiceField (choices=Designations_Choices,required=True, label = "Gift Designations", widget=forms.CheckboxSelectMultiple(attrs= {'class':'designations'})) Any ideas why this won't validate correctly even when 1/4 or 4/4 boxes are selected? --~--~-~--~~~---~--~~ 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: required checkboxes issue
> Without looking at any docs or code, it seems you have a mismatch in the > number of values expected by the form (one) and what will be returned by the > widget (multiple). Are you sure you don't really want to be using a > MultipleChoiceField? > > Karen That appears to have done it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
form issue
hi group. I have the following statement: return render_to_response('donate-now.html', {'form':form,'ErrCode':errcodevalue,'Status':responsestatus,'TextResult':responsetext}, context_instance=RequestContext(request)) Which pushes data back to the template where a form resides. I'm getting the following error: global name 'form' is not defined am I missing something? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
sending emails to multiple people
I am trying to send an email to three people as follows: if request.session['Email'] != '': #initialize email variables # render both html and text strings from the templates below textmessage = render_to_string('email_text.html', context_instance=RequestContext(request)) htmlmessage = render_to_string('email_html.html', context_instance=RequestContext(request)) from_email='[EMAIL PROTECTED]' to_email=request.session['Email'] + ",[EMAIL PROTECTED],[EMAIL PROTECTED]" subject = 'Thank you from XXX' if request.session['EmailFormat'] == 'T': #send text email here. send_mail(subject,textmessage,from_email,[to_email]) if request.session['EmailFormat'] == 'H': #send the html email now msg = EmailMultiAlternatives(subject,textmessage, from_email, [to_email]) msg.attach_alternative(htmlmessage, "text/html") msg.send() The first person gets the email but not the other two. Where am i screwing up? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: form issue
On Nov 19, 12:11 am, "David Zhou" <[EMAIL PROTECTED]> wrote: > It'll be helpful if you post the entire view, but well, like the error > says, is form defined? ah... i had it defined in another view and not in the current one... many thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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 -~--~~~~--~~--~--~---
del session variables
is there a way to kill a session rather than running a del statement on each session variable? I know in .asp you can simply say session.abandon. Is there an equivalent with django? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
weird form issue
I've got a form that is kind of working. It's very strange because only choice fields are being pushed to the form and the textfields are not visible. Has anyone ever run across this before? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
time differences
I need to know the # of seconds between two dates for my django application. I believe this has to be done with straight python. I've read the py docs on time functions but it doesn't make sense to me. Can anyone help? Here's my situation: timea='11/15/2008 11:35 AM' timeb=datetime.now() How can I calculate the diff between timeb and timea in seconds? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: time differences
On Nov 28, 1:35 pm, "Horst Gutmann" <[EMAIL PROTECTED]> wrote: > If you convert timea into a normal datetime instance just substract > timea from timeb and you will get a datetime.timedelta instance which > has everything you need :-) > > import datetime > a = datetime.datetime(2008, 11, 15) > b = datetime.datetime.now() > > print b-a > > -- Horst Well I need to know the exact # of seconds from 2008-09-16 08:01:16 to now not from just a date to date. It has to be exact... does this make sense. I was looking at this page http://pleac.sourceforge.net/pleac_python/datesandtimes.html in the "Converting DMYHMS to Epoch Seconds" section. I thought perhaps it would be easier to just get the epoch seconds between this time, and NOW() and subtract the two, however I keep getting an error locally in my terminal window reading: >>> import time >>> import datetime >>> t=datetime.datetime('2008-09-16 08:01:16') Traceback (most recent call last): File "", line 1, in TypeError: function takes at least 3 arguments (1 given) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
time help (again)
ok day 7 and no luck. I really need help. I need to calculate the difference between two dates, one pulled from the database, and one as the NOW time. I'm hoping someone out there can help me and explain the code to me. Yes I've read the docs but they don't make sense to me thus the reason i'm asking for help. Thank you in advance. the first date is pulled from the database and is in the format: 2008-12-01 22:02:59 the second date is the now time in the format: 2008-12-01 22:32:47.391200 I need to calculate the difference between the two dates in total amount of seconds. Here's what i've got so far: ctx.locals.session_id=ctx.sesid() c = ctx.request.db.cursor() c.execute('''SELECT hit_date from tablename where session_id=%s order by id desc limit 0,1''', (ctx.locals.session_id)) ctx.locals.lasttimestamp = c.fetchone() hittime=ctx.locals.lasttimestamp nowtime=datetime.datetime.now() totalseconds=nowtime-hittime Can anyone tell me how to do this in python. I'm coming from an asp background where there is a built in function to determine this. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: time help (again)
> http://www.python.org/doc/2.5.2/lib/datetime-timedelta.html yeah i said I don't understand this. --~--~-~--~~~---~--~~ 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: del session variables
> Have a look at theflush() method; I believe that might well be close to > what you are after. > > Regards, > Malcolm I'm trying to call the view below: def DoSessionReset(request): request.session.flush() return HttpResponseRedirect ('../shop') I'm getting this error: TypeError at /shop/start-new-order/ 'str' object is not callable --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
need urls help
hi group. I have an issue where I need a random quote to display on every page on my website. Writing the view is not a problem (at least I don't think it is), but how would I call the view on each page of my website in the urls file? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: need urls help
On Dec 29, 10:48 am, Briel wrote: > A solution, not sure if it's the best, would be to make a function in > basicly any file, that generates a quote. Then you can import the > function to every view you want and call it to get the random quote. > All you need then is to pass it to your html-file (and display it). > You could just write a bit of html for it, in your base html, that you > extend. well... i've got flatpages running as well and need the function called on those pages too... not just static template pages. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
can't get a model in the admin
here's my model: from django.db import models class Testimonial(models.Model): active=models.IntegerField(max_length=11, blank=False) testimony=models.CharField(max_length=500) name=models.CharField(max_length=75) postdate = models.DateTimeField (auto_now_add=True, blank=False, db_index=True) siteid=models.IntegerField(max_length=3,blank=False) class Admin: list_display = ('name','active','postdate','siteid') The user also has perms in the users to have full control over this model... Why can't it be seen in the admin area? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: can't get a model in the admin
> What version of Django are you using? The use of max_length instead of > maxlength implies something later than 0.96 but the use of 'class Admin' > implies something before 1.0. If you are using 1.0 or later 'class Admin' > is not how admin defs are specified any more, see the admin doc for the > current way. > > Karen Hi Karen - I'm using 1.0. I took out the class admin and added an admin.py file as follows: from learn.testimonials.models import Testimonial from django.contrib import admin admin.site.register(Testimonial) I restarted apache and got this error: TemplateSyntaxError at /admin/ Caught an exception while rendering: Tried RandomTesti in module testimonials.views. Error was: 'module' object has no attribute 'RandomTesti' RandomTesti is a customized template tag I've created for use in the site. Can you help me figure this out? What information do you need? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: can't get a model in the admin
can anyone help me on this issue? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
template does not exist
Hi everyone. I have checked and re-checked my path for my templates in the settings file. I have also confirmed at my template is sitting in the right directory: I'm trying to do a direct to template in my urls.py file as follows: from django.conf.urls.defaults import * urlpatterns = patterns('django.views.generic.simple', (r'^test/$','direct_to_template',{'template': 'base.html'}), ) The Traceback I get is: TemplateDoesNotExist base.html Django tried loading these templates, in this order: * Using loader django.template.loaders.filesystem.load_template_source: * Using loader django.template.loaders.app_directories.load_template_source: o /usr/lib/python2.5/site-packages/django/contrib/admin/ templates/base.html (File does not exist) any idea why it's looking in the admin/templates directory? Using python 2.5 and django 0.97x... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin model search
hi all... I have search fields setup in my admin model as such: search_fields = ['name','postdate','testimony'] When i try to search , it just shows everything in the database. Am I missing something here? TIA --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Sites issue
Hi Group... below you will see a code snippet which records a testimonial submitted off of a form into the database. Here's my setup... I'm hosting at webfaction with 3 instances of django running with 3 sites, 4 sites and 4 sites (only way I can avoid running over my RAM allotment). The sites use flatpages and sites. This code is in each website with the exception of the siteid it writes to the database. The code submits fine to the database but the wrong siteid # is recorded. Can you think of anything that might be causing this. In this example below, I even have the siteid hardcoded in the section where django actually saves to the database help greatly appreciated... --- #import django routines and template tags from django.http import * from django.shortcuts import get_object_or_404, render_to_response from django.template.loader import render_to_string from django.template import RequestContext from django.template import Template, Context from django.core.mail import send_mail, EmailMultiAlternatives from django.contrib.sites.models import Site #import date and time python functions from time import * from datetime import datetime from testimonials.forms import * from testimonials.models import Testimonial # THIS VIEW HANDLES THE TESTIMONIAL FORM. def DoTestimonialForm (request): if request.method =='POST': form = TestimonialForm (request.POST) # set an instance of the form if form is submitted if form.is_valid():#if there are no errors in the form data do the following mydata=Testimonial ( testimony=request.POST.get ('Testimony',''), name =request.POST.get('Name',''), active = 0, postdate=datetime.now(), siteid=1,) mydata.save() # send email notification to site admin about the new testimonial #textmessage = render_to_string ('email_text.html', context_instance=RequestContext(request)) textmessage = 'A new testimonial at wwwcom has been posted for your review from a customer named ' + request.POST.get('Name','') from_email='i...@com' to_email=['@gmail.com'] subject = 'A new testimonial has been posted for your review' send_mail (subject,textmessage,from_email,to_email) return HttpResponseRedirect ('/thankyou/') else: #form is not valid so return to step 1 and show errors return render_to_response("submit.html", {'form': form},context_instance=RequestContext(request)) else: # load the form to the template form=TestimonialForm() return render_to_response("submit.html",{'form': form}, context_instance=RequestContext(request)) 65,0-1Bot --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
MultipleChoiceField issue
Hi all. I'm using python2.5 / django .96x (yes i know - we're upgrading soon). I have an issue with a multiplechoice field which I can't figure out. Here are snippets from the form: # disaster choices previously defined Disaster=forms.MultipleChoiceField (required=True, choices=Disaster_Choices, label="Disaster(s)", widget=forms.CheckboxSelectMultiple(attrs={'class':'multibox'})) from the model: Disaster = models.CharField (max_length=20, blank=False,db_index=True) from the view: mydata = Record ( Disaster = CleanMe(request.POST.get('Disaster','')),, Active = 0) mydata.save() Ok so here's what's going on There are 4 disasters which appear as checkboxes on the form. This works great. When the form is submitted, I run the form field through a little function called CleanMe which strips out certain character combinations. I do an assert here right before the mydata = line to view what was submitted off of the form for the disaster options. If I select Earthquake, Tornado, Hurricane, I would expect to pass in EQ, TO, HU to the view. However, only HU is being passed to the view. No matter how many I select, only the last option is being passed. I'm obviously not doing something correctly but can someone point me in the right direction here? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MultipleChoiceField issue
> I'd guess you need to be calling getlist rather than get to pull all the > various values from the POST data. (Which is a detail you wouldn't need to > worry about if you were using the standard form clean() framework...not sure > why you are seemingly winging it on cleaning form data instead of using the > mechanisms built into forms?) > Hi Karen - thanks for your reply. I tried to do the following in the view: Disaster=request.POST.getlist('Disaster','') on the form i selected a, b and c: when i submitted the form, I asserted the value and get this: TypeError at /submit/ getlist() takes exactly 2 arguments (3 given) Can you provide me an example of how I should be using getlist? I don't see anything in the docs related to forms and getlist. Regarding the form clean() method, i'm looking for it but it would be a great help if you could point me in the right direction. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MultipleChoiceField issue
hi all. I'm NEW to the world of django and the Doc doesn't make any sense to me on this issue. Can someone give me an example of how to actually get all of the values out of a CheckboxSelectMultiple widget? I'm only able to get the last box checked. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MultipleChoiceField issue
nevermind i figured out how to use the getlist function... Thanks for your help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
pre-populating multiplechoicefields with session data
Hi group. Please look at this view: # this form runs the search mechanism def DoSearchForm (request): if request.method =='POST': form=SearchForm (request.POST) if form.is_valid(): try: myuid=request.user.id * 1 except: myuid=0 #form submitted passes validation so submit to database as a valid search term record mydata = SearchAttempt ( Terms = CleanMe(request.POST.get('Terms','')), suid = myuid ) mydata.save() #save to sarch_attempt table # save items to session variables request.session["Terms"]=request.POST.get('Terms','') request.session["Iforand"]=request.POST.get('Iforand','') request.session["Programelement"]=request.POST.get ('Programelement','') request.session["Disaster"]=request.POST.get ('Disaster','') request.session["Submissionmethod"]=request.POST.get ('Submissionmethod','') return HttpResponseRedirect('/search/results/') else: return render_to_response('submit-search.html', {'form': form}, context_instance=RequestContext(request)) else:# load form for first time if 'Terms' in request.session: form = SearchForm(initial={'Terms':request.session ['Terms'],'Iforand':request.session ['Iforand'],'Programelement':request.session ['Programelement'],'Disaster':request.session ['Disaster'],'Submissionmethod':request.session['Submissionmethod']}) else: form = SearchForm(initial={'Iforand':'exact'}) return render_to_response('submit-search.html', {'form': form}, context_instance=RequestContext(request)) This view is working perfectly except for one thing. If someone completes the form, it saves the form options to a session and inserts the term they searched for into the database. If they close their browser and come back to the search form, I want their previous choices to populate the form again. Terms and Iforand populate as they should. Programelement, Disaster, and Submissionmethod are all multiplechoicefield textbox lists and none of the previously selected options are selected. Can you see what i'm 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: pre-populating multiplechoicefields with session data
anyone have any idea on this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
checkboxInput values
If i use the multiple Checkbox Input, It results in list of the items which were selected. My question is can you do the same thing for a single checkbox? As an old ASP guy I'd do this: I'm trying to do this in django by the following: #...snip forms.py el1_Choices = ( ('EN', 'ENGLISH'), ) el1=forms.ChoiceField (required=False, choices=el1_Choices, widget=forms.CheckboxInput(attrs={'class':'multibox'}) ) The resulting HTML is: As you can see there is no value. It is returning the following error: Select a valid choice. That choice is not one of the available choices. Even though I've got the form field setup to required=False. What is the proper way to assign a value to a single checkbox? Am I just stuck with boolean and true/false? That seems like a lot of extra work on the back end. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: checkboxInput values
> What is the proper way to assign a value to a single checkbox? Am I > just stuck with boolean and true/false? That seems like a lot of > extra work on the back end. nevermind i just figured out to use a value attribute --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
trouble with template tag
Hi. I have the following template tag: @register.filter(name='elementtotext') @stringfilter def elementtotext(string): itext='Unknown' if string=='DR': itext='Door' if string=='FL': itext='Flooring' if string=='FO': itext='Foundation' if string=='FR': itext='Framing' if string=='GR': itext='Grounds' if string=='HV': itext='HVAC / Utilities' if string=='MI': itext='Miscellaneous' if string=='RF': itext='Roof' if string=='WM': itext='Wall Material' if string=='WI': itext='Window' return itext The purpose of the tag is to take a record set field value and return the text equivalent of that value. My field name in this example is tm.element. I can print the raw code to the screen fine but I'm having trouble running it through my template tag. Can someone tell me the proper syntax? I'm trying {% elementtotext tm.element %} and it errors out. I'm using python2.5 and django .97 or thereabout. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
executing raw sql results in traceback
hi gang. For various reasons i've decided to use a raw sql statement in my view. Following the example located at http://docs.djangoproject.com/en/dev/topics/db/sql/, I have a view which looks like this: def searchform(request): from django.db import connection ... # a massive sql statement is dynamically built here. called sqlall (used below) try: #setup recordset cursor=connection.cursor() cursor.execute (sqlall) tms=cusor.fetchall() #this will be pushed back to the template except IndexError: #nothing found so redirect to "no results page" return HttpResponseRedirect ('/search/results/none/') ... When I assert the sqlall variable, the sql statement executes perfectly in phpmyadmin. However, Django throws the following traceback: not enough arguments for format string I have no idea what this error means and why it's not working... 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: executing raw sql results in traceback
there shouldn't be really. The client has a search form and due to the way they want the search done there are about 40 option checkboxes for filtering in about 5 categories. It would have been easier if a filter with IN could have been used but the way the search logic is setup that is not an option. An example of the sql query being used is like this: Select * from table_name where field1 like '%,BC,%' and field2='AR' and field3 like '%,CM,%' order by date_received desc" %s is not used in this statement. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: executing raw sql results in traceback
On Feb 11, 8:01 am, Bobby Roberts wrote: > there shouldn't be really. The client has a search form and due to > the way they want the search done there are about 40 option checkboxes > for filtering in about 5 categories. It would have been easier if a > filter with IN could have been used but the way the search logic is > setup that is not an option. An example of thesqlquery being used > is like this: > > Select * from table_name where field1 like '%,BC,%' and field2='AR' > and field3 like '%,CM,%' order by date_received desc" > > %s is not used in this statement. anyone have any ideas on this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: executing raw sql results in traceback
On Feb 11, 8:38 pm, Bobby Roberts wrote: > On Feb 11, 8:01 am,BobbyRoberts wrote: > > > there shouldn't be really. The client has a search form and due to > > the way they want the search done there are about 40 option checkboxes > > for filtering in about 5 categories. It would have been easier if a > > filter with IN could have been used but the way the search logic is > > setup that is not an option. An example of thesqlquery being used > > is like this: > > > Select * from table_name where field1 like '%,BC,%' and field2='AR' > > and field3 like '%,CM,%' order by date_received desc" > > > %s is not used in this statement. > > anyone have any ideas on this? Anyone Bueller? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: executing raw sql results in traceback
> but I'm not entirely sure of that since you still haven't provided the > actual traceback which would show what code, exactly, is running into > trouble. Without the traceback I have to fall back on my crystal ball, and > it's pretty cloudy at the moment. > > Karen My apologies... I didn't see Alex's post. Google some times collapses threads on me. Replacing % with %% seemed to work. It queries the database and returns a dataset like this: ((6L, u'WI', u'ST', u'test3', u'test3', u'test3', u'test3', u'test3', u'PR', u',EQ,FL,HU,', u'test3', u',AC,', u'test3', 1, datetime.datetime (2009, 2, 7, 15, 38, 43), u'admin'), (5L, u'FR', u'CH', u'test3', u'test3', u'test3', u'test3', u'test3', u'PR', u',EQ,FL,HU,', u'test3', u',AC,', u'test3', 1, datetime.datetime(2009, 2, 7, 15, 23, 17), None), (4L, u'GR', u'BI', u'test', u'test', u'testusername', u'test', u'test', u'AS', u',EQ,', u'test', u',PR,TX,', u'test', 1, datetime.datetime(2009, 2, 7, 14, 41, 19), None), (3L, u'DR', u'AR', u'sdf', u'sourcelinktest', u'sdf', u'sdf', u'', u'PR', u',FL,HU,', u'sdf', u',SV,TX,', u'sdf', 1, datetime.datetime(2009, 2, 5, 12, 30, 30), None)) ( that is the value of tms=cursor.fetchall() ) I'm just not sure how to get the value of tms back up to my template. I'm passing in the data but when i try to do {{tms.title }} for example nothing prints. Forgive me --- i'm a python and django noob. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: executing raw sql results in traceback
On Feb 12, 3:29 pm, Karen Tracey wrote: > On Thu, Feb 12, 2009 at 10:26 AM, Bobby Roberts wrote: > > > My apologies... I didn't see Alex's post. Google some times collapses > > threads on me. Replacing % with %% seemed to work. It queries the > > database and returns a dataset like this: > > > ((6L, u'WI', u'ST', u'test3', u'test3', u'test3', u'test3', u'test3', > > u'PR', u',EQ,FL,HU,', u'test3', u',AC,', u'test3', 1, datetime.datetime > > (2009, 2, 7, 15, 38, 43), u'admin'), (5L, u'FR', u'CH', u'test3', > > u'test3', u'test3', u'test3', u'test3', u'PR', u',EQ,FL,HU,', > > u'test3', u',AC,', u'test3', 1, datetime.datetime(2009, 2, 7, 15, 23, > > 17), None), (4L, u'GR', u'BI', u'test', u'test', u'testusername', > > u'test', u'test', u'AS', u',EQ,', u'test', u',PR,TX,', u'test', 1, > > datetime.datetime(2009, 2, 7, 14, 41, 19), None), (3L, u'DR', u'AR', > > u'sdf', u'sourcelinktest', u'sdf', u'sdf', u'', u'PR', u',FL,HU,', > > u'sdf', u',SV,TX,', u'sdf', 1, datetime.datetime(2009, 2, 5, 12, 30, > > 30), None)) > > > ( that is the value of tms=cursor.fetchall() ) > > > I'm just not sure how to get the value of tms back up to my template. > > I'm passing in the data but when i try to do {{tms.title }} for > > example nothing prints. > > I'm confused -- what would you expect tms.title to be? You've pulled (it > looks like) 4 rows from your DB, each row containing 16(?) fields. Even if > one of those fields is a title, which of the four titles do you want? > > > Forgive me --- i'm a python and django noob. > > You've decided to bypass the Django ORM and use raw SQL: that means you are > going to have to write the code required to take the raw results from the DB > and turn them into more Python-code friendly objects if you want to use > constructs like object.title. What you get back from your fetchall call is > a tuple of tuples. You can iterate through them and build objects from the > data contained in them, it's not that hard. However, if you are so new to > Python that it isn't pretty clear to you what you need to do to do that, I'm > kind of wondering if you really want to be bypassing the ORM as you have > decided to do. I rather fear you've gone down this path of raw SQL because > it wasn't immediately clear how to do something (that may well be perfectly > possible) using the Django ORM and are now just making more work for > yourself instead of learning how to do whatever it is you need to do through > the ORM. > > However, if you are really sure this is the right path, this thread: > > http://groups.google.com/group/django-users/browse_thread/thread/c80e... > > discusses some ways of building model objects from your raw sql results that > you may find helpful. > > Karen Thanks for your informative reply. The reason that I chose raw sql is that the search form itself has 40 option boxes which control results in about 7 fields. I was looking at the filtering mechanism for django db calls and it really wouldn't apply due to the way that the database is structured (ie an IN filter wouldn't work for some of these things.). That url you referred to is just what i'm looking for. I'm an ASP programmer making the transition away from the dark side and still have wobbly python legs so i'm not always 100% sure what to search for. Thanks again. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django 0.97 and image thumbnails
hi all. I've got a model with the following line: Pic1 = models.ImageField(upload_to='/auctionimages',blank=True) is it possible to easily create a thumbnail in django 0.97 on python2.5. If not, can someone show me how? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
admin foreignkey selection box question
Hi everyone. I have two models - one for "auctions" and one for "auction FAQs". AuctionFAQs has a foreignkey field tied to the ID from auctions. The result of the selection box in my admin AuctionFAQs model is as follows: - Auction object Auction object It's pulling in the right ID value but how do i show something relevant selection options rather than Auction Object? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin foreignkey selection box question
> Set a __unicode__ method on your Auction model. > -- > DR. Hi Daniel... I'm new to the python world... can you tell me what that even is? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: admin foreignkey selection box question
On Feb 19, 1:08 pm, Karen Tracey wrote: > On Thu, Feb 19, 2009 at 12:53 PM, Bobby Roberts wrote: > > > > Set a __unicode__ method on your Auction model. > > > -- > > > DR. > > > Hi Daniel... I'm new to the python world... can you tell me what that > > even is? > > A quick read through the tutorial would have covered it. If you don't want > to be bothered with the tutorial (an unwise choice, in my opinion, but it's > up to you), you should still learn how to search the docs. Put __unicode__ > in the search box here: > > http://docs.djangoproject.com/en/dev/ > Karen - I appreciate your help that you provide, but a kinder tone to the new programmers coming from other backgrounds would be greatly appreciated. Many on this list talk at levels which others cannot follow. Therefore I have created a Noob django group at http://groups.google.com/group/djangonoobs. Everyone is welcome and simpleton type questions are welcome and answers should be helpful. Experts are encouraged to join and mentor new django programmers still trying to find their legs. I have, by the way read the docs and it's still confusing, thus the reason for my question in the first place --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Announcing Django Noob Group
... simpleton questions welcome, mentors encouraged to help... http://groups.google.com/group/djangonoobs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
clean data uniqueness question
hi gang i have a subclass on my form as follows: class NewUrl (forms.Field): def clean(self, value): rs=WebPage.objects.filter(url_slug=value) thislength=str(len(value)) if rs.count()!=0: raise forms.ValidationError ('This URL is already in use.') if not value: raise forms.ValidationError ('Please enter a url such as / my-page/') if len(value)>254: raise forms.ValidationError ('254 Characters Max. The current length is %s' % thislength) return value This checks to see if a url being added to the system is unique and it works great. My question is this. If i load data to a form (initial=) with an initial url, how can i check to see if the url going back on an update is unique AND not for the current record? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
global name 'request' is not defined
from django import forms from tinymce.widgets import TinyMCE def GetRequestId(request): curpath=request.path return curpath Hi all. I have a simple function i'm tryin to implement in my forms.py file. The intent is to get the current path. However, this code results in global name 'request' is not defined. Am I missing an import which I should be importing? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: global name 'request' is not defined
> The code you have given is incapable of producing that error - request > is passed as a parameter, so will always be defined within the > function. Are you sure the error is coming from within the function? > Give us the actual traceback that is being produced. > -- > DR. def GetRequestId(request): curpath=request.path return curpath # setup a subclass for URL on add form which will be used by the ADD and CLONE views. # the purpose is ti screen for urls goign into the system (non-preview urls) and class ExistingUrl (forms.Field): def clean(self, value): i=GetRequestId(request) << error is here assert False, i <<< just trying to print out the value of i here rs=WebPage.objects.filter(url_slug=value) thislength=str(len(value)) if rs.count()!=0: raise forms.ValidationError ('This URL is already in use.') if not value: raise forms.ValidationError ('Please enter a url such as / my-page/') if len(value)>254: raise forms.ValidationError ('254 Characters Max. The current length is %s' % thislength) return value Traceback being produced: global name 'request' is not defined Request Method: POST Request URL: http://sasquatch.beta.ornlfcu.mediapulse.com/manage/content/web-pages/edit/11/ Exception Type: NameError Exception Value:global name 'request' is not defined Here's what i'm trying to do. I've got a module that allows us to add new items and edit new items to the database. I was going to use a url slug which has to be unique anyway, but that will not work for this application. As a result i'm allowing users to enter a url path (ie /whatever/this/page/is/) and it's being served up fine through a middleware class I wrote to substitute for flatpges (it does more than standard flatpages). In my form above I'm trying to find a way to check and see on form submission if the url has been changed to another URL which is in the database already and not for the current record. That part I can handle. I think the key to this is getting request.path into my form field subclass above so that I can get the record id which is passed through the url. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: global name 'request' is not defined
> class MyForm(forms.Form): > def __init__(self, *args, **kwargs): > request = kwargs.pop('request', None) > if request: > self.request = request > super(MyForm, self).__init__(*args, **kwargs) > > ... and in the view: > myform = MyForm(request.POST, request=request) > > -- > DR. ok i don't understand all this (django noob here) but i need to check the url in a subclass that does specific validation, not in the view which saves the form. Basically if they enter a URL and it exists in the database for another record, I want it to raise a form validation error and tell the user that the url is in the database for another record. is there an easier way to do what is needed? I'm lost. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
reset button question
i'm trying to put a simple reset button on a form but it's not working Why wouldn't a standard html reset button be working? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
regular ole html forms
hi group. I've run across a situation where I don't really need a django form to capture the data. In fact i'm not sure how it would work anyway. Basically, I have a tabled set of data with a checkbox on each row and I want to be able to select them and submit that to a django view. The form looks something like this: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
regular ole html forms
hi group. I've run across a situation where I don't really need a django form to capture the data. In fact i'm not sure how it would work anyway. Basically, I have a tabled set of data with a checkbox on each row and I want to be able to select them and submit that to a django view. The form looks something like this: Is it possible to take a standard html form as such and then process it with a django view? I'm reading the form docs and don't see anything like that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
efficiency question on filters
pagelist=[] pg=WebPage.objects.filter(body__icontains=delurl) if pg.count()>0: for id in pg: pagelist.append(id.url_slug) pg2=WebPage.objects.filter(blurb__icontains=delurl) if pg2.count()>0: for id in pg2: pagelist.append(id.url_slug) What is the proper way to chain filters? This is the only way I can get it work where the body OR the blurb contains delurl. If i try to do this: pagelist=[] pg=WebPage.objects.filter (body__icontains=delurl,blurb__icontains=delurl) if pg.count()>0: for id in pg: pagelist.append(id.url_slug) that results in an AND comparison and doesn't return any values. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: efficiency question on filters
> If you take a look at Q objects they allow you to do just > that:http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-looku... > > Alex Hi Alex... that might take some reading up on and time is short at the moment. I just found the pipe delimiter in filters so: pg=WebPage.objects.filter(body__icontains=delurl) | WebPage.objects.filter(blurb__icontains=delurl) works fine for what i need. I do have a question though since i'm wanting to write the most efficient system possible in django. What is the difference between this method and using a Q object? Thanks for your input! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: efficiency question on filters
> For a case like this they probably result in roughly the same (if not > identical) SQL. In general it's better to use Q objects since django > doens't have to piece together 2 seperate cases and then munge them > together, which can get difficult with complicated aliasing and probably can > produce suboptimal SQL in those cases. > > Alexx > That's kind of what i was thinking... Here's what i have: pg=WebPage.objects.get( Q(body__icontains=delurl) | Q(blurb__icontains=delurl) in theory that should be identical to "select * from webpage where body like '%delurl%' or blurb like '%delurl%'" I have two records. One has the value i'm looking for in the blurb, the other in the body, so it should return 2. I'm getting this traceback: get() returned more than one WebPage -- it returned 2! Lookup parameters were {} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
unique slugs (duplicates allowed to be saved)
hi group... I thought slugs were unique, or supposed to be? Here's what i'm doing: in forms.py slug = forms.SlugField(required=True,widget=forms.TextInput(attrs= {'class':'slug','id':'slug'})) in models.py: url_slug = models.SlugField (blank=False, max_length=254,unique=True) I can currently save identical slugs in this model... what am i doing wrong here? I thought unique=True prevented that. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: unique slugs (duplicates allowed to be saved)
On May 27, 4:08 pm, Bobby Roberts wrote: > hi group... I thought slugs were unique, or supposed to be? Here's > what i'm doing: > > in forms.py > slug = forms.SlugField(required=True,widget=forms.TextInput(attrs= > {'class':'slug','id':'slug'})) > > in models.py: > url_slug = models.SlugField (blank=False, > max_length=254,unique=True) > > I can currently save identical slugs in this model... what am i doing > wrong here? I thought unique=True prevented that. Update: with a unique index on the database field it throws a nasty integrity error. How do i prevent duplicates like this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
stopping missing images from silently erroring
is there a way to set django so that it will show image placeholders for missing images? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
images do not upload
hi all.. using 1.0 w/ py 2.5 here. I have a problem with an ImageField failing to upload the images. i've checked the perms on the dir and they appear to be ok. Here are snippets of what i've got: from models.py pic = models.ImageField(upload_to='public/images/ bank_pics',blank=True) from views.py modbranch=Branch.objects.get(id=bra_id) modbranch.pic = manage_cleantext(request.POST.get('pic','')) modbranch.save() from forms.py pic = forms.ImageField(required=False, widget=forms.FileInput (attrs={'class':'filebrowser'})) a couple of questions. I thought that the upload_to should be appended to the file name that I upload when saved into the db field. Right now my db field just shows testpic.jpg rather than assets/public/images/bank_pics/ testpic.jpg as expected. Am I mistaken? Can you think of any reason that the image would not upload? I've even got the form as a multi-part encode. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: images do not upload
just checking if anyone has an update on this. I've added request.FILES to my view to accept the file from the form but nothing is working and it's not even saving the file name in the db at this time. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: images do not upload
Does anyone have an example of how to upload an image. I've followed the docs and it's just not working (ie no file is uploaded and the filename is not saved to the db. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
query aggregates
hi group how would i write a filter to do the equivalent of this sql query: "select year,count(year) from tablename order by year desc" to produce a result such as 2009 1000 2008 750 2007 722 ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
populating a dropbox with a directory listing.
Hi group. I need to pull a directory listing and populate a dropbox. I know how to do this with a queryset but how could i do it with something like this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ModelChoiceField queryset option
hi group i'm trying to create a drop box that is populated with a distinct list of values from a certain field (fieldname=page_plaque) in the table. Here is what i have in my forms.py class PagePlaqueModelChoiceField (forms.ModelChoiceField): def label_from_instance(self,obj): return obj.page_plaque page_plaque = PagePlaqueModelChoiceField (queryset=WebPage.objects.filter(page_plaque!=''), empty_label='Choose',required=False, widget=forms.Select(attrs= {'class':'dropbox'})) this is not working and errors out with: 'bool' object is not iterable Is this possible and if so what am i doing wrong? Can I pull a DISTINCT list of values for that field? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ModelChoiceField queryset option
> The issue is the line: WebPage.objects.filter(page_plaque!=''). The > queryset syntax doens't use the != operator anywhere. To do != operations > you need to instead do WebPage.objects.exclude(page_plaque=''). > ok that got past the error but there are dupes in there. Is there a way to pull a distinct list? ideally i'd like it to return something like this pic1.jpg pic1.jpg pic1.jpg pic2.jpg where the option value is the ID of the record from the table. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ModelChoiceField queryset option
> Hi. > You should take a read on the queryset api, that would help you a lot > In the furture. For distinct values add .distinct() so you fx get > ...filter(...).distinct() > > ~Jakob Jakob - I've read the docs and know about distinct. The issue here is that a modelchoicefield returns the ID and then whatever you specify to populate the human readable value in the selection box. See my example above of what I am looking for. If i just use distinct, the record id is always used so it will always be distinct... or am i misunderstanding something here. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
querystring redirect
hi all... is it possible to do the following? let's say the user types in the following url into their browser: mysite.com/redirect/?http://www.newsiteout.com/whatever.asp Is it possible to snag the redirect url after the ? in the url and then use it to do a redirect? I've run into a situation where a client has a need for an interim ("you're leaving our site") type page before doing a redirect. I'm trying to make this as easy as possible for the client. is this possible? I'm reading the response docs but i'm not really finding a good example. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Need help with a modelChoiceField
ok here's my form: class ParseFileChoiceField (forms.ModelChoiceField): def label_from_instance (self,obj): return obj.ProcessFile class FrmParser (forms.Form): parsefile = ParseFileChoiceField(queryset=Upload.objects.filter (numrecs__exact=0),empty_label='Choose',required=True,widget=forms.Select ()) The result is this: Choose Upload object I need the visible text to be the ProcessFile value rather than Upload Object 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need help with a modelChoiceField
hi. does anyone have any ideas why this is not working... we are using django 0.96 on this particular server. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Need help with a modelChoiceField
> label_from_instance was added after that version. For now the only > thing you can do is to define __unicode__ on the Upload model, and > that will provide the value that is displayed. > -- > DR. worked like a charm Daniel... thanks again! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
help with excel exports
Hi all - I'm pushing content to a template which i have built to properly organize the data for an excel spreadsheet. I'm generating the response in my view as such: response = render_to_response("spreadsheet.html", { 'tms': tms, }) response['Content-Type'] = 'application/vnd.ms-excel' response['Content-Disposition'] = 'attachment;filename=biblio- export.xls' response['Charset']='UTF-8' return response This works great with one exception. It saves the file to the person's last saved location... in my case it's the desktop, in other cases it's /downloads etc Is there a way to force the SAVE option so that when they click SAVE, the user can determine where to put the file? My testing so far indicates this is not browser independent --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
paginator for 0.96?
is there any other examples of how to use the paginator in 0.96 other than this: http://www.djangoproject.com/documentation/0.96/models/pagination/#sample-usage I'm looking more specifically for template side use so I can see how to work it. Thanks in advance, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
quick django gig $300
contact me privately for more information. A friend needs help wrapping up a project. I'll provide his email address to interested parties. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: paginator for 0.96?
anyone have ideas on this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: template tag question
On Aug 31, 1:38 pm, Julián C. Pérez wrote: > Hi > I use Django 1.0 and I define a template function like... > --- > from django import template > register = template.Library() > def doSomething(param1, param2): > # Do something like... > return str(param1)+''+str(param2) > register.simple_tag(doSomething) > --- > to use that in template system, assuming a and b are in context... > --- > {% doSomething a b %} > > --- > Hope it helps you out > ;) yeah just found that after i posted this msg... thanks for your quick response. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
template tag question
hi group. I"ve got an issue i'm needing help with. I have two variables, a and b in my template and I need to pass those to a single template tag so I can process them and return a result to the template. Is there a way to pass more than one variable to a template tag... if so, how? thanks in advance, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---