Re: form_for_model + FileField issue
Malcolm, I wasn't very clear in my question. Sorry about that. It took a bit of trial and error but I found a hack that works the way I want it to. I use the model and form_for_model/form_for_instance for all fields except the file uploads. For the file uploads I use FileInput(). That was what I meant by '... I could leave the FileFields out of the model and use a form class for those fields instead.' I you have any suggestions on how to secure/improve/validate this please let me know. Thanks, Vincent class files(forms.Form): file1 = forms.Field(widget = forms.FileInput()) file2 = forms.Field(widget = forms.FileInput()) def save(file,key,user,ext): if ext in ['pdf','doc']: f = open('%s%s_%s.%s' % ('/home/myhomedir/',key,user,ext,),'wb') f.write(file) f.close() @login_required def submit(request): try: # show previous input if available inst = Application.objects.get(user=request.user) ApplicationForm = form_for_instance(inst) except: # else create an empty form ApplicationForm = form_for_model(Application) if request.POST: form1 = ApplicationForm(request.POST) if form1.is_valid(): form1.cleaned_data entry = form1.save(commit=False) entry.user = request.user entry.save() # save files attached to the form pfile = request.POST.copy() pfile.update(request.FILES) form2 = files(pfile) for i in request.FILES.keys(): ext = request.FILES[i]['filename'][-3:] file = request.FILES[i]['content'] save(file,i,request.user,ext) # confirm data is submitted return render_to_response('submit/thankyou.html') else: form1 = ApplicationForm() form2 = files() return render_to_response('submit/submit.html',{'form1':form1,'form2':form2,}) TEMPLATE # Form {{ form1.as_table }} {{ form2.as_table }} On 6/12/07 8:12 PM, "Malcolm Tredinnick" <[EMAIL PROTECTED]> wrote: > > On Tue, 2007-06-12 at 20:03 -0500, Vincent Nijs wrote: >> Thanks for the reply Malcolm. >> >> That is too bad. I noticed that the FileFields do have a browse button in >> the admin form btw. Do they not use form_for_model? >> >> As an alternative, is there a way to use FileField 's separately from the >> the form_for_model fields? I am thinking I could leave the FileFields out of >> the model and use a form class for those fields instead. Not sure how to get >> this done however. Any suggestions/examples? > > Your questions don't really make sense. There is no FileField in > newforms yet. The current admin interface does not use newforms, so it > isn't pertinent to the issue. > > Do not get model fields and form fields confused, since they are > entirely different objects serving different purposes. You certainly > cannot chop and change them. > > Regards, > Malcolm > > > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: tutorial 4, generic views won't load from db?
Thanks, it worked! It was my fault to ingore the paragraph about change the variables names. Maybe if there were modified codes in the page, it will be better, because codes are much easier to discover. On 6月12日, 下午12时07分, Kelvin Nicholson <[EMAIL PROTECTED]> wrote: > On Sat, 2007-06-09 at 23:28 -0700, deerchao wrote: > > I'm new to django, and I'm following tutorials on djangoproject.com. > > Everything worked fine before I start using generic views. After > > modifying polls/urls.py, the /polls/ page can't get any polls, and / > > polls/1/ can't get any choices(there isn't a 404 error, but /polls/5/ > > raises one), either. > > Did you get this sorted out? It sounds like to me that things are > working, just aren't being displayed in the template. Maybe you missed > this part: > > "Change the template call from polls/detail.html to > polls/poll_detail.html" > > However, since you don't get a "Template Doesn't Exist" error, I'm > guessing poll_detail.html exists. This leads me to think this isn't > set: > > "Go through your templates, and modify any reference to latest_poll_list > to object_list, and change any reference to poll to object." > > So, double check that you have renamed poll to object (I know it sounds a > little confusing). > > {{ poll.question }} > > {% for choice in poll.choice_set.all %} > {{ choice.choice }} > {% endfor %} > > > To... > > {{ object.question }} > > {% for choice in object.choice_set.all %} > {{ choice.choice }} > {% endfor %} > > > I think... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Handling Very Large File Uploads and Cookie-less Visitors
Hello, Regarding very large file uploads, I know this probably gets asked a lot and I've found one thread that comes close to what the answer I'm looking for: http://groups.google.com/group/django-users/browse_thread/thread/ca95963aaa33ce1e/c69fb3381885f9a7 This thread was posted about a year ago and I cannot find any follow-ups to this discussion. I am running Django using mod_python and my question is: What happens when a very large file is uploaded? Does it all get stored in memory or is it stored in a temp file and accessed as a byte stream? I want to be able to allow very large file uploads but I want to make sure an upload does not use up all the memory on the machine. Regarding cookie-less visitors or visitors with cookies disabled on their browser or proxy. Django, with the SessionMiddleware, will always create a new session and send a new session id as a cookie to the browser. Even with just the HEAD script from libwww-perl, I am able to get the site to issue new sessions with every HEAD request. What happens if a script kiddie hammers the site with so many HEAD requests? Do dead/unused sessions pile up on the sessions table? Does Django do anything to mitigate this or at least clean up dead/unused sessions automatically? -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
free sms sending to all over the world(100%free)
LINK : http://smscity.com/?rid=466899 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: "Powered by Django" directory - Designer Wanted!
On Jun 11, 5:26 pm, olive <[EMAIL PROTECTED]> wrote: > After having click on "Add site" the form displayed again without any > success or failure message. Olive, I haven't had any such issues - the form will redisplay if you have any issues, but error messages should be shown to you. I've just tried submitting a site with no problems at all. Thanks to Wathi there is a new look & feel for the site that should be online soon. I'll make an announcement here and via the community page/ aggregator once it's live. Lastly, a few people asked about making screenshots of websites: I've put my code online on my blog (http://www.rossp.org/blog/2007/jun/13/ using-webthumb-api-python/) Ross --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Noob here. Accessing data across relationships
I think that requires more logic in the template than possible. My brain says tot do exactly what you suggest. But my template looks similar to this: {% for p in object.events.all %} {{ p.event_name }}, {% endfor %} If the Member isn't registered to one of the events, then I don't get a for that event, and it throws off the rest of the format for the table... On Jun 12, 6:32 pm, Kelvin Nicholson <[EMAIL PROTECTED]> wrote: > [snip > > > > > The trouble I'm having is, if someone is not assigned to an event, I > > get nothing displayed (duh, there's not an event); except I'm > > displaying this in a table, and if I don't have any data, then the > > cell formatting doesn't line up correctly. > > [snip] > > I just quickly perused your email; if the only problem you are having is > the loop creating the table row/column when there isn't any actual data, > couldn't you just create an {% if object %} in the template, and adjust > the formatting accordingly? > > Just a quick thought, > Kelvin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Noob here. Accessing data across relationships
[snip > > The trouble I'm having is, if someone is not assigned to an event, I > get nothing displayed (duh, there's not an event); except I'm > displaying this in a table, and if I don't have any data, then the > cell formatting doesn't line up correctly. [snip] I just quickly perused your email; if the only problem you are having is the loop creating the table row/column when there isn't any actual data, couldn't you just create an {% if object %} in the template, and adjust the formatting accordingly? Just a quick thought, Kelvin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Upload Image Example - Is anything busted with my example?
I am a Django newbie and had a lot of trouble figuring out how to upload an image. I looked at lots of examples of which no single one made it clear how to do this. After much effort I came up with something that works and at least I find to be clear so I wanted to post it for other newbies to use and for the pros to tell me if I did anything terribly wrong. I spent some effort trying to comment it well and also tried to name things uniquely so you know what is what. Hopefully this will save others time. Oh yeah I'll insert the obligatory Django Rocks here. Looking forward to version 1.0 (hopefully with full support for form_from_model to avoid this whole upload issue) Oh and as a favor to others If you do correct this please be very explicit about where corrections are made and what is new, and what is replaced and where these should go. Even better copy what I have here and edit that directly so there is a complete example to look at. #+ # model- #+ from django.db import models # Create your models here. class logomodel(models.Model): logofile = models.ImageField( upload_to='logoImg/%Y/%m/%d') fdate = models.DateField( auto_now_add = True) def __str__(self): return "logo %s" %str(self.id) class Admin: pass #+ # model- #+ #+ # - view - #+ # Create your views here. from django import http from django import newforms as forms from django.shortcuts import render_to_response, get_object_or_404 from django.http import HttpResponseRedirect from django.conf import settings from testSite_1.logoizeApp.models import logomodel #form for uploading class UploadLogo_Form( forms.Form ): logoFile = forms.Field( widget = forms.FileInput() , label='logo file') #clean the form (validation) method def clean_logoFile(self): from StringIO import StringIO from PIL import Image if 'logoFile' in self.clean_data:#make sure the data has the field "logoFile" #grab the cleaned version of the filename cleanFileName = self.clean_data['logoFile'] if cleanFileName.get('content-type'):#make sure it has the content-type key #split content-type into type and extension main, sub = cleanFileName.get('content- type').split('/') # check the content type to make sure it is an image of and acceptable type if not (main == 'image' and sub in ['jpeg','jpg','gif','png']):#broken for IE raise forms.ValidationError(_('JPEG,GIF,of PNG only please')) else: cleanFileName = 'none' raise forms.ValidationError(_('something wacky happened posted data does not include image')) return cleanFileName # the upload view def uploadLogo_View(request): if request.method == 'POST':#check if request is a post of the form data requestData = request.POST.copy()#copy the POST part of the request to requestData.update(request.FILES) upload_Form = UploadLogo_Form(requestData)#make a form from the data #checks validity of form (runs the clean_logoFile method above) if upload_Form.is_valid(): from PIL import Image from StringIO import StringIO #open the content and convert it to RGB imageIn = Image.open(StringIO(request.FILES['logoFile'] ['content'])) imageIn = imageIn.convert("RGB") #first create instance in the db with some dummy path location to get a unique id tempPath = 'dummy' #instantiate a new model with this data logoInstance = logomodel(logofile = tempPath) logoInstance.save() # save the new model adds row to db idNumber = logoInstance.id # Get the new id imagePath = '%slogo_%d.jpg' %(settings.MEDIA_ROOT, idNumber) imageIn.save(imagePath,'jpeg') #update the file path to the actual one used logoInstance.logofile = imagePath logoInstance.save() # save it to the data base return HttpResponseRedirect('../addLogoSuccess/') else: pass else:# this is the initial time the page is requested so make the form and render the page upload_Form = UploadLogo_Form()# create the form # renders the template either clean or with errors to correct return render_to_response('uploadfile_template.html', {'upForm':upload_Form}) # success view def
Re: new Django site: critterwatch.org
If I were you I'd get my hands on pictures of all of the "critters" and put them next to their names. It'd spice up the UI a bit. Udi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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_for_model + FileField issue
On Tue, 2007-06-12 at 20:03 -0500, Vincent Nijs wrote: > Thanks for the reply Malcolm. > > That is too bad. I noticed that the FileFields do have a browse button in > the admin form btw. Do they not use form_for_model? > > As an alternative, is there a way to use FileField 's separately from the > the form_for_model fields? I am thinking I could leave the FileFields out of > the model and use a form class for those fields instead. Not sure how to get > this done however. Any suggestions/examples? Your questions don't really make sense. There is no FileField in newforms yet. The current admin interface does not use newforms, so it isn't pertinent to the issue. Do not get model fields and form fields confused, since they are entirely different objects serving different purposes. You certainly cannot chop and change them. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: form_for_model + FileField issue
Thanks for the reply Malcolm. That is too bad. I noticed that the FileFields do have a browse button in the admin form btw. Do they not use form_for_model? As an alternative, is there a way to use FileField 's separately from the the form_for_model fields? I am thinking I could leave the FileFields out of the model and use a form class for those fields instead. Not sure how to get this done however. Any suggestions/examples? Thanks, Vincent On 6/12/07 7:51 PM, "Malcolm Tredinnick" <[EMAIL PROTECTED]> wrote: > > On Tue, 2007-06-12 at 18:50 -0500, Vincent Nijs wrote: >> Hi, >> >> I have a form linked to a model. I am using form_for_model or >> form_for_instance as required. >> >> The only issue is that FileField fields are not displayed with a 'browse' >> button. The function I am using is given below. >> >> I know from the documentation that model fields get converted to form fields >> by form_for_model (e.g., FileField to CharField). >> >> But I want a FileField in my form :) > > How to handle file uploads correctly and neatly in newforms is still > under development. Some results are in ticket #3297, although there will > be a hiatus in that work for a few weeks since Russell is away. > > Regards, > Malcolm > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Database protection/coherency between multiple applications accessing the same tables
On 6/12/07, womble <[EMAIL PROTECTED]> wrote: > We're a little closer to experimenting with this, and have another question: > is there any coherency checking/row (table?) locking implemented in > django's db layer? Django itself does not implement any locking features, or anything else designed to manage database concurrency. That's the job of your database -- so long as you're in a transaction you should get a consistent view of the data the whole time you're working with it, and good databases let you configure them to deal with concurrent data changes (e.g., with PostgreSQL you can set transactions to "serializable", and concurrent write attempts from two processes will result in one of them getting an exception saying that the data changed elsewhere). -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: form_for_model + FileField issue
On Tue, 2007-06-12 at 18:50 -0500, Vincent Nijs wrote: > Hi, > > I have a form linked to a model. I am using form_for_model or > form_for_instance as required. > > The only issue is that FileField fields are not displayed with a 'browse' > button. The function I am using is given below. > > I know from the documentation that model fields get converted to form fields > by form_for_model (e.g., FileField to CharField). > > But I want a FileField in my form :) How to handle file uploads correctly and neatly in newforms is still under development. Some results are in ticket #3297, although there will be a hiatus in that work for a few weeks since Russell is away. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: session variable in template
On Tue, 2007-06-12 at 13:27 +, Dushyant Sharma wrote: > i am building single page for logged in users and anonymous users > where i can use uid for logged in users and show specific things to > them and for this i want to use session variable in template. i am > trying request.session.uid in template where uid is session > variable.. Have a read of http://www.djangoproject.com/documentation/authentication/#authentication-data-in-templates . That should explain what you need. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: request.POST.getlist('fieldname') / repeated rows of fields
Well, now, that is an interesting find. It seems to me the upcoming prefix attribute should result in a dotted name, not a dashed one, so that one could make good use of this utility. On 07-Jun-10, at 9:35 PM, SmileyChris wrote: > django.utils.datastructures.DotExpandedDict --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
new Django site: critterwatch.org
Not officially launched yet, but I'd appreciate some people banging on critterwatch.org and telling me what breaks. It's a site to track how you state senators and congressmen vote. Right now it only has information for Georgia, but I'm working on adding the next state (namely, South Carolina) right now. Thanks --B --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: gettext_lazy and string interpolation
On Tue, 2007-06-12 at 04:32 -0700, Eugene Morozov wrote: > Hello, > What is the correct way to use gettext_lazy with string interpolation? > Aren't there built-in facilities for this in the Django? Just using it normally -- using a gettext_lazy proxy object wherever you would normally use a format string -- will do what you expect. s = gettext_lazy('my string %s %d') ... print s % ('fred', 11) The only thing to consider is to make sure that you don't actually do the interpolation too early -- since that converts it from a proxy to a string -- so the translation has to take place at that moment. All this means is don't do interpolation at import time, for example. Doing it inside views or anything called from a view should be fine, though, since the correct locale will already be in effect. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
God's Simple Plan of Salvation
God's Simple Plan of SalvationMy Friend: I am asking you the most important question of life. Your joy or your sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you are, nor if you are a church member, but are you saved? Are you sure you will go to Heaven when you die? God says in order to go to Heaven, you must be born again. In John 3:7, Jesus said to Nicodemus, "Ye must be born again." In the Bible God gives us the plan of how to be born again which means to be saved. His plan is simple! You can be saved today. How? First, my friend, you must realize you are a sinner. "For all have sinned, and come short of the glory of God" (Romans 3:23). Because you are a sinner, you are condemned to death. "For the wages [payment] of sin is death" (Romans 6:23). This includes eternal separation from God in Hell. " . . . it is appointed unto men once to die, but after this the judgment" (Hebrews 9:27). But God loved you so much He gave His only begotten Son, Jesus, to bear your sin and die in your place. " . . . He hath made Him [Jesus, Who knew no sin] to be sin for us . . . that we might be made the righteousness of God in Him" (2 Corinthians 5:21). Jesus had to shed His blood and die. "For the life of the flesh is in the blood" (Lev. 17:11). " . . . without shedding of blood is no remission [pardon]" (Hebrews 9:22). " . . . God commendeth His love toward us, in that, while we were yet sinners, Christ died for us" (Romans 5:8). Although we cannot understand how, God said my sins and your sins were laid upon Jesus and He died in our place. He became our substitute. It is true. God cannot lie. My friend, "God . . . commandeth all men everywhere to repent" (Acts 17:30). This repentance is a change of mind that agrees with God that one is a sinner, and also agrees with what Jesus did for us on the Cross. In Acts 16:30-31, the Philippian jailer asked Paul and Silas: " . . . 'Sirs, what must I do to be saved?' And they said, 'Believe on the Lord Jesus Christ, and thou shalt be saved . . . .' " Simply believe on Him as the one who bore your sin, died in your place, was buried, and whom God resurrected. His resurrection powerfully assures that the believer can claim everlasting life when Jesus is received as Savior. "But as many as received Him, to them gave He power to become the sons of God, even to them that believe on His name" (John 1:12). "For whosoever shall call upon the name of the Lord shall be saved." (Romans 10:13). Whosoever includes you. Shall be saved means not maybe, nor can, but shall be saved. Surely, you realize you are a sinner. Right now, wherever you are, repenting, lift your heart to God in prayer. In Luke 18:13, the sinner prayed: "God be merciful to me a sinner." Just pray: "Oh God, I know I am a sinner. I believe Jesus was my substitute when He died on the Cross. I believe His shed blood, death, burial, and resurrection were for me. I now receive Him as my Savior. I thank You for the forgiveness of my sins, the gift of salvation and everlasting life, because of Your merciful grace. Amen." Just take God at His word and claim His salvation by faith. Believe, and you will be saved. No church, no lodge, no good works can save you. Remember, God does the saving. All of it! God's simple plan of salvation is: You are a sinner. Therefore, unless you believe on Jesus Who died in your place, you will spend eternity in Hell. If you believe on Him as your crucified, buried, and risen Savior, you receive forgiveness for all of your sins and His gift of eternal salvation by faith. You say, "Surely, it cannot be that simple." Yes, that simple! It is scriptural. It is God's plan. My friend, believe on Jesus and receive Him as Savior today. If His plan is not perfectly clear, read this tract over and over, without laying it down, until you understand it. Your soul is worth more than all the world. "For what shall it profit a man, if he shall gain the whole world and lose his own soul?" (Mark 8:36). Be sure you are saved. If you lose your soul, you miss Heaven and lose all. Please! Let God save you this very moment. God's power will save you, keep you saved, and enable you to live a victorious Christian life. "There hath no temptation taken you but such as is common to man: but God is faithful, Who will not suffer you to be tempted above that ye are able; but will with the temptation also make a way to escape, that ye may be able to bear it" (1 Corinthians 10:13). Do not trust your feelings. They change. Stand on God's promises. They never change. After you are saved, there are three things to practice daily for spiritual growth:· Pray -- you talk to God. · Read your Bible -- God talks to you. · Witness -- you talk for God. You should be baptized in obedience to the Lord Jesus Christ as a public testimony of your salvation, and then unite with a Bible- believing church without delay. "Be not thou therefore ashamed of the testimony of our Lord . . .
Database protection/coherency between multiple applications accessing the same tables
Hi, in the past I've written to this list re using the django db back-end as a db access layer for a test-automation system I work on; we hope to re-write the current front-end with django at some point. We're a little closer to experimenting with this, and have another question: is there any coherency checking/row (table?) locking implemented in django's db layer? i.e. if I have two scripts, on two different machines, both accessing the same db & table, what built in support is there to catch race-conditions/invalid updates/etc? Are there any examples out there someone can point me to? Also, is there any difference with which db is used- MySql vs Postgres? So far we've found nothing by searching; I suspect we're using the wrong terminology... (Background: We are hoping to re-write the front-end web-gui in Django (current one is difficult to maintain, and hard for new developers), and as the backend (scheduler, always running) is in python and has an 'interesting'- i.e. slightly broken- db layer, we're thinking to fix to problems by taking advantage of django.) Thanks in advance, Julian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Deduping a queryset based on one field
On Tue, 2007-06-12 at 22:20 +, bahund wrote: > I have a Searchlog model, and I'm trying to build a queryset of all > unique searches ('searchstr' field). Using distinct() doesn't seem to > work because the pk will always be different. Ideally, I'd like to > use distinct() in a way where I could pass it the field I want to be > unique, such as: > > queryset = SearchLog.objects.order_by('-date').distinct('searchstr') You cannot do this at the moment. It might appear in the future, though. However, it looks like you might be able to get the same effect using a values queryset (using the .values() method in the query) and leaving out the pk field from the fields you want to retrieve. In that case, the distinct() filter will not be thrown off by the varying pk values. (I'm not in a position to be able to test this at the moment, but it looks correct from eye-balling the code). Alternatively, custom SQL is always possible. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Valid Lookup types by Model Field type
On Tue, 2007-06-12 at 21:54 +, schettino72 wrote: > Hello, > > Can I dynamically determine what are the valid lookup types for a > specified type of model field? > > i.e. If you try: > > >>> q1 = Entry.objects.filter(blog__startswith="What") > > where blog is a 'models.ForeignKey'. you will get an exception because > "startswith" is not valid for ForeignKey fields. This is more a data typing issue, than the fact that it is a foreign key. If you have a ForeignKey pointing to a primary key in the remote table that is a string, then you could use startswith (can't remember if we've fixed the bug that makes the foreign key have the right type in that case or not, but it should be possible). > > I am building a dynamic form where the users can select the field and > the type of lookup to filter a query. > Using newforms I do: > > >>> self.fields["comparison"] = forms.ChoiceField() > >>> self.fields["comparison"].choices = ([(i,i) for i in > >>> models.query.QUERY_TERMS]) > > The problem here is that the user can select any lookup type, not only > the valid ones. > I would like that each model class Field define a list of valid > options. I look the code and it looks like it is not possible. In practice, we don't need such a list. Maintaining such a list of restrictions would be fairly time consuming (and mistakes would be made). Some cases are backend dependent. In practice, the callers will use sensible search terms and we raise an error if they don't because the database detects the problem. If you wanted to build one by hand, the list of possible query terms is in django/db/models/query.py. Go through that list and for each data type, create a short list of search terms that aren't applicable (creating a blacklist is going to be easier than a whitelist). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: db rights
On Tue, 2007-06-12 at 11:59 -0500, Carl Karsten wrote: > What are the minimum GRANT options I need for running syncdb CREATE table privileges (which presumable also includes ALTER privileges), plus whatever might be needed to support any SQL in the initial SQL files that you might include in the project. > and the minimum needed for normal use? SELECT, DELETE and UPDATE privileges on the tables associated with all your models. So, any tables starting with your app names (myapp_* sort of patterns), plus SELECT permission on the django_user_* tables (if you are never going to add new users) and SELECT, DELETE and UPDATE on the session table. If you are using the admin interface, pretty much all the django_* tables will need DELETE/UPDATE permissions on them, otherwise you might be able to get away without needing access to those. There might be a few small things missing, but that should be pretty close. Basically, all models need read permissions on their respective tables. If you are creating new instances of a model, you need update and delete permissions. Nothing outside of syncdb (in Django itself) needs CREATE or DROP permissions. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: App Migration: ImportError @ isleap
On Mon, 2007-06-11 at 23:44 -0500, Jeremy Dunck wrote: > On 6/11/07, Justin Lilly <[EMAIL PROTECTED]> wrote: > > For archival purposes, the reason it wasn't working is I had named one of my > > apps "calendar". After I renamed it to agenda and remapped it appropriately, > > everything was in working order. > > Ouch. This sort of thing is actually a pretty common error-- the > usual one is that people name their first django site "site", which > breaks python's built-in site package, disabling packages and .pth's > in site-packages. > > Perhaps Django should validate that the thing you supply to startapp > and startproject aren't named something that's already importable. Whilst it's an annoying problem, I don't think this is a solution. We've talked about this a couple of times in the past (in particular, adding it to startapp and startproject). The problem is that it only solves the relatively small problem of initial creation and whatever happens to be visible at that moment. It doesn't add any robustness against installing third-party apps later (when you realise you actually need them) or moving from a development system to production or setting your Python import path in a different way so that now an entirely different set of names are visible. A solution like this stands a good chance of causing more pain than benefit, because people will rely on it too much at the start and then get bitten when the venture into the real world. Avoiding clashes with other modules on your Python path is something you always have to do in Python. Django doesn't feel like the right level to be trying to solve it (and every other language that allows inclusion of other units of code). Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: sqlite3: odd slice behavior
On Tue, 2007-06-12 at 17:21 -0400, Forest Bond wrote: [...] > My original question, to some extent, has become irrelevent, since QuerySets > that are the progeny of slice operations are explicitly forbidden further > QuerySet-like processing (filter, order_by). That was my original desire. > > However, I should point out that the sqlite3 backend should, IMO, always > return > a QuerySet, independent of internal object caching. This isn't worth it. You can't do anything further QuerySet-wise once you've taken a slice. So returning a list-like object is all that should be needed here and that's what we do. > > However, am I crazy to wonder if filtering QuerySets with slices in their > murky > past should be allowed? It could be implemented as a sub-query ... There is nothing in Django that does sub-queries (yet) and now is not the right time to be hacking up special cases like this. Remember that limit and offset are entirely non-relational operations, so, in part, the way we act the way we do in QuerySets is a consequence of this leaky abstraction (leaking up from SQL). Once you apply a limit/offset restriction to the result sequence, you cannot apply further relational operations to it. The *only* thing you can do is use it in a sub-query and that isn't particularly good SQL construction in any case (almost always there are better ways to get the same result with better performance characteristics). Once query construction is moved into it's own class, people who want to do strange and unusual things like this will be able to go crazy, sub-classing query construction, using queries as parameters to other queries -- the whole enchilada with extra beans. Best wishes, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Noob here. Accessing data across relationships
I'm having trouble pulling/formatting data into my template. I have added some Event items into the database. For the example, we'll say "golfing", "hiking" and "swimming". In my template, using the generic object_list, I want to list each member's information (easy enough) and then each event_name they've been assigned to (my problem). I can easily pull up a list of the events they're added to: (inside the template: a quick for loop over object.events.all) The trouble I'm having is, if someone is not assigned to an event, I get nothing displayed (duh, there's not an event); except I'm displaying this in a table, and if I don't have any data, then the cell formatting doesn't line up correctly. So! My thought process was to do part of the work myself in the view. But now I'm not sure where to go from here, and I'm not even sure how to ask the right questions (which is probably the whole of my problem as I'm sure I'm not the only one who has ever done this). What I get right now is similar to, in csv format (first line is hard coded into the template): name, address, conference id, golfing, hiking, swimming Justin, 1200 K St., 40, golfing swimming [note golfing swimming is one field] What I want in my output is a table (or csv) that reads like: name, address, conference id, golfing, hiking, swimming Justin, 1200 K St., 40, golfing, , swimming Here are my Models.simplified: class Conference(models.Model): conf_id = models.AutoField(primary_key=True) title = models.CharField(maxlength=100, core=True) class Event(models.Model): conference = models.ForeignKey(Conference)) event_name = models.CharField(maxlength=100, core=True) class Member(models.Model): name = models.CharField(maxlength=20) address = models.CharField(maxlenght=100) conferences = models.ManyToManyField(Conference) events = models.ManyToManyField(Event) class Admin: list_filter = ['events','conferences',] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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_for_model + FileField issue
Hi, I have a form linked to a model. I am using form_for_model or form_for_instance as required. The only issue is that FileField fields are not displayed with a 'browse' button. The function I am using is given below. I know from the documentation that model fields get converted to form fields by form_for_model (e.g., FileField to CharField). But I want a FileField in my form :) Is there a way around this? Or another way to create the form linked to the model that does not use form_for_model or form_for_instance? Thanks, Vincent def submit(request): try: inst = Application.objects.get(user=request.user) ApplicationForm = form_for_instance(inst) except: ApplicationForm = form_for_model(Application) if request.POST: form = ApplicationForm(request.POST) if form.is_valid(): form.cleaned_data entry = form.save(commit=False) entry.user = request.user entry.save() return render_to_response('submit/thankyou.html') else: form = ApplicationForm() return render_to_response('submit/submit.html',{'form':form,}) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Deduping a queryset based on one field
I have a Searchlog model, and I'm trying to build a queryset of all unique searches ('searchstr' field). Using distinct() doesn't seem to work because the pk will always be different. Ideally, I'd like to use distinct() in a way where I could pass it the field I want to be unique, such as: queryset = SearchLog.objects.order_by('-date').distinct('searchstr') Is there anything like this? I've seen a few discussions about handling unique queryset results at the db/model level (such as for many-to-many "tags"), by using the "unique=True" in the model declaration. That won't work because I want to allow duplicate search queries for other types of stats we're trying to keep (such as most popular searches). I'm wondering if this problem is something I can solve with a series of queryset API calls, custom SQL, or maybe something I need to solve with Python? Thanks in advance, Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
Thanks a lot guys. After I have changed my code to sales_person = request.POST['salespeople_dropdown'] it worked perfectly. On Jun 12, 2:55 pm, strelok31 <[EMAIL PROTECTED]> wrote: > Thanks Jeremy, > > I will try out your suggestions. I am not new to programming, I am new > to web programming and Django. I have done all four steps that your > suggested before, I have just done #2 wrong. I will correct it now. > Thanks. > > On Jun 12, 12:54 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > > > On 6/12/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > Any ideas? I have been stuck on this for a while and I got nobody else > > > to ask for help. Thanks again. > > > If you're really stuck, you need pointers as much as you need a > > solution; there really are many sources to find info on how to > > accomplish this fairly simple task. > > > General steps: > > 1) add to html, which you've already done. > > 2) add to python view, which you've done wrong. > > 3) add to python model, which you probably haven't done. > > 3) add to database, which you probably haven't done. > > > For #2, this line: > > sales_person = document.Submit.salespeople_dropdown.value > > most certainly should be something like this: > > sales_person = request.POST['salespeople_dropdown'] > > > Based on this line: > > from django.models.accukeys import acculicenses > > you're using an old version of Django (pre-0.95), which is fine, but > > means you should refer to documents for the version you're using. I > > suggest this:http://www.djangoproject.com/documentation/0_91/ > > > Anyway, for #3, go find the module accukeys.py, find the class in it > > named AccuLicense, and add a field attribute for sales_person. > > > For #4, however you handle your DB migration, add the sales_person > > column to the DB; you should see mysql's docs for how to do that. > > > If you are new to programming, rather than asking a broad question > > hoping for a very specific solution, consider contracting to get the > > job done or taking the time to learn the tools. > > > We want to make Django easy to use, but even so, a fairly large amount > > of knowledge is assumed. > > > Cheers, > > Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
Thanks Jeremy, I will try out your suggestions. I am not new to programming, I am new to web programming and Django. I have done all four steps that your suggested before, I have just done #2 wrong. I will correct it now. Thanks. On Jun 12, 12:54 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 6/12/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > > Any ideas? I have been stuck on this for a while and I got nobody else > > to ask for help. Thanks again. > > If you're really stuck, you need pointers as much as you need a > solution; there really are many sources to find info on how to > accomplish this fairly simple task. > > General steps: > 1) add to html, which you've already done. > 2) add to python view, which you've done wrong. > 3) add to python model, which you probably haven't done. > 3) add to database, which you probably haven't done. > > For #2, this line: > sales_person = document.Submit.salespeople_dropdown.value > most certainly should be something like this: > sales_person = request.POST['salespeople_dropdown'] > > Based on this line: > from django.models.accukeys import acculicenses > you're using an old version of Django (pre-0.95), which is fine, but > means you should refer to documents for the version you're using. I > suggest this:http://www.djangoproject.com/documentation/0_91/ > > Anyway, for #3, go find the module accukeys.py, find the class in it > named AccuLicense, and add a field attribute for sales_person. > > For #4, however you handle your DB migration, add the sales_person > column to the DB; you should see mysql's docs for how to do that. > > If you are new to programming, rather than asking a broad question > hoping for a very specific solution, consider contracting to get the > job done or taking the time to learn the tools. > > We want to make Django easy to use, but even so, a fairly large amount > of knowledge is assumed. > > Cheers, > Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Valid Lookup types by Model Field type
Hello, Can I dynamically determine what are the valid lookup types for a specified type of model field? i.e. If you try: >>> q1 = Entry.objects.filter(blog__startswith="What") where blog is a 'models.ForeignKey'. you will get an exception because "startswith" is not valid for ForeignKey fields. I am building a dynamic form where the users can select the field and the type of lookup to filter a query. Using newforms I do: >>> self.fields["comparison"] = forms.ChoiceField() >>> self.fields["comparison"].choices = ([(i,i) for i in >>> models.query.QUERY_TERMS]) The problem here is that the user can select any lookup type, not only the valid ones. I would like that each model class Field define a list of valid options. I look the code and it looks like it is not possible. Anyone tried this before? Cheers, Eduardo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: sqlite3: odd slice behavior
On Mon, Jun 11, 2007 at 09:43:55PM -0400, Forest Bond wrote: > On Mon, Jun 11, 2007 at 06:18:18PM +1000, Malcolm Tredinnick wrote: > > On Sun, 2007-06-10 at 15:45 -0400, Forest Bond wrote: > > > Using the sqlite3 backend, any slice operation on a QuerySet for which > > > the slice > > > does not start at 0, a list is returned instead of a QuerySet, and the > > > slice is > > > not performed in the database, but in Python. > > > > > > Is this expected behavior? The sqlite3 docs indicate that offsets can be > > > given, > > > so I see no reason this shouldn't be performed at the DB level. > > > > I'm unable to repeat this behaviour. Whenever I construct a QuerySet and > > slice it, the LIMIT/OFFSET bits get added. The only time the slicing is > > done in Python is where I have already accessed the results of the > > QuerySet (so it has been cached). In those cases, Django knows not to do > > another round-trip to the database. > > Ok, I understand the motivation for this design decision, but shouldn't the > slice still return a QuerySet? I see no reason why the (internal) cache > status > of the QuerySet should have such critical impact on the (external) API -- type > of returned objects. Well, I finally have a more thorough characterization of the situation, as illustrated here: In [1]: from loadmonitor.models import * In [2]: all_loads = Load.objects.all() In [3]: subset = all_loads[5:10] In [4]: type(subset) Out[4]: In [5]: subset.order_by('origination_state') --- Traceback (most recent call last) /home/fab/work/software/loadmonitor/ in () /home/fab/lib/python/django/db/models/query.py in order_by(self, *field_names) 406 "Returns a new QuerySet instance with the ordering changed." 407 assert self._limit is None and self._offset is None, \ --> 408 "Cannot reorder a query once a slice has been taken." 409 return self._clone(_order_by=field_names) 410 : Cannot reorder a query once a slice has been taken. In [6]: for load in all_loads: ...: pass ...: In [7]: subset = all_loads[5:10] In [8]: type(subset) Out[8]: In [9]: My original question, to some extent, has become irrelevent, since QuerySets that are the progeny of slice operations are explicitly forbidden further QuerySet-like processing (filter, order_by). That was my original desire. However, I should point out that the sqlite3 backend should, IMO, always return a QuerySet, independent of internal object caching. However, am I crazy to wonder if filtering QuerySets with slices in their murky past should be allowed? It could be implemented as a sub-query ... -Forest signature.asc Description: Digital signature
Re: Saving POSTed Data
On Jun 13, 5:53 am, robo <[EMAIL PROTECTED]> wrote: > if request.method == 'POST': > form1 = form_for_model(Order) > Orders = form1(request.POST, prefix='orders') This is a bit confusing. I'd suggest OrderForm = form_for_model(Order) order_form = OrderForm(request.POST, prefix='orders') ... if order_form.is_valid() and order_details_form.is_valid(): return HttpResponseRedirect('/chef') > I've read the Django tutorials on this, but I am still confused. It seems like you're reading some tutorials on (old)forms and trying to use newforms. They are two separate beasts, and should not be combined - you don't need any of that FormWrapper stuff. Side node: the IRC channel is useful for this sort of thing - dpaste your model and then go ask about it there for quick 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: image bundle for django
2007/6/12, Jeremy Dunck <[EMAIL PROTECTED]>: > > On 6/11/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I just finished a image bundle implementation for django, its a technique > > used in > > I really like this idea, but my needs are different. > > I don't need resizing of images in the bundle, and I don't like the > idea of loading all the original images in the bundle to determine > offsets in the final. Images bundle are nice when you need to download small images, icons for backoffice applications for example. So it's I nice add on for Django in my oppinion. I won't use it to download all the images but when you combine image bundle and normal image the result could be better than with just one techinique. My +1 to add it to the contribution folder. -- Antoni Aloy López Binissalem - Mallorca http://www.trespams.com Soci de Bulma - http://www.bulma.cat --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: generic view's templates and request
> It doesn't by default. However, have a look > athttp://www.djangoproject.com/documentation/templates_python/#django-c...to > see how to enable that. Generic views are given a RequestContext context, so > providing you enable the correct middleware processors, this will be possible. You thought about context processors not middleware processors, right? It messed me for a while but now my code works. So thanks again, you were very helpful. Here is my solution (even two solutions) The problem was: how to get access to 'request' from generic view's template. I used the following generic view: django.views.generic.list_detail.object_detail. 1. First solution requires us to modify urls.py import django.core.context_processors project_dict = { 'queryset': Project.objects.all(), 'context_processors': [django.core.context_processors.request] # this is context_processor which enables request for our generic view } urlpatterns = patterns('', (r'^projects/(?P\d+)/$', 'django.views.generic.list_detail.object_detail', project_dict), ) 2. Second solution is a global change for all generic views' templates We must modify settings.py file and add there: TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.request" #this one solves "lack of request" problem ) First four context processors here are defaults so I left them untouched. > Once you have the "request" variable in your template, you can forget > about GET or POST. Just access the variable you want as an attribute on > the "request" (you can do this in Python, too). HttpRequest classes have > a __getitem__ method that allows you to treat them like a dictionary and > they will look for the variable in POST first and then GET. Great! Thanks. -- Jakub Wisniowski --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
On 6/12/07, strelok31 <[EMAIL PROTECTED]> wrote: > > Any ideas? I have been stuck on this for a while and I got nobody else > to ask for help. Thanks again. If you're really stuck, you need pointers as much as you need a solution; there really are many sources to find info on how to accomplish this fairly simple task. General steps: 1) add to html, which you've already done. 2) add to python view, which you've done wrong. 3) add to python model, which you probably haven't done. 3) add to database, which you probably haven't done. For #2, this line: sales_person = document.Submit.salespeople_dropdown.value most certainly should be something like this: sales_person = request.POST['salespeople_dropdown'] Based on this line: from django.models.accukeys import acculicenses you're using an old version of Django (pre-0.95), which is fine, but means you should refer to documents for the version you're using. I suggest this: http://www.djangoproject.com/documentation/0_91/ Anyway, for #3, go find the module accukeys.py, find the class in it named AccuLicense, and add a field attribute for sales_person. For #4, however you handle your DB migration, add the sales_person column to the DB; you should see mysql's docs for how to do that. If you are new to programming, rather than asking a broad question hoping for a very specific solution, consider contracting to get the job done or taking the time to learn the tools. We want to make Django easy to use, but even so, a fairly large amount of knowledge is assumed. Cheers, Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
request.POST['salespeople_dropdown'] should have your value? On Jun 12, 3:31 pm, strelok31 <[EMAIL PROTECTED]> wrote: > Any ideas? I have been stuck on this for a while and I got nobody else > to ask for help. Thanks again. > > On Jun 4, 8:47 am, strelok31 <[EMAIL PROTECTED]> wrote: > > > I wanted to see if people have any ideas, I am sorry if I was not very > > clear in my explanation. > > > My task is to add a drop down selection list to the > > HTML page and the save the value selected to the MySQL database. > > > I have added a drop down selection list. The problem that I am having > > right now is how to capture the value selected by the user to be able > > to store it in the database. In the way that the program is working > > right now the file is being uploaded and the information in the file > > is decrypted and saved to the database. I just need to figure out a > > way to capture the value selected by the user and save it to the > > database in the content of the program. Meaning so I don't have to > > rewrite the whole program just make a small change. Right now the > > program is reading an external file and saving information from there > > to the database. > > > Thank a lot. > > > Russell Keith-Magee wrote: > > > On 6/2/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > > Any ideas? > > > > Let's get this straight: You send a multiple-page email, describing a > > > large application, with a vague description of what it does, and a > > > body of unindented Python code, and HTML that doesn't appear to come > > > from a Django template. As a result of some changes (which you don't > > > describe) you say it now "doesn't work" (in some unspecified way). > > > > And three hours after your original post, you complain that you > > > haven't gotten a response. > > > > Have you considered that maybe you might be unreasonable in your > > > expectations of a mailing list that is populated by volunteers? > > > > Yours, > > > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Kid and css file
Le lundi 11 juin 2007 à 13:37 -0700, Tyson Tate a écrit : > On Jun 11, 2007, at 11:18 AM, Francis wrote: > > > So far everything is working fine. But I have founded no working > > solution to make my /static/css /static/images /static/javascript > > works. > > Read this: > > http://www.djangoproject.com/documentation/static_files/ > > -Tyson Perfect, that solved my problem. Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: image bundle for django
On 6/11/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote: > Hi, > > I just finished a image bundle implementation for django, its a technique > used in I really like this idea, but my needs are different. I don't need resizing of images in the bundle, and I don't like the idea of loading all the original images in the bundle to determine offsets in the final. Also, I'd like named bundles so that I could build multiple separate bundles at the same time rather than one big bundle for the page; I think this'd help me hit pre-made bundles more often. So, I plan on doing another implementation in the same vein. I see you're using mx.Misc.OrderedMapping. Does that do anything that django.utils.datastructures.SortedDict doesn't do? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
Any ideas? I have been stuck on this for a while and I got nobody else to ask for help. Thanks again. On Jun 4, 8:47 am, strelok31 <[EMAIL PROTECTED]> wrote: > I wanted to see if people have any ideas, I am sorry if I was not very > clear in my explanation. > > My task is to add a drop down selection list to the > HTML page and the save the value selected to the MySQL database. > > I have added a drop down selection list. The problem that I am having > right now is how to capture the value selected by the user to be able > to store it in the database. In the way that the program is working > right now the file is being uploaded and the information in the file > is decrypted and saved to the database. I just need to figure out a > way to capture the value selected by the user and save it to the > database in the content of the program. Meaning so I don't have to > rewrite the whole program just make a small change. Right now the > program is reading an external file and saving information from there > to the database. > > Thank a lot. > > Russell Keith-Magee wrote: > > On 6/2/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > Any ideas? > > > Let's get this straight: You send a multiple-page email, describing a > > large application, with a vague description of what it does, and a > > body of unindented Python code, and HTML that doesn't appear to come > > from a Django template. As a result of some changes (which you don't > > describe) you say it now "doesn't work" (in some unspecified way). > > > And three hours after your original post, you complain that you > > haven't gotten a response. > > > Have you considered that maybe you might be unreasonable in your > > expectations of a mailing list that is populated by volunteers? > > > Yours, > > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Saving POSTed Data
This is my view code for this implementation: if request.method == 'POST': form1 = form_for_model(Order) Orders = form1(request.POST, prefix='orders') form2 = form_for_model(Order_Detail) Orders_Details = form2(request.POST, prefix='order_details') if Orders.is_valid(): if Orders_Details.is_valid(): Orders.save() Orders_Details.save() return HttpResponseRedirect("/chef/") else: errors = new_data = {} form = forms.FormWrapper(/*originally "manipulator" went here */, new_data, errors) ^^ how do I pass back a form that includes both models? Something like: form_a = form1.FormWrapper(form1, new_data, errors) form_b = form2.FormWrapper(form2, new_data, errors) return render_to_response('products/product_list.html', locals()) I've read the Django tutorials on this, but I am still confused. I'm really eager to learn custom forms and to master it once and for all. If anyone has a great tutorial for custom forms out there, please, please let me know. 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 -~--~~~~--~~--~--~---
db rights
What are the minimum GRANT options I need for running syncdb and the minimum needed for normal use? Everything I find on the web does a blanket ALL, some even on all DBs of the whole server. I couldn't find anything in the docs, and it really should be spelled out. Carl K --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Jasper Reports
Yeah...I'm surprised though that iReport hasn't branched off to have a Save As Report Lab report though. It is a nice report design package...they shouldn't tie themselves to one report format On Jun 12, 10:11 am, Joel <[EMAIL PROTECTED]> wrote: > I went down the exact same path as you. I wanted to use Jasper/iReport > with Django. In the end, it ended up being easier just using Report Lab > which has produced some very nice results. I do miss iReport, but for > our purposes we didn't need a graphical editor for the reports on this > project - they were very custom. > > It's nice that ReportLab integrates tightly with Django. I think that > trying to use Jasper would have been a kludge at best. > > -- Joel > > [EMAIL PROTECTED] wrote: > > Has anyone successfully used Jasper Reports on the server being called > > from a Django view? > > > I've done a few things with ReportLab, but we have the need for a > > graphical Report Designer, which I don't believe exists for Report > > Lab...so we were talking about the possibiltiy of using Jasper > > Reports...thought I'd see if anyone had done 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 -~--~~~~--~~--~--~---
Re: Jasper Reports
I went down the exact same path as you. I wanted to use Jasper/iReport with Django. In the end, it ended up being easier just using Report Lab which has produced some very nice results. I do miss iReport, but for our purposes we didn't need a graphical editor for the reports on this project - they were very custom. It's nice that ReportLab integrates tightly with Django. I think that trying to use Jasper would have been a kludge at best. -- Joel [EMAIL PROTECTED] wrote: > Has anyone successfully used Jasper Reports on the server being called > from a Django view? > > I've done a few things with ReportLab, but we have the need for a > graphical Report Designer, which I don't believe exists for Report > Lab...so we were talking about the possibiltiy of using Jasper > Reports...thought I'd see if anyone had done 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 -~--~~~~--~~--~--~---
Re: User Friendly Parent Categories in Admin Panel
You can see the category model we use in Satchmo here - http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/product/models.py Here's a template tag we use to build an HTML hierarchy of the categories - http://www.satchmoproject.com/trac/browser/satchmo/trunk/satchmo/shop/templatetags/category_display.py You can see the various parts in action on the demo store here - http://www.satchmoproject.com/shop/ I hope this helps. -Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
session variable in template
i am building single page for logged in users and anonymous users where i can use uid for logged in users and show specific things to them and for this i want to use session variable in template. i am trying request.session.uid in template where uid is session variable.. i have set request.session['uid']=str(user.id) now i want to dothe following in template {% if request.session.id %} you are logged in {% endif %} but nothing is showing here i am loggin user in login(request, user) request.session['uname']=username uu=User.objects.get(username=username) request.session['uid']=str(uu.id) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Jasper Reports
Hello, another way is to use OpenOffice: - easy to use and feature reach graphical interface (Text, Draw, Presentation or Speadsheet) - Native PDF export (you don't need any Adobe product) - standard Open Document Format (recommended way to populate data from a template using LXML for example) - PyUno API (to automate document opening and exporting) - very good performance Feel free (of charge) to ask question ;-) HTH, Olive --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
gettext_lazy and string interpolation
Hello, What is the correct way to use gettext_lazy with string interpolation? Aren't there built-in facilities for this in the Django? Eugene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Jasper Reports
On 12 июн, 04:53, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Has anyone successfully used Jasper Reports on the server being called > from a Django view? I've implemented a Jasper server in Jython. It listens on some network port and generates Jasper reports based on data incoming from socket. The data was sent by a Django application. This was work for hire, so I cannot share the sources. But it is really easy to use Jasper within Jython. And if it is possible to run Django under Jython, the task would become even simpler. Eugene --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: MySql Workbench
On 10 Jun 2007, at 21:05, CarlFK wrote: > > I use MySql Workbench for data modeling. It might be a good idea to > have it create django's model.py. Has anyone done anything like this? Fantastic idea. I tried importing a database into it, and all worked great except for foreign key relationships weren't shown.. The first base for me would be able to view a model in Workbench, that'd be great... regards tom Tom Smith http://www.everythingability.com yahoo, aim, skype: everythingability mob: +44 (0) 7720 288 285 tel: +44 (0) 1904 870 565 fax: +44 (0) 8716 613 413 --- usability, findability, profitability, remarkability --- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Custom filters failing with "no module"
James Bennett wrote: > So long as your code is in a location where your code can be imported > by Python, there is another way; there are a couple of undocumented > functions in the template system which handle the loading of tag > libraries. > [snip] > So something like > > from django.template import add_to_builtins > add_to_builtins('path.to.your.library') Good tip - thanks! I have to admit, though, that I think adding a custom filter should be as simple as this code alone: > from django.template import Library > > register = Library() > > @register.filter > def javadoc_filter(value, arg): >return "whatever" I think part of my confusion was that my subconscious thinking was "my filter code has been imported (I can see the .pyc) so I know python has seen it, and therefore the filter is registered with the library, so I should be able to use it.". This thinking does not reflect the current reality, and thats ok because I have a workaround. But I think there is merit in a plain approach like that. After all - Django is into the D.R.Y. principle, so having to use register.filter() *as well* as have to have the module in a certain directory, seems a bit repetitious. JFWIW Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Jasper Reports
I inherited an online reporting/statistic web-app built with Spring and Jasper Reports. After being exposed to that, it is safe to say that I wont vulentarily use Jasper in any future project, ever. I haven't followed any of the links here, but iReport is a pretty horrible program to work with as well if you intend to export the reports to Excel. I'm building a reporting app myself in django as a replacement for the Spring thingy I mentioned above. My approach is to roll my own reporting; based on a query and an lot of various configurations, I build an XML file with the query result and all the parameteres. Then I have various command-line applications that I call 'exporters'. I pipe the XML into the exporter, which is able to convert it to anything, and pipe the exporters output back into a file that I put up for download. It sounds a lot like 'not-invented-here' mentality, but with the requirement to export to virtually anything, plus the existing application was a mess, this was the best way to do it that I could think of. On Jun 12, 5:59 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I downloaded the screencast on it, which took forever, it looks pretty > crude right now. I'm sure it will develop over time, but my boss has > seen iReport for Jasper Reports before, which is why he was wanting me > to try and use that. > > I've done a form design tool for something else in Java a few years > ago... I'm toying with the idea of learning more about rfxml and > creating a java based designer for ReportLab...but that will probably > have to wait a while. > > On Jun 11, 9:14 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > > > [EMAIL PROTECTED] wrote: > > > Has anyone successfully used Jasper Reports on the server being called > > > from a Django view? > > > > I've done a few things with ReportLab, but we have the need for a > > > graphical Report Designer, which I don't believe exists for Report > > > Lab. > > > Check out:http://dabodev.com/documentation > > Report Designer Overview (Paul, 2006-02-13, 23 minutes) > > (gui report designer for reportlab) > > > I have never used it, but it looks pretty cool. > > > Carl K --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Sitemap questions (probably dumb ones)
2006/12/7, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > I've been playing with the sitemap stuff and am finding it to be quite > slick. I do, however, have some questions about some unusual cases. > > 1)It works beautifully for listing all the detail pages that make up a > list view, but what about the page that takes the list view? In my > case, For example, I've got all my guitar pages in there, but not the > "guitars" page itself. > > 2) what about pages that aren't directly tied to any particular view. > My home page, for example, is built mostly from template tags, grabbing > this and that from here and there. > > 3)What if there's some page that's completely outside of django? Create > a dummy class returning the hardcoded URL? I've got a forum-archive > subdomain django doesn't know anything about, since it only exists to > archive the old php-based board. > I have exactly the same question about pages which don't match a django models and which are not FlatPages. For example /, /blog/, /products/, etc. I can't find any example about that. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---