Re: Looping through my POST data?
Nathan, Thanks for the iteritems() method. I implemented that into my code. However, 'if values != 0:' never evaluates to False. Even though some of the forms elements values are 0. For example when I do a assert False, values on one of those elements I see: AssertionError at /rugs/cart/addpad/ [u'0'] Does that mean that the value is 0? below is my view function and template code: // def addpad(request): if request.method == 'POST': pads = request.session.get('pad', []) for a, values in request.POST.iteritems(): #assert False, values if values != 0: opad = RugPad.objects.get(id=a) s = opad.size p = opad.price pads.append({'size': s, 'price': p}) request.session['pad'] = pads else: assert False, "It got here" #It never gets here return render_to_response('addpad.html', {'spad': request.session['pad']}) / {% for a in pad %} --- 1 2 3 4 5 {{ a.size }} -- ${{ a.price }} {% endfor %} / I'm thinking that my values variable is not a int. I tried int(values) but that still didn't work. How do I get it so that values is a int so that I can do 'if values != 0:'? Thanks On Jul 27, 8:49 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I'm not sure if I'm following what your saying...but this is what I > think you want to do: > > if request.method == 'POST': >pads = request.session.get('pad', []) >for pad in pads: > if request.POST[pad.id] <> '---': # the select > name should be the pad id based on your template code > # do something here ... because it wasn't > --- > > On Jul 27, 5:54 pm, Greg <[EMAIL PROTECTED]> wrote: > > > I'm trying to loop through my POST data. However I am having > > difficulties. I think my 'for' statement might be wrong. Below is my > > function and template code > > > View function > > > def addpad(request): > > if request.method == 'POST': > > pads = request.session.get('pad', []) > > i = 0 > > b = 1 > > for a in request.POST: > > if a != '---': > > opad = RugPad.objects.get(id=b) > > s = opad.size > > p = opad.price > > pads.append({'size': s, 'price': p}) > > request.session['pad'] = pads > > i = i + 1 > > b = b + 1 > > return render_to_response('addpad.html', {'spad': > > request.session['pad']}) > > > / Template File > > > {% for a in pad %} > > > > > > > >--- > >1 > >2 > >3 > >4 > >5 > >{{ a.size }} -- ${{ a.price }} > > > > > > {% endfor %} > > > // > > > Notice how my 'for' statement is listed as ' for a in request.POST: > > '. However, when i do a 'assert False, a' it always returns the value > > '1'. I need to get the value of each select statement. Such as (---, > > 1,2,3,4,5). > > > Is that 'for' statement returning me the value of each select > > statement? > > > 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: static css problems on windows box
Excellent, I have it figured out... or I should say, I have it working. I'm not sure I have it set up correctly, but at least it's working. At first I couldn't figure out how the view source was going to help me. I mean, I can point the css wherever I want, but trying to access the css files directly gave me a few clues. I'm not sure why, but when I run the development server, I can just give a relative path to the admin css files and it doesn't really matter what I put, it still finds the dashboard.css file under the django insta. But, the mod_python apache one won't. Anyway, long story short, I mapped the same relative path from my admin_media in settings to also have an alias as Graham suggests in my httpd.conf and somehow I got it working. Changing my PythonPath to have \dev instead of \dev\testproj was key. The frustrating part is that I'm used to having everything under my document_root. Moving so many pieces out and having it work in one place and not another, with very little feedback as to why is annoying. I'm sure I'll get the hang of it soon. Anyway, thanks a ton for your help. -Jim On Jul 26, 11:58 pm, oggie rob <[EMAIL PROTECTED]> wrote: > > My problems are this. First off, I was able to get the development > > admin working with my project fine, but when I try to serve it up > > using apache and mod_python, it's looking for the project under my > > Python25 directory (c:\dev\Python25), not in c:\dev\testproj. > > I think you need to say C:\dev in your PythonPath instead of C:\dev > \testproj. Also make sure testproj has an __init__.py file, if it > doesn't already (should have been set up). > To debug, try putting a "import sys, print sys.path" debug statement > in a view & test it in the development server. That will show you what > to expect. > > > Also, when I copy the project to c:\dev\Python25, I can get the admin > > interface, but without CSS. > > So view the source & see where the CSS is supposed to come from. Then > try to get it by typing that address in the browser. I think you'll > find you need a leading slash in front of the mainmedia. > > > And worse, even in the development server, I can't get templates to > > use my custom css files at all. I include a line like > > > > but I've tried putting that file everywhere under the sun to no > > effect. > > See source again to determine if the file is being shown to the > browser properly. I'm going to guess that it is rendering just fine, > but you probably don't have main.css set up in your urls.py file > properly. > > Generally though, don't panic! Break down each problem & think it > through and you will probably be able to work it out. > > -rob --~--~-~--~~~---~--~~ 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: static css problems on windows box
In what context are you talking about? Although Apache needs / to be used in Location paths, ie., URLs, it is actually quite tolerant of DOS style \ being used in native file system paths in DocumenRoot, Directory and other directives. Python itself is also somewhat tolerant of / and \ being mixed up in paths, although you do have to make sure that \ is escaped appropriately. Graham On Jul 28, 2:31 am, yml <[EMAIL PROTECTED]> wrote: > Hello, > just for the sake pay attention to the difference between "\" and "/". > If I remember well ONLY "/" will work. > > yml > > On Jul 27, 10:59 am, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > On Jul 27, 6:31 pm, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > On Jul 27, 4:09 pm, devjim <[EMAIL PROTECTED]> wrote: > > > > > Mod_python is working and I have this in my http.conf > > > > > > > > SetHandler python-program > > > > PythonHandler django.core.handlers.modpython > > > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > > > PythonDebug On > > > > PythonPath "['c:devtestproj'] + sys.path" > > > > > > > > > > > > SetHandler None > > > > > > > > Instead of Location directive for media files, you should have Alias > > > directive and Directory for actual physical directory the files are > > > located in. For example something like: > > > > Alias /mainmedia C:/path/to/media/files > > > Whoops, missed the trailing slashes. Should be: > > > Alias /mainmedia/ C:/path/to/media/files/ > > > Grahamd > > > > > > > Order deny,allow > > > Allow from all > > > > > > > > > > SetHandler python-program > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > > PythonDebug On > > > PythonPath "['c:devtestproj'] + sys.path" > > > > > > > The Location directive will not work for media files as it is for > > > virtual resources, whereas Alias maps it to physical resources. > > > > Graham --~--~-~--~~~---~--~~ 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: Is cloning Facebook in Django feasible?
> And yes, facebook has been cloned in other countries, many, many times. > The most famous one is from china: http://xiaonei.com/ Not only did > they clone the features, they cloned the interface. It even got > acquired for lots of money. Or in Germany StudiVZ, which also got acquired. As some server path-leaks in PHP errors revealed, they apparently called their app "Fakebook" internally, which I thought was kind of clever ;) Michael --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Generating charts with ReportLab
I had the need to generate a few different types of charts using ReportLab. The wiki only had a sample of a Horizontal Bar Chart, so I've added a new sample on how to produce a Line Chart... http://code.djangoproject.com/wiki/Charts If anyone is interested in a sample for a Pie or Scatter chart, let me know, and I can add samples of these as well. --~--~-~--~~~---~--~~ 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: File Upload field problem in auto-generated django forms
On 7/28/07, Robert <[EMAIL PROTECTED]> wrote: > > Hi all- > I'm very new to django, so pardon my faulty nomenclature! > I'm trying to create a view that creates a guides the user through > inserting some information into a table in my database. One of the > columns in my database model is of the type "models.FileField()". Hi Robert, FileFields (and ImageFields) are one part of newforms that isn't quite complete yet. If you look at ticket #3297, you can see the progress that is being made on this feature. If you're adventurous, you could try applying one of those patches to your version of Django; otherwise, be aware that this is high on my list of priorities as something to fix. 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: Is cloning Facebook in Django feasible?
On 7/27/07, Duc Nguyen <[EMAIL PROTECTED]> wrote: > One facebook in america is enough. There is plenty of room for > competition in other countries. Yes, but a straight-up clone of Facebook isn't the way to do it. Facebook succeeded because it chose a specific target market and oriented itself to that target market; in this case, the market was American college students from (mostly) affluent backgrounds. In other countries the market will be different, and so simply "cloning" Facebook likely won't result in a site that's appealing enough to the target market in that country (if you target students, for example, you must deal with the fact that the educational system and culture vary widely from one country to another). You also have to face the likelihood of competitors -- Orkut in Brazil, for example -- and be prepared not to say "we're just like that other site", but to say "here's how we're different from that other site, and why we're better". -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django.contrib.markup problems
On 28/07/07, Steve <[EMAIL PROTECTED]> wrote: > I am on a shared hosting environment, and am attempting to make use of > the textile filter. I have installed the textile library in $HOME/lib/ > python2.3/site-packages, which is on my $PATH, and my $PYTHONPATH. I > can import textile through the python interactive interpreter and > execute it correctly. However, when I place 'django.contrib.markup' > into my INSTALLED_APPS, and add the textile filter to my template tag, > Django throws this error: > > Error in {% textile %} filter: The Python textile library > isn't installed. > > Since I couldn't get textile to work, I've since tried Markdown. > Again, I installed it into $HOME/lib/python2.3/site-packages, can > import it through the interpreter, but cannot use it in my Django > templates. I suspect whatever is hosting your site (mod_python? fcgi?) is using a different path or a different interpreter (like 2.4). Print the value of sys.path from a view and see whether it includes the right folder. The other thing is to look in the django/contrib/markup/templatetags/markup.py file and make sure django is importing the same thing you are in the shell. Rob :) --~--~-~--~~~---~--~~ 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: Looping through my POST data?
I'm not sure if I'm following what your saying...but this is what I think you want to do: if request.method == 'POST': pads = request.session.get('pad', []) for pad in pads: if request.POST[pad.id] <> '---': # the select name should be the pad id based on your template code # do something here ... because it wasn't --- On Jul 27, 5:54 pm, Greg <[EMAIL PROTECTED]> wrote: > I'm trying to loop through my POST data. However I am having > difficulties. I think my 'for' statement might be wrong. Below is my > function and template code > > View function > > def addpad(request): > if request.method == 'POST': > pads = request.session.get('pad', []) > i = 0 > b = 1 > for a in request.POST: > if a != '---': > opad = RugPad.objects.get(id=b) > s = opad.size > p = opad.price > pads.append({'size': s, 'price': p}) > request.session['pad'] = pads > i = i + 1 > b = b + 1 > return render_to_response('addpad.html', {'spad': > request.session['pad']}) > > / Template File > > {% for a in pad %} > > > >--- >1 >2 >3 >4 >5 >{{ a.size }} -- ${{ a.price }} > > > {% endfor %} > > // > > Notice how my 'for' statement is listed as ' for a in request.POST: > '. However, when i do a 'assert False, a' it always returns the value > '1'. I need to get the value of each select statement. Such as (---, > 1,2,3,4,5). > > Is that 'for' statement returning me the value of each select > statement? > > 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: Looping through my POST data?
request.POST is a dictionary, not a list, so a for loop like yours is iterating over the keys of the dict. to get the values, you can do: for value in request.POST.itervalues(): to iterate over both keys and values: for a, value in request.POST.iteritems(): On Jul 27, 2:54 pm, Greg <[EMAIL PROTECTED]> wrote: > I'm trying to loop through my POST data. However I am having > difficulties. I think my 'for' statement might be wrong. Below is my > function and template code > > View function > > def addpad(request): > if request.method == 'POST': > pads = request.session.get('pad', []) > i = 0 > b = 1 > for a in request.POST: > if a != '---': > opad = RugPad.objects.get(id=b) > s = opad.size > p = opad.price > pads.append({'size': s, 'price': p}) > request.session['pad'] = pads > i = i + 1 > b = b + 1 > return render_to_response('addpad.html', {'spad': > request.session['pad']}) > > / Template File > > {% for a in pad %} > > > >--- >1 >2 >3 >4 >5 >{{ a.size }} -- ${{ a.price }} > > > {% endfor %} > > // > > Notice how my 'for' statement is listed as ' for a in request.POST: > '. However, when i do a 'assert False, a' it always returns the value > '1'. I need to get the value of each select statement. Such as (---, > 1,2,3,4,5). > > Is that 'for' statement returning me the value of each select > statement? > > 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 -~--~~~~--~~--~--~---
Django.contrib.markup problems
I am on a shared hosting environment, and am attempting to make use of the textile filter. I have installed the textile library in $HOME/lib/ python2.3/site-packages, which is on my $PATH, and my $PYTHONPATH. I can import textile through the python interactive interpreter and execute it correctly. However, when I place 'django.contrib.markup' into my INSTALLED_APPS, and add the textile filter to my template tag, Django throws this error: Error in {% textile %} filter: The Python textile library isn't installed. Since I couldn't get textile to work, I've since tried Markdown. Again, I installed it into $HOME/lib/python2.3/site-packages, can import it through the interpreter, but cannot use it in my Django templates. If anybody could offer my any advice on how to get it working properly I would greatly appreciate 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 -~--~~~~--~~--~--~---
Re: db mock for unit testing
On 7/27/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote: > > Then I've paused and wrote DbMock class for django that uses some black > magic to steal django db connection and substitute it with temporary sqlite > in-memory db. How is this different to the default Django behavior if you specify SQLite as your database? Can't you get exactly the same behavior by creating a test_settings.py file that contains: from settings import * DATABASE_BACKEND='sqlite' and then run: ./manage.py --settings=test_settings test ? 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 -~--~~~~--~~--~--~---
Filter to find closest match
Hi group, I am converting one old application from excel to django. Almost all sorted but can't figure out how to find closest math in query like in excel: "=INDEX(TABLE5,MATCH(C203,CMW,1),MATCH(Sheet1!J26,CMH,1))" All tables in models relate to pricelisttable class PriceListTable(models.Model): name=models.ForeignKey(PriceList,edit_inline=True) width = models.IntegerField(core=True) height1 = models.IntegerField(null=True, blank=True) height2 = models.IntegerField(null=True, blank=True) height3 = models.IntegerField(null=True, blank=True) height4 = models.IntegerField(null=True, blank=True) height5 = models.IntegerField(null=True, blank=True) height6 = models.IntegerField(null=True, blank=True) currently I using filter to find closest match: step=100 w=2000 # get it from forms. value=pricelist.pricelisttable_set.filter(width__gte=w-step,width__lte=w+step)[0] The problem is that "step" is different for different tables so sometimes getting more values or none. What would be the best way to find the closest match? -- -- Michael --~--~-~--~~~---~--~~ 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: Is cloning Facebook in Django feasible?
John DeRosa wrote: > Ick! Why would you want to? Isn't one facebook in the world enough? :-) > One facebook in america is enough. There is plenty of room for competition in other countries. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
friends table adding choices from the same database
i'm working on an app that has a table called friends whose model looks like this: class Friend(models.Model): user = models.ForeignKey(User) friend = models.CharField(maxlength=100) status = models.CharField(maxlength=1,choices=FSTATUS_CHOICES) def __str__(self): return self.friend user is the user that added the friend, while friend SHOULD be the id of the user that has been added. Both fields use the user table. I cant use the same foreign key for both, this would be an error. Ideally i would want a drop down box with all the username for the friend field. I thought about using choices, but cant seem to create a tuple that is dynamically populated from the username field in the user table. Any ideas how i could go about this? P.S is this a recursive relationship? i dont think so but hopefully some DB guru can shed some light. --~--~-~--~~~---~--~~ 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: Is cloning Facebook in Django feasible?
Ick! Why would you want to? Isn't one facebook in the world enough? :-) [EMAIL PROTECTED] wrote: > Is it possible to develop a Facebook functional clone in Django? What > parts of it are provided out of the box? Any third-party contributions? > > > > > > --~--~-~--~~~---~--~~ 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: complex form => Newforms vs template
> So my question is am I missing something or I was just expecting too > much from the newforms? I had similar problems initially, and after hundreds of forms built I still get annoyed every time I have to build a newforms form. On the other hand, I can't really think of a better way to do it either (and I've tried, oh how I tried). Building a form from just a raw template IS easier, but rendering is only part of newforms... its the consistent way of doing validation in the view (or writing the template) without knowing about the form details that are important as far as I'm concerned. The best advice I can give is to take a few minutes and read all of the newforms code (especially the fields and widgets), and the regression tests. It's extremely well commented, and will probably help a lot. It did for me. http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/forms/tests.py >My last question is would it be absurd to have a form field called >TemplateField to which we can give a template string that will be >dynamically inserted and substituted in the template? You could do that if you want to. Override one of that form.as_table,as_ul, etc methods to render from a template attribute. I'm not sure why you would though since it's pretty easy to do {{ form.fieldname }} in your view template if you don't like the default newforms layouts. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
POST variable bug?
Hi, Blow is a screen paste of server log for a small project I am working on. I am just printing the httpRequests POST data. Django version 0.96, using settings 'rsync.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. httpr.POST = str(httpr.POST) = httpr.POST.values() = ['new site', 'sefg sdfg', 'new loc'] httpr.POST.keys() = ['sitename', 'destloc', 'sloc'] httpr.POST.items() = [('sitename', 'new site'), ('destloc', 'sefg sdfg'), ('sloc', 'new loc')] httpr.POST['destloc'][0] = s I am submitting a form with a multiple select field. POST['destloc'] should be a list ['bingo', 'sefg sdfg'] instead i get only 'sefg sdfg'. Is the mistake Django's or mine? Thank you for your help! --Saravana --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Looping through my POST data?
I'm trying to loop through my POST data. However I am having difficulties. I think my 'for' statement might be wrong. Below is my function and template code View function def addpad(request): if request.method == 'POST': pads = request.session.get('pad', []) i = 0 b = 1 for a in request.POST: if a != '---': opad = RugPad.objects.get(id=b) s = opad.size p = opad.price pads.append({'size': s, 'price': p}) request.session['pad'] = pads i = i + 1 b = b + 1 return render_to_response('addpad.html', {'spad': request.session['pad']}) / Template File {% for a in pad %} --- 1 2 3 4 5 {{ a.size }} -- ${{ a.price }} {% endfor %} // Notice how my 'for' statement is listed as ' for a in request.POST: '. However, when i do a 'assert False, a' it always returns the value '1'. I need to get the value of each select statement. Such as (---, 1,2,3,4,5). Is that 'for' statement returning me the value of each select statement? 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: Indent Problem?
Hi Greg, Make sure you are consistently using tabs or spaces for indentation. Most people set their editors to replace a tab with four spaces. I would recommend this configuration. Python will get confused if you start mixing tabs and spaces. -Benjamin On Jul 27, 2:59 pm, Greg <[EMAIL PROTECTED]> wrote: > I have the following view: > > def addpad(request): > if request.method == 'POST': > pads = request.session.get('pad', []) > i = 1 > b = 1 > for a in request.POST: > if a != '---': > opad = RugPad.objects.get(id=b) > s = opad.size > p = opad.price > pads.append({'size': s, 'price': p}) > request.session['pad'] = pads > b = b + 1 # This is where it says the indent > is wrong > return render_to_response('addpad.html', {'spad': > request.session['pad']}) > > However, in the second to last line 'b = b + 1' it says that the > indent is wrong. However, I have this the same as my indent for my if > statement. I though that this would be correct. Any suggestions? > > 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: Blog engine
This is great, Chris, but the fact of the matter is that it won't appeal to the "Wordpress crowd". That group wants in-browser setup, easy plugin architecture etc. contrib.admin wouldn't do the trick. The admin-panel would have to be hand made. For the plugin architecture: I have no idea how we'd do this well. Any input here? It *could* be done in a Facebook Apps-manner (the actual code is remotely hosted, the admin-panel would show a list of available plugins), but I don't know how ideal this would be in a real world scenario. It sure would be great, though! On Jul 25, 12:06 am, "Chris Moffitt" <[EMAIL PROTECTED]> wrote: > I think I mentioned earlier in this thread, that I do have my take on > creating a blog here > -http://www.satchmoproject.com/trac/browser/satchmoproject.com/satchmo... > > It's pretty full featured right now and makes use of the tagging and > comment_utils libraries. It still needs the feeds but that should be pretty > simple. It's BSD licensed so hopefully it will be useful to folks. > > -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 -~--~~~~--~~--~--~---
Indent Problem?
I have the following view: def addpad(request): if request.method == 'POST': pads = request.session.get('pad', []) i = 1 b = 1 for a in request.POST: if a != '---': opad = RugPad.objects.get(id=b) s = opad.size p = opad.price pads.append({'size': s, 'price': p}) request.session['pad'] = pads b = b + 1 # This is where it says the indent is wrong return render_to_response('addpad.html', {'spad': request.session['pad']}) However, in the second to last line 'b = b + 1' it says that the indent is wrong. However, I have this the same as my indent for my if statement. I though that this would be correct. Any suggestions? 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: Best Practices to Make your Apps Portable
> I just added it to the wiki: > > http://code.djangoproject.com/wiki/BestPracticesToWorkWith3rdPartyAppsAndMakingYoursPortable Looking there, I think you made a typo. The directory diagrams for specific apps and generic apps are the same. Furthermore, I can see how this system worked for you under the constraints that your system/team imposed. However, I think that having your apps (specific or general) simply live on the PythonPath is more elegant, more DRY, and more in tune with what Django already does. Remember when you set up Django and had to configure the PythonPath in the apache http.conf file? Consequently, I appreciate your idea as a contribution to the Django developer community, but I think that recommending it as a "best practice" is rather misleading. > > It's available in the resources page. > > http://code.djangoproject.com/wiki/DjangoResources > > > Best, > > Sebastian Macias > > > On Jul 26, 12:36 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: >> Sebastian Macias wrote: >>> Thanks a lot for the feedback everyone. >> >>> I have come up a perfect setup and folder structure (at least >>> perfect for my needs) that will allow me to work on generic apps and >>> project specific apps efficiently and just wanted to share it with >>> everyone in case it can save a anyone a headache. >> >>> *Folder structure for a django project* >> >>> /var/django_root/my_project_name/ >>>urls.py >>>settings.py >>>apps/ >>>my_project_specific_app_1/ >>>my_project_specific_app_2/ >>>my_project_specific_app_3/ >> >>> *Folder structure for generic/portable apps* >> >>> /var/django_root/shared/ >>>my_generic_portable_app_1/ >>>my_generic_portable_app_2/ >>>my_generic_portable_registration_app/ >> >>> *Development Setup* >> >>> I added the following to the top of my_project_name/settings.py so it >>> appends the portable/generic apps folder to the python path. >> >>> DEVELOPMENT = True >> >>> if DEVELOPMENT: >>> import sys >>> sys.path.append('/var/django_root/shared') >> >>> For extended convenience I symlinked my portable/generic apps folder >>> to my django project so I can quickly make changes to my generic apps >>> without having to go outside my django project folder structure >> >>> ln -s `pwd`/var/django_root/shared /var/django_root/my_project_name/ >>> shared >> >>> *Production Setup* >> >>> My Apache conf file: >> >>> >>> ServerName championsound.local >>> ServerAlias *.championsound.local >>> SetHandler python-program >>> PythonPath "['/var/django_root', '/var/django_root/shared'] + >>> sys.path" >>> PythonHandler django.core.handlers.modpython >>> SetEnv DJANGO_SETTINGS_MODULE championsound.settings >>> PythonDebug On >>> >> >>> Note how '/var/django_root' and '/var/django_root/shared' are added to >>> the PythonPath >> >>> Enjoy it! >> >>> Sebastian Macias >> >> Can you post this to the wiki? or tell me to. one of us should. :) >> >> 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: There's got to be a better way
> > Creating a template tag [1] might be a good idea here, especially if > you will be displaying a list of events on any other pages. > > In your view, you would have: > > future_events = > Event.objects.filter(start_date__gte=now).sort_by('start_date') > return render_to_response('clubs/events.html', {'events': > future_events}) > > And in the template, you would have: > > {% show_events events "Pacific" %} > {% show_events events "Central" %} > ... > > Or take out some more duplication: > > view: > > future_events = > Event.objects.filter(start_date__gte=now).sort_by('start_date') > regions = ["Pacific", "Central", ... ] > return render_to_response('clubs/events.html', { > 'events': future_events, > 'regions': regions}) > > template: > > {% for region in regions %} > {% show_events events region %} > {% endfor %} > > Now, you can do what you want with your newly created show_events > template tag. You could make the region optional, for example, and > display all events in the passed QuerySet if no region is specified. > > Also, if you aren't doing anything more in your view than passing the > couple of context variables to the template, you could even get rid of > your view entirely by using the direct_to_template generic view [2] > instead. > > [1]http://www.djangoproject.com/documentation/templates_python/#writing-... > [2]http://www.djangoproject.com/documentation/generic_views/#django-view... > > Gary Thanks Gary, but it's just one page, and a fairly specialized one... although I left it out of the above code, there's also a form to submit events, and the template creates calendars for them. --~--~-~--~~~---~--~~ 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: Best Practices to Make your Apps Portable
I use the following: my pythonpath includes /usr/local/lib/django/ within which I have: apps/ app1/(models,views,urls) app2/(models,views,urls), etc. vhosts/ vhost1/(settings,urls) vhost2/(settings,urls), etc. within the config for each apache virtual host I have a different DJANGO_SETTINGS_MODULE like vhosts.vhost1.settings this way apps and vhosts are completely separate in the hierarchy, but it is all within the same python path entry. It works well with subversion because I have one code structure to capture all my apps and vhosts and I can test out different vhost settings on different servers by changing DJANGO_SETTINGS_MODULE in the apache config. I have all my settings.py files import local_secrets.local_secrets, a function that returns the proper database password and secret key depending on whether a "DEVELOPMENT_MODE" parameter is set and on the calling vhost. local_secrets.py is elsewhere on my pythonpath on each physical server. That keeps that stuff out of my subversion tree. templates and media are stored elsewhere where the designers have access, using the same hierarchy as apps, but with an additional vhosts directory containing overrides specific to particular vhosts. In subversion I have code, templates and media directories below trunk. Initially I had templates and media as subdirectories in each app (to maximize app portability), but I found the access issues for designers too cumbersome (chmod won't follow symlinks so granting permissions to template and media subdirectories within each app is unwieldy, and it was much easier to have media actually in the media server docroot since we could use existing share permissions and have user-restore capability (the docroots are mounted from a snapvaulted SAN), and the designers don't play nice with subversion so I could give them their own branch, etc.) --~--~-~--~~~---~--~~ 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: There's got to be a better way
On Jul 26, 1:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > In my view, I have: > future_events = Event.objects.filter(start_date__gte=now) > pacific_events = future_events.filter(club__region='Pacific') > rocky_mountain_events = future_events.filter(club__region='Rocky > Mountain') > southwest_events = future_events.filter(club__region='Southwest') > midwest_events = future_events.filter(club__region='Midwest') > central_events = future_events.filter(club__region='Central') > northeast_events = > future_events.filter(club__region='Northeast') > southeast_events = > future_events.filter(club__region='Southeast') > > return render_to_response('clubs/events.html', {' > 'pacific_events': pacific_events, > 'rocky_mountain_events':rocky_mountain_events, > 'southwest_events':southwest_events, > 'midwest_events':midwest_events, > 'central_events':central_events, > 'northeast_events':northeast_events, > 'southeast_events':southeast_events, > }) > > And then in the view, I spit out: > {% if pacific_events %} > do stuff > {% endif %} > > For each event type, ad nauseum. It works, but I know I'm being stupid > here and thoroughly violating the DRY principle. Could someone show me > the light? Creating a template tag [1] might be a good idea here, especially if you will be displaying a list of events on any other pages. In your view, you would have: future_events = Event.objects.filter(start_date__gte=now).sort_by('start_date') return render_to_response('clubs/events.html', {'events': future_events}) And in the template, you would have: {% show_events events "Pacific" %} {% show_events events "Central" %} ... Or take out some more duplication: view: future_events = Event.objects.filter(start_date__gte=now).sort_by('start_date') regions = ["Pacific", "Central", ... ] return render_to_response('clubs/events.html', { 'events': future_events, 'regions': regions}) template: {% for region in regions %} {% show_events events region %} {% endfor %} Now, you can do what you want with your newly created show_events template tag. You could make the region optional, for example, and display all events in the passed QuerySet if no region is specified. Also, if you aren't doing anything more in your view than passing the couple of context variables to the template, you could even get rid of your view entirely by using the direct_to_template generic view [2] instead. [1] http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags [2] http://www.djangoproject.com/documentation/generic_views/#django-views-generic-simple-direct-to-template Gary --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Trouble setting up Pydev debugger
Hi everyone, I'm trying to use PyDev to debug my Django project. I have followed the instructions from Fabio: http://pydev.blogspot.com/2006/09/configuring-pydev-to-work-with-django.html Running the configuration he describes seems to work. It starts the development server. However, the debugger will not start, reporting this error: "server timed out after 10 seconds, could not connect to localhost: 11570" Does anyone have any suggestions on how to properly configure the debugger? Thanks, Benjamin --~--~-~--~~~---~--~~ 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: Is cloning Facebook in Django feasible?
You can clone facebook in any programming language using any framework you want. Django is one of the many frameworks which you can use to do it. And yes, facebook has been cloned in other countries, many, many times. The most famous one is from china: http://xiaonei.com/ Not only did they clone the features, they cloned the interface. It even got acquired for lots of money. [EMAIL PROTECTED] wrote: > Is it possible to develop a Facebook functional clone in Django? What > parts of it are provided out of the box? Any third-party contributions? > > > > > --~--~-~--~~~---~--~~ 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: Is cloning Facebook in Django feasible?
A localised version would make sense in a country where most people don't speak English On 27 июл, 19:55, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Is it possible to develop a Facebook functional clone in Django? What > > parts of it are provided out of the box? Any third-party contributions? > > This is like going to a company that sells construction equipment and > saying "is it possible to build a copy of the Empire State Building > with your tools?" ;) > > Yes, it's possible. But it's going to be a lot of work, it's going to > take a lot of time and there's already an Empire State Building that > people know and love, so people are left asking exactly what it is > that the cloning project would accomplish... > > -- > "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: Is cloning Facebook in Django feasible?
a localised version would make sense in a country where people mostly don't speak English On 27 июл, 19:55, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Is it possible to develop a Facebook functional clone in Django? What > > parts of it are provided out of the box? Any third-party contributions? > > This is like going to a company that sells construction equipment and > saying "is it possible to build a copy of the Empire State Building > with your tools?" ;) > > Yes, it's possible. But it's going to be a lot of work, it's going to > take a lot of time and there's already an Empire State Building that > people know and love, so people are left asking exactly what it is > that the cloning project would accomplish... > > -- > "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: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?
You can define a list of valid keys to look for: keys = ['one', 'two', 'three', 'four', 'five'] for key in keys: if not key in request.POST: continue .. do stuff .. Or you can delete the keys you don't want before looping: for key in ['x', 'y', 'submit']: del request.POST[key] for key, value in request.POST.iteritems(): ... do stuff ... On Jul 27, 8:04 am, Greg <[EMAIL PROTECTED]> wrote: > Jacob, > Yep that was it. If I shouldn't assume anything from the browser. > Then how would I loop through the contents of my data? Below is my > view and template file > > / > > This code is in my template file > > {% for a in pad %} > > > >--- >1 >2 >3 >4 >5 >{{ a.size }} -- ${{ a.price }} > > > {% endfor %} > > / > > This code is my view function: > > def addpad(request): > if request.method == 'POST': > i = 0 > for a in request.POST: > if a[i] != '---': > p = RugPad.objects.get(id=i) > assert False, request.POST > return render_to_response('addpad.html', {}) > > /// > > When the form is posted I want my addpad function to loop through all > the values that have been posted. And if any posted key's contain a > value of something other than '---' then I want to add that to the > cart (Currently I'm just doing an assert statement). If I have other > keys ( such as 'x', 'y', 'submit' ) in my dict then that will cause > the loop to error out. Would you know of any other way to do this so > that I don't have to rely on the contents that come from the web > browser? > > Thanks for your help > > On Jul 27, 9:48 am, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]> > wrote: > > > On 7/27/07, Greg <[EMAIL PROTECTED]> wrote: > > > > It should only have 8 keys (1 through 8). Instead I see the keys 'x' > > > and 'y'? It's causing a problem when I try to loop through my POST > > > data. > > > > Does anybody know why this is happening? > > > You're probably using an - those send along x/y > > coords of the image click. > > > As a matter of general principle, though, you shouldn't assume > > *anything* about the contents of data that comes from the web browser. > > The browser could be a robot posting data automatically, or you could > > be dealing with a greasemonkey script that's changing your markup, or > > whatever. You need to write your code to deal with extra and/or > > missing fields. > > > Jacob --~--~-~--~~~---~--~~ 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: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?
> {% for a in pad %} > > > I would suggest adding a prefix to that name: This way, when you are looping through your request.POST dictionary keys, you can skip keys that don't start with "pad-" that will prevent your loop from breaking if you get unexpected keys in the form post. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
complex form => Newforms vs template
Hello, May be what I am going to say is completely stupid but if it is the case please let me know why :-) I face the situation several times in the last weeks that I was willing to build a "complex" form, not directly related to a model. This forms had the following requirements: it should be dynamically generated based on the object I want to create. It was trying to update/create or only display information from many instances from many different models. I don't know if this can help: I was trying to display a form to collect an "Interview" of someone on a "Survey" which is composed of "Polls" which are composed of Choices. For each Poll the user can select one or several choice. A choice is represented by "choice.text", "choice.image" and a checkbox. I spent to several days on trying to achieve this with the newforms library and thank to the help of many people I finally reach to a point where I got something almost working. But the result was such a monster that I have decided to rewrite it with a template approach. I have now a form that is dynamically created thanks to a template rather than the class from the newforms library. So my question is am I missing something or I was just expecting too much from the newforms? My last question is would it be absurd to have a form field called TemplateField to which we can give a template string that will be dynamically inserted and substituted in the template? I hope that this post is not too long, and that the answer of these 2 questions is not in the documentation. Thank you for your feedbacks yml --~--~-~--~~~---~--~~ 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: Best Practices to Make your Apps Portable
I just added it to the wiki: http://code.djangoproject.com/wiki/BestPracticesToWorkWith3rdPartyAppsAndMakingYoursPortable It's available in the resources page. http://code.djangoproject.com/wiki/DjangoResources Best, Sebastian Macias On Jul 26, 12:36 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > Sebastian Macias wrote: > > Thanks a lot for the feedback everyone. > > > I have come up a perfect setup and folder structure (at least > > perfect for my needs) that will allow me to work on generic apps and > > project specific apps efficiently and just wanted to share it with > > everyone in case it can save a anyone a headache. > > > *Folder structure for a django project* > > > /var/django_root/my_project_name/ > >urls.py > >settings.py > >apps/ > >my_project_specific_app_1/ > >my_project_specific_app_2/ > >my_project_specific_app_3/ > > > *Folder structure for generic/portable apps* > > > /var/django_root/shared/ > >my_generic_portable_app_1/ > >my_generic_portable_app_2/ > >my_generic_portable_registration_app/ > > > *Development Setup* > > > I added the following to the top of my_project_name/settings.py so it > > appends the portable/generic apps folder to the python path. > > > DEVELOPMENT = True > > > if DEVELOPMENT: > > import sys > > sys.path.append('/var/django_root/shared') > > > For extended convenience I symlinked my portable/generic apps folder > > to my django project so I can quickly make changes to my generic apps > > without having to go outside my django project folder structure > > > ln -s `pwd`/var/django_root/shared /var/django_root/my_project_name/ > > shared > > > *Production Setup* > > > My Apache conf file: > > > > > ServerName championsound.local > > ServerAlias *.championsound.local > > SetHandler python-program > > PythonPath "['/var/django_root', '/var/django_root/shared'] + > > sys.path" > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE championsound.settings > > PythonDebug On > > > > > Note how '/var/django_root' and '/var/django_root/shared' are added to > > the PythonPath > > > Enjoy it! > > > Sebastian Macias > > Can you post this to the wiki? or tell me to. one of us should. :) > > 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: static css problems on windows box
Hello, just for the sake pay attention to the difference between "\" and "/". If I remember well ONLY "/" will work. yml On Jul 27, 10:59 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Jul 27, 6:31 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > > > On Jul 27, 4:09 pm, devjim <[EMAIL PROTECTED]> wrote: > > > > Mod_python is working and I have this in my http.conf > > > > > > SetHandler python-program > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > > PythonDebug On > > > PythonPath "['c:devtestproj'] + sys.path" > > > > > > > > > SetHandler None > > > > > > Instead of Location directive for media files, you should have Alias > > directive and Directory for actual physical directory the files are > > located in. For example something like: > > > Alias /mainmedia C:/path/to/media/files > > Whoops, missed the trailing slashes. Should be: > > Alias /mainmedia/ C:/path/to/media/files/ > > Grahamd > > > > > Order deny,allow > > Allow from all > > > > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > PythonDebug On > > PythonPath "['c:devtestproj'] + sys.path" > > > > > The Location directive will not work for media files as it is for > > virtual resources, whereas Alias maps it to physical resources. > > > Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-admin.py validate
Hello, This is the webpage you are looking for: http://www.djangoproject.com/documentation/settings/ you should read the section called : "The django-admin.py utility" and according to the os you are running you should set this variable. I hope that help On Jul 27, 3:11 pm, arf_cri <[EMAIL PROTECTED]> wrote: > I forgot to say that I don't know how to make it work... if it is not > obvious :). > > On Jul 27, 3:07 pm, arf_cri <[EMAIL PROTECTED]> wrote: > > > Traceback (most recent call last): > > File "/usr/bin/django-admin.py", line 5, in ? > > management.execute_from_command_line() > > File "/usr/lib/python2.4/site-packages/django/core/management.py", > > line 1563, in execute_from_command_line > > from django.utils import translation > > File "/usr/lib/python2.4/site-packages/django/utils/translation/ > > __init__.py", line 3, in ? > > if settings.USE_I18N: > > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > > line 28, in __getattr__ > > self._import_settings() > > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > > line 53, in _import_settings > > raise EnvironmentError, "Environment variable %s is undefined." % > > ENVIRONMENT_VARIABLE > > EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is > > undefined. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HttpResponse error with file downloads
Recently I've encountered the following error: -- Traceback (most recent call last): File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/usr/local/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target result = object(arg) File "/usr/local/lib/python2.5/site-packages/django/core/handlers/ modpython.py", line 178, in handler return ModPythonHandler()(req) File "/usr/local/lib/python2.5/site-packages/django/core/handlers/ modpython.py", line 161, in __call__ req.content_type = response['Content-Type'] TypeError: content_type must be a string -- This is my view code that returns the response, which produces this error: - response = HttpResponse(file_data) response['Content-Type'] = u'application/%s' % f response['Content-Disposition'] = u'attachment; filename="%s.%s"' % (t, f) return response - 'f' variable can be: 'zip', 'pdf', 'rtf', 'doc'. And when I print response ['Content-Type'], I see 'application/(f)' so I know that I pass it to Django as I'd expect. Has something changed recently in Django that could affect this code? This was working before. It could be mod_python or Apache error, not specific to Django, but I'm not sure. But perhaps, there's something 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is cloning Facebook in Django feasible?
On 7/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Is it possible to develop a Facebook functional clone in Django? What > parts of it are provided out of the box? Any third-party contributions? This is like going to a company that sells construction equipment and saying "is it possible to build a copy of the Empire State Building with your tools?" ;) Yes, it's possible. But it's going to be a lot of work, it's going to take a lot of time and there's already an Empire State Building that people know and love, so people are left asking exactly what it is that the cloning project would accomplish... -- "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: How to add a custom filter?
Hi Haku, On 7/27/07, Haku <[EMAIL PROTECTED]> wrote: > > I'm quite new to python and django. > > How can i add a custom filter? I've found one that i need ( > http://www.djangosnippets.org/snippets/192/ ) bt i dunno how to use it. Here is the documentation: http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags Greetings Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to add a custom filter?
I'm quite new to python and django. How can i add a custom filter? I've found one that i need ( http://www.djangosnippets.org/snippets/192/ ) bt i dunno how to use 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 -~--~~~~--~~--~--~---
db mock for unit testing
I do hardcore test-driven development and hate when tests hit my mysql database (even local one). Things get only worse when testcases start demanding radically different datasets. Then I've paused and wrote DbMock class for django that uses some black magic to steal django db connection and substitute it with temporary sqlite in-memory db. Here it is: http://www.djangosnippets.org/snippets/345/ So far, it works w/o any issues on my pet project. Will be glad to hear any comments and, especially, bugs found :) -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms.CharField now returns unicode, but how to specify encoding?
Just as you said, all my html files are using utf-8. So it is OK at this time. But some part of our program needs to handle the data from other web site. That is, those forms are in some HTML pages (or programs) that we cannot control. They will use GB2312 encoding definitely. So we still need some way to specify char encoding in Form or CharField. -- Gilbert On Jul 27, 10:15 pm, Sam Morris <[EMAIL PROTECTED]> wrote: > On Fri, 27 Jul 2007 05:42:12 -0700, Gilbert Fine wrote: > > I used django rev. 5559 for some time. After svn up today, I found > > CharField's cleaned_data is unicode. I think it is a good idea. > > Actually, I made this conversion in my source program. > > > The only question is how to specify encoding of the string sent from > > client browser? My users almost certainly using gb2312, not utf-8. > > HTML4's description of the FORM element's 'accept-charset' attribute[0] > states: > > The default value for this attribute is the reserved string > "UNKNOWN". User agents may interpret this value as the character > encoding that was used to transmit the document containing this FORM > element. > > [0]http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset > > So, you can try specifying that you want the submitted data to be encoded > as utf-8 there, or you can serve the pages containing the FORM as utf-8 > and hope that the browser behaves sensibly and follows suite. > > -- > Sam Morrishttp://robots.org.uk/ > > PGP key id 1024D/5EA01078 > 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms: common constraints
>> but those min max constraints are so common? why not include >> it? > > Because "common" is different for any given user and/or site. > I think *I've* only written a single form with min/max > validation, FWIW. Designing a framework is hard; you've got to > search for things that are as close to truly universal as > possible. This is especially the case with Django...writing a simple min/max validator is trivial to do and Django makes it easy to use any set of validators you want on your fields. That said, I don't see a great reason not to include a min_length and max_length validator in Django's standard toolkit of validators as I've seen this question pop up a couple other times on the list and have written them myself in the past. > Otherwise you end up including every little pet feature that > someone asks for, and that's known as "PHP". but pythonistas can at least sort them into namespaces ;) -tim --~--~-~--~~~---~--~~ 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: Can Django call cscript.exe to run vbscripts
On Jul 27, 2:35 pm, braveheart <[EMAIL PROTECTED]> wrote: > script process the input and forwards the output result to django; the > result is stored in a database or displayed on the page. Have the vbscript write to the same database django reads from or just output to a logfile that django knows where to find. Lorenzo --~--~-~--~~~---~--~~ 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: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?
Greg skrev: > I post some info to a view. When I do a 'assert False, request.POST' > I see the following > > [u'2'], u'5': [u'2'], u'4': [u'3'], u'7': [u'---'], u'6': [u'2'], > u'y': [u'4'], u'8': [u'---']}> > > It should only have 8 keys (1 through 8). Instead I see the keys 'x' > and 'y'? It's causing a problem when I try to loop through my POST > data. > > Does anybody know why this is happening? > I believe your form uses '' for the submit button. This will cause the x- and y-coordinates for the pixel clicked to be sent along with the rest of the form data. See http://www.w3.org/TR/html4/interact/forms.html#h-17.4.1 for more info. Nis --~--~-~--~~~---~--~~ 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: newforms: common constraints
On 7/27/07, james_027 <[EMAIL PROTECTED]> wrote: > but those min max constraints are so common? why not include it? Because "common" is different for any given user and/or site. I think *I've* only written a single form with min/max validation, FWIW. Designing a framework is hard; you've got to search for things that are as close to truly universal as possible. Otherwise you end up including every little pet feature that someone asks for, and that's known as "PHP". A good programmer will keep around his/her own library of common code and break it out whenever needed. If you need min/max validation often, you should make that the start of your own personal toolkit. Jacob --~--~-~--~~~---~--~~ 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: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?
On 7/27/07, Greg <[EMAIL PROTECTED]> wrote: > It should only have 8 keys (1 through 8). Instead I see the keys 'x' > and 'y'? It's causing a problem when I try to loop through my POST > data. > > Does anybody know why this is happening? You're probably using an - those send along x/y coords of the image click. As a matter of general principle, though, you shouldn't assume *anything* about the contents of data that comes from the web browser. The browser could be a robot posting data automatically, or you could be dealing with a greasemonkey script that's changing your markup, or whatever. You need to write your code to deal with extra and/or missing fields. Jacob --~--~-~--~~~---~--~~ 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: filter by if object exists
Thanks. I knew it was simple, and I'd seen it before, but couldn't remember or find it. On Jul 27, 9:33 am, "Jonathan Buchanan" <[EMAIL PROTECTED]> wrote: > > I just know this is a dumb question, and I've seen this done > > somewhere, but what I'm after is something like > > > GpUser.objects.filter('image'=True) > > > To only get the Gpuser objects that actually have an image, rather > > than all of them. Can someone point me in the right direction? > > GpUser.objects.filter(image__isnull=False) > > Seehttp://www.djangoproject.com/documentation/db-api/#isnull > > Jonathan. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
◘►Legally Access FREE Satellite TV on your PC◄◘
Access 1000's of Television Channels From All Over The World Watch all your favorite shows on your Computer from anywhere in the World! Save 1000's of $$$ over many years on cable and satellite bills. INSTANT DOWNLOAD Learn More About it at Link below: http://freetvonpc.50webs.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 -~--~~~~--~~--~--~---
◘►Legally Access FREE Satellite TV on your PC◄◘
Access 1000's of Television Channels From All Over The World Watch all your favorite shows on your Computer from anywhere in the World! Save 1000's of $$$ over many years on cable and satellite bills. INSTANT DOWNLOAD Learn More About it at Link below: http://freetvonpc.50webs.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 -~--~~~~--~~--~--~---
Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?
I post some info to a view. When I do a 'assert False, request.POST' I see the following It should only have 8 keys (1 through 8). Instead I see the keys 'x' and 'y'? It's causing a problem when I try to loop through my POST data. Does anybody know why this is happening? 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: filter by if object exists
> I just know this is a dumb question, and I've seen this done > somewhere, but what I'm after is something like > > GpUser.objects.filter('image'=True) > > To only get the Gpuser objects that actually have an image, rather > than all of them. Can someone point me in the right direction? GpUser.objects.filter(image__isnull=False) See http://www.djangoproject.com/documentation/db-api/#isnull Jonathan. --~--~-~--~~~---~--~~ 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: Can Django call cscript.exe to run vbscripts
b> Does someone have a solution ? Have you tried subprocess module mentioned before? What was your experience? BTW, it's nothing django-specific in calling external software from your python app... -- Andrey V Khavryuchenko Django NewGate - http://www.kds.com.ua/djiggit/ Development - http://www.kds.com.ua Call akhavr1975 on www.gizmoproject.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 -~--~~~~--~~--~--~---
filter by if object exists
I just know this is a dumb question, and I've seen this done somewhere, but what I'm after is something like GpUser.objects.filter('image'=True) To only get the Gpuser objects that actually have an image, rather than all of them. Can someone 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: newforms.CharField now returns unicode, but how to specify encoding?
On Fri, 27 Jul 2007 05:42:12 -0700, Gilbert Fine wrote: > I used django rev. 5559 for some time. After svn up today, I found > CharField's cleaned_data is unicode. I think it is a good idea. > Actually, I made this conversion in my source program. > > The only question is how to specify encoding of the string sent from > client browser? My users almost certainly using gb2312, not utf-8. HTML4's description of the FORM element's 'accept-charset' attribute[0] states: The default value for this attribute is the reserved string "UNKNOWN". User agents may interpret this value as the character encoding that was used to transmit the document containing this FORM element. [0] http://www.w3.org/TR/html4/interact/forms.html#adef-accept-charset So, you can try specifying that you want the submitted data to be encoded as utf-8 there, or you can serve the pages containing the FORM as utf-8 and hope that the browser behaves sensibly and follows suite. -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
unsubscribe
unsubscribe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
edit_inline following multiple relations in the admin site
For the following data relations System -< Nic -< Ip (where -< means OneToMany) Using edit_inline it is already possible to view the nics in the system detail page, but I would also like to see which ip's are associated with the listed nic's. Something similar is already in place when inline editing a model which has a ManyToMany relationship. To be clear, what I want is a system detail page which lists the following information: System Interfaces: Interface 1 Ip: 10.11.4.2 10.11.5.2 Interface 2 Ip: 82.17.x.x Currently my data model looks like this: class System(models.Model): name = models.CharField(maxlength=255) class SystemNic(models.Model): name = models.CharField(maxlength=45, core=True) system = models.ForeignKey(System, edit_inline=models.TABULAR, core=True) class Ipset(models.Model): systemnic = models.ForeignKey(SystemNic, edit_inline=models.TABULAR, core=True) ipaddress = models.CharField(maxlength=15, core=True) Is this possible without denormalization of the data model or is my only viable option in writing a separate view? With regards, Jos Houtman System administrator Hyves.nl email: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-admin.py validate
I forgot to say that I don't know how to make it work... if it is not obvious :). On Jul 27, 3:07 pm, arf_cri <[EMAIL PROTECTED]> wrote: > Traceback (most recent call last): > File "/usr/bin/django-admin.py", line 5, in ? > management.execute_from_command_line() > File "/usr/lib/python2.4/site-packages/django/core/management.py", > line 1563, in execute_from_command_line > from django.utils import translation > File "/usr/lib/python2.4/site-packages/django/utils/translation/ > __init__.py", line 3, in ? > if settings.USE_I18N: > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > line 28, in __getattr__ > self._import_settings() > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > line 53, in _import_settings > raise EnvironmentError, "Environment variable %s is undefined." % > ENVIRONMENT_VARIABLE > EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is > undefined. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
django-admin.py validate
Traceback (most recent call last): File "/usr/bin/django-admin.py", line 5, in ? management.execute_from_command_line() File "/usr/lib/python2.4/site-packages/django/core/management.py", line 1563, in execute_from_command_line from django.utils import translation File "/usr/lib/python2.4/site-packages/django/utils/translation/ __init__.py", line 3, in ? if settings.USE_I18N: File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 28, in __getattr__ self._import_settings() File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 53, in _import_settings raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined. --~--~-~--~~~---~--~~ 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: Open Linux Router
This is possible thank you for the heads up I will check that out. --~--~-~--~~~---~--~~ 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: porting of an application
I have got the idea what I have to do. I thought that it can be easier with some option for dump command. However thank you for this information. I will try to copy the stuff which I need. Nader On Jul 27, 1:27 pm, Tim Chase <[EMAIL PROTECTED]> wrote: > > I have two different database file, so I can't copy it. I would like > > to extract only the data of the app which I would port to other > > machine. > > I'm not sure how you ended up with two database files. However, > I suspect Daniel has the right idea: just copy the .db > file. If there's stuff in there you don't want, you can just > drop those tables or delete the stuff you don't want. Selective > dropping is usually a lot easier than trying to selectively copy > over the data that you do want. > > -tim --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
newforms.CharField now returns unicode, but how to specify encoding?
I used django rev. 5559 for some time. After svn up today, I found CharField's cleaned_data is unicode. I think it is a good idea. Actually, I made this conversion in my source program. The only question is how to specify encoding of the string sent from client browser? My users almost certainly using gb2312, not utf-8. 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: Can Django call cscript.exe to run vbscripts
I know that can be solved with python also, but i have to call from django almost 50 VBScripts (that are functional). I don't want to rewrite all that scripts to python, cause i don't have time for this. And I also have a huge library of vbscripts so if i will need a new script in the future i will just modify one of the scripts from my library. That's why i need a way to call cscript.exe within django. I will descibe what i would like to do with django and my vbscripts: Django should call cscript.exe which will execute a vbscript ; django takes a text input from the user and forward that to the script, the script process the input and forwards the output result to django; the result is stored in a database or displayed on the page. Does someone have a solution ? Thanks On Jul 21, 5:01 pm, Carl Karsten <[EMAIL PROTECTED]> wrote: > You might want to describe the current problem you need to solve. > > good chance it will be easier to solve using a few lines of python/django than > trying to run your existing vbscript. > > Carl K > > braveheart wrote: > > Anyone else have other solution ? > > > On Jul 20, 8:54 pm, Dennis Allison <[EMAIL PROTECTED]> > > wrote: > >> actually, look at module subprocess rather than os as the subprocess > >> module contains the current best practice solution. (Check the Python > >> 3000 docs to see what will be going away and avoid using them. :-) ) > > >> BUT, the vbscript GUI will not be available throught the web, at least not > >> easily. > > >> On Fri, 20 Jul 2007, Andrey Khavryuchenko wrote: > > >>> b> I'm an Windows System Administrator and for my job i often use > >>> b> vbscripts to automate my tasks. I was wondering if Django can call > >>> b> cscript.exe to execute a vbscript file (Offcourse django is assumed to > >>> b> run under Windows)? I know that i can also script wmi with python but > >>> b> i'm allready mastering vbscript and have a huge library of function > >>> b> vbscripts. > >>> b> Can someone help me pls ? > >>> Django app is a plain python script. So check python doc for starting > >>> external applications (module os). > >> -- --~--~-~--~~~---~--~~ 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: porting of an application
> I have two different database file, so I can't copy it. I would like > to extract only the data of the app which I would port to other > machine. I'm not sure how you ended up with two database files. However, I suspect Daniel has the right idea: just copy the .db file. If there's stuff in there you don't want, you can just drop those tables or delete the stuff you don't want. Selective dropping is usually a lot easier than trying to selectively copy over the data that you do want. -tim --~--~-~--~~~---~--~~ 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: porting of an application
How can I dump not the whole database, but a portion (only the information of one application) of of it? On Jul 27, 12:56 pm, Hodren Naidoo <[EMAIL PROTECTED]> wrote: > Just do a dump, and source the script into a newly created database > instance. > > On Fri, 2007-07-27 at 11:50 +, Nader wrote: > > Hallo, > > > I have an application on a computer at my work and I would like to > > port it to an other machine (a laptop). I can copy the source files > > (model.py, urls.py, *.html and configuration files) from first > > machine to the second. But how about the content of my database? I > > have used 'sqlite3' as a database engine. > > Could somebody tell me how I can do this? > > > With regards, > > Nader --~--~-~--~~~---~--~~ 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: porting of an application
I have two different database file, so I can't copy it. I would like to extract only the data of the app which I would port to other machine. On Jul 27, 1:04 pm, Daniel Ellison <[EMAIL PROTECTED]> wrote: > Nader wrote: > > But how about the content of my database? I > > have used 'sqlite3' as a database engine. > > Could somebody tell me how I can do this? > > If you're using sqlite3, wouldn't it simply be a matter of copying your > .db file to the new location? --~--~-~--~~~---~--~~ 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: porting of an application
Nader wrote: > But how about the content of my database? I > have used 'sqlite3' as a database engine. > Could somebody tell me how I can do this? If you're using sqlite3, wouldn't it simply be a matter of copying your .db file to the new location? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Is cloning Facebook in Django feasible?
Is it possible to develop a Facebook functional clone in Django? What parts of it are provided out of the box? Any third-party contributions? --~--~-~--~~~---~--~~ 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: porting of an application
Just do a dump, and source the script into a newly created database instance. On Fri, 2007-07-27 at 11:50 +, Nader wrote: > Hallo, > > I have an application on a computer at my work and I would like to > port it to an other machine (a laptop). I can copy the source files > (model.py, urls.py, *.html and configuration files) from first > machine to the second. But how about the content of my database? I > have used 'sqlite3' as a database engine. > Could somebody tell me how I can do this? > > With regards, > Nader > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
porting of an application
Hallo, I have an application on a computer at my work and I would like to port it to an other machine (a laptop). I can copy the source files (model.py, urls.py, *.html and configuration files) from first machine to the second. But how about the content of my database? I have used 'sqlite3' as a database engine. Could somebody tell me how I can do this? With regards, Nader --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
What should I do to make admin display more fields in User model?
Hi django fellows, I scubclassed django's User model to create my own more complicated model, I set it as my AUTH_PROFILE_MODULE in settings and I also wrote my own backend to authenticate against this new class. So far no problems. However, I also overrode User's Admin class and changed the 'fields' tuple, but nothing seems to have changed. What should I do more to make the admin interface reflect these settings and display the additional fields I need to edit? Thanks, Dan --~--~-~--~~~---~--~~ 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 contraints on admin
> I really love Django admin, however how can I add customer validation > or contraints to my models? I am coding for the GSoC Check constraints projecthere is a link to the project site. http://code.google.com/p/django-check-constraints/ Cheers Thejaswi Puthraya --~--~-~--~~~---~--~~ 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: static css problems on windows box
On Jul 27, 6:31 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Jul 27, 4:09 pm, devjim <[EMAIL PROTECTED]> wrote: > > > Mod_python is working and I have this in my http.conf > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > PythonDebug On > > PythonPath "['c:devtestproj'] + sys.path" > > > > > > SetHandler None > > > > Instead of Location directive for media files, you should have Alias > directive and Directory for actual physical directory the files are > located in. For example something like: > > Alias /mainmedia C:/path/to/media/files Whoops, missed the trailing slashes. Should be: Alias /mainmedia/ C:/path/to/media/files/ Grahamd > > Order deny,allow > Allow from all > > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > PythonDebug On > PythonPath "['c:devtestproj'] + sys.path" > > > The Location directive will not work for media files as it is for > virtual resources, whereas Alias maps it to physical resources. > > Graham --~--~-~--~~~---~--~~ 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: static css problems on windows box
On Jul 27, 4:09 pm, devjim <[EMAIL PROTECTED]> wrote: > Mod_python is working and I have this in my http.conf > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > PythonDebug On > PythonPath "['c:devtestproj'] + sys.path" > > > SetHandler None > Instead of Location directive for media files, you should have Alias directive and Directory for actual physical directory the files are located in. For example something like: Alias /mainmedia C:/path/to/media/files Order deny,allow Allow from all SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproj.settings PythonDebug On PythonPath "['c:devtestproj'] + sys.path" The Location directive will not work for media files as it is for virtual resources, whereas Alias maps it to physical resources. Graham --~--~-~--~~~---~--~~ 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: Open Linux Router
westymatt wrote on 07/27/07 06:41: > Yeah its the webserver for olr not the public site. The django server > seems like a good start, just add ssl and logging ect, and lots of > security enhancements Maybe the standalone WSGI server of CherryPie already does what you need? http://www.cherrypy.org/wiki/CherryPyDownload --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem when deleting a register from the database
On Jul 26, 4:24 pm, Nis Jørgensen <[EMAIL PROTECTED]> wrote: > AnaReis skrev: > > > Hi all! > > I have a delete that isn't working properly. It deletes more than 1 > > register when it shouldn't because I'm specifying the primary key in > > the filter. > > The class file is this: > > class UserInstrument(models.Model): > > user_name = models.CharField(primary_key=True, maxlength=60) > > instrument_name = models.CharField(blank=False, maxlength=60) > > permission = models.TextField(blank=True) > > def __str__(self): > > string="user_name: "+self.user_name+"; instr_name: > > "+self.instrument_name+"; permission: "+self.permission > > return string > > class Meta: > > db_table = 'User_instrument' > > unique_together = (("user_name", "instrument_name"),) > > In the view function I'm doing this: > > UserInstrument.objects.filter(user_name__exact=username, > > instrument_name__exact=itemid).delete() > > > Oh and another detail, in the MySQL table, the primary key is the > > user_name and the instrument_name together. > > I am not sure whether this is the cause of your problem, but > > - Django doesn't support multi-field primary keys > - Your model class tells Django that "user_name" alone is the primary > key, which is wrong (and will lead to strange primary key lookups). > - Django implements its own cascading delete, independent of the > database. In this I believe it loops throught the queryset, and deletes > the objects based on the primary key. Since you "lied" to it about what > the PK is, it deletes the wrong objects. > > Quick solution: Remove the primary_key=True from the model - this will > add the standard "id" autonumber field. > > Slow solution: Add support for multi-field primary keys to the database. > > Nis Hi, It would be much easier to just put an autonumber field, the problem is that I can't change the database. In the database, the primary key is a multi field primary key, it's the user_name and the instrument_name, and unfortunately I can't change this. The way I found to fix this was to put primary_key=True in all the fields that are actually primary keys. Now it works properly. Thanks for your help! Ana --~--~-~--~~~---~--~~ 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: Best way to pass data to a HttpResponseRedirect?
Nis Jørgensen wrote: > As others have said, you can stuff things into request.session (after > adding the right middleware incantations). Using the session middleware looks far better but it will take me a while to try that out. I'll try and do that next week. > What is so bad about leaving the url in the browser? I assume the error > message you display is the "correct" response for that url. Just > remember to add the correct status code - probably 400,403 or 404. Note > that if this is a GET url, it shouldn't have side effects, so your > "main?delete=100" example seems like a bad idea to begin with (unless > this is the page that shows an "Are you sure ...?" message). If it is a > POST, there is a lot of reason not to redirect it, since this will make > it harder for the user to use the back button to fix things. Yes its a GET that changes the database and I should look at that and change "main?delete=100" to main/del/100/ or something and make it a POST. And yes if I make it a POST I hadn't thought about users using the back button - which the will do :-( Thanks for this advice, and to Patrick for how he does things. Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding contraints on admin
On 27-Jul-07, at 1:21 PM, james_027 wrote: > I really love Django admin, however how can I add customer validation > or contraints to my models? there is an on-going GSoc project for this - and a thread on this list started yesterday. You could check that out -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ 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: Best way to pass data to a HttpResponseRedirect?
Michael Lake skrev: > Hi all > > Nis Jørgensen wrote: > >> The argument to HttpResponseRedirect is a url. You seem to be confusing >> it with a template. >> > > OK I can do this: > > code > # some error occurs > message = 'You have ... tell admin that ' > return HttpResponseRedirect('error/') > > and have in views.py > > def error(request, message): > { >return render_to_response('error_page.html', {'message':message}) > } > > But how to get the message into error() without passing it as a GET? > As others have said, you can stuff things into request.session (after adding the right middleware incantations). >> But if you have the data available, there is no reason to do a redirect. >> Just render the error message etc to the relevant template, then return >> that to the user. >> > > Why I dont want to pass it like this ?message='You have ... tell admin that > ' > is that its long and if the error is something like main?delete=100 but the > user cant > delete that id then a Redirect goes to a nice clean valid URL. > A render_to_response leaves the incorrect URL in the browser. What is so bad about leaving the url in the browser? I assume the error message you display is the "correct" response for that url. Just remember to add the correct status code - probably 400,403 or 404. Note that if this is a GET url, it shouldn't have side effects, so your "main?delete=100" example seems like a bad idea to begin with (unless this is the page that shows an "Are you sure ...?" message). If it is a POST, there is a lot of reason not to redirect it, since this will make it harder for the user to use the back button to fix things. Nis Jorgensen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
adding contraints on admin
Hi, I really love Django admin, however how can I add customer validation or contraints to my models? Thanks james --~--~-~--~~~---~--~~ 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: Best way to pass data to a HttpResponseRedirect?
we are using a context_processor. e.g., the view for a login-page could look like this: if everythins is ok: request.session['messages'] = ['message', 'You are logged in.'] return HttpResponseRedirect(referer) else: messages = ['error', 'Some error message.'] and then, you can use a context_processor: TEMPLATE_CONTEXT_PROCESSORS = ( 'www.views.context_processors.get_messages', ) get_messages could look like this (get_messages checks the session and returns a message-dict): def get_messages(request): messages = [] if request.session.get('messages'): messages = [request.session['messages'][0], request.session ['messages'][1]] del request.session['messages'] return { 'messages': messages, } patrick Am 27.07.2007 um 08:57 schrieb Michael Lake: > > Hi all > > Nis Jørgensen wrote: >> The argument to HttpResponseRedirect is a url. You seem to be >> confusing >> it with a template. > > OK I can do this: > > code > # some error occurs > message = 'You have ... tell admin that ' > return HttpResponseRedirect('error/') > > and have in views.py > > def error(request, message): > { >return render_to_response('error_page.html', {'message':message}) > } > > But how to get the message into error() without passing it as a GET? > >> If you want to display different content, you need >> to pass a different url or (not recommended) store the data you >> want to >> display, then display it to the user at the new url > >> But if you have the data available, there is no reason to do a >> redirect. >> Just render the error message etc to the relevant template, then >> return >> that to the user. > > Why I dont want to pass it like this ?message='You have ... tell > admin that ' > is that its long and if the error is something like main?delete=100 > but the user cant > delete that id then a Redirect goes to a nice clean valid URL. > A render_to_response leaves the incorrect URL in the browser. > > Mike > -- > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to pass data to a HttpResponseRedirect?
Ah does this way seem sensible? > Nis Jørgensen wrote: >>The argument to HttpResponseRedirect is a url. You seem to be confusing >>it with a template. code # some error occurs return HttpResponseRedirect('error/2/') def error(request, message): { error_messages = { '1': 'You dont have access.' , '2': 'Server error ...' } return render_to_response('error_page.html', {'message':message}) } That way the user gets a nice clean URL and I can send a specific message into the template. Is there some commonly accepted practice here in Django? Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: confused about the order of the CacheMiddleware in MIDDLEWARE_CLASSES
I am a newbie of django. In my opinion, it means the CacheMiddleware module process shoule after the SessionMiddleware . According to WSGI specification, CacheMiddleware shoule be the "client" of the SessionMiddleware. So we should put CacheMiddleware before SessionMiddleware . On 7月14日, 下午4时00分, Mesh007 <[EMAIL PROTECTED]> wrote: > Can any body give me some help information? > > Thanks very much > > On 7月13日, 下午3时06分, Mesh007 <[EMAIL PROTECTED]> wrote: > > > > > Hi, all: > > > I touch django not long before, and am learning it, when i touch the > > CacheMiddleware, i am confused confused about the order of the > > CacheMiddleware in MIDDLEWARE_CLASSES > > > It is say: "Put the CacheMiddleware after any middlewares that might > > add something to the Vary header. " in the > > documentation(http://www.djangoproject.com/documentation/0.96/cache/) > > > because SessionMiddleware and GZipMiddleware add Vary header, so, i > > code below in my settings.py: > > MIDDLEWARE_CLASSES = ( > > 'django.middleware.common.CommonMiddleware', > > 'django.contrib.sessions.middleware.SessionMiddleware', > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > 'django.middleware.cache.CacheMiddleware', > > ) > > but it doesn't work well, I use > > "request.COOKIES.get('sessionid','null') " show the sessionid on page, > > but it show the same value on different browser(the real session id is > > not that showd on page), it seem it should save differrnt version > > cache based vary header, In browser the vary header is Cookie > > > I see the codes below in file django/core/handlers/base.py (svn > > version) > > 47th line: self._response_middleware.insert(0, > > mw_instance.process_response) > > > Is it means from bottom from top middleware in MIDDLEWARE_CLASSES > > when process the response? > > so i guess that the CacheMiddleware should put before the > > SessionMiddleware, because the SessionMiddleware add cookie vary > > header, so the CacheMiddleware can get the vary header added by the > > SessionMiddleware in response object, but , i not sure,.- 隐藏被引用文字 - > > - 显示引用的文字 - --~--~-~--~~~---~--~~ 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: static css problems on windows box
> My problems are this. First off, I was able to get the development > admin working with my project fine, but when I try to serve it up > using apache and mod_python, it's looking for the project under my > Python25 directory (c:\dev\Python25), not in c:\dev\testproj. I think you need to say C:\dev in your PythonPath instead of C:\dev \testproj. Also make sure testproj has an __init__.py file, if it doesn't already (should have been set up). To debug, try putting a "import sys, print sys.path" debug statement in a view & test it in the development server. That will show you what to expect. > Also, when I copy the project to c:\dev\Python25, I can get the admin > interface, but without CSS. So view the source & see where the CSS is supposed to come from. Then try to get it by typing that address in the browser. I think you'll find you need a leading slash in front of the mainmedia. > And worse, even in the development server, I can't get templates to > use my custom css files at all. I include a line like > > but I've tried putting that file everywhere under the sun to no > effect. See source again to determine if the file is being shown to the browser properly. I'm going to guess that it is rendering just fine, but you probably don't have main.css set up in your urls.py file properly. Generally though, don't panic! Break down each problem & think it through and you will probably be able to work it out. -rob --~--~-~--~~~---~--~~ 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: Best way to pass data to a HttpResponseRedirect?
Hi all Nis Jørgensen wrote: > The argument to HttpResponseRedirect is a url. You seem to be confusing > it with a template. OK I can do this: code # some error occurs message = 'You have ... tell admin that ' return HttpResponseRedirect('error/') and have in views.py def error(request, message): { return render_to_response('error_page.html', {'message':message}) } But how to get the message into error() without passing it as a GET? > If you want to display different content, you need > to pass a different url or (not recommended) store the data you want to > display, then display it to the user at the new url > But if you have the data available, there is no reason to do a redirect. > Just render the error message etc to the relevant template, then return > that to the user. Why I dont want to pass it like this ?message='You have ... tell admin that ' is that its long and if the error is something like main?delete=100 but the user cant delete that id then a Redirect goes to a nice clean valid URL. A render_to_response leaves the incorrect URL in the browser. Mike -- --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best way to pass data to a HttpResponseRedirect?
Michael Lake skrev: > Hi all > > A really simple question: > > I'm mostly using code like this: > data = {'message': 'Some message to user...'} > return render_to_response('main.html', data) > > But for error messages to users if one wishes to use a redirect like this: > return HttpResponseRedirect('/error_page.html') > > How can one add data into this page? The Redirect is nice in that it does not > show > the old URL which might be quite wrong - hence the error. > > The Django docs say that HttpResponseRedirect('/whatever/url/') takes just > one > argument. I'd like to use one error_page.html template for a range of errors. > > Do people use maybe HttpResponseRedirect('error/') where error is some > defined > function and somehow pass a message string to it? The argument to HttpResponseRedirect is a url. You seem to be confusing it with a template. If you want to display different content, you need to pass a different url or (not recommended) store the data you want to display, then display it to the user at the new url But if you have the data available, there is no reason to do a redirect. Just render the error message etc to the relevant template, then return that to the user. Nis Jorgensen --~--~-~--~~~---~--~~ 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: newforms: common constraints
Thanks for the fast response Doug, but those min max constraints are so common? why not include it? james On Jul 27, 1:20 pm, Doug B <[EMAIL PROTECTED]> wrote: > Garg, hit enter too fast. > > Class MyForm(forms.Form): > username = forms.CharField(max_length=12) > def clean_username(self): > username = self.clean_data['username'] > if username == 'bob': > raise ValidationError("Bob is not allowed here") > return username > > If someone enters 'bob' for a username, form.is_valid() will be False, > anything else under 12 char long is ok > > There are existing fields that do a lot, for email, integers, and so > on... but if you want do do something they don't support, you've got > to do a bit yourself. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
static css problems on windows box
I'm a python and django noob and am having major problems getting css files to load. My problems are this. First off, I was able to get the development admin working with my project fine, but when I try to serve it up using apache and mod_python, it's looking for the project under my Python25 directory (c:\dev\Python25), not in c:\dev\testproj. Also, when I copy the project to c:\dev\Python25, I can get the admin interface, but without CSS. And worse, even in the development server, I can't get templates to use my custom css files at all. I include a line like but I've tried putting that file everywhere under the sun to no effect. Yes, I've seen the documentation and it did not help me any. Here's my setup: I'm running XP with apache installed, and django . 96. My dir structure looks like: c:\dev\testproj - is where I have my django project c:\dev\webdev - is my apache document root Python is installed in c:\dev\Python25 with django under there in lib \site_packages\django Mod_python is working and I have this in my http.conf SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE testproj.settings PythonDebug On PythonPath "['c:devtestproj'] + sys.path" SetHandler None I've tried adding a number of permutations of this to my settings.py file... I'll just include the last one MEDIA_ROOT = 'c:/dev/testproj/mainmedia/' MEDIA_URL = 'http://127.0.0.1:8000/mainmedia/' and this to my urls.py (r'^mainmedia/(?P.*)$', 'django.views.static.serve', {'document_root': 'c:/dev/testproj/mainmedia'}), ANY help would be 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 -~--~~~~--~~--~--~---
Best way to pass data to a HttpResponseRedirect?
Hi all A really simple question: I'm mostly using code like this: data = {'message': 'Some message to user...'} return render_to_response('main.html', data) But for error messages to users if one wishes to use a redirect like this: return HttpResponseRedirect('/error_page.html') How can one add data into this page? The Redirect is nice in that it does not show the old URL which might be quite wrong - hence the error. The Django docs say that HttpResponseRedirect('/whatever/url/') takes just one argument. I'd like to use one error_page.html template for a range of errors. Do people use maybe HttpResponseRedirect('error/') where error is some defined function and somehow pass a message string to it? Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Open Linux Router
Well I'm currently getting started with django in a professional sense. I've been doing some calendaring and whatnot (seen http://justinlilly.no-ip.org:8001/todo/ ) I have some sysadmin experience and whatnot. Any thoughts on what you guys need the most? -justin On 7/27/07, westymatt <[EMAIL PROTECTED]> wrote: > > > We are developing a web interface to quagga/xorp, ssh, ftp, rsync, > users/groups, apache, mysql, you know name it and the goal is to > develop a module to configure it and install it if its not there. We > went with a webmin design last time and we are now rewriting it in > django/python. What skills do you have? We have all kinds of things > from forum management/programming/site management/mailing list ect... > > > > > -- Justin Lilly University of South Carolina --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---