Re: django template variables
alright, thanks a lot Syed :P -- 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: doctests not running
Just for a case of more weirdness, here is my model.py with some extra doctests thrown in: import markdown from django.db import models from django.forms import ModelForm import settings class Flatpage(models.Model): """ >>> 1 + 2 3 """ page_name = models.CharField(max_length=100, primary_key=True, unique=True) title = models.CharField(blank=True, max_length=100) description = models.CharField(blank=True, max_length=255) markdown_content = models.TextField('content') content = models.TextField(editable=False) class Meta: ordering = ['page_name'] def __unicode__(self): """ >>> 2 + 3 5 """ return self.page_name def get_absolute_url(self): """ >>> 1 + 2 3 >>> home_fp = Flatpage.objects.get(page_name="Home") >>> home_fp.get_absolute_url() '/' Test that about page works: >>> about_fp = Flatpage.objects.get(page_name="About") >>> about_fp.get_absolute_url() '/about/' Use urlconf to determine url name from page name and then use url name to get absolute url. Returns none if there is no url name associated with the page name. Test that homepage works: """ from django.core.urlresolvers import reverse from urls import urlpatterns for urlpattern in urlpatterns: if (hasattr(urlpattern, "default_args") and "page" in urlpattern.default_args and urlpattern.default_args["page"] == self.page_name and hasattr(urlpattern, "name")): return reverse(urlpattern.name) return None def save(self, force_insert=False, force_update=False): """ >>> 1 + 3 4 """ self.content = markdown.markdown(self.markdown_content) super(Flatpage, self).save(force_insert, force_update) and here is the new test output: Installed 6 object(s) from 1 fixture(s) Doctest: osl_flatpages.models.Flatpage ... ok Doctest: osl_flatpages.models.Flatpage.__unicode__ ... ok Doctest: osl_flatpages.models.Flatpage.save ... ok -- Ran 3 tests in 0.005s It appears to be running doctests for every method except for get_absolute_url. On Jul 10, 11:45 pm, Jeffwrote: > Just to follow-up, the syntax itself does not appear to be a problem: > > >>> import doctest > >>> import osl_flatpages > >>> doctest.testmod(osl_flatpages.models, verbose=1) > > Trying: > home_fp = Flatpage.objects.get(page_name="Home") > Expecting nothing > ok > Trying: > home_fp.get_absolute_url() > Expecting: > '/' > ok > Trying: > about_fp = Flatpage.objects.get(page_name="About") > Expecting nothing > ok > Trying: > about_fp.get_absolute_url() > Expecting: > '/about/' > ok > 6 items had no tests: > osl_flatpages.models > osl_flatpages.models.Flatpage > osl_flatpages.models.Flatpage.DoesNotExist > osl_flatpages.models.Flatpage.MultipleObjectsReturned > osl_flatpages.models.Flatpage.__unicode__ > osl_flatpages.models.Flatpage.save > 1 items passed all tests: > 4 tests in osl_flatpages.models.Flatpage.get_absolute_url > 4 tests in 7 items. > 4 passed and 0 failed. > Test passed. > TestResults(failed=0, attempted=4) > > So the problem appears to be with the Django test runner not adding > the doctests to the test suite it runs. I'm still not sure how to fix > this issue unfortunately. > > On Jul 10, 9:50 pm, Jeff wrote: > > > > > Hi, > > > I have a rather complicated get_absolute_url method in a models.py > > file that I wanted to use two doctests to check. Unfortunately the > > doctests do not appear to run when I run python manage.py test > > according to the verbose output. > > > Here is the method: > > > def get_absolute_url(self): > > """ > > Use urlconf to determine url name from page name and then use > > url name > > to get absolute url. > > > Returns none if there is no url name associated with the page > > name. > > > Test that homepage works: > > >>> home_fp = Flatpage.objects.get(page_name="Home") > > >>> home_fp.get_absolute_url() > > '/' > > > Test that about page works: > > >>> about_fp = Flatpage.objects.get(page_name="About") > > >>> about_fp.get_absolute_url() > > '/about/' > > """ > > from django.core.urlresolvers import reverse > > from urls import urlpatterns > > > for urlpattern in urlpatterns: > > if (hasattr(urlpattern, "default_args") and > > "page" in urlpattern.default_args and > > urlpattern.default_args["page"] == self.page_name and > > hasattr(urlpattern, "name")): > > > return reverse(urlpattern.name) > > >
Re: doctests not running
Just to follow-up, the syntax itself does not appear to be a problem: >>> import doctest >>> import osl_flatpages >>> doctest.testmod(osl_flatpages.models, verbose=1) Trying: home_fp = Flatpage.objects.get(page_name="Home") Expecting nothing ok Trying: home_fp.get_absolute_url() Expecting: '/' ok Trying: about_fp = Flatpage.objects.get(page_name="About") Expecting nothing ok Trying: about_fp.get_absolute_url() Expecting: '/about/' ok 6 items had no tests: osl_flatpages.models osl_flatpages.models.Flatpage osl_flatpages.models.Flatpage.DoesNotExist osl_flatpages.models.Flatpage.MultipleObjectsReturned osl_flatpages.models.Flatpage.__unicode__ osl_flatpages.models.Flatpage.save 1 items passed all tests: 4 tests in osl_flatpages.models.Flatpage.get_absolute_url 4 tests in 7 items. 4 passed and 0 failed. Test passed. TestResults(failed=0, attempted=4) So the problem appears to be with the Django test runner not adding the doctests to the test suite it runs. I'm still not sure how to fix this issue unfortunately. On Jul 10, 9:50 pm, Jeffwrote: > Hi, > > I have a rather complicated get_absolute_url method in a models.py > file that I wanted to use two doctests to check. Unfortunately the > doctests do not appear to run when I run python manage.py test > according to the verbose output. > > Here is the method: > > def get_absolute_url(self): > """ > Use urlconf to determine url name from page name and then use > url name > to get absolute url. > > Returns none if there is no url name associated with the page > name. > > Test that homepage works: > >>> home_fp = Flatpage.objects.get(page_name="Home") > >>> home_fp.get_absolute_url() > '/' > > Test that about page works: > >>> about_fp = Flatpage.objects.get(page_name="About") > >>> about_fp.get_absolute_url() > '/about/' > """ > from django.core.urlresolvers import reverse > from urls import urlpatterns > > for urlpattern in urlpatterns: > if (hasattr(urlpattern, "default_args") and > "page" in urlpattern.default_args and > urlpattern.default_args["page"] == self.page_name and > hasattr(urlpattern, "name")): > > return reverse(urlpattern.name) > > return None > > And here is the test output: > Installed 6 object(s) from 1 fixture(s) > test_correct_template_loaded > (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok > test_description (osl_flatpages.tests.views.OslFlatpageTestCase) ... > ok > test_existent (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok > test_nonexistent (osl_flatpages.tests.views.OslFlatpageTestCase) ... > ok > test_nontemplate_content > (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok > test_template_content > (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok > test_title (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok > > -- > Ran 7 tests in 0.415s > > As you can see, there is no mention of the two doctests being run. > > Any ideas as to why the two doctests are not running? -- 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.
doctests not running
Hi, I have a rather complicated get_absolute_url method in a models.py file that I wanted to use two doctests to check. Unfortunately the doctests do not appear to run when I run python manage.py test according to the verbose output. Here is the method: def get_absolute_url(self): """ Use urlconf to determine url name from page name and then use url name to get absolute url. Returns none if there is no url name associated with the page name. Test that homepage works: >>> home_fp = Flatpage.objects.get(page_name="Home") >>> home_fp.get_absolute_url() '/' Test that about page works: >>> about_fp = Flatpage.objects.get(page_name="About") >>> about_fp.get_absolute_url() '/about/' """ from django.core.urlresolvers import reverse from urls import urlpatterns for urlpattern in urlpatterns: if (hasattr(urlpattern, "default_args") and "page" in urlpattern.default_args and urlpattern.default_args["page"] == self.page_name and hasattr(urlpattern, "name")): return reverse(urlpattern.name) return None And here is the test output: Installed 6 object(s) from 1 fixture(s) test_correct_template_loaded (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok test_description (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok test_existent (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok test_nonexistent (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok test_nontemplate_content (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok test_template_content (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok test_title (osl_flatpages.tests.views.OslFlatpageTestCase) ... ok -- Ran 7 tests in 0.415s As you can see, there is no mention of the two doctests being run. Any ideas as to why the two doctests are not running? -- 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.
Nose Testing
Hi, Does anyone know how to get nose testing to work on Google App Engine (dev_appserver.py)? I have given django-nose a try. It works fine on django1.2.1 without dev_appserver. Also, does anyone know how to hook up nose plugins with django-nose such as freshen? Thank you so much for helping. Binh Tran -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to modify many to many data without auto saving to DB?
On Saturday, July 10, 2010, zwebwrote: > Assume there is many to many between publication and article. (example > from django docs) > > By default following stmt will auto save the relationship between > a_publication and article11 in database. > > a_publication.articles = [article11] > > how do I get that so that it changes only in memory (for session) but > does not get saved in DB unless explicitly told to save? That's not how many-to-many relations work. M2m fields save on assignment, by design. The only way to avoid the save is to avoid the assignment; collate your list of related objects in a let before assigning them to the m2m field. 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-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: Reversing URL with unnamed capturing groups
On Sunday, July 11, 2010, Phui Hockwrote: > Hi, > It seems that if I split a URL with unnamed capturing groups into > different urls.py files, urlresolvers.reverse(..) doesn't work as > expected. For example: > > --- root urls.py --- > (r'^foo/(.*)/', include('foo.urls')) > > --- foo/urls.py --- > url('^(.*)/$', blackhole, name='foo_1') > > When I do urlresolvers.reverse('foo_1', args=["1", "2"], I'd expect / > foo/1/2/. However, the actual result is /foo/2/2/. Is that not > supported, or am I doing something totally wrong here? Named capturing > group is the only way to go? > The problem you are describing is ticket #11559. At least at the moment, it's not supported behavior. The ticket contains a discussion of the complications associated with the idea. 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-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: Admin site not formatted
Read: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/?from=olddocs#id1 It tells you about serving static files with mod_python. Graham On Jul 11, 3:50 am, octopusgrabbuswrote: > Using Apache and not the built-in Django web server, I can reach the > admin site, but it's not formatted well, as it is with the built-in > web server. > > Any ideas on what to do? > > Here's the location directive in apache > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE chapter4.settings > PythonOption django.root /home/amr/web/django/chapter4 > PythonPath "['/home/amr/web/django/'] + ['/home/amr/web/django/ > favorites/'] + sys.path > " > PythonDebug On > -- 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: mod_wsgi problem with installation
You have not supplied all the output, but likely that you don't have either python-dev or httpd-dev packages installed and so cant find header files for one of the other. Read the README in the mod_wsgi source code for requirements as to what must be installed on your system. Graham On Jul 10, 9:08 pm, tazimkwrote: > hi, > > Trying to figure out why make gives following errors . > What is wrong with installation ? > > mod_wsgi.c:14532: error: initializer element is not constant > mod_wsgi.c:14532: warning: data definition has no type or storage > class > mod_wsgi.c:14533: warning: parameter names (without types) in function > declarati on > mod_wsgi.c:14533: warning: data definition has no type or storage > class > mod_wsgi.c:14534: error: syntax error before '}' token > mod_wsgi.c:14536: warning: parameter names (without types) in function > declarati on > mod_wsgi.c:14536: warning: data definition has no type or storage > class > mod_wsgi.c:14537: warning: parameter names (without types) in function > declarati on > mod_wsgi.c:14537: warning: data definition has no type or storage > class > mod_wsgi.c:14541: error: syntax error before '(' token > mod_wsgi.c:14563: warning: data definition has no type or storage > class > mod_wsgi.c:14565: warning: parameter names (without types) in function > declarati on > mod_wsgi.c:14565: warning: data definition has no type or storage > class > mod_wsgi.c:14567: error: syntax error before "return" > apxs:Error: Command failed with rc=65536 > . > make: *** [mod_wsgi.la] Error 1 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How to pass a GET param that contains multiple items
I have a url in my app that needs to get info from a GET param. For example, let's say my url is retrieving books by any of a set of authors, so the url might be this to get books authored by smith, johnson, or klein: www.example.com/books/?author=smith+johnson+klein I notice that when I look at request.GET.get('author') on the server, the '+' is gone and replaced by space: Is this django doing this for me or is this some sort of general http protocal thing? My main question is just - what's the accepted way to pass in a get parameter that contains a bunch of times. What if the parameter itself has spaces? I've seen this '+' used - is that standard or just personal preference? Thanks, Margie -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to modify many to many data without auto saving to DB?
Is there a reason why Django does auto save to DB in following stmts? Any way to tell it not to auto save to db? examples, where publications and articles are many to many.. a_publication.articles = [article11] or request.user.groups = [group1] On Jul 9, 5:06 pm, zwebwrote: > Assume there is many to many between publication and article. (example > from django docs) > > By default following stmt will auto save the relationship between > a_publication and article11 in database. > > a_publication.articles = [article11] > > how do I get that so that it changes only in memory (for session) but > does not get saved in DB unless explicitly told to save? > > [I cannot change the table structure to remove many to many] -- 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.
Calendar Templatetag
Hello, I am currently using the Calendar Templatetag found at http://djangosnippets.org/snippets/129/ and it suites my current needs. However, I would like to extend the functionality of the templatetag by rendering previous and next months i.e., June 2010, July 2010, August 2010, September 2010 as well as capturing events in multiple days. I looked at Django-Schedule and Swingtime, but the apps are too complex for my simple needs. The code: from datetime import date, timedelta from django import template from myapp.models import Event register = template.Library() from datetime import date, timedelta def get_last_day_of_month(year, month): if (month == 12): year += 1 month = 1 else: month += 1 return date(year, month, 1) - timedelta(1) def month_cal(year, month): event_list = Event.objects.filter(start_date__year=year, start_date__month=month) first_day_of_month = date(year, month, 1) last_day_of_month = get_last_day_of_month(year, month) first_day_of_calendar = first_day_of_month - timedelta(first_day_of_month.weekday()) last_day_of_calendar = last_day_of_month + timedelta(7 - last_day_of_month.weekday()) What is the best method for adding this added functionality. Am I better writing views or context processor month_cal = [] week = [] week_headers = [] i = 0 day = first_day_of_calendar while day <= last_day_of_calendar:What is the best method for adding this added functionality. Am I better writing views or context processor if i < 7:What is the week_headers.append(day) cal_day = {} cal_day['day'] = day cal_day['event'] = False for event in event_list: if day >= event.start_date.date() and day <= event.end_date.date(): cal_day['event'] = True if day.month == month: cal_day['in_month'] = True else:s are cal_day['in_month'] = False week.append(cal_day) if day.weekday() == 6: month_cal.append(week) week = [] i += 1 day += timedelta(1) return {'calendar': month_cal, 'headers': week_headers} register.inclusion_tag('agenda/month_cal.html')(month_cal) My question is: How should I attempt to add this functionality given the model that I am currently using uses a start_date and end_date. Appreciate yours inputs and suggestions. VR, _Mario -- 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: IntegrityError
As another idea, can you just update your SITE_ID setting (http:// docs.djangoproject.com/en/1.2/ref/settings/#site-id)? It defaults to 1 (for the example.com instance), but if you've got a new Site object for your actual domain, you should just be able to use its id instead. -Justin On Jul 10, 7:32 am, Karen Traceywrote: > On Sat, Jul 10, 2010 at 2:04 AM, Fynn wrote: > > Exception Type: IntegrityError at /comments/post/ > > Exception Value: insert or update on table "django_comments" violates > > foreign key constraint "django_comments_site_id_fkey" > > DETAIL: Key (site_id)=(1) is not present in table "django_site". > > > It is right, the key 1 does not exist in django_site, because I > > deleted example.com via the admin site. I didn't think it was > > important. Was I wrong? > > Yes. Rather than deleting the example.com site you should have updated it to > contain correct information for your site. Comments is one of the contrib > apps that uses the sites framework. > See:http://docs.djangoproject.com/en/dev/ref/contrib/sites/#how-django-us... > > Karen > --http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Apache configuration
Hi, Please use mod_wsgi instead of mod_python, it is better in all ways. http://docs.djangoproject.com/en/1.2/howto/deployment/modwsgi/#howto-deployment-modwsgi Best, Anders Petersson On Jul 10, 7:49 pm, octopusgrabbuswrote: > I worked through samples in the Visual Quickpro Guide Django. I used > python manage.py runserver while running through the examples. > > Now, I want to configure this in Apache. Django is complaining about > finding modules underneath my top directory. > > Here's the apache configuration: > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE chapter4.settings > PythonOption django.root /home/amr/web/django/chapter4 > PythonPath "['/home/amr/web/django/'] + ['/home/amr/web/django/ > favorites/'] + sys.path > " > PythonDebug On > > > Here is the error: > > Request Method: GET > Request URL:http://localhost:8586/ > Exception Type: ImportError > Exception Value: > > No module named favorites.models > > Exception Location: /home/amr/web/django/chapter4/favorites/views.py > in , line 3 > P > > I can remove this error by editing view.py in chapter4/favorites and > modifying > > from favorites.models import * > > to > > from models import * > > My question is what configuration changes can I make in Apache to > avoid making this edit, given this code works with Django's default > web server? > > Thanks. > cmn -- 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.
Apache configuration
I worked through samples in the Visual Quickpro Guide Django. I used python manage.py runserver while running through the examples. Now, I want to configure this in Apache. Django is complaining about finding modules underneath my top directory. Here's the apache configuration: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE chapter4.settings PythonOption django.root /home/amr/web/django/chapter4 PythonPath "['/home/amr/web/django/'] + ['/home/amr/web/django/ favorites/'] + sys.path " PythonDebug On Here is the error: Request Method: GET Request URL: http://localhost:8586/ Exception Type: ImportError Exception Value: No module named favorites.models Exception Location: /home/amr/web/django/chapter4/favorites/views.py in , line 3 P I can remove this error by editing view.py in chapter4/favorites and modifying from favorites.models import * to from models import * My question is what configuration changes can I make in Apache to avoid making this edit, given this code works with Django's default web server? Thanks. cmn -- 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.
Admin site not formatted
Using Apache and not the built-in Django web server, I can reach the admin site, but it's not formatted well, as it is with the built-in web server. Any ideas on what to do? Here's the location directive in apache SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE chapter4.settings PythonOption django.root /home/amr/web/django/chapter4 PythonPath "['/home/amr/web/django/'] + ['/home/amr/web/django/ favorites/'] + sys.path " PythonDebug On -- 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.
Serving static files
Hi Below is my code: settings.py MEDIA_URL = '/static/' STATIC_DOC_ROOT = 'C:/djangotest/codificador/static/' urls.py urlpatterns = patterns(' ', (r'^static/(?P.*)$', 'django.static.views.serve', {'document_root': settings.STATIC_DOC_ROOT}), ) base.html in style tag:
Reversing URL with unnamed capturing groups
Hi, It seems that if I split a URL with unnamed capturing groups into different urls.py files, urlresolvers.reverse(..) doesn't work as expected. For example: --- root urls.py --- (r'^foo/(.*)/', include('foo.urls')) --- foo/urls.py --- url('^(.*)/$', blackhole, name='foo_1') When I do urlresolvers.reverse('foo_1', args=["1", "2"], I'd expect / foo/1/2/. However, the actual result is /foo/2/2/. Is that not supported, or am I doing something totally wrong here? Named capturing group is the only way to go? -- 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: defining custom attributes for a model
On Fri, Jul 9, 2010 at 4:52 PM, Sells, Fredwrote: > I've got a model as illustrated below. Is there any way I can define my > own attributes that are not columns like the "fredsstuff" below? > > > class A(MDSSection): > A0100A = models.CharField(max_length=10, help_text='''Text : > Facility National Provider Identifier (NPI)''') > A0100B = models.CharField(max_length=12, help_text='''Text : > Facility CMS Certification Number (CCN)''') > A0100C = models.CharField(max_length=15, help_text='''Text : > State provider number''') > A0200 = models.CharField(max_length= 1, help_text='''Code : > Type of provider''') > A0310A = models.CharField(max_length= 2, help_text='''Code : > Type of assessment: OBRA''') > ... > class Meta: > db_table = 'A' > fredsstuff = "xy" > > def validate(self): > errors = self.checkThis(fredsstuff) > return errors Just put fredsstuff at class-level class A(MDSSection): # fields here... # class attributes foo = 'bar' def do_stuff(self): return self.foo You can access with: A.foo or obj = A.objects.all()[0] obj.foo ~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.
"SESSION_SAVE_EVERY_REQUEST = True" performance hog? Any other cons?
SESSION_SAVE_EVERY_REQUEST = True (in settings.py) seems to avoid a lot of potential bugs from forgetting to set request.session.modified = True when necessary. Is this a serious performance problem? If not, I would think this would be a good *default* value for Django no? Chris -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-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: What causes request.session to be erased?...When you go to different view?
Wow beautiful. Thanks. I needed that. cs On Jul 10, 12:14 am, Javier Guerra Giraldezwrote: > On Fri, Jul 9, 2010 at 11:36 PM, Chris Seberino wrote: > > elif form.is_valid(): > > ... > > request.session["posts"].append(form.cleaned_data) > > > > > I noticed that everytime I revisit this form and rerun this view, the > > request.session["posts"] lists gets blown away and is empty again!?!? > > > Am I misunderstanding something about requests and sessions? > > from the docs > (http://docs.djangoproject.com/en/1.2/topics/http/sessions/#when-sessi... > > # Gotcha: Session is NOT modified, because this alters > # request.session['foo'] instead of request.session. > request.session['foo']['bar'] = 'baz' > In the last case of the above example, we can tell the session > object explicitly that it has been modified by setting the modified > attribute on the session object: > > request.session.modified = True > > that's exactly your case. the session object is saved automatically > only when it's marked as modified. but when you modify an object > inside the session and not the session itself; it doesn't gets > notified of the change, so you have to tell it explicitly. > > -- > Javier -- 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: Testing many-to-many models on a legacy database
On Sat, Jul 10, 2010 at 9:31 AM, Derekwrote: > Running Django 1.2.1 under Python 2.6. > I am obviously missing something cruccial, but I am just not sure where this > is... > I have a setup which includes a number of many-to-many models in a legacy > database. For example: > > class Grouping(models.Model): > id = models.AutoField(primary_key=True, db_column='GroupingID') > name = models.CharField(max_length=250, db_column='GroupingName', > unique=True) > class TaxAgreement(models.Model): > id = models.AutoField(primary_key=True, db_column='TaxID') > title = models.CharField(max_length=100, db_column='TaxTitle', > unique=True) > groupings = models.ManyToManyField(Grouping, > db_table='taxagreementgrouping') Use through keyword http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.through groupings = models.ManyToManyField(Grouping, through='TaxAgreementGrouping') ~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.
Re: how to dynamically update model fields?
On Sat, Jul 10, 2010 at 12:01 AM, zwebwrote: > I want to provide a method as follows, > > def update_some_model_field(key, field_name, value): > '''user provides the primary key of row, field name in model and the > value and the method updates the field for that row with the value''' > > 1. model_obj = Some_model.objects.get(pk = key) > 2. model_obj."field_name" = value ## HOW to make this line generic?? > I do not want to do lots of If as shown below. > 3. model_obj.save() [...] > > Any suggestions? setattr(model_obj, field_name, value) ~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.
Testing many-to-many models on a legacy database
Running Django 1.2.1 under Python 2.6. I am obviously missing something cruccial, but I am just not sure where this is... I have a setup which includes a number of many-to-many models in a legacy database. For example: class Grouping(models.Model): id = models.AutoField(primary_key=True, db_column='GroupingID') name = models.CharField(max_length=250, db_column='GroupingName', unique=True) class TaxAgreement(models.Model): id = models.AutoField(primary_key=True, db_column='TaxID') title = models.CharField(max_length=100, db_column='TaxTitle', unique=True) groupings = models.ManyToManyField(Grouping, db_table='taxagreementgrouping') class Meta: db_table = 'taxagreement' ... class TaxAgreementGrouping(models.Model): #many-to-many id = models.AutoField(primary_key=True, db_column='id') grouping = models.ForeignKey(Grouping, db_column='grouping_id') tax_agreement = models.ForeignKey(TaxAgreement, unique=True, db_column='taxagreement_id') class Meta: db_table = 'taxagreementgrouping' Now when I run the "python manage.py test", the run fails with this error: _mysql_exceptions.OperationalError: (1050, "Table 'taxagreementgrouping' already exists") and if I look through the table creation output statements, I see that 'taxagreementgrouping' table was created along with the 'taxagreement' one. Now if I change the TaxAgreement model to this: class TaxAgreement(models.Model): id = models.AutoField(primary_key=True, db_column='TaxID') title = models.CharField(max_length=100, db_column='TaxTitle', unique=True) groupings = models.ManyToManyField(Grouping) then the test runs just fine. However, when I now want to dump a copy of the database to serve a fixture, I run this: python manage.py dumpdata myapp > myapp/fixtures/myapp.json Error: Unable to serialize database: (1146, "Table 'taxagreement_grouping' doesn't exist") So now I go back to the database, and rename the TaxAgreementGrouping table: RENAME TABLE taxagreementgrouping TO taxagreement_grouping; and also update the model: class TaxAgreementGrouping(models.Model): #many-to-many id = models.AutoField(primary_key=True, db_column='id') grouping = models.ForeignKey(Grouping, db_column='grouping_id') tax_agreement = models.ForeignKey(TaxAgreement, unique=True, db_column='taxagreement_id') class Meta: db_table = 'taxagreement_grouping' Now the dump does not give me the above error anymore, but when I rerun the "python manage.py test", I get: _mysql_exceptions.OperationalError: (1050, "Table 'taxagreement_grouping' already exists") So obviously the problem - and I am not sure exactly what that is? - is not fixed... Any pointers or clues to resolve this? I really need to start testing sooner rather than later. Thanks Derek -- 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: IntegrityError
On Sat, Jul 10, 2010 at 2:04 AM, Fynnwrote: > Exception Type: IntegrityError at /comments/post/ > Exception Value: insert or update on table "django_comments" violates > foreign key constraint "django_comments_site_id_fkey" > DETAIL: Key (site_id)=(1) is not present in table "django_site". > > > It is right, the key 1 does not exist in django_site, because I > deleted example.com via the admin site. I didn't think it was > important. Was I wrong? > Yes. Rather than deleting the example.com site you should have updated it to contain correct information for your site. Comments is one of the contrib apps that uses the sites framework. See: http://docs.djangoproject.com/en/dev/ref/contrib/sites/#how-django-uses-the-sites-framework Karen -- http://tracey.org/kmt/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: www.djangoproject.com
On Thu, Jul 8, 2010 at 11:53 PM, Nick Raptiswrote: > Sorry for the rant but I can finally express my delayed frustration on this > bug.. > > I first I spent some 2-3 hours trying to find out if this problem came from > a broken ipv6 configuration. > Then, I actually had to delete all my profile files (delete half, find out > if it solves it, restore, delete half again) until I knew that prefs.js (the > about:config file) was responsible. > I then checked the more than a 6000 lines of that file in the same manner > (deleting half the lines each time) to find the offending option. > At that time I thought half my hair had gone grey! > > The only two sites affected by this was djangoproject.com and djangobook.com > Could be a django configuration issue on those, as other django powered > sites behaved normally. Ok - this is a little concerning. Are you saying that passing an invalid language preference as part of your request header causes Django sites (or, at least, some Django sites) to break? If so, this sounds like something that needs to be fixed in Django. > I'm SO glad that my frustrating time hunting this down actually helped > another soul! :D If you haven't torn all your hair out hunting this problem down in the first place, I'd appreciate any help you can provide in narrowing this problem down to a specific set of circumstances or configurations (both client side and server side). 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-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.
mod_wsgi problem with installation
hi, Trying to figure out why make gives following errors . What is wrong with installation ? mod_wsgi.c:14532: error: initializer element is not constant mod_wsgi.c:14532: warning: data definition has no type or storage class mod_wsgi.c:14533: warning: parameter names (without types) in function declarati on mod_wsgi.c:14533: warning: data definition has no type or storage class mod_wsgi.c:14534: error: syntax error before '}' token mod_wsgi.c:14536: warning: parameter names (without types) in function declarati on mod_wsgi.c:14536: warning: data definition has no type or storage class mod_wsgi.c:14537: warning: parameter names (without types) in function declarati on mod_wsgi.c:14537: warning: data definition has no type or storage class mod_wsgi.c:14541: error: syntax error before '(' token mod_wsgi.c:14563: warning: data definition has no type or storage class mod_wsgi.c:14565: warning: parameter names (without types) in function declarati on mod_wsgi.c:14565: warning: data definition has no type or storage class mod_wsgi.c:14567: error: syntax error before "return" apxs:Error: Command failed with rc=65536 . make: *** [mod_wsgi.la] Error 1 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: could not join irc #django channel
On Saturday 10 July 2010 10:12:21 evileyes wrote: > When I join irc #django channel, the server response "Cannot join > channel (+r) - you need to be identified with services", does anyone > know what is it means? > how can I join #django channel? > please do a google search on this list - the same problem came up yesterday with almost the same topic. -- Regards Kenneth Gonsalves Senior Associate NRC-FOSS at AU-KBC -- 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 template variables
dude I missed 1 important import. first add this, - from django.template import RequestContext also makesure your template path is set in settings.py mine looks something like this 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. "C:/Appframework/evento/evento/templates" ) so all my html file reside inside the templates directory, its like doc-root. it can also have sub directories inside it. it also has to be on the same level as my setttings.py and manage.py -- and no you can render as many variables as like this variables = RequestContext(request,{ 'paragraph': para , 'variable2':v2, 'variable3':v3}) - hope this solves you problem. On Sat, Jul 10, 2010 at 1:39 PM, commonzenpythonwrote: > thanks, unfortunately i keep getting a 404, the templates name is > 2col.html, its inside ash/templates, the url i have is (r'^paragraph/ > $', 'show_para'), and the views is > from django.http import HttpResponse > from django.shortcuts import render_to_response > > def show_para(request): >para = "I love this project" >variables = RequestContext(request,{ 'paragraph': para}) >return render_to_response('2col.html',variables) > > even if it works i was wondering if i would have to create a new > function for every variable, > 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. > > -- Syed Ali Saim Project Manager Softech Worldwide LLC -- 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: translation for variables
On Sat, Jul 10, 2010 at 05:26, Börniwrote: >> > Hello together, >> >> Are you running "django-admin.py compilemessages" to create the >> relevant django.mo file after the event? > > Yes, i've tried it with the existing django.po file. And my other try > was to create an additional file called database.po > > makemessages removes my manualy added entries from django.po Well, actually it doesn't remove them so much as not recognise them, and therefore not including them at merge time. Makemessages is a wrapper around gnu's gettext which does all the creation an d merging automagically. Hence, you can't just "add" a msgid to a po file - if the actual string is not in the file, or not marked to be translated, it wont appear in the po file. > compilemessages creates mo files from my database.po and django.mo > file, but django seems to ignore translations from any other files > than django.mo? Yes, that is expected behavior. All translations are expected to go into a django.po file. All of my apps have a locale folder that contains the relevant lang po|mo files...This means you will have a _lot_ of django.po files scattered throughout you various apps, but that's how it works. Since most apps use some form of version control makes this easy enough, given the generally tiny file size of po|mo files. > Have a nice day and thank you very much for help, No hassles mate. If my explanations don't make sense, let me know. cheers L. -- 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: Cannot connect to #django on irc
given you have a registered nick here is the simple step by step way. 1: Launch irc client 2: type /server irc.freenode.net 3: once connected to the server use password to identify you nick by typing /msg nickserv identify 4: joind channel django by typing /j #django and have fun! On Sat, Jul 10, 2010 at 11:12 AM, Ran Zhuwrote: > *I try every thing I can do, but still can't join #django, it really drive > me crazy!* > * > * > *I already register a nick name named "zhuran", how can I join #django?* > > 2010/7/10 Ran Zhu > > what is nickServ? it's a server like "irc.freenode.net" or the nick name I >> want to registerd? >> >> >> On Sat, Jul 10, 2010 at 7:57 AM, Kenneth Gonsalves wrote: >> >>> On Friday 09 July 2010 14:34:15 david ally wrote: >>> > I have been trying to join the irc channel for django and it is always >>> > giving me one problem or the other, one time it would respond that i >>> need >>> > to identify with service, other times is etc... >>> > >>> > == #django Cannot join channel (+r) - you need to be identified with >>> > services, >>> > >>> > -NickServ- You failed to identify in time for the nickname david >>> > >>> > Also, where do I setup the password for the django channel? I thought >>> it is >>> > supposed to be the same password i setup in the google group? >>> > >>> >>> you need a password for registering which will work on all freenode >>> channels. >>> Get onto freenode and do: >>> /msg nickserv register >>> >>> this will register your nick if it is not already registered. Once >>> registered, >>> to identify: >>> /msg nickserv identify >>> >>> and for help: >>> /msg nickserv help >>> >>> >>> -- >>> Regards >>> Kenneth Gonsalves >>> Senior Associate >>> NRC-FOSS at AU-KBC >>> >>> -- >>> 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. > -- Syed Ali Saim Project Manager Softech Worldwide LLC -- 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 template variables
thanks, unfortunately i keep getting a 404, the templates name is 2col.html, its inside ash/templates, the url i have is (r'^paragraph/ $', 'show_para'), and the views is from django.http import HttpResponse from django.shortcuts import render_to_response def show_para(request): para = "I love this project" variables = RequestContext(request,{ 'paragraph': para}) return render_to_response('2col.html',variables) even if it works i was wondering if i would have to create a new function for every variable, 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.
IntegrityError
Hi everyone, I'm using Nathan Borror's blog application which uses django's comment framework. I'm using django with a postgres database. Now, each time I try to add a comment, there is an IntegrityError: Environment: Request Method: POST Request URL: http://10.10.10.3:8080/comments/post/ Django Version: 1.2.1 Python Version: 2.6.5 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.comments', 'django.contrib.contenttypes', 'django.contrib.markup', 'django.contrib.messages', 'django.contrib.sessions', 'django.contrib.sites', 'basic.blog', 'basic.inlines', 'tagging'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware') Traceback: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ base.py" in get_response 100. response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.6/dist-packages/django/utils/ decorators.py" in _wrapped_view 76. response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/ http.py" in inner 37. return func(request, *args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/django/contrib/comments/ views/comments.py" in post_comment 123. comment.save() File "/usr/local/lib/python2.6/dist-packages/django/contrib/comments/ models.py" in save 85. super(Comment, self).save(*args, **kwargs) File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save 435. self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py" in save_base 535. transaction.commit_unless_managed(using=using) File "/usr/local/lib/python2.6/dist-packages/django/db/transaction.py" in commit_unless_managed 175. connection._commit() File "/usr/local/lib/python2.6/dist-packages/django/db/backends/ __init__.py" in _commit 32. return self.connection.commit() Exception Type: IntegrityError at /comments/post/ Exception Value: insert or update on table "django_comments" violates foreign key constraint "django_comments_site_id_fkey" DETAIL: Key (site_id)=(1) is not present in table "django_site". It is right, the key 1 does not exist in django_site, because I deleted example.com via the admin site. I didn't think it was important. Was I wrong? I'm a bit puzzled here. The traceback doesn't contain any of Nathan's or my code, it's only code that django ships with. It's called via a blog template: {% render_comment_form for object %} Would be glad if someone could help me to solve this. -- 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: Cannot connect to #django on irc
*I try every thing I can do, but still can't join #django, it really drive me crazy!* * * *I already register a nick name named "zhuran", how can I join #django?* 2010/7/10 Ran Zhu> what is nickServ? it's a server like "irc.freenode.net" or the nick name I > want to registerd? > > > On Sat, Jul 10, 2010 at 7:57 AM, Kenneth Gonsalves wrote: > >> On Friday 09 July 2010 14:34:15 david ally wrote: >> > I have been trying to join the irc channel for django and it is always >> > giving me one problem or the other, one time it would respond that i >> need >> > to identify with service, other times is etc... >> > >> > == #django Cannot join channel (+r) - you need to be identified with >> > services, >> > >> > -NickServ- You failed to identify in time for the nickname david >> > >> > Also, where do I setup the password for the django channel? I thought it >> is >> > supposed to be the same password i setup in the google group? >> > >> >> you need a password for registering which will work on all freenode >> channels. >> Get onto freenode and do: >> /msg nickserv register >> >> this will register your nick if it is not already registered. Once >> registered, >> to identify: >> /msg nickserv identify >> >> and for help: >> /msg nickserv help >> >> >> -- >> Regards >> Kenneth Gonsalves >> Senior Associate >> NRC-FOSS at AU-KBC >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-us...@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com >> . >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Cannot connect to #django on irc
what is nickServ? it's a server like "irc.freenode.net" or the nick name I want to registerd? On Sat, Jul 10, 2010 at 7:57 AM, Kenneth Gonsalveswrote: > On Friday 09 July 2010 14:34:15 david ally wrote: > > I have been trying to join the irc channel for django and it is always > > giving me one problem or the other, one time it would respond that i need > > to identify with service, other times is etc... > > > > == #django Cannot join channel (+r) - you need to be identified with > > services, > > > > -NickServ- You failed to identify in time for the nickname david > > > > Also, where do I setup the password for the django channel? I thought it > is > > supposed to be the same password i setup in the google group? > > > > you need a password for registering which will work on all freenode > channels. > Get onto freenode and do: > /msg nickserv register > > this will register your nick if it is not already registered. Once > registered, > to identify: > /msg nickserv identify > > and for help: > /msg nickserv help > > > -- > Regards > Kenneth Gonsalves > Senior Associate > NRC-FOSS at AU-KBC > > -- > 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. > > -- Name:朱然 Dept: 阿里巴巴-B2B-技术部-核心系统部-产品部-需求分析部 Tel: 0571-85022088-35905 Email:ran.z...@alibaba-inc.com AliTalk:ranzhur msn:zhuran1...@live.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-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.
could not join irc #django channel
hi all, When I join irc #django channel, the server response "Cannot join channel (+r) - you need to be identified with services", does anyone know what is it means? how can I join #django channel? -- 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: Database caching and multi db
On Fri, Jul 9, 2010 at 1:41 AM, tiemonsterwrote: > It seems that when running unit tests, the test runner not only > creates all tables on both of my connections (which it should not do, > if I read the documentation correctly), Tables will be created on all connections, according to the syncdb rules of your router (by default, all tables on all databases). However, the non-default databases will not be flushed at the end of each test unless you specify multi_db=True in your test case. This is done for performance reasons; unless you're specifically testing cross-database behavior, the overhead of setting up and tearing down multiple databases is quite onerous. > but also tries to create the > cache table twice, causing the error below. Please let me know if I'm > missing something here. I have two MySQL connections, called default > and datastore, and have my CACHE_BACKEND set to db://cache_table. It sounds like you may have found a problem (or, a series of related problems). At present, the cache database backend doesn't have any specific multi-db awareness. The CACHE_BACKEND setting doesn't allow you to specify which database the cache backend should operate upon; the backend itself just gets a cursor on the 'default' backend. On top of that, the createcachetable management command accepts a --database argument when it is run from the command line, which allows you to control where the cache table is created... but the create_test_db() utility doesn't pass that option when it programatically invokes createcachetable as part of database setup. So, when you try to create a test database, and you've specified a database cache backend, it will repeatedly try to create the database cache table on the default database. This explains why TEST_MIRROR fixed your problem. When you set TEST_MIRROR, you're effectively telling the test infrastructure that you don't need to create a specific database, so you avoid accidentally trying to create the cache table twice. So - yes, this should be logged as a ticket. As for a fix, there are three parts that are required. Firstly, create_test_db() should pass the database flag to the createcachetable command when it is invoked. Secondly, the cache backend itself needs to be made multi-db aware, so it doesn't just use the default database connection. Thirdly, the create_test_db() call needs an additional check -- as well as checking if the database cache backend is in use, it needs to check if the test database that is being created actually requires the cache table. Conceptually, problems 2 and 3 need to be fixed by the router. However, the API for the router requires that you provide a model as the basis for decision making; since the database cache backend doesn't use a Django model this won't really work well in practice. A better approach is probably to just add extra arguments to the CACHE_BACKEND setting when db:// is specified -- so, something like: CACHE_BACKEND="db://mycachetable?max_entries=100_db=foo_db=slave1_db=slave2" which would mean that: * the table would only be created on the database alias "foo" * one of [slave1, slave2] would be selected at random for read purposes. When unspecified, read_db would default to the same value as write_db; if write_db is unspecified, it would default to 'default'. 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-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 template variables
you can use django render_to_response which by far the most common and preferred way, i found as newbie my self. here is an example: (roughly but will give you an idea) --- Now following this is an extremly crude tut by myself, for a superb one try http://docs.djangoproject.com/en/1.2/intro/tutorial01/#intro-tutorial01 -- 1: you need to create and html file in which you will write your markup something, like and store it somewhere in your template directory lets assume you call it paragraph.html . {{paragraph}} 2: Next edit urls.py and add a pettern something similar this is important cause this is how django will know what url your looking for and call the appropriate function, the function you will write in step three. open urls.py and add # this is how django serves a function to prepare a view for a url. So here is what you tell django to do when some one request a url say # "http://yourserver/paragraph/; urlpatterns = patterns('', (r'^paragraph/$', show_para) ,) 3: You will write your business logic in views.py, in form of function from django.shortcuts import render_to_response def show_para(request) para = " I love this project" variables = RequestContext(request,{ 'paragraph': para}) # telling django to store the value in para , in the template variable paragraph return render_to_response('paragraph.html',variables) # here is what the user is served an html, with values you placed in it. -- On Sat, Jul 10, 2010 at 12:01 PM, commonzenpythonwrote: > hey guys, im trying to create a template that uses variables like > {{ paragraph }} , but i cannot find how to get django to render > the paragraph into the variable, i know i have to create a .py file > that uses django's render class to render the paragraph but how can i > connect the html file to the .py file so that it renders 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-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. > > -- Syed Ali Saim Project Manager Softech Worldwide LLC -- 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 template variables
hey guys, im trying to create a template that uses variables like {{ paragraph }} , but i cannot find how to get django to render the paragraph into the variable, i know i have to create a .py file that uses django's render class to render the paragraph but how can i connect the html file to the .py file so that it renders 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-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.