Re: Re-usable/pluggable app form question.

2009-09-03 Thread Peter Coles
You want your project "foo" to be able to (1) render content from a template and also (2) handle a request to a specific url. If you want to do (1), you can add 'django.template.loaders.app_directories.load_template_source' to your TEMPLATE_LOADERS in your settings file. In fact, it may be there

Re: Basic 404.html template issue

2009-09-07 Thread Peter Coles
In your example, when testing the 404 page, you wrote that you're no longer visiting a url under http://localhost:8000, but now you're visiting a url under http://fairware:8000 – was this an error in your post or were you actually checking the wrong server? The testserver will handle 404 pages pr

Re: Managers in admin

2009-09-08 Thread Peter Coles
Are you certain that the django admin interface is actually using LiveEntryManager? I just tested this out (using trunk): class BadManager(models.Manager): def all(self): return self.get_query_set().filter(slug='') def filter(self, *args, **kwargs): return super(BadManager, self).filter(

Re: Link for new page

2009-09-08 Thread Peter Coles
Make yourself familiar with the django documention page—if you know where to look for stuff there, you'll find it to be a very handy resource. http://docs.djangoproject.com/en/dev/ > 1: How can I go to next page when i submit the data in index page(log > in page) http://docs.djangoproject.com/en

Re: Having Trouble with Reverse method

2009-09-08 Thread Peter Coles
What you provided looks correct -- which means that something else is probably broken... Some things to investigate: 1. If you manually go that url: http:/in_development/ does anything get served? 2. Is your ROOT_URLCONF setup to properly point to this file in your settings file? 3. Is this anot

Re: Choices of foreign keys?

2009-09-09 Thread Peter Coles
Hey Léon, ChoiceField is a form field, not a table column—maybe you're thinking about CommaSeparatedIntegerField? You could use that and hardcode which categories represent which ids in your python code. http://docs.djangoproject.com/en/dev/ref/models/fields/#commaseparatedintegerfield On the ot

Re: Custom url in django Django sitemap

2009-09-09 Thread Peter Coles
Hi eli, If you want serve a "static file" (that never changes and doesn't take advantage of django's template system) then you shouldn't be serving it with django. You can use django if you really want: http://docs.djangoproject.com/en/dev/howto/static-files/ but you're better off having your se

Re: Choices of foreign keys?

2009-09-09 Thread Peter Coles
ou say that an object should be represented as a table in SQL. I know > that, too. But the choices I mentioned above, are confusing me. Can > you explain me why they exist, or give me a good example that justify > choices? > > -leond > > On Sep 9, 6:36 pm, Peter Coles wrote

Re: custom tag - render() isn't called

2009-09-11 Thread Peter Coles
I tried the above template_tag and it worked fine for me, maybe you're doing something wrong in the template? My best guess for why "__init__" would be called and not "render" is that the template_tag is not getting rendered due to some other logic in the template. All of these examples below wi

Re: Custom url in django Django sitemap

2009-09-11 Thread Peter Coles
bout the django sitemap > frameworkhttp://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/, > and problem: how to add my custom page (serving by server) to output > (XML) of the django sitemap framework? > > regards. > > On 9 Wrz, 18:47, Peter Coles wrote: >

Re: Having Trouble with Reverse method

2009-09-11 Thread Peter Coles
ndering: Reverse for > > 'dwrangler.project- > > root' with arguments '()' and keyword arguments '{}' not found." > > > This is interesting because it's throwing the error message for a > > template tag that has worked that calls

Re: Link for new page

2009-09-11 Thread Peter Coles
    Success >             >             >                 Log in Successfully!!! >             >             >             >             ''' >     return HttpResponse(login) > > But I want to see the page when I click the Forget password? link.( href

Re: Context object not completely rendering

2009-09-14 Thread Peter Coles
Your code looks ok, but something is obviously wrong, you'll need to debug this to figure out what's going wrong. Here are some quick ideas of how to go about debugging it—if at any point something looks or works contrary to what you'd expect then try to figure out why that's happening and you'll

Re: QuerySet: clone vs deepcopy?

2009-09-23 Thread Peter Coles
Depending on what framework or language you're working with, a "clone ()" method can be implemented as either a deep copy or a shallow copy. I do not see a __deepcopy__ function or a clone function on QuerySet (apart from the "private" _clone function). Are you referring to the django.db.models.

Re: Disable apache directory browsing

2009-09-23 Thread Peter Coles
Did you try it inside a Directory tag? For example, try putting something like this into your httpd.conf, where "path_to_htdocs" is the actual path to your htdocs directory: Options -Indexes +FollowSymLinks AllowOverride None Order allow,deny Allow from all Or even change the

Re: Reverse Method Not finding URLs

2009-09-23 Thread Peter Coles
Looks like your regex isn't matching: reverse('view-project', args=['blue-dog']) is trying the regex here: url(r'^(?P\w+)/$', 'view_project', name="view-project"), I think you want (?P[\w\-]+). Whenever I'm unsure about a regex, I open up a shell "import re" and test it out. -- Peter On

Re: Sorting field-rendering order of forms.Form instances

2009-09-23 Thread Peter Coles
If you check out the source code in django.forms.forms, the forms use a SortedDict class that is defined in django.utils.datastructures. I'd probably go about this by creating a class called something like SortableForm: from django.utils.datastructures import SortedDict class SortableForm(forms.

Template tags variables cannot be None, False, True?

2010-05-19 Thread Peter Coles
Do tags not support the literals None, False, or True? Why would numbers and strings be supported, but not these? It is possible to pass these as variables into the context (even in a context processor) as {'None': None, 'True': True, 'False': False} and it's possible that someone may be using vari

Context manager to pick which database to use?

2015-04-28 Thread Peter Coles
When using multiple databases, I would love for a simple way to declare which database should be used during execution of django ORM calls. Perhaps this could even use a context manager and look something like this: # declare that all calls within this context should default to using 'readonly'

Re: Context manager to pick which database to use?

2015-04-28 Thread Peter Coles
Or maybe more versatile would be a context manager that accepts a database router. Something like the following? with database_router(my_router): … On Tuesday, April 28, 2015 at 3:26:48 PM UTC-4, Peter Coles wrote: > > When using multiple databases, I would love for a simple way to d

Re: Context manager to pick which database to use?

2015-04-28 Thread Peter Coles
com/en/1.8/ref/models/querysets/#django.db.models.query.QuerySet.using> > > for the exceptional case? > > I'm afraid the introduction of a context manager would require the > addition of a thread-local global state that a database router could rely > on. > > Simon

migrate does not store default values in the database

2014-10-24 Thread Peter Coles
I'm trying out the migrations in Django 1.7 and I was surprised when my migrations did not set default values in the database. Can someone share the motivation for this functionality? (more details below) This was surprising given the documentation I read: 1. the release notes

Re: migrate does not store default values in the database

2014-10-24 Thread Peter Coles
Should I copy this question over to "django-dev" (do they accept posts from non-internal devs)? I've seen people complain in the past about reopening or commenting on closed tickets. On Friday, October 24, 2014 7:05:41 PM UTC-4, Jon Dufresne wrote: > > On Fri, Oct 24, 2

Using a foreign key id value triggers `refer_to_missing_field` error on migrate

2014-11-06 Thread Peter Coles
I had an inline AdminModel that I was ordering by the id of a foreign key value, e.g., class ThingAdmin(admin.TabularInline): model = models.Thing ordering = ('rel_id',) Where "rel_id" references the actual db column vs the object "rel". This worked like a charm in the admin interface,

Writing a “circuit breaker” for use in Django

2015-08-07 Thread Peter Coles
I’d like to write a circuit breaker wrapper to use with services that I call from inside a Django app, and I’d like to get some pointers on the following questions: 1. What’s the most global, persisting, shared-across-requests type of data I can read & write to memory? 2. However I can

Re: Writing a “circuit breaker” for use in Django

2015-08-10 Thread Peter Coles
l you need to do is drive a screw, don't > waste time filing a blade onto the face of a hammer. > > On Fri, Aug 7, 2015 at 5:54 PM, Peter Coles > wrote: > >> I’d like to write a circuit breaker wrapper to use with services that I >> call from inside a Django app,

Re: Writing a “circuit breaker” for use in Django

2015-08-10 Thread Peter Coles
er design, maybe you want an asynchronous processing, meaning the web >> request would just register that a request to calculate something was made, >> send the request to the jobs queue and return saying the request was >> received please come back later >> >> yo