Running Django on a shared-hosting provider with Apache in fcgi mode
Hi! I have a shared hosting. Need to place there my django application. I created ./.htaccess in my root directory which contains following [EMAIL PROTECTED] ~ $ cat ./http/.htaccess AddHandler fastcgi-script .fcgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L] Also created file: mysite.fcgi #!/usr/bin/python import sys, os # Add a custom Python path. # sys.path.insert(0, "/home/virtwww/w_technobud-com-ua_94216229/TECHNOBUD") # Switch to the directory of your project. (Optional.) # os.chdir("/home/user/myproject") # Set the DJANGO_SETTINGS_MODULE environment variable. os.environ['DJANGO_SETTINGS_MODULE'] = "TECHNOBUD.settings" from django.core.servers.fastcgi import runfastcgi runfastcgi(method="threaded", daemonize="false") But when I am trying to access my web server using browser, I am getting contents of mysite.fsgi instead of site The django project (TECHNOBUD is located in my home directory) Please help me... Need to host it urgently Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Running Django on a shared-hosting provider with Apache in fcgi mode
Well, when I am trying to do it, I am getting 500 Error (shown in console) Status: 500 INTERNAL SERVER ERROR Content-Type: text/html http://www.w3.org/TR/html 4/loose.dtd"> TemplateDoesNotExist at /
Re: Running Django on a shared-hosting provider with Apache in fcgi mode
Also [EMAIL PROTECTED] ~/TECHNOBUD $ python manage.py runfcgi > text.txt WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! On Tue, Nov 25, 2008 at 8:42 PM, Oleg Oltar <[EMAIL PROTECTED]> wrote: > Well, when I am trying to do it, I am getting 500 Error (shown in console) > Status: 500 INTERNAL SERVER ERROR > Content-Type: text/html > > > http://www.w3.org/TR/html > 4/loose.dtd"> > > > > TemplateDoesNotExist at / >
Re: Running Django on a shared-hosting provider with Apache in fcgi mode
Aha, the 500 Error was template missconfiguredNow I am getting my homeage printed in console when running command, but still need to ser WSGI PARAMS Please help On Tue, Nov 25, 2008 at 8:43 PM, Oleg Oltar <[EMAIL PROTECTED]> wrote: > Also > [EMAIL PROTECTED] ~/TECHNOBUD $ python manage.py runfcgi > > text.txt > WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! > WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! > WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! > WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! > > > > On Tue, Nov 25, 2008 at 8:42 PM, Oleg Oltar <[EMAIL PROTECTED]> wrote: > >> Well, when I am trying to do it, I am getting 500 Error (shown in console) >> Status: 500 INTERNAL SERVER ERROR >> Content-Type: text/html >> >> >> > http://www.w3.org/TR/html >> 4/loose.dtd"> >> >> >> >> TemplateDoesNotExist at / >>
Please help me with static files serving
Hi! I am trying to setup django to use static files for development purposes. I used http://docs.djangoproject.com/en/dev/howto/static-files/ But actually failed to serve anything :( My urls.py urlpatterns = patterns('django.views.generic.simple', (r'','direct_to_template',{'template':'index.html'}), ) if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P.*)$','django.views.static.serve', {'\ document_root': '/Users/oleg/media/spilka/'}), ) But needed media is not loaded, e.g. `-- spilka |-- css | `-- styles.css And http://127.0.0.1:8000/media/css/styles.css gives Page not found: /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/css/styles.css Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Please help me with static files serving
That did the trick :) Works now! Thanks On Tue, Dec 9, 2008 at 9:38 AM, Jeff Anderson <[EMAIL PROTECTED]>wrote: > Oleg Oltar wrote: > > Hi! > > > > I am trying to setup django to use static files for development purposes. > > I used http://docs.djangoproject.com/en/dev/howto/static-files/ > > > > But actually failed to serve anything :( > > > > My urls.py > > > > urlpatterns = patterns('django.views.generic.simple', > > > > (r'','direct_to_template',{'template':'index.html'}), > >) > > if settings.DEBUG: > > urlpatterns += patterns('', > > (r'^media/(?P.*)$','django.views.static.serve', {'\ > > document_root': '/Users/oleg/media/spilka/'}), > > ) > > > > But needed media is not loaded, e.g. > > > > `-- spilka > > |-- css > > | `-- styles.css > > > > And http://127.0.0.1:8000/media/css/styles.css > > gives Page not found: > > > /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/css/styles.css > You've run into a "gotcha" with your MEDIA_URL and ADMIN_MEDIA_PREFIX. > Basically the development server will add the static file view > automatically based on the ADMIN_MEDIA_PREFIX url. This is set to > '/media' so your own media URL is passed, and it is trying to serve the > files from the admin media. > > One way to fix this is to change your url from /media to something else, > and leave all the admin media at /media. Usually what I do is change the > ADMIN_MEDIA to something else. '/admin/media' makes sense to me, so > that's usually what I set it to. Some people set their MEDIA_URL url to > something like '/static'. Another logical way to set the URLs is to have > MEDIA_URL be '/media' and ADMIN_MEDIA_PREFIX set to '/media/admin' > > Hopefully this is helpful and makes sense! > > > Jeff Anderson > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to add tinyMCE to django 1.0.2 admin
Hi! I want to add tinyMCE to my project's admin site. I downloaded the latest version of the editor, added the js/tiny_mce to my media files Added following to my urls.py from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('django.views.generic.simple', (r'^contacts$', 'direct_to_template',{'template':'visitcard/contacts.html'} ), (r'^construction$', 'direct_to_template',{'template':'visitcard/construction.html'}), (r'^portfolio1$', 'direct_to_template',{'template':'visitcard/portfolio.html'}), (r'^partners$', 'direct_to_template',{'template':'visitcard/partners.html'}), (r'^articles$', 'direct_to_template',{'template':'visitcard/artilcles.html'}), (r'^portfolio$', 'direct_to_template',{'template':'visitcard/portfolio1.html'}), (r'^dom_karkasnij$', 'direct_to_template', {'template':'visitcard/dom_karkas.html'}), (r'^$', 'direct_to_template',{'template':'visitcard/index.html'} ), ) urlpatterns += patterns('', (r'^tiny_mce/(?P.*)$','django.views.static.serve', {'document_root': '/Users/oleg/Desktop/TECHNOBUD/TEMPLATES/static_media/js/tiny_mce' }), (r'^admin/', include('cms.admin_urls')), (r'^admin/(.*)', admin.site.root), ) Also created the config for tinyMCE: textareas.js tinyMCE.init({ mode : "textareas", theme : "advanced", //content_css : "/appmedia/blog/style.css", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_buttons1 : "fullscreen,separator,preview,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,separator,image,cleanup,help,separator,code", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", auto_cleanup_word : true, plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,fullscreen", plugin_insertdate_dateFormat : "%m/%d/%Y", plugin_insertdate_timeFormat : "%H:%M:%S", extended_valid_elements : "a[name|href|target=_blank|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", fullscreen_settings : { theme_advanced_path_location : "top", theme_advanced_buttons1 : "fullscreen,separator,preview,separator,cut,copy,paste,separator,undo,redo,separator,search,replace,separator,code,separator,cleanup,separator,bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,help", theme_advanced_buttons2 : "removeformat,styleselect,formatselect,fontselect,fontsizeselect,separator,bullist,numlist,outdent,indent,separator,link,unlink,anchor", theme_advanced_buttons3 : "sub,sup,separator,image,insertdate,inserttime,separator,tablecontrols,separator,hr,advhr,visualaid,separator,charmap,emotions,iespell,flash,separator,print" } }); My models file: from django.db import models class Article(models.Model): title = models.CharField(max_length=60) body = models.TextField(max_length=3000) slug = models.SlugField(unique=True) The editor is still not appearing on my admin interface, when I am trying to add articles... Did I miss something? Please help me to understand the problem Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 add tinyMCE to django 1.0.2 admin
Ok, I read the doc...But not sure if I done everything correctly, as the tinyMCE is still not in my admin So what I've done: beryl:TECHNOBUD oleg$ cp /Users/oleg/src/django1.0/django/contrib/admin/templates/admin/change_form.html ./TEMPLATES/admin/ Then I edited copied file and added: tinyMCE.init({ mode: "textareas", theme:"simple" }); after the line: (I read this solution in practical-django-projects book) That's all what I've done so far. But the editor still didn't appear Thanks, Oleg On Wed, Jan 14, 2009 at 12:18 AM, Brian Neal wrote: > > On Jan 13, 3:43 pm, "Oleg Oltar" wrote: > > Hi! > > > > I want to add tinyMCE to my project's admin site. > > You didn't list any admin.py code. Check out the docs on the admin > interface: > > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django.contrib.admin > > After you read through that, pay attention to the ModelAdmin media > definitions: > > > http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-media-definitions > > It is there you specify the tinymce javascript files. When the admin > displays the form for your models it will generate the appropriate > script tags to the javascript files. > > Good luck! > BN > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 add tinyMCE to django 1.0.2 admin
Also my admin code is from TECHNOBUD.visitcard.models import Article from django.contrib import admin admin.site.register(Article) Need help :( I tried to do everything from the beginning, so started a new project. I added there django tiny_mce application. I added these code to my settings file: TINYMCE_JS_URL='http://127.0.0.1:8000/smedia/js/tiny_mce/tiny_mce_src.js' TINYMCE_DEFAULT_CONFIG={ 'theme': 'advanced', 'mode': 'textareas', } Also added a line to urls: (r'^tinymce/', include('tinymce.urls')), But still, not sure how to make my fields be represented by the mce Please help! On Wed, Jan 14, 2009 at 9:26 AM, Oleg Oltar wrote: > Ok, I read the doc...But not sure if I done everything correctly, as the > tinyMCE is still not in my admin > > So what I've done: > > beryl:TECHNOBUD oleg$ cp > /Users/oleg/src/django1.0/django/contrib/admin/templates/admin/change_form.html > ./TEMPLATES/admin/ > > Then I edited copied file and added: > > > > tinyMCE.init({ > mode: "textareas", > theme:"simple" > }); > > > after the line: > > > > (I read this solution in practical-django-projects book) > > > > That's all what I've done so far. But the editor still didn't appear > > Thanks, > Oleg > > On Wed, Jan 14, 2009 at 12:18 AM, Brian Neal wrote: > >> >> On Jan 13, 3:43 pm, "Oleg Oltar" wrote: >> > Hi! >> > >> > I want to add tinyMCE to my project's admin site. >> >> You didn't list any admin.py code. Check out the docs on the admin >> interface: >> >> >> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django.contrib.admin >> >> After you read through that, pay attention to the ModelAdmin media >> definitions: >> >> >> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-media-definitions >> >> It is there you specify the tinymce javascript files. When the admin >> displays the form for your models it will generate the appropriate >> script tags to the javascript files. >> >> Good luck! >> BN >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 add tinyMCE to django 1.0.2 admin
yep, trying it But still not sure how to add it to admin On Wed, Jan 14, 2009 at 10:54 AM, izzy_dizzy wrote: > > Try using django-tiny_mce > > Here's its documentation: > http://django-tinymce.googlecode.com/svn/tags/release-1.2/docs/.build/html/index.html > > > > On Jan 14, 3:26 pm, "Oleg Oltar" wrote: > > Ok, I read the doc...But not sure if I done everything correctly, as the > > tinyMCE is still not in my admin > > > > So what I've done: > > > > beryl:TECHNOBUD oleg$ cp > > > /Users/oleg/src/django1.0/django/contrib/admin/templates/admin/change_form.html > > ./TEMPLATES/admin/ > > > > Then I edited copied file and added: > > > > > > > > tinyMCE.init({ > > mode: "textareas", > > theme:"simple"}); > > > > > > > > after the line: > > > > > > > > (I read this solution in practical-django-projects book) > > > > That's all what I've done so far. But the editor still didn't appear > > > > Thanks, > > Oleg > > > > On Wed, Jan 14, 2009 at 12:18 AM, Brian Neal wrote: > > > > > On Jan 13, 3:43 pm, "Oleg Oltar" wrote: > > > > Hi! > > > > > > I want to add tinyMCE to my project's admin site. > > > > > You didn't list any admin.py code. Check out the docs on the admin > > > interface: > > > > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#module-django. > .. > > > > > After you read through that, pay attention to the ModelAdmin media > > > definitions: > > > > >http://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-me. > .. > > > > > It is there you specify the tinymce javascript files. When the admin > > > displays the form for your models it will generate the appropriate > > > script tags to the javascript files. > > > > > Good luck! > > > BN > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 add tinyMCE to django 1.0.2 admin
it, worked! thanks everyone! On Wed, Jan 14, 2009 at 3:40 PM, kamil wrote: > > Hi Oleg > > You must create your admin config eg: > > class ArticleOptions(admin.ModelAdmin): > >class Media: >js = ('/static_media/js/tiny_mce/tiny_mce.js', '/static_media/ > js/textareas.js') > > > Please check if it correspond to your urs. > good luck > kamil > > On Jan 13, 9:43 pm, "Oleg Oltar" wrote: > > Hi! > > > > I want to add tinyMCE to my project's admin site. I downloaded the latest > > version of the editor, added the js/tiny_mce to my media files > > > > Added following to my urls.py > > from django.conf.urls.defaults import * > > > > # Uncomment the next two lines to enable the admin: > > from django.contrib import admin > > admin.autodiscover() > > > > urlpatterns = patterns('django.views.generic.simple', > >(r'^contacts$', > > 'direct_to_template',{'template':'visitcard/contacts.html'} ), > >(r'^construction$', > > 'direct_to_template',{'template':'visitcard/construction.html'}), > >(r'^portfolio1$', > > 'direct_to_template',{'template':'visitcard/portfolio.html'}), > >(r'^partners$', > > 'direct_to_template',{'template':'visitcard/partners.html'}), > >(r'^articles$', > > 'direct_to_template',{'template':'visitcard/artilcles.html'}), > >(r'^portfolio$', > > 'direct_to_template',{'template':'visitcard/portfolio1.html'}), > >(r'^dom_karkasnij$', 'direct_to_template', > > {'template':'visitcard/dom_karkas.html'}), > >(r'^$', > > 'direct_to_template',{'template':'visitcard/index.html'} ), > > > >) > > > > urlpatterns += patterns('', > > > > (r'^tiny_mce/(?P.*)$','django.views.static.serve', > > {'document_root': > > '/Users/oleg/Desktop/TECHNOBUD/TEMPLATES/static_media/js/tiny_mce' }), > > (r'^admin/', include('cms.admin_urls')), > > (r'^admin/(.*)', admin.site.root), > > ) > > > > Also created the config for tinyMCE: textareas.js > > tinyMCE.init({ > > mode : "textareas", > > theme : "advanced", > > //content_css : "/appmedia/blog/style.css", > > theme_advanced_toolbar_location : "top", > > theme_advanced_toolbar_align : "left", > > theme_advanced_buttons1 : > > > "fullscreen,separator,preview,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,separator,image,cleanup,help,separator,code", > > theme_advanced_buttons2 : "", > > theme_advanced_buttons3 : "", > > auto_cleanup_word : true, > > plugins : > > > "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu,fullscreen", > > plugin_insertdate_dateFormat : "%m/%d/%Y", > > plugin_insertdate_timeFormat : "%H:%M:%S", > > extended_valid_elements : > > > "a[name|href|target=_blank|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", > > fullscreen_settings : { > > theme_advanced_path_location : "top", > > theme_advanced_buttons1 : > > > "fullscreen,separator,preview,separator,cut,copy,paste,separator,undo,redo,separator,search,replace,separator,code,separator,cleanup,separator,bold,italic,underline,strikethrough,separator,forecolor,backcolor,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,help", > > theme_advanced_buttons2 : > > > "removeformat,styleselect,formatselect,fontselect,fontsizeselect,separator,bullist,numlist,outdent,indent,separator,link,unlink,anchor", > > theme_advanced_buttons3 : > > > "sub,sup,separator,image,insertdate,inserttime,separator,tablecontrols,separator,hr,advhr,visualaid,separator,charmap,emotions,iespell,flash,separator,print" > > } > > > > }); > > > > My models file: > > from django.db import models > > > > class Article(models.Model): > > title = models.CharField(max_length=60) > > body = models.TextField(max_length=3000) > > slug = models.SlugField(unique=True) > > > > The editor is still not appearing on my admin interface, when I am trying > to > > add articles... Did I miss something? Please help me to understand the > > problem > > > > Thanks, > > Oleg > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Error when Resending forgotten password
Hi! I am getting a strange error when trying to reset, forgotten password. I am using it this way # Password resend group (r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', 'django.contrib.auth.views.password_reset_confirm', {'template_name':'registration/password_reset_confirm.html'}), (r'^resend/$', 'django.contrib.auth.views.password_reset', {'template_name':'registration/password_reset_form.html', 'email_template_name':'registration/password_reset_email.html', 'post_reset_redirect':'/'}), ) The error Environment: Request Method: POST Request URL: http://127.0.0.1:8000/resend/ Django Version: 1.0.2 final Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'loginregister.loginreg'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.5/site-packages/django/contrib/auth/views.py" in password_reset 92. form.save(**opts) File "/usr/local/lib/python2.5/site-packages/django/contrib/auth/forms.py" in save 135. t.render(Context(c)), None, [user.email]) File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in send_mail 345. connection=connection).send() File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in send 271. return self.get_connection(fail_silently).send_messages([self]) File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in send_messages 166. new_conn_created = self.open() File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in open 131. local_hostname=DNS_NAME.get_fqdn()) File "/usr/local/lib/python2.5/smtplib.py" in __init__ 244. (code, msg) = self.connect(host, port) File "/usr/local/lib/python2.5/smtplib.py" in connect 310. raise socket.error, msg Exception Type: error at /resend/ Exception Value: (49, "Can't assign requested address") Can you please help me to understand the problem? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Error when Resending forgotten password
What the should be look like? Is there any example? Is it at all possible to send email from local working machine? On Fri, Jan 23, 2009 at 8:45 AM, Alex Koshelev wrote: > Try to check your EMAIL_ settings. > > > > On Fri, Jan 23, 2009 at 8:55 AM, Oleg Oltar wrote: > >> Hi! I am getting a strange error when trying to reset, forgotten password. >> I am using it this way >> >># Password resend group >> >> (r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', >> 'django.contrib.auth.views.password_reset_confirm', >> {'template_name':'registration/password_reset_confirm.html'}), >> >>(r'^resend/$', >> 'django.contrib.auth.views.password_reset', >> {'template_name':'registration/password_reset_form.html', >> 'email_template_name':'registration/password_reset_email.html', >> 'post_reset_redirect':'/'}), >>) >> >> >> The error >> >> Environment: >> >> Request Method: POST >> Request URL: http://127.0.0.1:8000/resend/ >> Django Version: 1.0.2 final >> Python Version: 2.5.2 >> Installed Applications: >> ['django.contrib.auth', >> 'django.contrib.contenttypes', >> 'django.contrib.sessions', >> 'django.contrib.sites', >> 'loginregister.loginreg'] >> Installed Middleware: >> ('django.middleware.common.CommonMiddleware', >> 'django.contrib.sessions.middleware.SessionMiddleware', >> 'django.contrib.auth.middleware.AuthenticationMiddleware') >> >> >> Traceback: >> File "/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py" >> in get_response >> 86. response = callback(request, *callback_args, >> **callback_kwargs) >> File "/usr/local/lib/python2.5/site-packages/django/contrib/auth/views.py" >> in password_reset >> 92. form.save(**opts) >> File "/usr/local/lib/python2.5/site-packages/django/contrib/auth/forms.py" >> in save >> 135. t.render(Context(c)), None, [user.email]) >> File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in >> send_mail >> 345. connection=connection).send() >> File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in send >> 271. return >> self.get_connection(fail_silently).send_messages([self]) >> File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in >> send_messages >> 166. new_conn_created = self.open() >> File "/usr/local/lib/python2.5/site-packages/django/core/mail.py" in open >> 131. >> local_hostname=DNS_NAME.get_fqdn()) >> File "/usr/local/lib/python2.5/smtplib.py" in __init__ >> 244. (code, msg) = self.connect(host, port) >> File "/usr/local/lib/python2.5/smtplib.py" in connect >> 310. raise socket.error, msg >> >> Exception Type: error at /resend/ >> Exception Value: (49, "Can't assign requested address") >> >> >> Can you please help me to understand the problem? >> >> Thanks, >> Oleg >> >> >> > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Reverse match Exception on password_reset_confirm
Hi! I am trying to add password reset function to my application. But when I am trying to process the email with confirmation link: code: # Password resend group (r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', 'django.contrib.auth.views.password_reset_confirm'), Also I copied template reset_password_confirm.html to my register/ folder in my templates But when I am trying to process the url = http://localhost:8000/reset/1-29s-f1e5514c29ac724ad0c2/ Getting NoReverseMatch at /reset/1-29s-f1e5514c29ac724ad0c2/ Reverse for '' with arguments '()' and keyword arguments '{}' not found. Request Method:GETRequest URL: http://localhost:8000/reset/1-29s-f1e5514c29ac724ad0c2/Exception Type: NoReverseMatchException Value: Reverse for '' with arguments '()' and keyword arguments '{}' not found. Exception Location:/usr/local/lib/python2.5/site-packages/django/core/urlresolvers.py in reverse, line 243Python Executable:/usr/bin/pythonPython Version:2.5.2Python Path:['/Users/oleg/Sites/loginregister', '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', '/usr/local/lib/python2.5/site-packages/HarvestMan-2.0.4betadev-py2.5.egg', '/usr/local/lib/python2.5/site-packages/pyparsing-1.5.1-py2.5.egg', '/usr/local/lib/python2.5/site-packages/sgmlop-1.1.1_20040207-py2.5-macosx-10.3-i386.egg', '/Users/oleg/Sites', '/Users/oleg/devnavikola', '/Users/oleg/Sites/loginregister', '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/local/lib/python2.5/plat-mac/lib-scriptpackages', '/usr/local/lib/python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/PIL']Server time:Fri, 23 Jan 2009 13:50:13 -0600 PLEASE HELP!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to access mail.outbox
Hi! I am trying to write nose tests for my django application. One of the points is to check if emails are sent properly. The suggested in the doc way( http://docs.djangoproject.com/en/dev/topics/testing/#django.core.mail.django.core.mail.outbox) it to check it is to use mail.outbox variable But it's actually created by test runner only http://code.djangoproject.com/browser/django/tags/releases/1.0.2/docs/topics/testing.txt . The ``outbox`` attribute is a special attribute that is created *only* when the tests are run. It doesn't normally exist as part of the :mod:`django.core.mail` module and you can't import it directly. So there is no way to check this with nose? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django docs and automation tests
Hi! Can you please explain me idea of testing django applications with Client() There many examples in doc, where test cases just checked the response.status_code == 200, But I am often getting 302 instead of 200. Is there any workaround in this case? thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Unicode error
Hi. I want to use django admin, for adding articles into my db. My language is Russian. I defined model in the following way: from django.db import models from tinymce import models as tinymce_models class Article(models.Model): title = models.CharField(max_length=60) body = tinymce_models.HTMLField() slug = models.SlugField(unique=True) def get_absolute_url(self): return "/article/%s/" % self.slug def __str__(self): return 'Title: %s' %(self.title) But when I am trying to add an article from django admin I am getting UnicodeEncodeError at /admin/visitcard/article/add/ 'ascii' codec can't encode characters in position 7-13: ordinal not in range(128) How can I encode those fields added from the admin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Unicode error
THANKS On Mon, Jan 26, 2009 at 10:21 PM, Daniel Roseman < roseman.dan...@googlemail.com> wrote: > > On Jan 26, 8:08 pm, Oleg Oltar wrote: > > Hi. > > I want to use django admin, for adding articles into my db. My language > is > > Russian. > > > > I defined model in the following way: > > > > from django.db import models > > from tinymce import models as tinymce_models > > > > class Article(models.Model): > > title = models.CharField(max_length=60) > > body = tinymce_models.HTMLField() > > slug = models.SlugField(unique=True) > > > > def get_absolute_url(self): > > return "/article/%s/" % self.slug > > > > def __str__(self): > > return 'Title: %s' %(self.title) > > > > But when I am trying to add an article from django admin I am getting > > > > UnicodeEncodeError at /admin/visitcard/article/add/ > > > > 'ascii' codec can't encode characters in position 7-13: ordinal not in > > range(128) > > > > How can I encode those fields added from the admin > > Assuming you're using a version of Django greater than 0.96, you > should define __unicode__, not __str__, and ensure that you return a > unicode string from that method. > > def __unicode__(self): >return u'Title: %s' % self.title > > -- > DR. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Extending User with a profile
Hi! I want to add a profile to every user, that I can register in my application. In future it should contain such fields as avatar, email, about_me fields I found a snippet how to extend django User model: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ But when added the proposed code to my view: (so now it looks like this) from django.contrib.auth.models import User class UserProfile(models.Model): url = models.URLField about = models.TextField() user = models.ForeignKey(User, unique=True) I caught an exception on syncdb class UserProfile(models.Model): File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", line 80, in __new__ new_class.add_to_class(obj_name, obj) File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", line 164, in add_to_class value.contribute_to_class(cls, name) TypeError: Error when calling the metaclass bases unbound method contribute_to_class() must be called with URLField instance as first argument (got ModelBase instance instead) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Extending User with a profile
Os my bug. It was a mistype in a model. Exception gone now On Tue, Jan 27, 2009 at 8:43 PM, Oleg Oltar wrote: > Hi! > I want to add a profile to every user, that I can register in my > application. In future it should contain such fields as avatar, email, > about_me fields > > I found a snippet how to extend django User model: > http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ > > But when added the proposed code to my view: > (so now it looks like this) > from django.contrib.auth.models import User > > > class UserProfile(models.Model): > url = models.URLField > about = models.TextField() > user = models.ForeignKey(User, unique=True) > > > I caught an exception on syncdb > >class UserProfile(models.Model): > File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", > line 80, in __new__ > new_class.add_to_class(obj_name, obj) > File "/usr/local/lib/python2.5/site-packages/django/db/models/base.py", > line 164, in add_to_class > value.contribute_to_class(cls, name) > TypeError: Error when calling the metaclass bases > unbound method contribute_to_class() must be called with URLField > instance as first argument (got ModelBase instance instead) > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Creating test databases. Nose framework
Hi! I am trying to create few nose test for my application. I need to test registration/login, so want to create a test sqlite3 database, and pre-populate it with some data. No sure how to do it. I created a setup method: def setup(): setup_test_environment() create_test_db() But getting an exception on from django.db.backends.creation import create_test_db Please help me to find it out how to use the create_test_db function to create the db Also. How to add some data there without running tests first? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Article lists
Hi! I'm planing to add an article list to my application. The idea is to show every article stored in the database but in a truncated way. So I used the following template tags to produce the list {% autoescape off %} {% for article in list_of_articles %} {{article.title}} {{article.body|truncatewords:120}} {% endfor %} {% endautoescape %} But have few questions about how to extend the result. 1. truncatewords filter produces "...", is there a way I can change it to 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-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: Creating test databases. Nose framework
thanks for the doc. So if I have to store a User object in db (with fields (name, email, pass) How should I define the fixture? Should I define it in setup? Also, is there a way I can actually create the test db. Still can't import create_test_db :( On Wed, Jan 28, 2009 at 12:49 AM, Jeff Hammerbacher wrote: > Hey Oleg, > > To load some sample data for your tests, see Django's documentation on > fixtures: > http://docs.djangoproject.com/en/dev/topics/testing/#fixture-loading. > > Later, > Jeff > > > On Tue, Jan 27, 2009 at 1:05 PM, Karen Tracey wrote: > >> On Tue, Jan 27, 2009 at 3:51 PM, Oleg Oltar wrote: >> >>> Hi! >>> I am trying to create few nose test for my application. >>> I need to test registration/login, so want to create a test sqlite3 >>> database, and pre-populate it with some data. >>> No sure how to do it. >>> >>> I created a setup method: >>> def setup(): >>> setup_test_environment() >>> create_test_db() >>> >>> But getting an exception on from django.db.backends.creation import >>> create_test_db >>> >>> Please help me to find it out how to use the create_test_db function to >>> create the db >>> >>> Also. How to add some data there without running tests first? >>> >>> >> I know nothing of nose, but: >> >> http://www.assembla.com/wiki/show/nosedjango >> >> says it is a plugin for nosetests that supports fixture loading & test >> database setup and teardown, which seems to be what you are looking for? >> >> Karen >> >> >> > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Creating test databases. Nose framework
Can't find how to add predefined data to the db. Sorry for being silly, maybe someone can point me? Please On Wed, Jan 28, 2009 at 2:45 AM, Russell Keith-Magee wrote: > > On Wed, Jan 28, 2009 at 5:51 AM, Oleg Oltar wrote: > > Hi! > > I am trying to create few nose test for my application. > > I need to test registration/login, so want to create a test sqlite3 > > database, and pre-populate it with some data. > > No sure how to do it. > > I created a setup method: > > def setup(): > > setup_test_environment() > > create_test_db() > > But getting an exception on from django.db.backends.creation import > > create_test_db > > create_test_db() is a method on creation object, not a method to be > imported from the creation module. Invocation is: > > from django.db import connection > connection.creation.create_test_db() > > See django.test.simple.run_tests() for a full working example. > > Yours > Russ Magee %-) > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Creating test databases. Nose framework
Any idea? On Wed, Jan 28, 2009 at 11:41 AM, Oleg Oltar wrote: > Can't find how to add predefined data to the db. Sorry for being silly, > maybe someone can point me? > Please > > > On Wed, Jan 28, 2009 at 2:45 AM, Russell Keith-Magee < > freakboy3...@gmail.com> wrote: > >> >> On Wed, Jan 28, 2009 at 5:51 AM, Oleg Oltar >> wrote: >> > Hi! >> > I am trying to create few nose test for my application. >> > I need to test registration/login, so want to create a test sqlite3 >> > database, and pre-populate it with some data. >> > No sure how to do it. >> > I created a setup method: >> > def setup(): >> > setup_test_environment() >> > create_test_db() >> > But getting an exception on from django.db.backends.creation import >> > create_test_db >> >> create_test_db() is a method on creation object, not a method to be >> imported from the creation module. Invocation is: >> >> from django.db import connection >> connection.creation.create_test_db() >> >> See django.test.simple.run_tests() for a full working example. >> >> Yours >> Russ Magee %-) >> >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Changing database fields
Hi! I am creating my first application. Which is to be a small publishing system. I defined a model, which represent a single article, and also added about 15 articles to my database (which is sqlite3). Now I understand that I should extend my models with few more fields (e.g. need to add categories and date_published). I thought that can simply add those to my models, but then realized that I need to modify already created fields... Is there a common practice to do it? Maybe some recipe? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Creating test databases. Nose framework
> > Generally, you'll want to wait more than 6 hours before asking again. A > couple of days, at least, would be a reasonable period. > Sorry...Will note On Thu, Jan 29, 2009 at 2:54 AM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Wed, 2009-01-28 at 17:19 +0200, Oleg Oltar wrote: > > Any idea? > > Generally, you'll want to wait more than 6 hours before asking again. A > couple of days, at least, would be a reasonable period. > > > On Wed, Jan 28, 2009 at 11:41 AM, Oleg Oltar > > wrote: > > Can't find how to add predefined data to the db. Sorry for > > being silly, maybe someone can point me? > > Add it just like you normally add objects to the database. Create them > in the test setup methods and save them. Or load them up with raw SQL. > > Regards, > Malcolm > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Nosetests. maximum recursion depth exceeded
Hi! I am creating one of my firsts django projects. I created nose tests to cover my application and got 100% code coverage My repo is git://github.com/oltarasenko/usermanaging.git Now I am trying to modify my project to make settings be platform independent. So I added following lines to my settings.py: # Django settings for loginregister project. import os.path import sys PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) DATABASE_NAME = os.path.join(PROJECT_ROOT, 'users.db') # Or path to database file if using sqlite3. ROOT_URLCONF = 'urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. os.path.join(PROJECT_ROOT, 'templates') ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.admin', 'django.contrib.sessions', 'django.contrib.sites', 'loginreg' ) Now when I run my application everything seems to work! Everything but my nosetests which returns long trace for me which contains one line (displayed many times): sub_match = pattern.resolve(new_path) File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 181, in resolve sub_match = pattern.resolve(new_path) File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 181, in resolve sub_match = pattern.resolve(new_path) File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", line 179, in resolve for pattern in self.urlconf_module.urlpatterns: RuntimeError: maximum recursion depth exceeded (I use: beryl:db_settings oleg$ nosetests --cover-package=loginreg --with-coverageto run tests) Could anyone suggest why I am getting it? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Nosetests. maximum recursion depth exceeded
Why it worked before I tried to change settings.py? Why actually site works? Maybe something is in my tests? Btw, my code organized this way: /proj urls.py settings ./app tests.py urls.py As I changed the project name I also hacked the tests file so now it contains following: import os import re os.environ['PYTHNONPATH'] = '$PYTHONPATH:$PWD' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # Is this correct? I presume that the second line is incorrect. Where it looks for the settings? On Tue, Feb 3, 2009 at 7:08 PM, Steve Holden wrote: > > Oleg Oltar wrote: > [...] > > > > sub_match = pattern.resolve(new_path) > > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", > > line 181, in resolve > > sub_match = pattern.resolve(new_path) > > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", > > line 181, in resolve > > sub_match = pattern.resolve(new_path) > > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", > > line 179, in resolve > > for pattern in self.urlconf_module.urlpatterns: > > RuntimeError: maximum recursion depth exceeded > > > > (I use: beryl:db_settings oleg$ nosetests --cover-package=loginreg > > --with-coverageto run tests) > > > > > > > > Could anyone suggest why I am getting it? > > > Is something doing a 301 redirection to itself, possibly? > > regards > Steve > -- > Steve Holden+1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Nosetests. maximum recursion depth exceeded
Seems no :( I tried to manually specify correct path os.environ['DJANGO_SETTINGS_MODULE'] = 'db_settings.settings' but have same issue :( (NOTE, i didn't create it with startpoject command, I just cloned project from repo. May it help to understand the issue?) On Tue, Feb 3, 2009 at 8:59 PM, Oleg Oltar wrote: > Why it worked before I tried to change settings.py? Why actually site > works? > Maybe something is in my tests? > > Btw, my code organized this way: > > /proj >urls.py >settings > ./app > tests.py > urls.py > > > As I changed the project name I also hacked the tests file so now it > contains following: > import os > import re > > > > os.environ['PYTHNONPATH'] = '$PYTHONPATH:$PWD' > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # Is this correct? > > > I presume that the second line is incorrect. Where it looks for the > settings? > > On Tue, Feb 3, 2009 at 7:08 PM, Steve Holden wrote: > >> >> Oleg Oltar wrote: >> [...] >> > >> > sub_match = pattern.resolve(new_path) >> > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", >> > line 181, in resolve >> > sub_match = pattern.resolve(new_path) >> > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", >> > line 181, in resolve >> > sub_match = pattern.resolve(new_path) >> > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", >> > line 179, in resolve >> > for pattern in self.urlconf_module.urlpatterns: >> > RuntimeError: maximum recursion depth exceeded >> > >> > (I use: beryl:db_settings oleg$ nosetests --cover-package=loginreg >> > --with-coverageto run tests) >> > >> > >> > >> > Could anyone suggest why I am getting it? >> > >> Is something doing a 301 redirection to itself, possibly? >> >> regards >> Steve >> -- >> Steve Holden+1 571 484 6266 +1 800 494 3119 >> Holden Web LLC http://www.holdenweb.com/ >> >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Nosetests. maximum recursion depth exceeded
Well seems I found the solution. I just moved the project folder in my repo (so now we have repo->myproject), so the name myproject will not change after cloning, and now it all works Any idea why? On Tue, Feb 3, 2009 at 9:05 PM, Oleg Oltar wrote: > Seems no :( > I tried to manually specify correct path > os.environ['DJANGO_SETTINGS_MODULE'] = 'db_settings.settings' > but have same issue :( > > (NOTE, i didn't create it with startpoject command, I just cloned project > from repo. May it help to understand the issue?) > > > On Tue, Feb 3, 2009 at 8:59 PM, Oleg Oltar wrote: > >> Why it worked before I tried to change settings.py? Why actually site >> works? >> Maybe something is in my tests? >> >> Btw, my code organized this way: >> >> /proj >>urls.py >>settings >> ./app >> tests.py >> urls.py >> >> >> As I changed the project name I also hacked the tests file so now it >> contains following: >> import os >> import re >> >> >> >> os.environ['PYTHNONPATH'] = '$PYTHONPATH:$PWD' >> os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # Is this correct? >> >> >> I presume that the second line is incorrect. Where it looks for the >> settings? >> >> On Tue, Feb 3, 2009 at 7:08 PM, Steve Holden wrote: >> >>> >>> Oleg Oltar wrote: >>> [...] >>> > >>> > sub_match = pattern.resolve(new_path) >>> > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", >>> > line 181, in resolve >>> > sub_match = pattern.resolve(new_path) >>> > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", >>> > line 181, in resolve >>> > sub_match = pattern.resolve(new_path) >>> > File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py", >>> > line 179, in resolve >>> > for pattern in self.urlconf_module.urlpatterns: >>> > RuntimeError: maximum recursion depth exceeded >>> > >>> > (I use: beryl:db_settings oleg$ nosetests --cover-package=loginreg >>> > --with-coverageto run tests) >>> > >>> > >>> > >>> > Could anyone suggest why I am getting it? >>> > >>> Is something doing a 301 redirection to itself, possibly? >>> >>> regards >>> Steve >>> -- >>> Steve Holden+1 571 484 6266 +1 800 494 3119 >>> Holden Web LLC http://www.holdenweb.com/ >>> >>> >>> >>> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Processing multiple forms on one page
Hi! I am writing a small application for user profile management. I need to display and to process output from 2 form on the page of own profile. How can I do it? 1. Form if to change avatar. (Contains browse and upload buttons) 2. Form is for changing user details, e.g. info field, or maybe emails I want these form to be processed independently. E.g. user can submit one without filling another. I have read a post about similar problem here: http://groups.google.com/group/django-users/browse_thread/thread/1ff0909af4e0cdfe but didn't find a solution for me. e.g. if we have following code: if request.method == 'POST': form1 = RegistrationForm(request.POST) form2 = ...(request.POST) How to process them? Mean one of them will be empty, and it means I don't need to return an error in that case. Actually, I need to understand which of them is in post. But how? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Processing multiple forms on one page
Thanks! I will try the first idea, will create separate views. But in this case, I will have to add user authentification code to all 3 views Now it looks like this: def user_profile(request, profile_name): currentUser = request.user owner = get_object_or_404(User, username = profile_name) try: ownersProfile = owner.get_profile() except Exception, e: ownersProfile = UserProfile(user=owner) ownersProfile.save() # This is my profile if owner.username == currentUser.username: if request.method == 'POST': print request print HHHT uploadForm = ProfileAvatarEdit(request.POST, request.FILES) handleUploadedFile(request.FILES['avatar']) return HttpResponseRedirect('.') else: form = ProfileAvatarEdit() data = RequestContext(request, { 'owner' : owner, 'ownersProfile' : ownersProfile, 'form' : form, } ) return render_to_response('registration/profile.html', data) Should I use this if owner.username == currentUser.username: in all 3 views which I will have? On Wed, Jun 24, 2009 at 11:42 AM, Daniel Roseman wrote: > > On Jun 24, 6:45 am, Oleg Oltar wrote: >> Hi! >> >> I am writing a small application for user profile management. >> >> I need to display and to process output from 2 form on the page of own >> profile. How can I do it? >> >> 1. Form if to change avatar. (Contains browse and upload buttons) >> 2. Form is for changing user details, e.g. info field, or maybe emails >> >> I want these form to be processed independently. E.g. user can submit >> one without filling another. >> >> I have read a post about similar problem >> here:http://groups.google.com/group/django-users/browse_thread/thread/1ff0... >> but didn't find a solution for me. >> >> e.g. if we have following code: >> if request.method == 'POST': >> form1 = RegistrationForm(request.POST) >> form2 = ...(request.POST) >> >> How to process them? Mean one of them will be empty, and it means I >> don't need to return an error in that case. >> Actually, I need to understand which of them is in post. But how? >> >> Thanks, >> Oleg > > You need to use the 'prefix' parameter when instantiating the form. > http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms > -- > DR. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
How to handle image uploading in a proper way
Hi! I use a following code: def handleUploadedFile(file): destination = open('%s'%(file.name), 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() return destination I call it from view using this code. handleUploadedFile(request.FILES['avatar']) Have a question is that OK to do it this way? What if something will happen on client/server side and the close() method will not be called? can it be an issue? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Sending JSON response from views
Hi! I am trying to implement something like a jubber web application, using django and flex The server code should send a list of users who's online. Here's how I defined a model class ActiveList(models.Model): STATUS_CHOISES = ( (u'F', u'free'), (u'B', u'busy'), ) user = models.ForeignKey(User, unique=True) status = models.CharField(max_length=2, choices = STATUS_CHOISES) The view look like this def getActiveUsers(request): activeList = ActiveList.objects.all() data = serializers.serialize("json", activeList, fields = (u'user', 'status')) return HttpResponse(data, mimetype='application/json') The question, how can I return username of user in fields. I want the JSON response to contain value user.username instead of id of user oject Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Accessor for field clashes with related field
Hi! I want to create an object that contains 2 links to users. For example class GameClaim(models.Model): target = models.ForeignKey(User) claimer = models.ForeignKey(User) isAccepted = models.BooleanField() but I am getting an error when running server: Accessor for field 'target' clashes with related field 'User.gameclaim_set'. Add a related_name argument to the definition for 'target'. Accessor for field 'claimer' clashes with related field 'User.gameclaim_set'. Add a related_name argument to the definition for 'claimer'. Please explain why I am getting the error and how to fix it? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
ForeignKey drop box modification in admin site
Hi! I have 3 models: categories sections articles Each section is related to some category, and in similar way each article is related to some section: The code looks like this: class Category(models.Model): category = models.CharField(max_length=200) name = models.CharField(max_length = 200, help_text=u"Имя категории") def __unicode__(self): return u"Категория %s" %self.name class Section(models.Model): section = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, blank = True) category = models.ForeignKey(Category, blank=True) def __unicode__(self): return u"%s" %(self.section) class Article (models.Model): url = models.CharField(max_length=200, unique=True) section = models.ForeignKey(Section, blank=True) def __unicode__(self): return u"%s" %(self.section) Currently if I am adding an article from admin site, I can chose a section, but after the quantity of sections on my site grew up, I want to see which section is related to which category. Is there a way to add category name to a list box where, I chose sections for articles Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django testing applications: using fixtures
Django testing application: using fixtures Hi ! I came across strange problem while trying to use mixtures in my unittests For example, I created a fixture from the database: silver:jin oleg$ python manage.py dumpdata > datastored.json Strange, but when the fixture is loaded while the test run I see an error: Problem installing fixture './datastored.json': Traceback (most recent call last): File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/commands/loaddata.py", line 119, in handle obj.save() File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/serializers/base.py", line 163, in save models.Model.save_base(self.object, raw=True) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/base.py", line 362, in save_base rows = manager.filter(pk=pk_val)._update(values) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/query.py", line 435, in _update return query.execute_sql(None) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/sql/subqueries.py", line 117, in execute_sql cursor = super(UpdateQuery, self).execute_sql(result_type) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/sql/query.py", line 1734, in execute_sql cursor.execute(sql, params) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/backends/mysql/base.py", line 83, in execute return self.cursor.execute(query, args) File "build/bdist.macosx-10.3-i386/egg/MySQLdb/cursors.py", line 166, in execute self.errorhandler(self, exc, value) File "build/bdist.macosx-10.3-i386/egg/MySQLdb/connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue IntegrityError: (1062, "Duplicate entry 'goserver-activelist' for key 'app_label'") I tried to check, why it happens, but I can't see any duplication in the json file Could you please take a look, why it happens? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django unittests, django.contrib.admin.sites.AlreadyRegistered error
Hi! I am trying to run unitests for one of my application. Here is the code of the test (it doesn't do anything yet) import os import re #import unittest from django.core import management from django.test import TestCase from django.test.client import Client from django.core import mail from django.test.utils import setup_test_environment from django.contrib.auth.models import User from django.db import connection from goserver.models import ActiveList # class GoserverTestCase(TestCase): #fixtures = ['dat.json'] def setUp(self): pass def test_active_list_works(self): c = Client() c.get('/login/') self.assertEquals(True, True) When I run those tests I get an error: Installing index for goserver.Game model . -- Ran 1 test in 3.497s OK Destroying test database... -- Unit Test Code Coverage Results -- Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/__init__.py", line 340, in execute_manager utility.execute() File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/__init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/base.py", line 192, in run_from_argv self.execute(*args, **options.__dict__) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/base.py", line 219, in execute output = self.handle(*args, **options) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/commands/test.py", line 33, in handle failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive) File "/opt/local/lib/python2.5/site-packages/django_test_coverage-0.1-py2.5.egg/django-test-coverage/runner.py", line 58, in run_tests modules.extend(_package_modules(*pkg)) File "/opt/local/lib/python2.5/site-packages/django_test_coverage-0.1-py2.5.egg/django-test-coverage/runner.py", line 92, in _package_modules modules.append(__import__(impstr + '.' + name, {}, {}, [''])) File "/Users/oleg/jin/goclub/trunk/jin/goserver/admin.py", line 11, in admin.site.register(ActiveList, ActiveListAdmin) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/admin/sites.py", line 64, in register raise AlreadyRegistered('The model %s is already registered' % model.__name__) django.contrib.admin.sites.AlreadyRegistered: The model ActiveList is already registered silver:jin oleg$ >From the coverage module I guess Also, when I remove this line c.get('/login/') So test looks like this class GoserverTestCase(TestCase): #fixtures = ['dat.json'] def setUp(self): pass def test_active_list_works(self): c = Client() self.assertEquals(True, True) There is no error at all Could you please explain the problem? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 testing applications: using fixtures
egister/fixtures' for json fixture 'initial_data'... No json fixture 'initial_data' in '/Users/oleg/jin/goclub/trunk/jin/../jin/register/fixtures'. Checking '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures' for fixtures... Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures' for xml fixture 'initial_data'... No xml fixture 'initial_data' in '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures'. Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures' for json fixture 'initial_data'... No json fixture 'initial_data' in '/Users/oleg/jin/goclub/trunk/jin/../jin/captcha/fixtures'. Checking '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures' for fixtures... Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures' for xml fixture 'initial_data'... No xml fixture 'initial_data' in '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures'. Trying '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures' for json fixture 'initial_data'... No json fixture 'initial_data' in '/Users/oleg/jin/goclub/trunk/jin/../jin/goserver/fixtures'. Checking absolute path for fixtures... Trying absolute path for xml fixture 'initial_data'... No xml fixture 'initial_data' in absolute path. Trying absolute path for json fixture 'initial_data'... No json fixture 'initial_data' in absolute path. No fixtures found. Problem installing fixture 'dat.json': Traceback (most recent call last): File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/management/commands/loaddata.py", line 119, in handle obj.save() File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/serializers/base.py", line 163, in save models.Model.save_base(self.object, raw=True) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/base.py", line 362, in save_base rows = manager.filter(pk=pk_val)._update(values) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/query.py", line 435, in _update return query.execute_sql(None) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/sql/subqueries.py", line 117, in execute_sql cursor = super(UpdateQuery, self).execute_sql(result_type) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models/sql/query.py", line 1734, in execute_sql cursor.execute(sql, params) File "/opt/local/lib/python2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/backends/mysql/base.py", line 83, in execute return self.cursor.execute(query, args) File "build/bdist.macosx-10.3-i386/egg/MySQLdb/cursors.py", line 166, in execute self.errorhandler(self, exc, value) File "build/bdist.macosx-10.3-i386/egg/MySQLdb/connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue IntegrityError: (1062, "Duplicate entry 'goserver-activelist' for key 'app_label'") test_active_list_works (jin.goserver.tests.GoserverTestCase) ... ok -- Ran 1 test in 13.441s OK Destroying test database... -- Unit Test Code Coverage Results -- NameStmts Exec Cover Missing - goserver.__init__ 1 1 100% goserver.admin 6 0 0% 5-12 goserver.helpers 35 0 0% 5-84 goserver.managers 5 360% 15-18 goserver.models28 2589% 30, 43, 61 goserver.tests 17 17 100% goserver.urls 4 0 0% 1-5 goserver.views 56 0 0% 6-133 - TOTAL 152 4630% silver:jin oleg$ On Mon, Sep 7, 2009 at 1:53 PM, Oleg Oltar wrote: > I double checked my fixtures > > Only one is loaded. Here is the log output from the test command > > > > > Also I attached the fixture itself > > > > On Mon, Sep 7, 2009 at 1:41 PM, V wrote: > >> >> do you load several fixtures in your unittest class? >> from the error message, my guess would be that you have two fixtures >> that contain the same model's data, and the model has a unique column >> you can dump data for a specific app only, thus you might avoid such >> problems >> >> bye, V >> >> On Sep 6, 7:21 pm,
Sitemap index examples needed
Hi! I have following models relation: class Section(models.Model): section = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, blank = True) class Article (models.Model): url = models.CharField(max_length = 30, unique=True) is_published = models.BooleanField() section = models.ForeignKey(Section) I need to create a sitemap for articles, which contains sitemap files for sections. I was reading django documentation about it here http://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/ But didn't manage to find answer how can I: 1) Define sitemap class in this case 2) How can I pass section parameters into url file (as it's explained in the docs) 3) From where to get {'sitemaps': sitemaps} if I defined sitemap as a python class in another file in the application --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Encoding question
Hi! One of my tests returned following text () The test: from django.test.client import Client c = Client() resp = c.get("/") resp.content In [25]: resp.content Out[25]: '\r\n\r\n\r\nhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>\r\n\r\nhttp://www.w3.org/1999/xhtml";>\r\n \r\n\r\n \r\n\nJapanese innovation | \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f \xd0\xb8\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8\n\r\n \n\n\n\r\n\r\n Is there a way I can convert it to normal readable text? (I need for example to find a string of text in this response to check if my test case Pass or failed) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Encoding question
It's more then great! Thanks! 2009/9/9 ray > > Hi Oleg > > You can use BeautifulSoup > > from BeautifulSoup import BeautifulSoup > >>> html = '\r\n\r\n\r\n Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>\r\n\r\n xmlns="http://www.w3.org/1999/xhtml";>\r\n \r\n http-equiv="content-type" content="text/html; charset=utf-8" />\r\n\r\n >\nJapanese innovation | > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f > \xd0\xb8\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8\n\r\n >\n content="\xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > \xd0\xa2\xd0\xb5\xd1\x85\xd0\xbd\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xb3\xd0\xb8\xd0\xb8, > \xd0\x98\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8, > \xd0\x94\xd0\xbe\xd0\xbc\xd0\xb0\xd1\x88\xd0\xbd\xd1\x8f\xd1\x8f > \xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x86\xd0\xb0" />\n name="description" > content="\xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > \xd1\x8f\xd0\xbf\xd0\xbe\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb5 > \xd0\xb8\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8, > \xd1\x8f\xd0\xbf\xd0\xbe\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb5 > \xd1\x82\xd0\xb5\xd1\x85\xd0\xbd\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xb3\xd0\xb8\xd0\xb8, > \xd0\xbd\xd0\xb0\xd1\x83\xd0\xba\xd0\xb0 > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd0\xb8, > \xd1\x83\xd1\x87\xd0\xb5\xd0\xbd\xd0\xbd\xd1\x8b\xd0\xb5 > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > \xd0\xba\xd0\xbe\xd0\xbc\xd0\xbf\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb8 > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > \xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x80\xd1\x8b > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f" />\n\r\n\r\n' > >>> soup = BeautifulSoup(html) > >>> print soup.prettify() > www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > http://www.w3.org/1999/xhtml";> > >> > > Japanese innovation | Япония инновации > > > > > > > best wishes > > Ray McBride > > On 9 Sep, 10:06, Oleg Oltar wrote: > > Hi! > > > > One of my tests returned following text () > > > > The test: > > from django.test.client import Client > > c = Client() > > resp = c.get("/") > > resp.content > > > > In [25]: resp.content > > Out[25]: '\r\n\r\n\r\n > Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd > ">\r\n\r\n > xmlns="http://www.w3.org/1999/xhtml";>\r\n \r\n > http-equiv="content-type" content="text/html; charset=utf-8" />\r\n > > \r\n\nJapanese innovation | > > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f > > > \xd0\xb8\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8\n\r\n > > \n > content="\xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > > > \xd0\xa2\xd0\xb5\xd1\x85\xd0\xbd\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xb3\xd0\xb8\xd0\xb8, > > \xd0\x98\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8, > > \xd0\x94\xd0\xbe\xd0\xbc\xd0\xb0\xd1\x88\xd0\xbd\xd1\x8f\xd1\x8f > > \xd1\x81\xd1\x82\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x86\xd0\xb0" > />\n > name="description" > > content="\xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > > \xd1\x8f\xd0\xbf\xd0\xbe\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb5 > > \xd0\xb8\xd0\xbd\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8, > > \xd1\x8f\xd0\xbf\xd0\xbe\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb5 > > > \xd1\x82\xd0\xb5\xd1\x85\xd0\xbd\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xb3\xd0\xb8\xd0\xb8, > > \xd0\xbd\xd0\xb0\xd1\x83\xd0\xba\xd0\xb0 > > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd0\xb8, > > \xd1\x83\xd1\x87\xd0\xb5\xd0\xbd\xd0\xbd\xd1\x8b\xd0\xb5 > > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > > \xd0\xba\xd0\xbe\xd0\xbc\xd0\xbf\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb8 > > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f, > > \xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x80\xd1\x8b > > \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8f" />\n\r\n\r\n > > > > Is there a way I can convert it to normal readable text? (I need for > example > > to find a string of text in this response to check if my test case Pass > or > > failed) > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Encoding question
Well, I prefer to find alt tag inside my image and check that it's correct instead of, checking that whole response contains some text. btw, have a problem: b = BeautifulSoap(client.get("/")) b.find('img')["alt"] again gives me those strange symbols I am updating my django now. (was using 1.0) On Wed, Sep 9, 2009 at 2:37 PM, Karen Tracey wrote: > On Wed, Sep 9, 2009 at 5:06 AM, Oleg Oltar wrote: > >> Hi! >> >> One of my tests returned following text () >> >> The test: >> from django.test.client import Client >> c = Client() >> resp = c.get("/") >> resp.content >> >> In [25]: resp.content >> Out[25]: '\r\n\r\n\r\n> Strict//EN" > > [snip] >> >> Is there a way I can convert it to normal readable text? (I need for >> example to find a string of text in this response to check if my test case >> Pass or failed) >> >> > Is there some reason you can not simply use assertContains ( > http://docs.djangoproject.com/en/dev/topics/testing/#django.test.TestCase.assertContains)? > There was a bug in this method handling unicode in responses, but that has > been fixed in both 1.0.3 and 1.1: > > http://code.djangoproject.com/ticket/10183 > > Karen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Deploying django application
Hi! I am trying to serve my project using server-spawned processes I created file .htaccess in my web_root directory which contains: AddHandler fastcgi-script .fcgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L] And also added file mysite.fcgi to same dir #!/usr/bin/python import sys, os # Add a custom Python path. sys.path.insert(0, "/home/user/python") # Switch to the directory of your project. (Optional.) # os.chdir("/home/user/myproject") # Set the DJANGO_SETTINGS_MODULE environment variable. os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" from django.core.servers.fastcgi import runfastcgi runfastcgi(method="threaded", daemonize="false") But when trying to go to my domain http://goclub.org.ua/ I see the contents of mysite.fcgi instead of my site... Could you please help me to understand the problem --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Deploying django application
There are few thing here: 1. I am root on that box. So can change apache conf. But have a little knowledge how to do it. So decided to use that way, as thought it's easier for hosting many django apps. So please tell me what to check. 2. I believe that htaccess is working as web server redirected me to mysite.fcgi 3. I am using fedora, so installed fcgid from yum, but not fcgi. Can it cause the problem? Should I install fcgi instead? Thanks in advance, Oleg On Mon, Apr 6, 2009 at 1:41 AM, Daniel Roseman wrote: > > On Apr 5, 10:04 pm, Oleg Oltar wrote: >> Hi! >> >> I am trying to serve my project using server-spawned processes >> >> I created file .htaccess in my web_root directory which contains: >> AddHandler fastcgi-script .fcgi >> RewriteEngine On >> RewriteCond %{REQUEST_FILETherNAME} !-f >> RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L] >> >> And also added file mysite.fcgi to same dir >> #!/usr/bin/python >> import sys, os >> >> # Add a custom Python path. >> sys.path.insert(0, "/home/user/python") >> >> # Switch to the directory of your project. (Optional.) >> # os.chdir("/home/user/myproject") >> >> # Set the DJANGO_SETTINGS_MODULE environment variable. >> os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings" >> >> from django.core.servers.fastcgi import runfastcgi >> runfastcgi(method="threaded", daemonize="false") >> >> But when trying to go to my domainhttp://goclub.org.ua/I see the >> contents of mysite.fcgi instead of my site... >> >> Could you please help me to understand the problem > > Directives are only allowed in .htaccess files if the main Apache > configuration has been set to allow them. It's possible that whoever > runs your server has not allowed the use of AddHandler in .htaccess, > so it is serving the file rather than running it. > > Talk to your hosting company and see if this is the case, and if so > whether there are any alternatives that they support. > -- > DR. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Customizing admin form
Hi! I have a model which contains several TextFields and CharFields. I want to make all char fields longer and wider. How to do it? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Creating custom feeds
Hi! I want to create RSS2 feed. I read the doc http://www.djangoproject.com/documentation/0.96/syndication_feeds/ So created a class # coding: utf-8 from django.contrib.syndication.feeds import Feed from articleManager.models import Article as article class LatestEntries(Feed): title = 'TITLE' link = 'http://example.com' description = "DESCRIPTION HERE" def items(self): return article.objects.order_by("-pub_date")[:10] But I need to add 2 custom attributes to my feed: 1. image_logo - need to add an image logo of my site 2. fulltext - a full text of an article (from my model) Is there a way I can 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Creating custom feeds
Even more. How feeds are different from any other pages? What if I will simply generate a template of needed structure using django models + views (as described in tutorials) Thanks, Oleg On Mon, Apr 20, 2009 at 3:14 PM, Oleg Oltar wrote: > Hi! > > I want to create RSS2 feed. I read the doc > http://www.djangoproject.com/documentation/0.96/syndication_feeds/ > > So created a class > > # coding: utf-8 > from django.contrib.syndication.feeds import Feed > from articleManager.models import Article as article > > > class LatestEntries(Feed): > title = 'TITLE' > link = 'http://example.com' > description = "DESCRIPTION HERE" > > > > def items(self): > return article.objects.order_by("-pub_date")[:10] > > > But I need to add 2 custom attributes to my feed: > 1. image_logo - need to add an image logo of my site > 2. fulltext - a full text of an article (from my model) > > Is there a way I can 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Creating sub sections
Hi! I am writing an application - a kind of article manager. I defined my model this way: class Section(models.Model): #id = models.IntegerField(unique=True) section = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, blank = True) def __unicode__(self): return u"%s" %(self.section) class Article (models.Model): # Tiny url url = models.CharField(max_length = 30, unique=True) is_published = models.BooleanField() author = models.CharField(max_length = 150) title = models.CharField(max_length = 200) short_description = models.TextField(max_length = 600) body = tinymce_models.HTMLField() #body = models.TextField(max_length = 1) pub_date = models.DateTimeField('date_published') # Image fields main_image = models.ImageField(upload_to="upload", blank=True) image_description = models.CharField(max_length = 100, help_text= u"Строка описания картинки: 8-10 слов") section = models.ForeignKey(Section) # SEO seo_description = models.TextField(max_length = 300) seo_keywords = models.CharField(max_length = 100) #comment = models.ForeignKey(Comment) def get_absolute_url(self): return "/article/%s/" % self.url def __unicode__(self): return u"Article: %s" %(self.title) It allows me to assign articles to different sections. But now I need to define subsections. How can I do it? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Creating sub sections
Can you please provide a simple example? 2009/4/21 Andy Mikhailenko > > http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey > > class Section(Model): >... >parent = models.ForeignKey('self') > > plus some code to build the string representing the path. > > On Apr 21, 1:30 pm, Oleg Oltar wrote: > > Hi! > > I am writing an application - a kind of article manager. I defined my > model > > this way: > > > > class Section(models.Model): > > #id = models.IntegerField(unique=True) > > > > section = models.CharField(max_length=200, unique=True) > > name = models.CharField(max_length=200, blank = True) > > > > def __unicode__(self): > > return u"%s" %(self.section) > > > > class Article (models.Model): > > # Tiny url > > url = models.CharField(max_length = 30, unique=True) > > is_published = models.BooleanField() > > author = models.CharField(max_length = 150) > > title = models.CharField(max_length = 200) > > short_description = models.TextField(max_length = 600) > > body = tinymce_models.HTMLField() > > #body = models.TextField(max_length = 1) > > pub_date = models.DateTimeField('date_published') > > # Image fields > > main_image = models.ImageField(upload_to="upload", blank=True) > > image_description = models.CharField(max_length = 100, > > help_text= u"Строка описания > > картинки: 8-10 слов") > > > > section = models.ForeignKey(Section) > > # SEO > > seo_description = models.TextField(max_length = 300) > > seo_keywords = models.CharField(max_length = 100) > > #comment = models.ForeignKey(Comment) > > > > def get_absolute_url(self): > > return "/article/%s/" % self.url > > > > def __unicode__(self): > > return u"Article: %s" %(self.title) > > > > It allows me to assign articles to different sections. > > > > But now I need to define subsections. How can I do it? > > > > Thanks, > > Oleg > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django development on OS X. Accessing development server from local network
Have a problem. Just noticed that my application has a layout issue in IE7. I just wanted to make tests on development server from other PC (with IE installed), on my local network. How can I do it? Don't really want to deploy apache on local PC for testing Please help me to understand how to test it. Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Displaying content in different styles.
Hi! I created a simple view to display articles on my homepage. Here's the code: def homepage(request): news = models.Section.objects.get(section = 'News') articles = models.Article.objects.exclude(section = news.id ).order_by("-pub_date") list_of_news = models.Article.objects.filter(section = news.id ).order_by("-pub_date") return render_to_response('home.html', {'news' : list_of_news[:4], 'articles' : articles[:6] } Now I want to make first news item a little bit bigger, and to place it in a different form. I am processing the list in a template this way: {% for item in news %} {{ item.title }} {{ item.short_description|truncatewords:60}} {% endfor %} Is there a way to check in the loop if it's a first item. And if so to process it in a different way? Or do I have pass first article to template separately? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Clearing ImageField from django admin
Hi! I am using ImageField to add optional images to my articles from admin. image2 = models.ImageField(upload_to="upload", blank=True) I added one image from my server to this field Is there a way to remove the image. If i for example decided not to use the image on the article at all? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Clearing ImageField from django admin
Didn't find solution yet. So if you can please help me! On Wed, May 6, 2009 at 6:29 PM, Oleg Oltar wrote: > Hi! > I am using ImageField to add optional images to my articles from admin. > > image2 = models.ImageField(upload_to="upload", blank=True) > > I added one image from my server to this field > Is there a way to remove the image. If i for example decided not to use the > image on the article at all? > > Thanks, > Oleg > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
creating objects in views
Hi! I am running small blog-styled information site. Which contains articles added via admin application Now I am trying to add possibility to add comments, so I defined a comment Model (which contains Foreign Key to article object, and few text fields), also defined forms. Can you please explain how should I create a comment object in view? (After processing data from form). I don't understand where can I get, the article name (id, guid or something) to link article and comment Thanks in advance, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: creating objects in views
Well, the problem with built in comments framework is that I need few more fields in comments. What I created is: MODEL: class Comment(models.Model): name = models.CharField(max_length = 30) body = models.CharField(max_length = 2000) article = models.ForeignKey(Article) def __unicode__(self): return u"%s" %(self.name) FORM: class CommentForm(forms.Form): ''' The Register form is created to deal with registration process check if data is clean and passwords match each other ''' username = forms.CharField(label='Name', max_length=30) body = forms.CharField(required = True, label = 'Comment Body', widget=forms.Textarea) def clean_body(self): if 'body' in self.cleaned_data: body = self.cleaned_data['body'] if not re.search(r'^\w+$', username): raise forms.ValidationError('Error: body can contains \ only alphanumeric characters') VIEW: def article_page(request, page_name): article = get_object_or_404(models.Article, url = page_name) articles_list = models.Article.objects.exclude(is_published__exact="0").order_by("-pub_date") if request.method == 'POST': form = CommentForm(request.POST) # Creating a comment if form.is_valid(): comment = Comment( name = from.cleaned_data['name'], body = form.cleaned_data['body'], article = ) return render_to_response('article.html', {'section': article.title, 'article' : article, 'articles' : articles_list} ) Not sure how to fill the article field :( Thanks in advance, Oleg On Tue, May 12, 2009 at 1:01 PM, Daniel Roseman < roseman.dan...@googlemail.com> wrote: > > On May 12, 10:51 am, Oleg Oltar wrote: > > Hi! > > I am running small blog-styled information site. Which contains articles > > added via admin application > > Now I am trying to add possibility to add comments, so I defined a > comment > > Model (which contains Foreign Key to article object, and few text > fields), > > also defined forms. > > > > Can you please explain how should I create a comment object in view? > (After > > processing data from form). I don't understand where can I get, the > article > > name (id, guid or something) to link article and comment > > > > Thanks in advance, > > Oleg > > Firstly, have you investigated the built-in comment app? It's quite > full-featured, and may do everything you want. > > Assuming you've decided that your own model is the way to go, the > answer to your question will depend on the way you've defined your > form and view. Presumably the comment form is displayed at the bottom > of an article page, so you'll already have the ID of the article - so > I don't really understand what your issue is. Perhaps you could post > the code you have so far? > -- > DR. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: creating objects in views
Thanks a lot! I don't know why I missed article variable! Thanks, again! On Thu, May 14, 2009 at 11:23 PM, Gene wrote: > > You may still be able to use the built-in django-comments, as it's > easy to customize (especially if your just adding extra fields). You > can read about it here: > http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/#ref-contrib-comments-custom > > Gene > > On May 14, 12:59 pm, Oleg Oltar wrote: > > Well, the problem with built in comments framework is that I need few > more > > fields in comments. > > > > What I created is: > > > > MODEL: > > > > class Comment(models.Model): > > name = models.CharField(max_length = 30) > > body = models.CharField(max_length = 2000) > > article = models.ForeignKey(Article) > > > > def __unicode__(self): > > return u"%s" %(self.name) > > > > FORM: > > > > class CommentForm(forms.Form): > > ''' > > The Register form is created to deal with registration process > > check if data is clean and passwords match each other > > ''' > > username = forms.CharField(label='Name', max_length=30) > > body = forms.CharField(required = True, > > label = 'Comment Body', > > widget=forms.Textarea) > > > > def clean_body(self): > > if 'body' in self.cleaned_data: > > body = self.cleaned_data['body'] > > if not re.search(r'^\w+$', username): > > raise forms.ValidationError('Error: body can contains \ > > only alphanumeric characters') > > > > VIEW: > > > > def article_page(request, page_name): > > article = get_object_or_404(models.Article, url = page_name) > > articles_list = > > > models.Article.objects.exclude(is_published__exact="0").order_by("-pub_date") > > > > if request.method == 'POST': > > form = CommentForm(request.POST) > > # Creating a comment > > if form.is_valid(): > > comment = Comment( > > name = from.cleaned_data['name'], > > body = form.cleaned_data['body'], > > article = > > ) > > > > return render_to_response('article.html', > > {'section': article.title, > >'article' : article, > >'articles' : articles_list} > > ) > > > > Not sure how to fill the article field :( > > > > Thanks in advance, > > Oleg > > > > On Tue, May 12, 2009 at 1:01 PM, Daniel Roseman < > > > > roseman.dan...@googlemail.com> wrote: > > > > > On May 12, 10:51 am, Oleg Oltar wrote: > > > > Hi! > > > > I am running small blog-styled information site. Which contains > articles > > > > added via admin application > > > > Now I am trying to add possibility to add comments, so I defined a > > > comment > > > > Model (which contains Foreign Key to article object, and few text > > > fields), > > > > also defined forms. > > > > > > Can you please explain how should I create a comment object in view? > > > (After > > > > processing data from form). I don't understand where can I get, the > > > article > > > > name (id, guid or something) to link article and comment > > > > > > Thanks in advance, > > > > Oleg > > > > > Firstly, have you investigated the built-in comment app? It's quite > > > full-featured, and may do everything you want. > > > > > Assuming you've decided that your own model is the way to go, the > > > answer to your question will depend on the way you've defined your > > > form and view. Presumably the comment form is displayed at the bottom > > > of an article page, so you'll already have the ID of the article - so > > > I don't really understand what your issue is. Perhaps you could post > > > the code you have so far? > > > -- > > > DR. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Adding new permissions to django-admin
Hi! I am writing small django based informational site. I have several publishers, who add articles to my database using the adding application. I have defined my main article model this way: class Article (models.Model): # Tiny url url = models.CharField(max_length = 30, unique=True, help_text =u"Уникальный короткий url-tag") is_published = models.BooleanField(help_text= u"Необходимо отметить для того что б статья стала \ опубликованой на сайте") author = models.CharField(max_length = 150, help_text = u"Автор. Использовать только настоящие и\ мена") title = models.CharField(max_length = 200, help_text= u"Заголовок статьи") short_description = models.TextField(max_length = 600, help_text = u"Врез", verbose_name = u"Вре\ з") body = tinymce_models.HTMLField() #body = models.TextField(max_length = 1) pub_date = models.DateTimeField('date_published') # Image fields main_image = models.ImageField(upload_to="upload", help_text=u"Основное изображение") image_description = models.CharField(max_length = 100, help_text= u"Строка описания картинки: 8-10 слов") section = models.ForeignKey(Section) # SEO seo_description = models.TextField(max_length = 300, help_text = u"Описание текста для поисковых\ машин. Коротко о тексте") seo_keywords = models.CharField(max_length = 100, help_text = u"Ключевые слова, для поиска. Долж\ ны присутствовать в тексте") Have several questions: 1. Can I allow some users from my django admin users to edit only articles that they added (not the whole base) 2. Can I disallow some users to edit some sections (and also some articles) Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Counting pageviews
Hi! I am writing simple article manager application. Is there a way I can store pageviews number for my articles in database (want to display them in future, and use for rating on site) Thanks in advance, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Counting pageviews
Well, what I want is t implement voting application, so my users can see article, vote for it and see the vote displayed So I want to show in template: this page was viewed 100 times, and has 10 votes for example how can I get those numbers On Sat, May 16, 2009 at 12:12 PM, Antoni Aloy wrote: > > 2009/5/15 Oleg Oltar : > > Hi! > > > > I am writing simple article manager application. Is there a way I can > store > > pageviews number for my articles in database (want to display them in > > future, and use for rating on site) > > > > Thanks in advance, > > Oleg > > > You can use google analytics for that. > You can store it also in your views before displaying the page or you > can use your own javascript method. > > Perhapts I don't understand the question, but if you own the site you > can do whatever you want. If you use the view method you can't use > cache and this could have a great impact in performance. It depends on > your needs and application. > > -- > Antoni Aloy López > Blog: http://trespams.com > Site: http://apsl.net > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Exception in model in admin with non unicode
Hi! I am creating a simple application for managing articles. It contains of several entities: 1) categories 2) sections 3) articles The code: class Categoty(models.Model): categoty = models.CharField(max_length=200) name = models.CharField(max_length = 200, help_text="Имя категории") def __unicode__(self): return u"Категория %s" %self.name class Section(models.Model): section = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, blank = True) def __unicode__(self): return u"%s" %(self.section) class Article (models.Model): # Tiny url url = models.CharField(max_length = 30, unique=True, help_text =u"Уникальный короткий url-tag") is_published = models.BooleanField(help_text= u"Необходимо отметить для того что б статья стала опубликованой на сайте") author = models.CharField(max_length = 150, help_text = u"Автор. Использовать только настоящие имена") title = models.CharField(max_length = 200, help_text= u"Заголовок статьи") short_description = models.TextField(max_length = 600, help_text = u"Врез", verbose_name = u"Врез") body = tinymce_models.HTMLField() #body = models.TextField(max_length = 1) pub_date = models.DateTimeField('date_published') I just added new entity (Category). Synced the database and added new Category to admin. Strange when I am adding an article with russian text or Section with russian name, everything is OK But when I a trying to add a new category via admin, and use name of it in russian I am getting this exception: Warning at /admin/articleManager/categoty/add/ Incorrect string value: '\xD0\xB2\xD0\xB2\xD0\xB2' for column 'name' at row 1 Request Method:POSTRequest URL: http://127.0.0.1:8000/admin/articleManager/categoty/add/Exception Type: WarningException Value: Incorrect string value: '\xD0\xB2\xD0\xB2\xD0\xB2' for column 'name' at row 1 Exception Location:/opt/local/lib/python2.5/warnings.py in warn_explicit, line 102Python Executable:/opt/local/bin/pythonPython Version:2.5.1Python Path:['/Users/oleg/jin/categoties/trunk/jin', '/opt/local/lib/python2.5/site-packages/simplejson-1.7.3-py2.5-macosx-10.3-i386.egg', '/opt/local/lib/python2.5/site-packages/markdown-1.7-py2.5.egg', '/opt/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/opt/local/lib/python2.5/site-packages/HarvestMan-2.0.4betadev-py2.5.egg', '/opt/local/lib/python2.5/site-packages/web.py-0.31-py2.5.egg', '/opt/local/lib/python2.5/site-packages/sgmlop-1.1.1_20040207-py2.5-macosx-10.3-i386.egg', '/opt/local/lib/python25.zip', '/opt/local/lib/python2.5', '/opt/local/lib/python2.5/plat-darwin', '/opt/local/lib/python2.5/plat-mac', '/opt/local/lib/python2.5/plat-mac/lib-scriptpackages', '/opt/local/lib/python2.5/lib-tk', '/opt/local/lib/python2.5/lib-dynload', '/opt/local/lib/python2.5/site-packages', '/opt/local/lib/python2.5/site-packages/Numeric', '/opt/local/lib/python2.5/site-packages/PIL']Server time:Wed, 20 May 2009 00:59:39 -0500 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Exception in model in admin with non unicode
Hm... You're right...But I don't understand how it happened... I used sync db to create those table mysql> show create table articleManager_categoty\G *** 1. row *** Table: articleManager_categoty Create Table: CREATE TABLE `articleManager_categoty` ( `id` int(11) NOT NULL AUTO_INCREMENT, `categoty` varchar(200) NOT NULL, `name` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql> can you suggest a command to change charset? Thanks On Wed, May 20, 2009 at 4:12 PM, Karen Tracey wrote: > 2009/5/20 Oleg Oltar > >> [snip]Strange when I am adding an article with russian text or Section >> with russian name, everything is OK >> But when I a trying to add a new category via admin, and use name of it in >> russian I am getting this exception: >> >> Warning at /admin/articleManager/categoty/add/ >> >> Incorrect string value: '\xD0\xB2\xD0\xB2\xD0\xB2' for column 'name' at row 1 >> >> > This means that the character set for your category table (or at least the > name column within it) is set to something (probably the default latin1) > that has no representation for the Unicode value specified. To confirm, > take a look at the output of 'show create table' for your category table in > a mysql shell. You then need to alter the table so that its character set > is utf-8. See: > > http://dev.mysql.com/doc/refman/5.0/en/alter-table.html > > You want to use the "convert to character set" option. > > Karen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Exception in model in admin with non unicode
Well... I just restored my database from production dump... On prod I have correct UTF-8 On Wed, May 20, 2009 at 4:49 PM, Karen Tracey wrote: > On Wed, May 20, 2009 at 9:37 AM, Oleg Oltar wrote: > >> Hm... You're right...But I don't understand how it happened... I used sync >> db to create those table >> > > syncdb doesn't specify a character set, it uses the database default. I > don't understand how some of your tables would have one value while others > have a different one unless you created them at different times while the > server was set to have different defaults. > > >> >> mysql> show create table articleManager_categoty\G >> *** 1. row *** >>Table: articleManager_categoty >> Create Table: CREATE TABLE `articleManager_categoty` ( >> `id` int(11) NOT NULL AUTO_INCREMENT, >> `categoty` varchar(200) NOT NULL, >> `name` varchar(200) NOT NULL, >> PRIMARY KEY (`id`) >> ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 >> 1 row in set (0.00 sec) >> >> mysql> >> >> >> can you suggest a command to change charset? >> > > That's the doc I pointed to. It's something like 'ALTER TABLE > articleManager_categoty CONVERT TO CHARACTER SET UTF8' but I'm not 100% sure > without trying it that that is the correct syntax. > > Karen > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Displaying objects in template
Hi! I have a model with a Sections and Categories related this way: class Category(models.Model): categoty = models.CharField(max_length=200) name = models.CharField(max_length = 200, help_text=u"Имя категории") def __unicode__(self): return u"Категория %s" %self.name class Section(models.Model): section = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, blank = True) category = models.ForeignKey(Category, blank=True) def __unicode__(self): return u"%s" %(self.section) I passed a categories to the template. Is there a way I can display all sections related to each category in template? Not sure how to do it? {% for category in categories %} {{ category.name}} {% for section in %} But how to get all sections from one category? And the second question If I am passing a variable to the base template (I want to use the code to generate menu from categories), how to handle it in separate (extended templates)? E.g. do I have to query categories in each my view and pass it as value to all templates I use? Thanks in advance Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Displaying objects in template
Ok, I got it now What about the inheritance? Question 2? On Wed, May 20, 2009 at 9:30 PM, Alex Gaynor wrote: > > > 2009/5/20 Oleg Oltar > > Hi! >> I have a model with a Sections and Categories related this way: >> >> class Category(models.Model): >> categoty = models.CharField(max_length=200) >> name = models.CharField(max_length = 200, help_text=u"Имя категории") >> >> def __unicode__(self): >> return u"Категория %s" %self.name >> >> class Section(models.Model): >> section = models.CharField(max_length=200, unique=True) >> name = models.CharField(max_length=200, blank = True) >> category = models.ForeignKey(Category, blank=True) >> >> def __unicode__(self): >> return u"%s" %(self.section) >> >> >> I passed a categories to the template. Is there a way I can display all >> sections related to each category in template? >> >> Not sure how to do it? >> >> {% for category in categories %} >> >> {{ >> category.name}} >> {% for section in %} >> But how to get all sections from one category? >> >> >> And the second question >> >> If I am passing a variable to the base template (I want to use the code to >> generate menu from categories), how to handle it in separate (extended >> templates)? E.g. do I have to query categories in each my view and pass it >> as value to all templates I use? >> >> >> Thanks in advance >> Oleg >> >> >> >> > {% for section in category_object.section_set.all %} > > {% endfor %} > > As documented here: > http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Displaying objects in template
Is there any doc I can read about it? On Wed, May 20, 2009 at 9:50 PM, Alex Gaynor wrote: > > > 2009/5/20 Oleg Oltar > >> Ok, I got it now >> What about the inheritance? Question 2? >> >> On Wed, May 20, 2009 at 9:30 PM, Alex Gaynor wrote: >> >>> >>> >>> 2009/5/20 Oleg Oltar >>> >>> Hi! >>>> I have a model with a Sections and Categories related this way: >>>> >>>> class Category(models.Model): >>>> categoty = models.CharField(max_length=200) >>>> name = models.CharField(max_length = 200, help_text=u"Имя >>>> категории") >>>> >>>> def __unicode__(self): >>>> return u"Категория %s" %self.name >>>> >>>> class Section(models.Model): >>>> section = models.CharField(max_length=200, unique=True) >>>> name = models.CharField(max_length=200, blank = True) >>>> category = models.ForeignKey(Category, blank=True) >>>> >>>> def __unicode__(self): >>>> return u"%s" %(self.section) >>>> >>>> >>>> I passed a categories to the template. Is there a way I can display all >>>> sections related to each category in template? >>>> >>>> Not sure how to do it? >>>> >>>> {% for category in categories %} >>>> >>>> {{ >>>> category.name}} >>>> {% for section in %} >>>> But how to get all sections from one category? >>>> >>>> >>>> And the second question >>>> >>>> If I am passing a variable to the base template (I want to use the code >>>> to generate menu from categories), how to handle it in separate (extended >>>> templates)? E.g. do I have to query categories in each my view and pass it >>>> as value to all templates I use? >>>> >>>> >>>> Thanks in advance >>>> Oleg >>>> >>>> >>>> >>>> >>> {% for section in category_object.section_set.all %} >>> >>> {% endfor %} >>> >>> As documented here: >>> http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships >>> >>> Alex >>> >>> -- >>> "I disapprove of what you say, but I will defend to the death your right >>> to say it." --Voltaire >>> "The people's good is the highest law."--Cicero >>> >>> >>> >> >> >> > Right, there are 2 solutions to that (that I can think of). 1 is to write > a template context processor. The other is to write a custom inclusion > template tag. I personally favor the 2nd one because it gives you a little > bit more control. > > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Displaying objects in template
Just want to tell you big big thank you! On Wed, May 20, 2009 at 10:52 PM, Alex Gaynor wrote: > > > 2009/5/20 Oleg Oltar > >> Is there any doc I can read about it? >> >> On Wed, May 20, 2009 at 9:50 PM, Alex Gaynor wrote: >> >>> >>> >>> 2009/5/20 Oleg Oltar >>> >>>> Ok, I got it now >>>> What about the inheritance? Question 2? >>>> >>>> On Wed, May 20, 2009 at 9:30 PM, Alex Gaynor wrote: >>>> >>>>> >>>>> >>>>> 2009/5/20 Oleg Oltar >>>>> >>>>> Hi! >>>>>> I have a model with a Sections and Categories related this way: >>>>>> >>>>>> class Category(models.Model): >>>>>> categoty = models.CharField(max_length=200) >>>>>> name = models.CharField(max_length = 200, help_text=u"Имя >>>>>> категории") >>>>>> >>>>>> def __unicode__(self): >>>>>> return u"Категория %s" %self.name >>>>>> >>>>>> class Section(models.Model): >>>>>> section = models.CharField(max_length=200, unique=True) >>>>>> name = models.CharField(max_length=200, blank = True) >>>>>> category = models.ForeignKey(Category, blank=True) >>>>>> >>>>>> def __unicode__(self): >>>>>> return u"%s" %(self.section) >>>>>> >>>>>> >>>>>> I passed a categories to the template. Is there a way I can display >>>>>> all sections related to each category in template? >>>>>> >>>>>> Not sure how to do it? >>>>>> >>>>>> {% for category in categories %} >>>>>> >>>>>> {{ >>>>>> category.name}} >>>>>> {% for section in %} >>>>>> But how to get all sections from one category? >>>>>> >>>>>> >>>>>> And the second question >>>>>> >>>>>> If I am passing a variable to the base template (I want to use the >>>>>> code to generate menu from categories), how to handle it in separate >>>>>> (extended templates)? E.g. do I have to query categories in each my view >>>>>> and >>>>>> pass it as value to all templates I use? >>>>>> >>>>>> >>>>>> Thanks in advance >>>>>> Oleg >>>>>> >>>>>> >>>>>> >>>>>> >>>>> {% for section in category_object.section_set.all %} >>>>> >>>>> {% endfor %} >>>>> >>>>> As documented here: >>>>> http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships >>>>> >>>>> Alex >>>>> >>>>> -- >>>>> "I disapprove of what you say, but I will defend to the death your >>>>> right to say it." --Voltaire >>>>> "The people's good is the highest law."--Cicero >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> Right, there are 2 solutions to that (that I can think of). 1 is to >>> write a template context processor. The other is to write a custom >>> inclusion template tag. I personally favor the 2nd one because it gives you >>> a little bit more control. >>> >>> >>> Alex >>> >>> -- >>> "I disapprove of what you say, but I will defend to the death your right >>> to say it." --Voltaire >>> "The people's good is the highest law."--Cicero >>> >>> >>> >> >> >> > Right, sorry: > > context processors: > http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/ > > inclusion tag: > http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags > > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Displaying objects in template
Strange :( This code produces nothing in template how can I debug it? Please help 2009/5/20 Oleg Oltar > Just want to tell you big big thank you! > > > On Wed, May 20, 2009 at 10:52 PM, Alex Gaynor wrote: > >> >> >> 2009/5/20 Oleg Oltar >> >>> Is there any doc I can read about it? >>> >>> On Wed, May 20, 2009 at 9:50 PM, Alex Gaynor wrote: >>> >>>> >>>> >>>> 2009/5/20 Oleg Oltar >>>> >>>>> Ok, I got it now >>>>> What about the inheritance? Question 2? >>>>> >>>>> On Wed, May 20, 2009 at 9:30 PM, Alex Gaynor wrote: >>>>> >>>>>> >>>>>> >>>>>> 2009/5/20 Oleg Oltar >>>>>> >>>>>> Hi! >>>>>>> I have a model with a Sections and Categories related this way: >>>>>>> >>>>>>> class Category(models.Model): >>>>>>> categoty = models.CharField(max_length=200) >>>>>>> name = models.CharField(max_length = 200, help_text=u"Имя >>>>>>> категории") >>>>>>> >>>>>>> def __unicode__(self): >>>>>>> return u"Категория %s" %self.name >>>>>>> >>>>>>> class Section(models.Model): >>>>>>> section = models.CharField(max_length=200, unique=True) >>>>>>> name = models.CharField(max_length=200, blank = True) >>>>>>> category = models.ForeignKey(Category, blank=True) >>>>>>> >>>>>>> def __unicode__(self): >>>>>>> return u"%s" %(self.section) >>>>>>> >>>>>>> >>>>>>> I passed a categories to the template. Is there a way I can display >>>>>>> all sections related to each category in template? >>>>>>> >>>>>>> Not sure how to do it? >>>>>>> >>>>>>> {% for category in categories %} >>>>>>> >>>>>>> {{ >>>>>>> category.name}} >>>>>>> {% for section in %} >>>>>>> But how to get all sections from one category? >>>>>>> >>>>>>> >>>>>>> And the second question >>>>>>> >>>>>>> If I am passing a variable to the base template (I want to use the >>>>>>> code to generate menu from categories), how to handle it in separate >>>>>>> (extended templates)? E.g. do I have to query categories in each my >>>>>>> view and >>>>>>> pass it as value to all templates I use? >>>>>>> >>>>>>> >>>>>>> Thanks in advance >>>>>>> Oleg >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> {% for section in category_object.section_set.all %} >>>>>> >>>>>> {% endfor %} >>>>>> >>>>>> As documented here: >>>>>> http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships >>>>>> >>>>>> Alex >>>>>> >>>>>> -- >>>>>> "I disapprove of what you say, but I will defend to the death your >>>>>> right to say it." --Voltaire >>>>>> "The people's good is the highest law."--Cicero >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> Right, there are 2 solutions to that (that I can think of). 1 is to >>>> write a template context processor. The other is to write a custom >>>> inclusion template tag. I personally favor the 2nd one because it gives >>>> you >>>> a little bit more control. >>>> >>>> >>>> Alex >>>> >>>> -- >>>> "I disapprove of what you say, but I will defend to the death your right >>>> to say it." --Voltaire >>>> "The people's good is the highest law."--Cicero >>>> >>>> >>>> >>> >>> >>> >> Right, sorry: >> >> context processors: >> http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/ >> >> inclusion tag: >> http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags >> >> >> Alex >> >> -- >> "I disapprove of what you say, but I will defend to the death your right >> to say it." --Voltaire >> "The people's good is the highest law."--Cicero >> >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
How to use filtering
Hi! I am trying to understand how to use filters in django. I have following models: class Section(models.Model): section = models.CharField(max_length=200, unique=True) name = models.CharField(max_length=200, blank = True) category = models.ForeignKey(Category, blank=True) public = models.BooleanField() def __unicode__(self): return u"%s" %(self.section) class Article (models.Model): is_published = models.BooleanField(help_text= u"Необходимо отметить для того что б статья стала опубликованой на сайте") author = models.CharField(max_length = 150, help_text = u"Автор. Использовать только настоящие имена") title = models.CharField(max_length = 200, help_text= u"Заголовок статьи") section = models.ForeignKey(Section) Can you please suggest me a way to can get a list of articles where section public attribute is true? Thanks, Oleg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Uploading Images
Hi! I know that the problem probably was discussed many times already, but I really can't make it working. I read the documentation and prepared the following code: model: class UserProfile(models.Model): """ User profile model, cintains a Foreign Key, which links it to the user profile. """ about = models.TextField(blank=True) user = models.ForeignKey(User, unique=True) ranking = models.IntegerField(default = 1) avatar = models.ImageField(upload_to="usermedia", default = 'images/js.jpg') def __unicode__(self): return u"%s profile" %self.user form: class ProfileEdit(forms.Form): about = forms.CharField(label = 'About', max_length = 1000, required=False) avtar = forms.ImageField() view: def handleUploadedFile(file): destination = open('usermedia/new.jpg', 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() return True def user_profile(request, profile_name): owner = get_object_or_404(User, username = profile_name) ownersProfile =get_object_or_404(UserProfile, user = owner) form = ProfileEdit(request.POST) if request.method == 'POST': form = ProfileEdit(request.POST, request.FILES) if form.is_valid(): handleUploadedFile(request.FILES['file']) else: form = ProfileEdit() data = RequestContext(request, { 'owner' : owner, 'ownersProfile' : ownersProfile, 'form' : form } ) return render_to_response('registration/profile.html', data) And part of template: {{ form.as_p }} After trying this code in browser I am getting a text field with browse button, so when I chose file to upload, and finally click upload I am getting 404 Error. Not sure what I might doing wrong. Please help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Uploading Images
I made a mistake in view.py. Corrected version is def handleUploadedFile(file): destination = open('usermedia/new.jpg', 'wb+') for chunk in file.chunks(): destination.write(chunk) destination.close() return destination def user_profile(request, profile_name): owner = get_object_or_404(User, username = profile_name) ownersProfile =get_object_or_404(UserProfile, user = owner) form = ProfileEdit(request.POST) if request.method == 'POST': if form.is_valid(): ownersProfile.about = form.cleaned_data['about'] ownersProfile.avatar = handleUploadedFile(request.FILES['file']) ownersProfile.save() return HttpResponseRedirect("/") else: form = ProfileEdit() Also changed a little bit template: {{ form.as_p }} But I am getting: MultiValueDictKeyError at /account/profile/test "Key 'file' not found in " :( On Mon, Jun 15, 2009 at 6:54 AM, Oleg Oltar wrote: > Hi! > > I know that the problem probably was discussed many times already, but > I really can't make it working. > > I read the documentation and prepared the following code: > > model: > > class UserProfile(models.Model): > """ > User profile model, cintains a Foreign Key, which links it to the > user profile. > """ > about = models.TextField(blank=True) > user = models.ForeignKey(User, unique=True) > ranking = models.IntegerField(default = 1) > avatar = models.ImageField(upload_to="usermedia", default = > 'images/js.jpg') > > > def __unicode__(self): > return u"%s profile" %self.user > > > form: > > class ProfileEdit(forms.Form): > about = forms.CharField(label = 'About', max_length = 1000, required=False) > avtar = forms.ImageField() > > > view: > def handleUploadedFile(file): > destination = open('usermedia/new.jpg', 'wb+') > for chunk in file.chunks(): > destination.write(chunk) > destination.close() > return True > > def user_profile(request, profile_name): > owner = get_object_or_404(User, username = profile_name) > ownersProfile =get_object_or_404(UserProfile, user = owner) > form = ProfileEdit(request.POST) > if request.method == 'POST': > form = ProfileEdit(request.POST, request.FILES) > if form.is_valid(): > handleUploadedFile(request.FILES['file']) > else: > form = ProfileEdit() > > > > data = RequestContext(request, > { > 'owner' : owner, > 'ownersProfile' : ownersProfile, > 'form' : form > } > ) > return render_to_response('registration/profile.html', data) > > > And part of template: > > > {{ form.as_p }} > > > > > > After trying this code in browser I am getting a text field with > browse button, so when I chose file to upload, and finally click > upload I am getting 404 Error. > Not sure what I might doing wrong. > Please help > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Manager is not accessible via model instances
Hi! I have following model: class UserProfile(models.Model): """ User profile model, cintains a Foreign Key, which links it to the user profile. """ about = models.TextField(blank=True) user = models.ForeignKey(User, unique=True) ranking = models.IntegerField(default = 1) avatar = models.ImageField(upload_to="usermedia", default = 'images/js.jpg') updated = models.DateTimeField(auto_now=True, default=datetime.now()) is_bot = models.BooleanField(default = False) is_active = models.BooleanField(default = True) is_free = models.BooleanField(default = True) objects = ProfileManager() def __unicode__(self): return u"%s profile" %self.user And a manager class ProfileManager(models.Manager): """ Stores some additional helpers, which to get some profile data """ def get_active_members(self): ''' Get all people who are active ''' return self.filter(is_active = True) When, I try to call something like UserProfile.obgets.get_active_members() I am getting the raise AttributeError, "Manager isn't accessible via %s instances" % type.__name__ AttributeError: Manager isn't accessible via UserProfile instances Could you please help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Manager is not accessible via model instances
the code I use is active_list = UserProfile.objects\ .get_active_members()\ .exclude(user = current_user) On Fri, Sep 18, 2009 at 7:28 PM, Daniel Roseman wrote: > > On Sep 18, 4:34 pm, Oleg Oltar ltarase...@gmail.com> > wrote: > > Hi! > > > > I have following model: > > > > class UserProfile(models.Model): > > """ > > User profile model, cintains a Foreign Key, which links it to the > > user profile. > > """ > > about = models.TextField(blank=True) > > user = models.ForeignKey(User, unique=True) > > ranking = models.IntegerField(default = 1) > > avatar = models.ImageField(upload_to="usermedia", default = > > 'images/js.jpg') > > updated = models.DateTimeField(auto_now=True, default=datetime.now()) > > is_bot = models.BooleanField(default = False) > > is_active = models.BooleanField(default = True) > > is_free = models.BooleanField(default = True) > > objects = ProfileManager() > > > > def __unicode__(self): > > return u"%s profile" %self.user > > > > And a manager > > > > class ProfileManager(models.Manager): > > """ > > Stores some additional helpers, which to get some profile data > > """ > > def get_active_members(self): > > ''' > > Get all people who are active > > ''' > > return self.filter(is_active = True) > > > > When, I try to call something like > UserProfile.obgets.get_active_members() > > > > I am getting the > > > > raise AttributeError, "Manager isn't accessible via %s instances" % > > type.__name__ > > AttributeError: Manager isn't accessible via UserProfile instances > > > > Could you please help > > Are you really calling UserProfile.objects.get_active_members()? If > so, this should work. But the error says you are calling it from a > UserProfile *instance*. Please show the exact code that you're using > to call the manager. > -- > DR. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Linking items from the same model
Hi I am trying to create a model for Article site. I want to link each article with 3-5 related articles, so what I am thinking of is creating code this way: class Article (models.Model): # Tiny url url = models.CharField(max_length = 30, unique=True) is_published = models.BooleanField() author = models.CharField(max_length = 150) title = models.CharField(max_length = 200) short_description = models.TextField(max_length = 600) body = tinymce_models.HTMLField() related1 = models.ForeignKey(Article) related2 = models.ForeignKey(Article) related3 = models.ForeignKey(Article) But not sure if it's possible to make a foreign key relation to the same model. Also if for example, I will decide to bind 6, 7 articles together, how that will work, do I have to write related4, 5, 6in the model? I want to have more common solution, so if I binding more articles, I don't need to redefine code again and again What I am thinking of is not to extend Article models with related fields.. (It looks ugly) Maybe it worth creating another model? For example: ArticleSet But how to define there unrestricted list (without limit of items)..Could you suggest a way? Thanks in advance --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Linking items from the same model
I tried to do it. It works really nice. I wonder how can I query all articles related to the current one in a view... Need some examples. Also currently I see all articles in a listbox...And as far as I have more then 200 in the database it's quite hard to select something. Maybe its possible to arrange some filters to the list? On Sat, Oct 17, 2009 at 7:40 PM, bruno desthuilliers < bruno.desthuilli...@gmail.com> wrote: > > > > On 17 oct, 17:45, Oleg Oltar wrote: > > Hi > > > > I am trying to create a model for Article site. I want to link each > article > > with 3-5 related articles, so what I am thinking of is creating code this > > way: > > > > class Article (models.Model): > > # Tiny url > > url = models.CharField(max_length = 30, unique=True) > > is_published = models.BooleanField() > > author = models.CharField(max_length = 150) > > title = models.CharField(max_length = 200) > > short_description = models.TextField(max_length = 600) > > body = tinymce_models.HTMLField() > > related1 = models.ForeignKey(Article) > > related2 = models.ForeignKey(Article) > > related3 = models.ForeignKey(Article) > > > > But not sure if it's possible to make a foreign key relation to the same > > model. > > It is of course possible, and it's documented here: > > > http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey > > But: > > >Also if for example, I will decide to bind 6, 7 articles together, > > how that will work, do I have to write related4, 5, 6in the model? I > > want to have more common solution, so if I binding more articles, I don't > > need to redefine code again and again > > A very sensible concern !-) > > And the solution is obviously to use a many to many relationship - as > documented here: > > http://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield > > You'll probably want to make this relationship symetrical (as > explained in the FineManual). > > HTH > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Linking items from the same model
I would really want to add some sort of filtering to that http://img.skitch.com/20091017-mfs2mbhbuudk2rgquium1bu61d.png On Sat, Oct 17, 2009 at 10:00 PM, Oleg Oltar wrote: > I tried to do it. It works really nice. > > I wonder how can I query all articles related to the current one in a > view... Need some examples. > > > Also currently I see all articles in a listbox...And as far as I have more > then 200 in the database it's quite hard to select something. Maybe its > possible to arrange some filters to the list? > > > On Sat, Oct 17, 2009 at 7:40 PM, bruno desthuilliers < > bruno.desthuilli...@gmail.com> wrote: > >> >> >> >> On 17 oct, 17:45, Oleg Oltar wrote: >> > Hi >> > >> > I am trying to create a model for Article site. I want to link each >> article >> > with 3-5 related articles, so what I am thinking of is creating code >> this >> > way: >> > >> > class Article (models.Model): >> > # Tiny url >> > url = models.CharField(max_length = 30, unique=True) >> > is_published = models.BooleanField() >> > author = models.CharField(max_length = 150) >> > title = models.CharField(max_length = 200) >> > short_description = models.TextField(max_length = 600) >> > body = tinymce_models.HTMLField() >> > related1 = models.ForeignKey(Article) >> > related2 = models.ForeignKey(Article) >> > related3 = models.ForeignKey(Article) >> > >> > But not sure if it's possible to make a foreign key relation to the same >> > model. >> >> It is of course possible, and it's documented here: >> >> >> http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey >> >> But: >> >> >Also if for example, I will decide to bind 6, 7 articles together, >> > how that will work, do I have to write related4, 5, 6in the model? I >> > want to have more common solution, so if I binding more articles, I >> don't >> > need to redefine code again and again >> >> A very sensible concern !-) >> >> And the solution is obviously to use a many to many relationship - as >> documented here: >> >> http://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield >> >> You'll probably want to make this relationship symetrical (as >> explained in the FineManual). >> >> HTH >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: digg style pagination
I am trying to use the application http://code.google.com/p/django-pagination/, that you proposed in the latest post. But getting an exception. Could you help to fix it please? TemplateSyntaxError at /section/home Caught an exception while rendering: 'request' Original Traceback (most recent call last): File "/opt/local/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/opt/local/lib/python2.5/site-packages/django_pagination-1.0.5-py2.5.egg/pagination/templatetags/pagination_tags.py", line 90, in render page_obj = paginator.page(context['request'].page) File "/opt/local/lib/python2.5/site-packages/django/template/context.py", line 49, in __getitem__ raise KeyError(key) KeyError: 'request' Request Method: GET Request URL: http://127.0.0.1:8000/section/home Exception Type: TemplateSyntaxError Exception Value: Caught an exception while rendering: 'request' Original Traceback (most recent call last): File "/opt/local/lib/python2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/opt/local/lib/python2.5/site-packages/django_pagination-1.0.5-py2.5.egg/pagination/templatetags/pagination_tags.py", line 90, in render page_obj = paginator.page(context['request'].page) File "/opt/local/lib/python2.5/site-packages/django/template/context.py", line 49, in __getitem__ raise KeyError(key) KeyError: 'request' On Mon, Sep 7, 2009 at 7:38 PM, Michael Ralan wrote: > > It's possible to get digg-style pagination yes. What you need to do is > this. > > Get the django-pagination add-on from the following url > > http://code.google.com/p/django-pagination/ > > The documentation says unzip the pagination folder to a path > accessible to python. This is usually taken to mean your site-packages > folder. I couldn't do that because my app will be hosted on a server > where I don't have that sort privilege. > > So what I did was to unzip it into a folder I did have access to. > Because I'm running django using mod_wsgi there is a place I could add > the following line to my initialization code. (Actually I added it to > my projectfolder\apache\django.wsgi file). Unless the latter is > already familiar to you probably have to scratch around somewhere. > > sys.path.append('g:/xampp/htdocs/pagination') > > From this point I followed the included documentation and it works! > > For the digg-look and feel I had to download some .css styling at > > > http://mis-algoritmos.com/2007/03/16/some-styles-for-your-pagination/?page=2 > > Hope this helps! > > Regards > > On Aug 17, 3:19 pm, sniper wrote: > > Hi, > > Thanks for the help. I thought there would be django's official built > > in > > functionality which i might have missed, but looks like i have to > > use unofficial third party code. > > > > On Aug 14, 6:49 pm, Benjamin Wohlwend wrote: > > > > > Hi, > > > > > On Aug 14, 8:54 pm,sniper wrote: > > > > > > I am asking this because in the admin page, the list page uses digg > > > > style paging. > > > > > Like everything else that comes with Django, the admin app is open > > > source, so nothing stops you from having a peek. This particular > > > functionality can be found in django/contrib/admin/templatetags/ > > > admin_list.py, line 28[1]. The template tag has some admin-specifics > > > in it, you'd have to copy the template tag and adjust it. Or, and this > > > is probably what David so eloquently suggested, you could use one of > > > the countless digg-style paginators for Django that float around the > > > net. I'm quite fond of this[2] one because it extends the built-in > > > pagination facilities instead of completely reinventing the wheel. > > > > > Kind regards, > > > Benjamin > > > > > [1] > http://code.djangoproject.com/browser/django/trunk/django/contrib/adm... > > > [2]http://www.djangosnippets.org/snippets/773/ > --~--~-~--~~~---~--~~ > You received this message because you are subscribed to the Google 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-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=.
Re: digg style pagination
Agree. Fixed now On Thu, Nov 19, 2009 at 11:51 AM, Tim Chase wrote: >> But getting an exception. Could you help to fix it please? >> >> TemplateSyntaxError at /section/home >> >> Caught an exception while rendering: 'request' >> >> Original Traceback (most recent call last): >> File "/opt/local/lib/python2.5/site-packages/django/template/debug.py", >> line 71, in render_node >> result = node.render(context) >> File >> "/opt/local/lib/python2.5/site-packages/django_pagination-1.0.5-py2.5.egg/pagination/templatetags/pagination_tags.py", >> line 90, in render >> page_obj = paginator.page(context['request'].page) >> File "/opt/local/lib/python2.5/site-packages/django/template/context.py", >> line 49, in __getitem__ >> raise KeyError(key) >> KeyError: 'request' > > Sounds exactly like the error suggests: you haven't included the > request in your rendering context. What is your view for > rendering this template? Does it pass a RequestContext to > render_to_response or does it just pass a dictionary without > > 'request': request, > > in it? > > -tim > > > -- > > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-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=. > > > -- 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=.
Serving admin media files
Hi I am trying to serve static files from another domain (sub domain of current domain). To serve all media files I used this settings: MEDIA_URL = 'http://media.bud-inform.co.ua/' So when in template I used {{ MEDIA_URL }} it was replace with the setting above. Now I am trying to serve admin media files from the same subdomain, I changed the settings this way: ADMIN_MEDIA_PREFIX = 'http://media.bud-inform.co.ua/admin%5Fmedia/', and expected that all calls to media from my admin site will be made to this url But actually it didn't work this way, I still see paths to CSS made as following: http://bud-inform.co.ua/media/css/login.css Could you suggest how to serve admin media files correctly -- 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.
Django: PYTHON_EGG_CACHE, access denied error
Hi! I am deploying my django application on a server, and on last stages I am getting this error: ExtractionError at /admin/ Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is currently set to: /.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. Request Method: GET Request URL:http://go-ban.org/admin/ Exception Type: ExtractionError Exception Value: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is currently set to: /.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory. Exception Location: /usr/lib/python2.5/site-packages/pkg_resources.py in extraction_error, line 887 Python Executable: /usr/bin/python Python Version: 2.5.2 Python Path:['/home/oleg/sites/goban', '/usr/lib/python2.5/site-packages/PIL-1.1.7-py2.5-linux-i686.egg', '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg', '/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/PIL', '/var/lib/python-support/python2.5'] Server time:Sun, 6 Dec 2009 14:05:47 +0200 Maybe someone come across similar issue? The strangest thing here is that I am using another django site on this host with no such error :( -- 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.
Help me to fix problem related to migration from one server to another
Hi, I've moved my django application from one server to another, and spotted strange bug with media after it: Traceback (most recent call last): File "/usr/lib/python2.5/site- packages/Django-1.1.1-py2.5.egg/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.5/site-packages/Django-1.1.1-py2.5.egg/django/views/static.py", line 51, in serve if os.path.isdir(fullpath): File "/usr/lib/python2.5/posixpath.py", line 195, in isdir st = os.stat(path) UnicodeEncodeError: 'ascii' codec can't encode characters in position 44-46: ordinal not in range(128) The image I am trying to access actually have Cyrillic symbols in the name, but it didn't made a problem on previous environment Thanks, Oleg -- 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.
Django, serving different comments for site in other language
Hi I have created an article site, where articles are published in several languages. I am using transmeta (http://code.google.com/p/django-transmeta/) to support multiple languages in one model. Also I am using generic comments framework, to make articles commentable. I wonder what will happen if the same article will be commented in one language and then in another. Looks like all comments will be displayed on both variants The question actually is: Is there a possibility to display only comments submitted with current language of the article? -- 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: dump utf8 data from database
Which database do you use? Also you can dump data using python manage.py help dumpdata (So data can be imported to any database). Thanks, Oleg On Tue, Jan 26, 2010 at 6:22 AM, Weiwei wrote: > Hi all, > > is there a easy way to dump utf8 data from database? > > 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. > > -- 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.
Django comments application. How to make comments private by default?
Someone is posting many bad comments to my site. Is there possibility to make all submitted comments private by default (so I will need to review them to enable)? (I am using http://docs.djangoproject.com/en/dev/ref/contrib/comments/) -- 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 comments application. How to make comments private by default?
Yes, definitely. But I can't make it work: e.g. in my admin file class ArticleCommentModerator(CommentModerator): enable_field = 'enable_comments' auto_moderate_field='date_published' moderate_after=1 moderator.register(BaseArticle, ArticleCommentModerator) model class BaseArticle(models.Model): menu = models.ForeignKey(Menu) url = models.CharField(max_length = 200, unique = True) title = models.CharField(max_length = 500, blank = True) keywords = models.CharField(max_length = 800, blank = True) seo_description = models.TextField(blank = True) content = tinymce_models.HTMLField() author = models.CharField(max_length = 800, blank = True) published = models.BooleanField(default = False) enable_comments = models.BooleanField(default=False) pub_date = models.DateTimeField('date_published', blank = True) And I see: Comment post not allowed (400) Why: comment_will_be_posted receiver 'pre_save_moderation' killed the comment The comment you tried to post to this view wasn't saved because something tampered with the security information in the comment form. The message above should explain the problem, or you can check the comment documentation<http://docs.djangoproject.com/en/dev/ref/contrib/comments/>for more help. Without any other explanations... On Fri, Apr 2, 2010 at 9:19 PM, Rolando Espinoza La Fuente < dark...@gmail.com> wrote: > On Fri, Apr 2, 2010 at 12:52 PM, Oleg Oltar wrote: > > Someone is posting many bad comments to my site. Is there possibility to > > make all submitted comments private by default (so I will need to review > > them to enable)? > > Looking for comment moderation? > http://docs.djangoproject.com/en/dev/ref/contrib/comments/moderation/ > > ~Rolando > > -- > 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.
Help with django translation for django-sorting
Hi need help, I am using django soring application: https://github.com/directeur/django-sorting I just wonder if there is a way to make local names for sorting filters... E.g. I am trying to localize following: {% anchor total Rating %} And using standard django trick {% anchor total _("Rating") %} is not helping... Don't know what to do... See: http://stackoverflow.com/questions/5978927/django-sorting-localization-is-not-working -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.