Re: cpu load
> I recently upgraded Django from 0.96 to 1.0.2 but noticed that the CPU > load for the same site traffic jumped by 50%. Has anyone else noticed > anything similar or might have any clue as to why this might happen? Hi there, do you do any pickling or serializing of QuerySets? I do remember reading a blog (someone may be able to find the URL) where the author mentioned the same problem. He managed to find out that it was caused by changes queryset-refactor, especially the way QuerySets behaved during pickling. Sorry I can't give you the exact link :( Cheers Jirka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Pickling Querysets (Query?)
Hi, this is how I do it, but don't rely on effectiveness of this solution - I'd be the first one to say that I'm a mediocre programmer :) def serialize(data): '''Input: instance of PluginParameters Output: base64-encoded string that can be stored in a database ''' if not isinstance(data, PluginParameters): error('Attempt to serialize data of unsupported type (%s)' % type(data)) raise TypeError('Cannot serialize data of type %s' % type(data)) # Loop through all attributes, identify any QuerySets # and use only their 'query' attribute for pickling (disregard the rest) for attr_name in data.__dict__: value = getattr(data, attr_name) if isinstance(value, QuerySet): setattr(data, attr_name, value.query) if _compress: res = b64encode(zlib.compress(pickle.dumps(data))) else: res = b64encode(pickle.dumps(data)) debug2('Serialized parameters: %g bytes' % len(res)) return res def deserialize(data): '''process base64 encoded pickled object and return an instance of PluginParameters ''' debug2('Deserializing parameters: %g bytes' % len(data)) if _compress: res = pickle.loads(zlib.decompress(b64decode(data))) else: res = pickle.loads(b64decode(data)) # identify any 'query' object and reconstruct the original QuerySet for attr_name in res.__dict__: value = getattr(res, attr_name) if isinstance(value, Query): # the black magic starts here ;-) model = value.model # get the original model owning the query qs = model.objects.all() # create a QuerySet based on that model qs.query = value # reattach the orignal 'query' to the QuerySet setattr(res, attr_name, qs) # and inject this back to the # PluginParameters object return res Hope this helps Jirka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: where is my pythonpath
KillaBee, PYTHONPATH is an environment variable, not a file. Try typing "env" at yout Ubuntu command line. How to modify the environment variable was already descibed in this thread so I won't go into that again. Cheers Jirka On 9/18/08, KillaBee <[EMAIL PROTECTED]> wrote: > > That give me the folder, I know that I was in the right folder. I am > looking for a file called PythonPath and there is none. What is this > file that I am editing. Do I just put A symlink in the folder. > > On Sep 18, 11:20 am, Sérgio Durand <[EMAIL PROTECTED]> wrote: >> would be this you are looking for ? >> >> python -c "from distutils.sysconfig import get_python_lib; print >> get_python_lib()" >> >> []'s >> Sergio Durand >> >> KillaBee escreveu: >> >> > I need to edit my pythonpath, but where 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: OT: hide directory listing on server
> However when i go to .com/media/profile_pics/ i get a directory > listing of all the folders in this directory. > > Can i disable this?? so its not possible to "browse" all the profile > pics, without knowing the exact path of a given file. Hi Peter, read the Summary section of http://httpd.apache.org/docs/2.2/mod/mod_autoindex.html You could also completely remove the mod_autoindex from Apache, but make sure that it won't have any unwanted side effects on your website. Cheers Jirka Vejrazka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Python Multiprocessing With Django
> I have a management command that that starts up a few process to process a > request: http://dpaste.com/7925/. Hi, I was recently debugging similar issue and came to a conclusion (which may be wrong of course :) that multiprocessing and Django DB connections don't play well together. I ended up closing Django DB connection first thing in the new process. It'll recreate a new connection when it needs one, but that one will have no references to the connection used by the parent. So, my Process.start() calls a function which starts with: >>> from django.db import connection >>> connection.close() This solved my problem. Cheers Jirka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Python Multiprocessing With Django
> Thanks Jirka, that fixed the problem. But I think I will file a bug report > that seem to be very hacky :) Great, I'm glad it solved your problem. Personally, I don't think it is a bug, as we both pushed Django well beyond its "area of expertise". I really believe that Django is great for serving web content and everyone (including) me trying to implement it in different areas must be ready for problems and gotchas here and there. But YMMV. Cheers Jirka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Help about models
> I commented out the ForeignKey because it caused an error. Just a small coding note - it was causing an error because you did not specify the model name exactly (compare the character case) Jirka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ORM using tons of memory and CPU
Hi, correct me if I got it wrong, but you essentially need these 4 things: 1) obtain the date for the the newest messages to delete 2) get cacheID of all objects to be deleted 3) delete the files 4) delete these objects from the database So, you could use something like this: # get the date newest_to_delete = datetime.today() - timedelta(days=settings.DAYSTOKEEP) # get cacheID's of emails to be deleted, requires Django 1.0+ to_be_purged = archivedEmail.objects.filter(received__lte=newest_to_delete).values('cacheID', flat=True) # to_be_purged is now a Python list of cacheID's for item in to_be_purged: delete_file(item) # do the os.unlink() operations # now delete the entries from the database archivedEmail.objects.filter(received__lte=newest_to_delete).delete() Since you keep all files in flat directories, I'm assuming that you are not deleting millions of emails per day (otherwise the file lookup operations would really be the bottleneck). Hence, this "list of cacheID's" approach might be the fastest way. The iterator idea suggested before is good too, you'd have to compare them yourself on your data set to figure out what works better. Hope this helps Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORM using tons of memory and CPU
Well, I was bound to get something wrong :) > to_be_purged = > archivedEmail.objects.filter(received__lte=newest_to_delete).values('cacheID', > flat=True) the end of the line should be .values_list('cacheID', flat=True) # not .values( Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can a django form render a javascript (interactive) calendar?
>> > Is it possible for django to render a javascript calendar? How so? >> > If this is possible, a code snippet would be very helpful. Django Admin has a JavaScript calendar you can copy or learn from - take a look at django.contrib.admin.widgets.AdminDateWidget Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
> class Choice(models.Model): > poll = models.ForeignKey(Poll) > choice = models.CharField(max_length=200) > votes = models.IntegerField() > def __unicode__(self): > return self.question > > > I know the structure is wrong. > Any suggestions would be greatly appreciated. Hi, I'm not sure why you'd think the structure is wrong (i.e. state actual errors or problems rather than generic statements). However there is one problem with your Choice model. It does not have any self.question, so __unicode__() can't really return it. You probaby want to use "return self.choice" there (or compose some text string based on existing model fields). HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Models Tutorial Django
Hmm, I can't see anything wrong with your code, so I'm gonna go to the basics - how about your code indentation? Is the "def __unicode__()" the same way as your model field definitions? The __unicode__() function must be part of your Poll class, not standalone. Cheers Jirka On 11/05/2010, HelloWorld wrote: > Hi Jirka > > Thanks for your answer! > > By structure I mean, I just followed the tutorial and am not sure if > the position and order of these tutorial code is right in my code: > > class Poll(models.Model): > # ... > def __unicode__(self): > return self.question > > class Choice(models.Model): > # ... > def __unicode__(self): > return self.choice > > > AND > > import datetime > # ... > class Poll(models.Model): > # ... > def was_published_today(self): > return self.pub_date.date() == datetime.date.today() > > > And I know the result is wrong because in the API it does not return > what the tutorial says should be returned: > > TUTORIAL: > >>>> from mysite.polls.models import Poll, Choice > > # Make sure our __unicode__() addition worked. >>>> Poll.objects.all() > [] > > > ME: > >>>> Poll.objects.all() > [] > > Thanks for the time! > > Best > > Z. > > > > > On May 11, 12:03 pm, Jirka Vejrazka wrote: >> > class Choice(models.Model): >> > poll = models.ForeignKey(Poll) >> > choice = models.CharField(max_length=200) >> > votes = models.IntegerField() >> > def __unicode__(self): >> > return self.question >> >> > I know the structure is wrong. >> > Any suggestions would be greatly appreciated. >> >> Hi, >> >> I'm not sure why you'd think the structure is wrong (i.e. state >> actual errors or problems rather than generic statements). >> >> However there is one problem with your Choice model. It does not >> have any self.question, so __unicode__() can't really return it. You >> probaby want to use "return self.choice" there (or compose some text >> string based on existing model fields). >> >> HTH >> >> Jirka >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group >> athttp://groups.google.com/group/django-users?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Shows indendation error
Ravi, the "default" lines where you just uncommented existing lines (like the "include admin") start with spaces, the lines you've created start with Tab characters. Mixing tabs and spaces is not a good practice (generally, it's recommended to use spaces only). If you swich your editor to "display special characters" or similar (most editors can do that), you'll be able to see it yourself. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python Database Framework
> Do anyone knows a Python Database framework, which resembles Django's > approach to database programming? I need it to use outside of Django, for > other Python scripts. Any reason why you wouldn't Django itself? I do use the ORM to multiple projects that have no relation to web. Works very well. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Session not working as i had hoped
Hi, a simple hint: try to point out a place in your code where has_visited does exist and is set to False. Also, you probably don't want to have any code in your view after an unconditional "return" statement - that code would never get executed. HTH Jikra -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django minimum deployment requirements
As long as you have Django installed, yes. It's in the documentation. Cheers Jirka On 26/05/2010, Murasame wrote: > Can a Django powered app run in a standard apache mod_python only > webserver? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: generate cache by visiting protected links
> i have cache enabled on a few heavy statistical views. > I would like to generate the pages before a user goes to that page and maybe > even > regenerate the pages every hour to avoid the initial delay. > However, i can't seem to automate the caching as my site's authentication > gets in the way > of automating this. > > I've tried code that i googled that performs a cookie based login > using urllib and urllib2 but that didn't work. > > Basically, i would need a view that is started when the server starts and > gets called > every hour to generate or visit the url of the stats page. > And this would have to be via a logged in user as otherwise access to the > stats is forbidden. Hi, is the statistics user-dependent? If not, just create a cron job (or similar, depending on your platform) that will calculate the statistics every hour and maybe even create the main blocks of the page to be displayed. You can either create a custom management command to do this or write a script that uses ORM (and templating system) and Django cache. It very much depends on you setup, but should not be too difficult. Basically, you probably don't need a "view" to populate the cache. HTH Jirka P.S. http://docs.djangoproject.com/en/dev/howto/custom-management-commands/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: generate cache by visiting protected links
> ret_val = stats_top_callers_per_year(_request) > cache.set(reverse("stats_top_callers_per_year"), ret_val) Hi, it's your code and I won't try talk you out of it :) However, I don't see any reason why you couldn't call "stats_top_caller_per_year" from an external script, unless you do some magic related to request in that function. You're overriding the user to be the one with pk=1 anyway, so you can do the same in a script launched by cron the same way. As long as you have a system-wide cache (ideally memcached backend), nothing prevents you from doing that. As for the cache key, it can be anything you want as long as it's unique, less than the backend allows (I think it's 250 chars for memcached, see the docs) and does not contain whitespaces (some cache backends do allow those). A common idiom is an md5 of something that uniquely identifies the cache object, but in your case you'd be free to call it "stats_top_callers_per_year" or similar. No need to play with reverse(). It's all just Python and Django does not really get much in a way unless needed. So, no one tells you what the cache keys must look like, and it's unlikely that you'd stumble upon cache keys Django uses internally. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: generate cache by visiting protected links
> I could indeed, as you correctly point out, put it in a cronjob provided > that i can access the cache that is currently used byt the site. > I haven't yet found how to do that. Probably not that hard. > But i don't see a benefit to putting the code in a cronjob. > Apparently, you do, so could you enlighten me? :) Well, it probably depends on the frequency od data change as well as other factors. I personally don't like spawning another thread in a request-response cycle, but if it works for you, be happy with it :) Based on the print statement on your code I assume your website does run under the development server, so you may have very different requirements than a usual production (read: always running) site :) > As for the cache key, i did the reverse because i thought i had > read in the documentation that this was the standard way Django puts > stuff in the cache. Sure - you can do it, no problem. The reason Django uses it is that it caches various pages and the url pattern is a good way to make sure that the cache key is unique for each page. You could put anything there, even a static string :) > But it's not the link as returned by reverse, though i haven't found yet > what it is. If i find it, i can set i correctly in the thread so that I don't > have to manually check to see if the page is cached when a statistics page > is called. You will always have to check it, as it's not guarranteed to stay in the cache forever. Assuming that the data is in cache is a Bad Thing :) If you set your cache key to "yearly_statistics" or something similar, you will have no issue with figuring out what the key is :) Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: generate cache by visiting protected links
> That's why i asked on what Django uses as a key to set and entry in the cache. > If i generate the page and put it on the cache and then rely on Django to get > it, > the key i use needs to be the same as Django uses otherwise the page isn't > found in the > cache and the page is generated again and then cached by Django. > And that's just what i want to avoid. > I'm happy to leave the caching to Django, i just want to "help" cache it > initially :) OK - now I see what you're trying to achieve :) What is slow for you? Is it the data calculation, or actualy constructing the HTML page from the data (read:context) and page template? If it's the former, I'd still cache inside the function that calculates the data (with a fixed string key) to get the "transparency of the program". Using the "hack" with the cache key you plan to use sounds clever, but a bit difficult to pick up if someone else needs to read and understand the code later. Just my 2 cents :) Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: generate cache by visiting protected links
> I still have 2 approaches i can take. I still believe that there is a 3rd option there - to bypass the view / auth / login machinery completely :) If your primary goal is to cache the statistics and the statistics does not depend on the user that is logged in (you did pass a user with pk=1 in one of your previous emails), then you don't really need to call any view to cache the data. You can call the function that calculates the statistics (that would cache the data internally within the function), then call this function from anywhere upon start of your webserver (or cron job, as mentioned before). As long as you have a global cache (i.e. memcached), this would work very nicely and you would not have to do any urllib2 login magic. Let me give you a short example: def stats_top_callers_per_year(some_parameters_not_tied_to_a_specific_user): cache_key = 'stats_top_callers_per_year' data = cache.get(cache_key) if data: return data # calculate the data somehow cache.set(cache_key, data) # <- set appropriate timeout there Then have small script called before (or shortly after) your web server start, that would import this function from your code, hence calculating the statistics. Then, as long as you use memcached, your web would use the cached statistics every time the stats_top_callers_per_year() would be called frmo your views. Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Which program will run when we execute "djano-admin.py startproject mysite" command?
Hi Balu, django-admin.py uis copied to C:\Python2x\Scripts on your PC (depending on the specific Python version). This is not typically on you system path, so Windows can't find it. A simple solution is to copy or move the django-admin.py from Scripts subdir to C:\Python2x (where python.exe resides. Cheers Jirka On 01/08/2010, balu wrote: > Thank you. I could able to run python programs well using the Python > GUI. It is the problem raised when I tried to execute "django-admin.py > startproject mysite" command on Windows 7 > > On Aug 1, 9:26 pm, Karen Tracey wrote: >> On Sun, Aug 1, 2010 at 11:47 AM, balu wrote: >> > Still I couldn't made it on window 7. May be it is incompatible with >> > Django >> >> I don't have Windows 7 to test, but the problem you are describing >> (Windows >> not knowing what executable is associated with .py files) is not a >> Django-specific problem: it would affect any Python application. >> >> You might have better luck if you search generally on getting the python >> executable properly associated with the .py file extension on Windows 7. >> >> The alternative way of running the command, that is including "python" at >> the front of the command, requires that the path to the python.exe file be >> included in your windows PATH. So if you cannot find out how to get the >> .py >> file association set up properly, you could instead figure out where >> python.exe is add that directory to your PATH. >> >> Karen >> --http://tracey.org/kmt/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: os.path
os.path is a standard Python module, you do have it already. Cheers Jirka On 02/08/2010, yalda.nasirian wrote: > hi > > note > > If you want to be a bit more flexible and decoupled, though, you can > take advantage of the fact that Django settings files are just Python > code by constructing the contents of TEMPLATE_DIRS dynamically, for > example: > > import os.path > > TEMPLATE_DIRS = ( > os.path.join(os.path.dirname(__file__), 'templates').replace('\ > \','/'), > ) > > where is my is.path ? how can i get it ? > > tanx friends > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
cx_Oracle not working (was: How to access a MySQL table in Django?)
> yeah, i was able to find that exact thing yesterday, and it works and i am so > happy. now i have one more problem, i cnat get oracle-cx to work. it says > that "no software installation was found" or something like that. i have the > python-mysql working but i cant seem to get the oracle database connector to > work. got anny suggestions? im running a linux platform with Ubuntu. Hi, cx_Oracle needs Oracle client installed on the system to work. You can get one for Ubuntu from http://www.oracle.com/technology/tech/oci/instantclient/index.html (Basic will work just fine). Upon downloading, just unpack it somewhere on your system where all users can read the files and set LD_LIBRARY_PATH environment variable to point to that dir. So, I have the following line in my /etc/profile: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/oracle/instantclient_11_2 This should do the job for you. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: urlpattern problem !
> but when i login in my admin page i cant see all of my objects( like > Publisher, Author, ...) > http://www.djangobook.com/en/1.0/chapter06/ > i just have groups , users , sites . > can you help me Hi, the Django Book 1.0 is slightly outdated, the admin works slightly differently with current version of Django. It's well documented on http://docs.djangoproject.com/en/1.2/ref/contrib/admin/ In a nutshell, you want a file called "admin.py" in the same directory where you have models.py, containing something like this: from django.contrib import admin from models import Publisher, Author admin.site.register(Publisher) admin.site.register(Author) HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: CSRF verification failures (admin)
> I have run into a consistent CSRF error in admin. > It occurs when user tries to change his/her password. > Every single time it returns CSRF error. > My admin templates are not modified. Hi, I'm not sure what your specific problem might be, but I experienced CSRF problem in admin in 2 situations: - cookies disabled in browser for the site (and long forgotten by me :) - running admin on SSL-enabled site and having faulty browser addin that was stripping referer values even for SSL sites. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching JSON in Django
> Is your AJAX query POST or GET query? Because as you may know, POST queries > are not cached, GET queries are. Also, GET requests are not cached in some cases (e.g. when GET parameters are used) - it's really difficult to figure out what's wrong without knowing specific details. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Caching JSON in Django
> I think that might be the case... I do extract parameters from GET. > > Am I out of luck? Well, nothing can stop your from doing the caching manually so you can tune it exactlly to your needs. It's actually not that difficult: from django.core.cache import cache def my_view(request): # some way to determine exact instaned of JSON data needed cache_key = 'some_way_to_uniquely_identify_json_data' json_data = cache.get(cache_key) if not json_data: # get the response data the hard way json_data = get_json_data() cache.set(cache_key, json_data) return HttpResponse(json_data) HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Query overhead or not ?
> tags = Tag.objects.all() > > for t in tags: > indexed_tags[t] = Post.objects.filter(tags__name=t).count() > > Next I would sort indexed_tags and I have a dictionary of which tags are used > the most. > > I'm wondering if this is a good idea ? Since if I have 1000 tags this would > require 1000 queries just for one simple tag cloud. > Is there a better way of solving this without adding an extra count field to > the Tag model. Hi Jonas, your gut feeling was correct - it's not a very good idea, although it might work for a small site. You might want to take a look at database aggregation in Django: http://docs.djangoproject.com/en/1.2/topics/db/aggregation/ Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django app that uploads media files and servers them through a view?
>> Is anyone aware of a Django app that lets you upload media files (not >> necessarily in the admin site) but serves them through a view instead >> of as static files via the web server? I need to control access to the >> media using permissions. Thanks > > Serving media using views are very inefficient, but I`m facing the > same problem; how to serve media using better suited servers like > nginx for media but still having some way of checking > permissions/authentication etc. ?? > > I`m working on a project similar to Windows Home Server, where users > can upload and backup their media and access it through a web > interface. Serving static media using django was terrible and using > nginx was incredibly fast, but I lost all access control to the static > media. Hi there, while I don't have first-hand experience, I do remember (from EuDjangoCon) that this can be achieved quite effectively using perlbal's reproxy feature. It does not handle the "upload" part, but that should not be difficult to code using Django's file upload mechanisms or 3rd party packages. Just my 2 cents, that's where I'd start looking if I needed this... Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re:
> My Url look like this > > di/sub?word=check&type=00&submit=Submit > --- > but it shows the error for symbols "?" > --- > i want to print only the word check in this url and it can be anyword > given by user Hi Sami, while you technically *can* make this working, it's not the usual way of handling URL's. Anything beyond a question mark is a parameter and is better handled inside your view. So, your urls.py would look like this: (r"^wap/di/sub", hellow) And your view would contain the following code: def hellow(request): word = request.GET['word'] return HttpResponse(word) But you should need two things: - the code does not contain any error checking (i.e. what happens if "word" is not provided in the URL - There is a security issue. Displaying anything that user provides on the output page *without checking it first* is insecure and can lead to various security-related issues I'll leave the JavaScript bit to your excercise as I don't really understand what you're trying to achieve with that. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re:
> def current_datetime(request): > > word = request.GET['word'] > return HttpResponse(word) > > but it still showing Error > Exception Value: > > unindent does not match any outer indentation level (view.py, line 7) The error is exactly what is says - indentation is important in Python and the bottom line is clearly indented differently then the line above it. You might consider spending a bit of time with some Python tutorial such as http://diveintopython.org/ Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re:
> my re reuested url is > http://localhost/wap/di/sub?word=check&type=00&submit=Submit Sami, please don't spam the list with the same requests. Your other question has been answered and if you have follow up questions, it's better to keep them in the same email thread. (also, please use a proper email subject next time you email to the list). Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Legacy URLs redirect
> And failed most spectacularly. Do I need to be escaping something, or > what am I missing? Yes. Even for the raw regular expressions, the question mark at the beginning must be escaped. Try a simple test case: import sys import re s = r'\?q=taxonomy/term/[0-9]+$' re_pattern = re.compile(s, re.IGNORECASE) if re_pattern.search(sys.argv[1]) is not None: print 'Match' $ django_test.py http://aaa.com/test?q=taxonomy/term/23 Match Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: design problem..how to store web page's data for later comparison
> Yes, it's definitely possible. DBs support very large text fields nowadays, I > wouldn't worry about it. Postgres's text field type is only limited by the > 1GB value-size limit general to all Postgres DB fields. Plus, you can easily compresss web pages very effectively using built-in Python funcitons. I assume you won't be storing images, only HTML content (and maybe some JavaScript or CSS). You can expect some 80% reduction in size just by implementing some 4-6 lines of code... Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: choosing queryset
> I've two modules called plan and income and both have a class called > Income in their respective models. Now if I do user.income_set, it is > accessing the income set under plan. How do I alter it to access > income.income? Any ideas? Hi, have you had a chance to check out related_name in the documentation? It does define "how should the other model call me". See http://docs.djangoproject.com/en/dev/ref/models/fields/ HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to use tkinter widget in django
> thanks for the replies.. > I am wondering if javascript is the only alternative if I want to use > such a custom widget. > If anyone knows about any such python widget please tell me.. You might want to dig a bit into website design to understand how JavaScript-based systems work. That would help you to understand why you *cannot* use any Python widget for such task. (polite hint - JavaScript runs in the browser and can be started from a HTML page served by a server) Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: interface django and rest
> Please Suggest me an tutorial for interfacing django and restfuli thanks Hi Sami, you might want to check this out: http://bitbucket.org/jespern/django-piston/wiki/Home Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Import csv file in admin
I must still be missing something here. If all you want to do is to read CSV file and save the data in the database, I still don't understand why you use the forms machinery. You only *need* to use the data model, e.g. from myapp.models import Data csvfile = csv.reader('something.csv') for line in csvfile: do_necessary_data_conversions_or_checks(line) try: Data.objects.create(field1=line[0], field2=line[1], ...) except (IndexError, IntegrityError): print 'Invalid line encountered:\n%s' % line What am I missing? Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Start project not working
Hi, first of all, if you will be sending emails like these, you're likely to get ignored by people who are otherwise happy to anser questions like yours (hint: 3 consecutive emails about the same topic in 2 conferences, "anonymous" user etc.) Now for the real "answer". You have not told us anything to identify the issue. Your django-admin.py is clearly working as it responded with a standard error message (no need to copy in full to the email). This message appears if parameters supplied to django-admin.py were incorrect. Since you have not actually shown what exactly you've typed, no one will be able to tell you what is wrong. I'm going to guess that you have not typed "django admin-py startproject myproject". This would not give you the "usage" message. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Import csv file in admin
> I try to follow the ideas, but i feel like taking the dirty way. > Here's my work: > Because i can't replace the modelform created by the admin for the > "Data" model with a standard form as the Django docs says, i created a > view to replace the "add" view generated by the admin and put a > standard form: Jorge, I think you need to get back to basics and try to understand what is run where. All the code you are writing for Django is run on the server and only web pages are *displayed* to users on their machines. This means that in order to import a CSV file, you need to transfer it to the server first and then you'll be able to import it there. Note that this has nothing to do with the admin site. This is a fundamental think to understand. I'd suggest that you forget the admin site for the moment and focus on the "transfer CSV file to server first". Take a look at the email Felix has sent you regarding FileField and try to code the part that handles file upload to the server. Once you have that, you can start thinking about importing the contents of the file into the database. Cheers Jirka P.S. OK, there is a way to import data without uploading them to server first, but it's much more complicated than the one outlined above and involves multiple different technologies that have to work together. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Howto crypt forms in Django?
> is there a way not to send form data in plain-text format? I've found > jCryption for PHP ("In short words jCryption is a javascript HTML-Form > encryption plugin, which encrypts the POST/GET-Data that will be sent > when you submit a form."). Is there a way to crypt data without using > SSL? Christian, any solution similar to jCryption would not add much security to your forms. Since it does not use challenge-response, anyone who could obtain the plain-text form data can now obtain encrypted data and the encryption keys (and the fact that you'd be using something like jCryption). So, not much security added, only a bit of obfuscation. So, you should use SSL if you worry about security. Sorry. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Country->State->City Dropdown list
> The following is my django code. I would like to have 3 column drop- > down list. It sounds like you might want to check out Dajax (http://www.dajaxproject.com/), Dojango (http://code.google.com/p/dojango/) or JQuery (there are plenty of examples for using JQuery with Django out there). Cheers Jirka P.S. Starting your email with "URGENT" it likely to give you less responses, not more -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Validate single field in model
> But can i do something similar in the Model itself ? Hi, have you checked the documentation? http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to get hold of a (database) connection from within a thread
> How can I get hold of the connection used to create the object, from within > each thread, so that each thread closes the connection that it has just > used? Alternatively, how can I get a list of all the open connections that > Django is using at any one time. I am using the "standard" model query API, > and not executing custom SQL directly. Hi Joseph, I use simple: >>> from django.db import connection >>> connection.close() Please note that this is pre-multidb support, so you'll probably have to use the connections dictionary - see multi-db documentation for details. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: question about involve "vncserver" command with django
> For example, django listen on tcp port 8000, and the Xvnc also listen > on tcp port 8000. > It's wired. Hi Bill, this is technically impossible, two programs cannot listen on the same TCP port (on one interface). It's very likely that it was Django webserver listening there. Overall, starting VNC from a web application seems like a bad idea in principle as the request-response cycle is not well suited for this (as well as other reasons). Can you describe what are you trying to achieve and why? Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: question about involve "vncserver" command with django
> What am I doing is want to simplify using vnc. > I'm a Linux administrator. As you know, if users want to use vnc they > must login the server with ssh to start vnc server first. > Then get the port or id number, then use vncviewer or http link to > access the vncserver. > I just want them to access the http link let django start the > vncserver and use it. they don't need to install any ssh client. Well, using a web server to start VNC still seems like a bad idea. How do you stop the VNC server once a user does not need it anymore? The SSH approach is a good one (for extra security, you may require users to tunnel the VNC traffic via SSH). Or you can just leave the VNC server running all the time, is there a problem with that? I just don't see why you would need to start the VNC server dynamically, but that's well beyond Django and OT for this conference :) Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: spaces preserved
> Can someone please suggest how to get the complete string ? Passing (semi-) arbitrary strings in GET parameters can lead to all sorts of issues (probably less for english-only sites). You might be better off by passing primary key of the item model or some other unique identifier that is "web safe" (number or simple string with no whitespace). So, in your form you'd have: {{ machine.product_name }} and in your view: form myapp.models import Machine # or whatever it is pk = request.GET['product'] value = Machine.objects.get(pk=pk) # or use get_object_or_404 shortcut Hope someone can describe it better than me as I'm not a web developer :) Cheers Jirka P.S. This all assumes you pull the form entries from your database. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ReportLab and Django - templates? ; FK object has no attribute split
Hi Victor, It really depends on complexity of your PDF. I needed to do something similar some time ago and used ReportLab addon called "pisa" and used standard Django template language to define the PDF contents. You might want to take a look, it worked well enough for simple PDF pages. Cheers Jirka On 18/11/2010, Victor Hooi wrote: > Hi, > > I'm trying to use ReportLab to produce a PDF output for one of my > views. > > My first question is - at the moment, I'm building up the PDF inside > my view. Is this really the recommended way of doing it? It's like > I've got presentation code inside my view (controller). Isn't there a > cleaner way of doing it, or going from a template to PDF somehow? (I > know ReportLab offers a commercial package using RML templates, > however I was hoping for an opensource/free method). > > Second question, I have a model with several FK fields. E.g. > > class Article(models.Model): > category = models.ForeignKey(Category) > subject = models.ForeignKey(Subject) > > Both the category and subject classes have fields called "name", and > __unicode__ methods defined which return name. > > I'm trying to refer to these fields in my PDF output. I have a list of > items in article_list (i.e. queryset): > > for item in article_list: > text = item.category > category = Paragraph(text, styles['Heading2']) > story.append(category) > > text = '%s' % item.subject > subject = Paragraph(text, styles['Heading3']) > story.append(subject) > > When I try to run this code, I get: > > 'Category' object has no attribute 'split' > > and the same error with subject, obviously, once it gets to that bit > of the code. > > Any idea why this might be, or how to fix it? Any help is much > appreciated. > > Cheers, > Victor > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORA-01425
> I'm using Django against an Oracle 10 database. It used to work. Then they > upgraded it to 10.2.0.5 (not sure what from, I can probably find out). Hi Tim, sorry, I don't have a solution for you, but you might want to check out http://code.djangoproject.com/ticket/14149 and add description of your environment there so there is more "use cases" listed there. Actually, I do have a solution - I do monkeypatch the Oracle backend so it matches my version of Oracle (i.e. 2 or 4 backslashes). Cheers Jirka P.S. This got me thinking - maybe the Oracle backend could do some "autodetection" of which version works fine in the current environment? Yes, it'd be extra query at startup I guess, but don't really see any other way... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORA-01425
> Interesting that I'm seeing this in an upgrade from 10.2.0.4 to 10.2.0.5. > > Instead of changing from LIKE to LIKEC - if I add more backslashes will that > work? Honestly, I can't tell. It's been too long and I can't test it now :-((( Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORA-01425
> It looks as though something like that may be necessary. For those of > you running into this problem, do you get the error with the following > query? > cursor.execute(r"SELECT 1 FROM DUAL WHERE TRANSLATE('A' USING NCHAR_CS) LIKE TRANSLATE('A' USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)") No error for me, but that's on a monkeypatched system. I can try without the patch, but only after weekend :( In [7]: res = c.execute(r"SELECT 1 FROM DUAL WHERE TRANSLATE('A' USING NCHAR_CS) LIKE TRANSLATE('A' USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)") In [8]: list(res) Out[8]: [(u'1',)] Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORA-01425
> No error for me, but that's on a monkeypatched system. I can try > without the patch, but only after weekend :( Actually, screw production servers :) Tried on unpatched Django 1.2.1, got exactly the same result, no error. Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ORA-01425
OK - here's my 2 cents: Django 1.2.1, Oracle 9.2.0.7 Cheers Jirka In [1]: from django.db import connections In [2]: c = connections['oracle'].cursor() In [3]: c.execute(r"SELECT 1 FROM DUAL WHERE 'A' LIKE TRANSLATE('A' USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)") --- Traceback (most recent call last) /data/ig/webapps/ig/ in () /usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py in execute(self, query, params) 505 self._guess_input_sizes([params]) 506 try: --> 507 return self.cursor.execute(query, self._param_generator(params)) 508 except Database.IntegrityError, e: 509 raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] : ORA-01425: escape character must be character string of length 1 In [4]: c.execute("SELECT 1 FROM DUAL WHERE DUMMY LIKE TRANSLATE('X' USING NCHAR_CS) ESCAPE TRANSLATE('\' USING NCHAR_CS)") --- Traceback (most recent call last) /data/ig/webapps/ig/ in () /usr/lib/python2.5/site-packages/django/db/backends/oracle/base.py in execute(self, query, params) 505 self._guess_input_sizes([params]) 506 try: --> 507 return self.cursor.execute(query, self._param_generator(params)) 508 except Database.IntegrityError, e: 509 raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] : ORA-01425: escape character must be character string of length 1 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Can I remove the django source dir after install?
> - download the tar file > - extract to a dir c:\django-1.1.1 > - run "python setup.py install" > > Can I now delete the c:\django-1.1.1 dir? (it seems like all the > necessary files have been copied over to the python site library dir. > Or, is there something that I may still need in the c:\django-1.1.1 > dir? Yes, you can safely do that. You can also keep it as reading the source files is a great way to learn a few tricks and techniques and it's a bit easier than digging in python's site-packages :) Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Python based web reporting tool?
> I have a question for those of you doing web work with python. Is > anyone familiar with a python based reporting tool? I am about to > start on a pretty big web app and will need the ability to do some end > user reporting (invoices, revenue reports, etc). It can be an existing > django app or anything python based so I can hook into it. Thanks! I've recently written (part of) something small that used Django templates, ReportLab and pisa (mentioned in Django docs) to generate PDF. Unfortunately, I did not have a chance to completely finish it and it's not likely to be done anytime soon. But the PDF part was pretty easy thanks to pisa. Check this out: http://www.20seven.org/journal/2008/11/pdf-generation-with-pisa-in-django.html Hope this helps Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How crypt python code
Hi, You can't really. The code has to be executed, therefore it has to be readable by the server. So, by definition, it is readable by sever admin(s).. You could implement some obfuscation, but it,s not really worth it. The best you can do is to check your hosting contract/agreement, see what it says about ownership and privacy. Or use your own server(s) in a trusted environment. Cheers Jirka On 12/01/2010, nameless wrote: > I have to upload my django project on shared hosting. > How can I crypt my code ? > I want to hide my code on server. > > Thanks :) > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: two different models, order by date
Hi, > i have a simple question here, i've been trying to found the answer > but somehow i got confused if this is wheter possible or not: it's always possible, just a matter of time and effort (and cost) ;-) > I have two django models, movies and books , i want to get all the > objects from both models and order them by date, getting result_set > that > might look like this: > > movie1 > movie2 > book1 > movie3 > book2 It depends a bit on the context (i.e. do you really want all objects or just the most recent ones?). I'll only provide a few hints. - convert whatever you need to combine into lists. You may want all or just latest 20 objects, i.e >>> movies = Movie.objects.all() >>> books = Book.objects.all() or >>> movies = Movie.objects.all().order_by('-id')[:20] >>> books = Book.objects.all().order_by('-id')[:20] then >>> my_objects = list(movies).extend(list(books)) then >>> my_objects.sort(key=...) # see http://wiki.python.org/moin/HowTo/Sorting Hope this helps Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form.has_changed always true?
Hi, if I digress from the has_changed() problem, you mentioned you wanted to send email after a user profile has changed. Assuming that the profile is a model in the database, you might consider tying your logic to the model rather than the form. The post_save signal tied to the profile-related model might just do the trick for you. Cheers Jirka On 07/01/2010, Alastair Campbell wrote: > Hi everyone, > > I've been looking for a simple way to send an email when a user > updates their profile. > > After some digging I found form.has_changed() which appears to fit the > bill. However, it always seems to return true, so I could end up > bombarding our elderly admin lady with lots of useless emails. > > I'm using a simple model form (with a sub-set of the available > fields), rendered in the default manner, no hidden fields or anything. > If I open the page, hit save, if form.has_changed(): runs. > > Is there anything else that might cause has_changed to be true? > > Perhaps this is why has_changed() isn't mentioned in the documentation? > > I kinda hope I'm being stupid on this one, I'd rather not get into a > long comparison function! > > -Alastair > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Problem
> But i m getting following Error after loading admin module in > setting.py(Please Download attached file from Files Section): Hi, you have not provided the error message nor any link where we can see it (as far as I can see), so it's difficult to judge what the specific problem is... Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Serving https with runserver
>> Then maybe web server is the best option. In all cases you have to >> configure something until someday 'runserver' come with ssl support. I think that no one would really object if runserver was SSL-aware, however people requesting it need to be aware that having an SSL-aware webserver is significantly more difficult that having a simple HTTP web server. The things that come to mind are: - extra dependencies: I'm not sure about all of those, but at least openssl comes to mind - the need to have a server certificate: While not a terribly complex task to generate one, some decisions need to be made (e.g. where it will be stored?). - more complex URL handling for testing. As local server uses port 8000 by default and links are usually relative, it's not a big deal. But if people start relying on having HTTPS dev webserver, they might get confused if that one is not running on default port 443. So, if dev web server was running on port 8443, people would need to keep this in mind when working on their templates / redirects. On top of those, I can see 2 big risks: - if SSL-aware development server exists and easily available (just one command), people could start relying on it as it'd be much easier to set up than any other SSL website. That would be a big mistake, the dev server would be very insecure, missing lots of necessary features (and almost certainly having a self-signed certificate). - it'd probably only escalate things. If people get SSL-enabled dev server, they start asking why it does not support client-side certificates :) Just my 2 cents. Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Creating fancier views
> customising templates. I am wondering if there is an easy way to > spice up certain things, such as tables, in a similar way to the admin > interface does. Specifically I'd like sortable/filterable columns at > this time, perhaps with the option to add checkboxes/custom buttons to > each row later (for editing records or selecting multiple records). Hi, this is not very specific to Django as it is done using custom CSS (layout) and client-side JavaScript (sorting, filtering). For CSS, check out http://www.w3schools.com/css/ or similar (Google for it). For JavaScript, nothing prevents you from checking Admin JS files and reusing those and/or learning from them. Hope it helps a bit Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to create connection pooling in django
> I am using Django1.1.1(Apache via mod_wsgi deployment) with MSSQL DB. I > found that the new DB connection is getting created for every request . But > i want to use connection pooling. > Can anyone provide me the link to achive connection pooling. > Thanks and Regards, vijay, first, pelase don't spam the conference with repeated emails The fact that no-one replied to you in a few hours does not mean that you need to resend your question. You need to consider timezones across the globe and the fact that people usually reply in their spare time and only if they actually know the answer or feel that they can help/contribute. Are you sure that the fact that a new database connection is created for each request is a problem for you? Most people need to solve other performance issues first before they find out that connection pooling would be a problem worth fixing. I'm not doubting your situation, just asking why you think that connection pooling would significantly help you. Creating a new DB connection is pretty cheap and quick on MySQL. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to check size of a dict or list in template
> In the template I want to show something like > > {%if not len(objects_tatus ) %} # just to clarify the purpose..I know > But how can I check the size of the dictionary? If it was a Queryset I > could have used qset.count ..but here it would not work. > Can somebody help? Hi there, there is probably more than one way to do it, but the one that comes to mind is to write a simple custom filter, see http://dpaste.com/167380/ (not tested) then you could use: {% if object_status|generic_length > 0 %} (or the pre-1.2 equivalent using ifequal). See http://docs.djangoproject.com/en/1.1/howto/custom-template-tags/#howto-custom-template-tags if you are not familiar with custom tags. Please note that I have tested the code, so use it as a guidance only. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Newbie question: upgrade to python 2.6: cannot (re)connect to Django?
Hi Bob, > MacPro1:Downloads$ ls > Django-1.1.1.tar You have not unpacked the Django archive. You need to run: $ tar xf Django-1.1.1.tar It will create a subdirectory (named "Django-1.1.1" probably), then you need to move to that subdirectory $ cd Django-1.1.1 and then run the $ python setup.py install Regards Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: send_mass_mail()
> how much mails can i send with send_mass_mail() > i have like 7000 users and i have send mail to all of them. Hi, I have never used it myself, but a quick glance at the source code does not show any reason why this would not work. However, keep two things in mind: - the emails are first all constructed in memory, which could be a bit of a problem if the email body is large - the SMTP server must be able to handle 7000 emails in one go Hope this helps a bit Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: need help in multi db
Hi Silaja, first, I'm going to guess that no one will be able to solve your problem. There are multiple reasons for it: - Multiple database support is in Django 1.2. You insist on using it on Django 1.1, without mentioning why you can't upgrade (the upgrade would make sense for any reader not knowing the context that only you currently do know) - the code written by Eric F. is an interesting hack for older versions of Django, but not too many people have probably used it, so there would be little experience with that. However, there is a problem: - * you have not specified what your problem was when you tried it * So, even people willing to spend their time helping you could not do it as they would not know how far you have gotten implementing it and what actually stopped you from succeeding. - you mentioned "i.e some of rows in some "x" table in one database and some of rows in "x" table in other database. i want to select which database used to add/retrieve the rows dynamically". This is quite complex and even the code from Eric's site will not help you much. If you make it working, it will lay the foundations, but you'd still be quite far from reaching your goal. I'm afraid that you need to give us more detail and the actual context before you can expect better answer than "upgrade to Django 1.2". Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: templates?
Hi Nadeesh, you need to use forward slashes, even on Windows (or double-backslashes). So, changing to: DJANGO_SETTINGS_MODULE=C:/django/Django-1.1.1/djangotest/mysite/settings might solve your problem, assuming everything else is OK. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: templates?
> DJANGO_SETTINGS_MODULE=C:/django/Django-1.1.1/djangotest/mysite/settings Oops - I take it back (it's been a long day). You need to supply Python path, i.e just "mysite.settings" if you PYTHONPATH is already set to PYTHONPATH=C:\django\Django-1.1.1\djangotest and mysite is a directory there. Sorry about that Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: local application source files checksum
> The thing is: the application will get approved from an organization, > and after that I have to avoid any kind of source edit, > until another approval.. Hi, one option would be using proper permission for editing the source code and Tripwire/AIDE for reporting on any unauthorized changes... Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to check if I installed Django well?
Hi, if you've untarred the Django archive, you have a new directory called (probably) Django-1.1.1. Just go into that directory (in the command line, do "cd Django-1.1.1") and then run installation the standard Python way (for Python packages): "python setup.py install". It should run for a few moments and (hopefully) complete without errors. Then you will be able to remove the original package you've downloaded and the "untarred" directory. Diango will be installed in your Python's site-packages directory. To test, you can try: C:\> python >>> import django >>> django.VERSION (1, 1, 1) Hope it helps Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to run a given project
> i get "Database wit does not exist " (wit is the database for this > proj but i dont if i should make it in postrgres or ??,i tries making > it and then i got other errors) > im working in Linux Hi, it seems that your database setup is incorrect or the database just does not exist. If it is the latter, I'd suggest that you review Django tutorial [1] and define database settings, then synchronizing your models. For start, you might want to use SQLite3 as it's by far the easiest one to set up. Cheers Jirka [1] http://docs.djangoproject.com/en/1.1/intro/tutorial01/#database-setup -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django noob - static views or dynamic pages in web application?
Hi, sorry, but it seems that you need to take another look at the Django documentation to figure out how it works. Let me point out couple of things that were not exactly right in your email. First, Django is not a CMS (although there are CMS systems based on Django). Django is a *web development* framework. > URL is passed via a variable in urls.py No, Django takes the URL requested by the user and looks it up in a list of patterns defined in urls.py. If a match is found, Django calls the view function (typically locates in views.py) that was associated with that URL pattern. > which then locates a row in a database containing > the html code to send to a template. Typically, there is no HTML code in the database. Templates contain (most of) the HTML code. The data in the database is then used to complete the HTML code from templates. > create static pages inside views.py as well? I'd be surprised if someone had static pages in view functions. That's what templates are for (or, in some cases, specific Django functionality like flatpages) > I'm actually about to embark on a web application which will consist > of about 200 different page views and 12 different templates, all > performing some kind of in depth function. Do I try and integrate my > web app with a Django CMS or am I being an idiot if I create each of > these pages in views.py? Well, it's difficult to say without knowing more, but you'd typically want to create templates for those pages. The rest (data models, structure of urls.py and views) really depends on the web application you'd be trying to create. > I can't find any information on best practices with Django and not > sure where to start. Check out the overview: http://docs.djangoproject.com/en/1.1/intro/overview/ and then move onto the tutorial (on the same site). There are also several good books and websites loaded with content available. Such as http://www.djangobook.com Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: More tutorials and recipes?
> What I am looking for is something that goes beyond the tutorials to > bridge the gap to the detail of the modules. Are there any? Hi, how about checking out some existing applications to learn how those work? Many of them are small enough to get the useful tips and tricks from them in 10 minutes (per app ;-) http://code.djangoproject.com/wiki/DjangoResources HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Send e-mail with large files from form attached
> I've got a form with 20 ImageFields - such a form for sending photos > to the site admin as a request for a new user. Well, Django certainly > handles and uploads the, that's OK. But when it comes to sending all > the files as an attachment - I got stuck. > Small files are read nicely. But when someone "clever" fills out all > the form files (all the twenty) with images each one at least 10 Mb - > Django consumes so much memory... so I'm not in knowledge to handle > that. Hi, email is not really suitable for sending large amounts of data. The fact that people use it that way is a bit sad, but you should not really follow their example. So, you're trying to send up to 200 MB via email. That's in fact some 270 MB, because binary data is base64 encoded in emails, typically (not always, but often). That is the reason for the memory problem. As Paulo pointed out, created a unique, temporary URL for downloading those images and send just the link to that URL. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Signals in Django
> Is it possible to get real signals into Django processes? I have > several processes that collect data for analysis, so they run a long > time normally. For maintenance purposes, it would be handy to be able > to send a SIGHUP to the processes and have them shut down cleanly. I > read up on the pseudo signals module in Django, but I can see no method > to handle real signals from a non-Django process. Hi, yes, sure - Django is just python, so nothing prevents you from using signals. You'll have to step out of the usual request-response cycle, however. I have an internal project that uses "real" signals, based on libevent/pyevent. It uses Django ORM for data handling. All works nicely. Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: set up database engine
>> how exactly set up the database engine as SQLight? The tutorial >> doesn't seem to tell us... Hi, if you edit the file "settings.py" in your project directory, all you need to do is to tell Django that you want to use SQLite3 and where you want the database (somewhere on your disk, where you have write permissions). As all necessary libraries are included in Python 2.5+, Django will automaticaly create the database for you once you run "manage.py syncdb". The database will be just one physical file. Cheers Jirka P.S. Hint (for settings.py) import os DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = os.path.split(__file__)[0] + 'mydatabase.sqlite3' -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to achieve the break tag in django template
>> now i have a finished template which wrote by j2ee,like this: >> <#list dailyStarList as dailyS> >> > 0>class="list_color_w"<#else>class="list_color"><#list Hi, the syntax you're using is not standard Django template syntax, so unless someone has replaced the default Django tempating system with the same one as you did (and is familiar with it and read your email), you are unlikely to get a response from this list. Sorry Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to achieve the break tag in django template
> the syntax you're using is not standard Django template syntax, so > unless someone has replaced the default Django tempating system with > the same one as you did (and is familiar with it and read your email), > you are unlikely to get a response from this list. Oops - sorry. I misread your email (another proof I should not reply to anyone before my first cup of coffee ;-) I'm not very familiar with j2ee syntax, but the logic seems a bit too heavy for a template, you might be better off implementing the logic in a view (hence, standard Python+Django), put the result in the context and only display the context in a template. Just my 2 cents. Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: null field issue
Hi Marc, if I remember correctly (can't check now), the documentation clearly states that you should avoid using null=True on CharField unless you have a good reason. Your example is a textbook reason why is it recommended - having two distinct states for "empty string" (i.e. "blank" and "null") leads to inconsistencies and confusion. HTH Jirka -Original Message- From: Marc Aymerich Sender: django-users@googlegroups.com Date: Thu, 1 Mar 2012 22:43:19 To: Reply-To: django-users@googlegroups.com Subject: null field issue I have a model with a filed like name = models.CharField(max_length=255, blank=True, null=True) With Django admin I've created some instances of that model without filling name field. Now I'm querying that model with name__isnull=True and the filter doesn't return any single object!! acctually on the database (postgresql) the name field is an empty string '' instead of the expected NULL. Why the admin fills name field with an empty string? Is this a normal behaviour? -- Marc -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Dajaxice is not defined!!! please heelpppp!! :(
> i am trying to use dajax in my page and i followed all steps several times > as given hier: http://dajaxproject.com/ > > but once i click on onclick="Dajaxice.home.randomize(Dajax.process), nothing > is happening and i saw in console of firefox, there it says, "Dajaxice is > not defined". but i included the {% dajaxice_js_import %} in the head, and > even i linked the dajaxice.core.js file statically from my STATIC_URL. but > it still says the same error. how can i go around this problem? is there any > way of getting this work? Hi, I did have this problem a few weeks ago. Did you doublecheck your urls.py for Dajaxice-related links? What happens if you call Dajaxice URL directly? (you should see requests for dajaxice.core.js in your development server log). Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Stuck in URL............!!! Help
> 1. ^wikicamp/(?P[^/]+)/edit/$ > 2. ^wikicamp/(?P[^/]+)/save/$ > 3. ^wikicamp/(?P[^/]+)/$ > > The current URL, wikicamp/, didn't match any of these. All defined URL's expect wikicamp/some_page_name/ (and maybe some extras after). The requested URL has no page name, terminates right after "wikicamp/" - hence the error... HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django connect alternate database.
Hi, search documentation for "database routers" and using() in the ORM... HTH Jirka -Original Message- From: Min Hong Tan Sender: django-users@googlegroups.com Date: Fri, 25 May 2012 22:18:23 To: Reply-To: django-users@googlegroups.com Subject: django connect alternate database. hi, I have a situation. currently i have one default django 's database. but, i wound like to connect to mssql/other database. - how can i get connected to ms-sql/other database? - is it we have to create class in models? the database is for read only. Hope able to get the information. Regards, MH -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Tutorial database problem
Hi, you're creating your database file in /usr/bin which is intended for system executable files, not databases etc. It's highly likely that you don't even have write permissions there (unless you work using the "root" account which is a big NO-NO). Set your database file somewhere where you can write for sure, such as /home//test_db.db. You can easily find out if you have write permissions somewhere by using the "touch" command, i.e. "touch /home//test_db.db - it'll either create an empty file which means that this path is OK for your database, or give you an error. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to generate secure passwords
Hi, Are you trying to create passwords on behalf of users? This is usually a bad idea. If I got your message wrong and you talk about secure password hashes, is there something specific you did not like about the current Django auth system? Or maybe you are interested in password complexity requirements? It's really difficult to guess. Please describe the problem you're trying to solve a bit better. Cheers Jirka -Original Message- From: Emily Namugaanyi Sender: django-users@googlegroups.com Date: Tue, 29 May 2012 23:03:39 To: Django users Reply-To: django-users@googlegroups.com Subject: How to generate secure passwords Hi Django users, I am working on a project that as to generate secure passwords (passwords that cannot be hacked) every time a user register and the password lasts for a period of time. S,here I am wondering whether django has a provision for this or I need to find another way... Thank you for your time Emily. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django newbie
> experience. However when I'm trying to execute following command in > command prompt (Windows 7), I get this error. > File "", line 1 > django-admin.py startproject mysite > ^ > SyntaxError: Invalid synatx Hi there, this is a typical Python interpreter error message. It seems that you're typing your command in a Python prompt, not the Windows prompt. Can you copy & paste the whole command you're typing including the beginning of the line? Cheers Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.4 - how to display a success message on form save
Hi, have you checked the messaging framework in Django? HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django 1.4 - how to display a success message on form save
>> @Jirka - thanks. I saw something about the messaging framework and even >> tried one example which did not work. Using the messaging framework is actually very simple. You need to enable the messaging framework (see the steps here: https://docs.djangoproject.com/en/1.4/ref/contrib/messages/ ) In your template, you need this (I have that in my base template so it's included in all pages): {% if messages %} {% for message in messages %} {{ message }} {% endfor %} {% endif %} Obviously, you'll need some formatting/CSS around it. And in your views.py (or forms.py, ...) from django.contrib import messages if form.is_valid(): messages.success(request, 'Your form was saved') And that's it! Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem to complète the xml template
> Hello, > http://cdm-fr.fr/2006/schemas/CDM-fr.xsd"; language="fr-FR"> > {% if formations %} > > Hi there, you probably want to follow your {% if formations %} statement with: {% for formation in formations %} Check Django template documentation again - you're moving along the right path, but your template is missing the loop across individual formations. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: rendering modelForms
Hi Marilena, I'm also using Twitter Bootstrap and over time migrated to this template snipped that I'm including in my templates at the place where you put {{ form.as_table }} http://dpaste.com/hold/768995/ If you find it useful, great :) I'm not a web developer by nature so there may be a better way to do this - just be warned :) HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form.save() fails silently - how to debug?
> Thank you for the suggestion, but unfortunately that too does not work. > > I really need to find a way to get at the source of the problem; I would > think an error message should be generated but none shows up... Are you doing some magic in model's save() by any chance? Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: form.save() fails silently - how to debug?
Sorry, I should have read your code before answering. I'm struggling to understand what you do in your clean() method. Are you sure you're returning the right set of data? Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: merge data from multiple models
Hi there, > As templates cannot do lookups into a dictionary Templates can do lookups into a dictionary, see https://docs.djangoproject.com/en/1.4/topics/templates/#variables (check the "Behind the scenes" section). From what you've described, I'd try to prepare the necessary data in a view (using caching, if possible at all), build the appropriate data structure to be displayed and then use the template layer to do a "dummy" display. Then you'd have the full power of Python at your disposal to perform the best access to your data and combining the models together into and array of items or a dictionary, depending on your need. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: invoking a funcion or module as root
Hi there, you definitely don't want to allow apache to setuid() to root as you've pointed out. You have a few options, probably the easiest one is to write a pair of scripts for each task you want your application to perform with root privileges. - the first script will only contain "sudo " - the second script should contain the necessary step(s) that need to be performed with root privileges. It should be simple to minimize chances for security issues Then you'd configure your sudoers file to allow apache process to call the "second script" *including the right set of parameters* (if applicable) with sudo permissions. You'd then call your "first script" using subprocess() call from your views.py (or whereever appropriate). (you could technically bypass the whole "first script", but it'll greatly improve readability if you do it this way, no one will have to read your python code to match it to your sudoers file if problems occur). Even better solution would be fixing your security model, having a web application perform high-privileged tasks on a system seems flawed in 99% of cases I can think of, but maybe you have a good reason why you need it that way. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: DJANGO_DEFAULT_SETTINGS
It's always good to copy the error message you're getting. It seems that you try to run "python manage.py shell" ang getting an error that DJANGO_SETTINGS_MODULE is not set. Please follow at least a bit of the tutorial on docs.djangoproject.com which will teach you how to set this variable properly. HTH Jirka -Original Message- From: Carlos Andre Sender: django-users@googlegroups.com Date: Tue, 14 Aug 2012 15:48:18 To: Reply-To: django-users@googlegroups.com Subject: Re: DJANGO_DEFAULT_SETTINGS Ok, the quest is relative a how that work with forms of data in settins.py! not relative to date time. in real i'm want insert data in databases athroughl shell and thi error is show! 2012/8/14 Satinderpal Singh > On Tue, Aug 14, 2012 at 9:42 PM, Carlos Andre wrote: > > hi developers i'm with a ptoblem in this date. How work? > > thanks! > Please clear your question, if you are looking for date and time at > your page please follow the following tutorial: > http://www.djangobook.com/en/2.0/chapter03/ > > -- > Satinderpal Singh > http://satindergoraya.blogspot.in/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: DJANGO_DEFAULT_SETTINGS
> right, I was being very brief in my description! > But it is the following: > I want to insert data into the database from the shell, django shell, but > the result is always that you can not import the settings because the va > riavel DJANGO_SETTINGS_MODULE is not set Did you read my previous email and checked the documentation at all? It's all described there: https://docs.djangoproject.com/en/1.4/faq/usage/ https://docs.djangoproject.com/en/1.4/ref/django-admin/ If you read this and *still* have a problem, come back and ask a specific question with what you already tried (e.g. do you have a database defined and created?) and what specific error(s) are you experiencing. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: What is the easy way to install DJango?
It's easy to install Django on a Windows machine to test it out and develop code. Most of this is covered here: https://docs.djangoproject.com/en/1.4/topics/install/ In a nutshell, you need: - Python 2.x (2.7) - install it if you already have not done so - Django (start with a stable release e.g. 1.4, download link on the main Django page) - to install the downloaded Django package (covered in docs) - to find your "django-admin.py" (most likely in C:\Python27\Scripts) and use it to create your first project. - follow the official tutorial to learn the basics https://docs.djangoproject.com/en/1.4/intro/tutorial01/ It's pretty straightforward, most people have trouble locating the django-admin.py which is not on system PATH by default. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django development running on 127.0.0.1:8000 not accessible from same machine
Hi nav, A long shot - do you happen to have a proxy defined in your browser? It is possible to define a proxy for *all* request (including localhost) - this would have the same effect. HTH Jirka -Original Message- From: nav Sender: django-users@googlegroups.com Date: Mon, 27 Aug 2012 21:00:12 To: Django users Reply-To: django-users@googlegroups.com Subject: Re: Django development running on 127.0.0.1:8000 not accessible from same machine Hi Anton, Thank you for your email. I have tried all of the methods you had suggested but to no avail. In all my years of Django development the localhost address has worked flawlessly. I have also tried with multiple Django projects and other Linux installations and the problem persists. This makes me think this is a DNS issue that may be due to a network related problem. In which case I will have to investigate. I will post once I find a work around or solution. Cheers, nav On Aug 27, 5:36 pm, Anton Baklanov wrote: > oh, i misunderstood your question. > > try to type url with schema into browser's address bar. i mean, use > 'http://localhost:8000/'instead of 'localhost:8000'. > also it's possible that some browser extension does this, try disabling > them all. > > > > > > > > > > On Mon, Aug 27, 2012 at 10:53 AM, nav wrote: > > Dear Folks, > > > I am running my django development server on 127.0.0.1:8000 and accessing > > this address from my web browser on the same machine. In the past few days > > I have found thet the web browsers keep prepending the address with "www." > > when using the above address. 127.0.0.1 without the prot number works fine > > but the django development server requires a port number. > > > I have not encountered this problem before and am puzzled by what is > > happening. I am working on a Kubuntu 12.04 linux box and my /etc/hosts/ > > file is below if that helps: > > > > > 127.0.0.1 localhost > > 127.0.1.1 > > > # The following lines are desirable for IPv6 capable hosts > > ::1 ip6-localhost ip6-loopback > > fe00::0 ip6-localnet > > ff00::0 ip6-mcastprefix > > ff02::1 ip6-allnodes > > ff02::2 ip6-allrouters > > > > > TIA > > Cheers, > > nav > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To view this discussion on the web visit > >https://groups.google.com/d/msg/django-users/-/EZzlz6iQOGoJ.> To post to > >this group, send email todjango-us...@googlegroups.com. > > To unsubscribe from this group, send email > > to>django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Regards, > Anton Baklanov -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: sending data with HttpResponseRedirect
If you have sessions enabled, you can use the built-in messages framework (look in contrib) to display a message on the "next" page. Alternatively, you can save (semi-) arbitrary data in the user session and retrieve it in the view that displays the "success" page. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django.contrib.markup deprecated in 1.5 - what's the alternative?
Hi Phil, incidentally, I was looking at this just recently. The contrib.markup was deprecated mainly due to security issues with 3rd party libraries that could not be fixed in Django itself and were compromising its security. For more, read https://code.djangoproject.com/ticket/18054 Can't tell you what the replacement is. I rolled up my own markup filter, but I only have a handful of trusted users for my web app so I don't have to be too concerned with trusting their inputs. You can copy the markup filter from 1.4 - just be aware of the security consequences. HTH Jirka -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.