Re: Optimistic Locking
How about rewriting save method complately and make additional condition in WHERE clausule like this: UPDATE ... WHERE id=666 AND mtime=object_mtime Checking number of updated rows would give you information about success and would guarantee that there is no data manipulation between mtime check and save. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: A naive question re: text styling tags
I'd integrate javascript WYSIWYG editor like FCKEditor or TinyMCE to edit TextField type fields. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django multilingual
Theres earlier similar discussion. http://groups.google.com/group/django-users/browse_frm/thread/d6e7eab4cc81c7b8 For unlimited landuage support check my post at this thread. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: website side component processing
I just got new idea that maybe I should use custom template tags to call processing of all common subpage components. That would be even more efficient and flexible, because I could have many different premade templates to choose from in admin panel and each of them having different set of components. Whad do you think? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
website side component processing
I'm quite new to django/python (migrating from php). I've been developing cms-like web applications for years now. Now I'm trying to create quite advanced CMS using django. Lately I moved from doing simple tests in django to tearing other peoples django apps into pieces to get the idea of best practices when using django. The thing I dont know is where do I put code for processing side (left/ top/right/foot) componets of webpage. Simple examples show just how to display content of one component into what I'd "center content area". But where should I process small side components (like box of latest news leads and such) which should be shown on every subpage. I'm sure there is more proper way of doing this other way than: def my_view_1(request): process_side_subpage_components() # below process all stuff formy_view_1() def my_view_2(request): process_side_subpage_components() # below process all stuff formy_view_2() etc... In php I've writtent small OOP framework for myself and it basicly worked like this: * AbstractPage - class defining page methods, basic behaviour and convention of use. (common for each project) * ProjectPage extends AbstractPage - processing all subpage side components. (customized for each project) * ComponentViewPage extends ProjectPage - processing all data for currently displayed component. (common or customized depending on project) And when "ComponentViewPage" was being processed, all the common side components were automaticly processed too because this page inherited its behaviour from ProjectPage. What would be most elegant and most efficient way to do that in Django? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Best practice for implementing multilingual content in template
I think that better idea would be doing something like that (I'm using even more complicated models myself): class Page(models.Model): #parent page in tree of pages parent = models.ForeignKey('self', related_name="children", blank=True, null=True) slug = models.SlugField(unique=True) #name for admin page listing name = models.CharField(max_length=255) #short description for admin page listing descr = models.TextField() #relative order of silblings order = models.IntegerField() author = models.ForeignKey(User) class Content(models.Model): #melongs to which page page = models.ForeignKey(Page) author = models.ForeignKey(User) #version in what language lang = models.CharField(max_length=3) title = models.CharField(max_length=255) content = models.TextField() COMPONENTS = ( ('article', 'Article'), ('news', 'News'), ('partners', 'Partners'), ) component = models.CharField(max_length=50, choices=COMPONENTS) #is page published for this language version published = models.BooleanField() #template = models.ForeignKey(Template) We got relational database so lets use relations to be more efficient and have less data redunddancy. To explain a bit more class Page has one row per each page and has related as many rows in Content class as the number of languages. Just keep current language in session and use it to filter content rows to get the one you need. All the data that is shared among instances of page for each language is kept in Page class (less data redundancy). All the data that differs between languages is kept in Content (we read from database to memory only the data for one language - thats efficiency). Hope that helps :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Tutorial03: question about efficiency
Thanx all for explanations :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Tutorial03: question about efficiency
theres line of code in tutorial: Poll.objects.all().order_by('-pub_date')[:5] this gives 5 Poll objects. I wonder if this is efficient way of getting them? Does django get all rows first and then sort it and then slice it to get only 5? Or is it optimized somehow. The question is if its simplified for the tutorial and inefficient or this is the right way to do 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: Django Tutorial02 / TEMPLATE_DIRS
This was one of my most stupid problems. PyDev with RSE was not saving file fo linux virtual machine correctly and this caused the problem. Thank you for all the help. I hope, I'll come up with wiser problems next time ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial02 / TEMPLATE_DIRS
On Jan 18, 2:01 am, Rock <[EMAIL PROTECTED]> wrote: > The templates have to be within a directory named "templates" found in > the /var/www/ directory. > BUT DON'T PUT TEMPLATES THERE! Put the templates dir in the same > directory as your settings.py > file and set the path accordingly in the settings.py file. > > Here is another good alternative: > > Comment out the filesystem loading option. This means that the second > loader (which is the > app_directories template loader) will be used exclusively. Now put > your templates file within > your application directory, i.e., myapp/templates/ and put the > templates in there. Now you > don't have to specify an absolute path in the settings.py file for > template loading. I might try that as a last thing, coz its avoiding not solving the issue ;) And I want to know whats wrong to be able to prevent it to hapen in the future. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial02 / TEMPLATE_DIRS
On Jan 18, 1:11 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Jan 17, 2008 2:08 PM, code_berzerker <[EMAIL PROTECTED]> wrote: > [...] > Check the value of settings.__file__ from python manage.py shell after > importing settings, just to make sure it is using the file you think it is. > I don't see any code in Django that would filter or clear that setting, so > my first inclination is to think it is using some other settings file than > what you are expecting. I did this: python manage.py shell >>> import settings >>> settings.__file__ and it showed value of my app settings file just as I was expecting. > > I can't help with pdb, coming most recently from a Java background to Django > I already had Eclipse up and running and it was easy enough to add PyDev to > that for debugging Django stuff, so that is what I tend to use. I also use PyDev, but I run it on windows and use Remote Site Explorer to modify files directly on linux virtual machine. This way I cant do remote debugging. And debuging it on win xp probably wouldnt solve issue coz paths and permitions on windows and linux differ too much. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial02 / TEMPLATE_DIRS
> So, though the settings.py you posted has TEMPLATE_DIRS with your '/ > var/www...'directory listed, the one you are running with has no > TEMPLATE_DIRS. Yes I've noticed that, but I use settings.py listed above. Django uses db configuration from that file and other things too. Somehow TEMPLATE_DIRS gets cleared or filtered. for example if I run python manage.py shell from project dir and inspect settings module it is empty. I'm kinda new to Python and Django, so I may actually do some stupid mistake on the way. I'm getting frustrated enough to convinve myself to use pdb to run that code step by step. I dont know how to use pdb and it scares me yet Still considering installing Django on windows and trying to debug it through Eric or SPE (but since winxp is different platform I can get different issues and that holds me off it). BTW if it does matter I've setup Ubuntu (just shell, no X-Windows) on VMWare and using it as development server from windows xp. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial02 / TEMPLATE_DIRS
Trying to solve the problem I added following code to settings.py: ALLOWED_INCLUDE_ROOTS = ( '/var/www', ) but it didnt help. I skipped this error for a bit and continued with tutorial and heres backtrace of what happened later and also my settings.py content. ** * backtrace: * ** TemplateDoesNotExist at /test/djtest/polls/ polls/index.html Request Method: GET Request URL:http://192.168.233.129:8080/test/djtest/polls/ Exception Type: TemplateDoesNotExist Exception Value:polls/index.html Exception Location: /usr/lib/python2.5/site-packages/django/template/ loader.py in find_template_source, line 72 Python Executable: /usr/bin/python Python Version: 2.5.1 Python Path:['/var/www/test/djtest/mysite', '/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/ python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/ python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/ lib/python2.5/site-packages/Numeric', '/var/lib/python-support/ python2.5'] Template-loader postmortem Django tried loading these templates, in this order: * Using loader django.template.loaders.filesystem.load_template_source: * Using loader django.template.loaders.app_directories.load_template_source: o /usr/lib/python2.5/site-packages/django/contrib/admin/ templates/polls/index.html (File does not exist) Traceback Switch to copy-and-paste view * /usr/lib/python2.5/site-packages/django/core/handlers/base.py in get_response 75. # Apply view middleware 76. for middleware_method in self._view_middleware: 77. response = middleware_method(request, callback, callback_args, callback_kwargs) 78. if response: 79. return response 80. 81. try: 82. response = callback(request, *callback_args, **callback_kwargs) ... 83. except Exception, e: 84. # If the view raised an exception, run it through exception 85. # middleware, and if the exception middleware returns a 86. # response, use that. Otherwise, reraise the exception. 87. for middleware_method in self._exception_middleware: 88. response = middleware_method(request, e) ▼ Local vars Variable Value callback callback_args () callback_kwargs {} debug e TemplateDoesNotExist('polls/index.html',) exceptions mail_admins middleware_method > request , POST:, COOKIES: {'sessionid': '54170faf598f4c6a41c2be99843f5d7c'}, META: {'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'text/plain', 'DJANGO_SETTINGS_MODULE': 'mysite.settings', 'GATEWAY_INTERFACE': 'CGI/ 1.1', 'HISTCONTROL': 'ignoreboth', 'HOME': '/home/notroot', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml+xml,text/ html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en- us,en;q=0.5', 'HTTP_CACHE_CONTROL': 'max-age=0', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=54170faf598f4c6a41c2be99843f5d7c', 'HTTP_HOST': '192.168.233.129:8080', 'HTTP_KEEP_ALIVE': '300', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/ 20071127 Firefox/2.0.0.11', 'HUSHLOGIN': 'FALSE', 'LANG': 'en_US.UTF-8', 'LESSCLOSE': '/usr/bin/lesspipe %s %s', 'LESSOPEN': '| / usr/bin/lesspipe %s', 'LOGNAME': 'notroot', 'LS_COLORS': 'no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:', 'MAIL': '/var/mail/notroot', 'OLDPWD': '/var/www/test/djtest', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/ games', 'PATH_INFO': '/test/djtest/polls/', 'PWD': '/var/www/test/ djtest/mysite', 'QUERY_STRING': '', 'REMOTE_ADDR': '192.168.233.1', 'REMOTE_HOST': '', 'REQUEST_METHOD': 'GET', 'RUN_MAIN': 'true', 'SCRIPT_NAME': '', 'SERVER_NAME': 'ubuntu.localdomain', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/ 0.1 Python/2.5.1', 'SHELL': '/bin/bash', 'SHLVL': '1', 'TERM': 'linux', 'TZ': 'Europe/Warsaw', 'USER': 'notroot', '_': '/usr/bin/ python', 'wsgi.errors': ', mode 'w' at 0xb7d4e0b0>, 'wsgi.file_wrapper': , 'wsgi.input': , 'wsgi.multiprocess': False, 'wsgi.multithread':
Re: Django Tutorial02 / TEMPLATE_DIRS
On Jan 17, 5:33 am, Collin Grady <[EMAIL PROTECTED]> wrote: > On Jan 16, 11:22 am, code_berzerker <[EMAIL PROTECTED]> wrote: > > > I put my templates somewhere in /var/www/ just beside project code and > > media files. > > If /var/www is a web root, your project code should *not* be there. > Don't ever put django code in a web-readable directory if you can help > it :) Thanx, I will use your advice when I put django app on production server :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django Tutorial02 / TEMPLATE_DIRS
On Jan 16, 8:36 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > 1. settings.TEMPLATE_LOADERS contains the entry > django.template.loaders.filesystem.load_template_source before the > entry django.template.loaders.app_directories.load_template_source the order is correct > 2. the path specified in TEMPLATE_DIRS has no typos path is verified via commandline (cd /path/to/tpl/) and was correct > 3. the user you are running the Django application as has read/write > access to that template directory. Are you using the built-in > development server (python manage.py runserver) or an external web > server (Apache)? If it's the latter, you will need to make sure that > the user that Apache runs as has access to that template directory. I use devserver and even setting 777 on the directory tree for templates doesnt help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django Tutorial02 / TEMPLATE_DIRS
In Django Tutorial02 theres TEMPLATE_DIRS setting with path to templates. I copied some admin templates doing exactly as tutorial says. I'm using current SVN Django build. I put my templates somewhere in /var/www/ just beside project code and media files. What may be the reason that django doesnt see these templates? regars --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---