Providing custom settings with default values

2012-07-22 Thread Tomas Ehrlich
Hello there, until now I (and many others) used to define default custom settings in /settings.py in this way: from django.conf import settings default = lambda k, v: getattr(settings, k, v) PREFIX_KEY = default('PREFIX_KEY', 'value') ... and in other modules I used django-settings along my own

Re: A very basic question with Django

2012-10-10 Thread Tomas Ehrlich
Common guys, this thread isn't about me and CGI :) I really don't care what it is and know, when you've just told me what it is I don't care even more :) If you know what's CGI, feel free to answer the original question: "Could Django be deployed using CGI?" Cheers, Tom :) Dne Wed, 10 Oct 2012

Re: Unhandled exception during validation

2012-10-12 Thread Tomas Ehrlich
Well, in this case, I don't see problem in erroritself (that happens). I see problem in missing trackback (that's not usual). My assuption was that "something" suppress it (don't know if it's possible, but I assume it is). Cheers, Tom Dne Fri, 12 Oct 2012 17:00:01 +0100 Tom Evans napsal(a): >

Re: django multi db routing doesnt work wich multiple schemas

2012-10-12 Thread Tomas Ehrlich
Hi Michał, is "schema" the same as thing as "tablespace"? If so, you should define them using db_tablespace meta keyword. https://docs.djangoproject.com/en/1.4/topics/db/tablespaces/ DATABASES creates new database connection and it's really not possible to make relations between databases. Cheer

Re: Question in document "How to use Django with Apache and mod_wsgi"

2012-10-18 Thread Tomas Ehrlich
Hello, have you set proper aliases in apache site config? Alias /robots.txt /path/to/mysite.com/static/robots.txt Alias /favicon.ico /path/to/mysite.com/static/favicon.ico AliasMatch ^/([^/]*\.css) /path/to/mysite.com/static/styles/$1 Alias /media/ /path/to/mysite.com/media/ Alias /static/ /path

Re: Question in document "How to use Django with Apache and mod_wsgi"

2012-10-18 Thread Tomas Ehrlich
another problem as the following > picture. As the picture, my models don't have "Add" and "Change" button, > which they have when I run this site on development server or when I just set > DEBUG in settings.py to True. > > > > > > Dae Ja

Re: Stop executing template tag

2012-10-19 Thread Tomas Ehrlich
Hi Nikhil, you can't do that with django template system without additional "raw" tag. Here's a relevant article: http://www.holovaty.com/writing/django-two-phased-rendering/ Cheers, Tom Dne Fri, 19 Oct 2012 15:51:39 +0530 Nikhil Verma napsal(a): > Hello people > > I need some suggestion in

Re: ImportError: Could not import settings

2012-10-20 Thread Tomas Ehrlich
Hello, there's a little hint at the end of exception: > No module named unipath Seems like you import module unipath in your settings.py, which is not on your sys.path. I never set PYTHONPATH for development and everything works fine. Python adds current directory to sys.path, so when you run ./

Re: urls.py and default values...

2012-10-21 Thread Tomas Ehrlich
Hello, you need to make 'year' argument optional: def student_reports(request, year=None): year = year or datetime.date.today().year ... Another option could be passing extra option to you view function: https://docs.djangoproject.com/en/1.4/topics/http/urls/#passing-extra-options-to-view

Re: Status of bug #11580 ?

2012-11-07 Thread Tomas Ehrlich
Hi Michał, actually, you *do have* such a privilege. Simply clone development version of django, fix the file with bug, test it, and post patch to ticket you've mentioned. If you include test which check, that your patch really fix the bug, core developers will pull in into repository soon. It's

Re: Queries to multiple tables

2012-11-10 Thread Tomas Ehrlich
Hi Kristofer, I usualy put methods like this one into Model, although Manager is also possible. Definitely not View or sth else. Why I like Model more than Manager is this difference (suppose your method is called make_payment): Account.make_payment # via Model Account.objects.make_payme

Re: What used @models.permalink and get_absolute_url? Please an example to better understand this. An example of the documentation is not clear to me

2012-11-17 Thread Tomas Ehrlich
Hi there, the key idea is: *Let's have URLs defined at one and only one place.* So, when you have urls.py like this: urlpatterns = patterns('', '^blog/(?P\w+)', BlogDetail.as_view(), name='blog-detail', '^articles/(?P\w+)', ArticleDetail.as_view(),

Re: How to customize Django Admin interface with custom urls and views?

2013-03-06 Thread Tomas Ehrlich
Hello John, welcome in Django, hope you'll find it useful as I did. Extend Django admin is a little bit tricky, but not impossible. You can add your own views to admin simply by extending your ModelAdmin subclass. See https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.M

Re: Template inheritance

2013-03-09 Thread Tomas Ehrlich
Hi Nenad, you can wrap your meta-refresh line in another block and then delete it's content in templates which shouldn't be refreshed. # base_site.html {% block extrahead %} {% block extrahead-refresh %} {% endblock %} {% endblock %} # change_form.html -- deletes content of block

Re: Template inheritance

2013-03-11 Thread Tomas Ehrlich
ew, you have to sublass ModelAdmin or whole AdminSite. It's overkill when you need tune some details like this. Cheers, Tom Dne Mon, 11 Mar 2013 11:51:47 + Tom Evans napsal(a): > On Sat, Mar 9, 2013 at 10:28 AM, Tomas Ehrlich > wrote: > > Hi Nenad, > > you can

Re: [ANN] Introducing Brillixy - Django admin skin & customization kit

2013-03-12 Thread Tomas Ehrlich
Hi Alex, congratulation to alpha release of your app. I was about to suggest you django-bootstrap-admin, django-admin-tools and django-fluent-dashboard, but since you already know Admin tools, could you please provide more details about your app? I took a quick look at demo page and read Readme fi

Re: What are the steps to build a website?

2013-03-25 Thread Tomas Ehrlich
> You can't do it perfectly the first time. The only way to do it well > is experience. The only way to get experience is to make mistakes. I disagree. When you make mistake, you know what's wrong, but you still don't know, what's right. You need to learn, how to make things right. To Benjamin:

Re: request.FILES empty, I think I am doing everything correctly

2013-04-04 Thread Tomas Ehrlich
Hi John {% csrf_token %} must be definitely inside the tag. It renders . Please try it and tell if it works. Cheers, Tom Dne Thu, 4 Apr 2013 14:38:58 -0700 (PDT) John napsal(a): > This is Django 1.5 > Python 2.7.3 > MYSQL Database > > Here is the model that I am using: > > class Supporti

Sharing session among multiple domains (generic web development question)

2013-06-11 Thread Tomas Ehrlich
Hi there, this question isn't bound to Django Web Framework as the major limitation are cookies: I have single instance Django site running on multiple domains. Each domain simply filters specific categories. There's an eshop and I need to share sessions among all domains so user can log in on one

Re: Sharing session among multiple domains (generic web development question)

2013-06-11 Thread Tomas Ehrlich
one, if you implement that please > share how > > > On Tue, Jun 11, 2013 at 10:04 AM, Tomas Ehrlich > wrote: > > > Hi there, > > this question isn't bound to Django Web Framework as the major > > limitation are cookies: > > > > I have single

Re: Sharing session among multiple domains (generic web development question)

2013-06-11 Thread Tomas Ehrlich
jango-users-and-sessions-across-projects/ > I hope this helps. > > Best regards, > Marcin > > On 14:22 Tue 11 Jun , Tomas Ehrlich wrote: > > Hi Avraham, > > I know that cookies can be shared among subdomains, but my customer wants to > > have separate

Re: Model inheritance, implicit OneToOneField and stray inherited reverse relations

2013-06-12 Thread Tomas Ehrlich
Hi Benjamin, you can create explicit OneToOne field with parent_link=True https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.OneToOneField.parent_link Then you can set different related_name for each model. Cheers, Tom Dne Wed, 12 Jun 2013 01:10:40 -0700 (PDT) Benjamin

Re: Sharing session among multiple domains (generic web development question)

2013-06-12 Thread Tomas Ehrlich
Hi Tom, that's interesting approach. I'm going to use it and publish code later. Thank you! Cheers, Tom PS: The key is the name of problem:) SSO https://github.com/ojii/django-simple-sso https://github.com/bltravis/django-token-sso Dne Wed, 12 Jun 2013 10:30:43 +0100 Tom Evans napsal(a):

Re: Customize the admin look and feel

2013-06-27 Thread Tomas Ehrlich
Hi there, please try: TEMPLATE_DIRS = ( "C:/xampp/htdocs/mytemplates/" ) After all, it's TEMPLATE_DIRS not TEMPLATE_FILES. It should contain directories with templates. Cheers, Tom Dne Thu, 27 Jun 2013 09:46:40 -0700 (PDT) krazyXplorer <1.kc.d...@gmail.com> napsal(a): > I am new to Djan

Re: Form validation vs. DRY

2013-07-03 Thread Tomas Ehrlich
Hi Roman, you can use model validation https://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects It works similar to form validation. After, when you create ModelForm, it will take validation rules from model. All these validations should be called outside save() Cheers,

Namespace URLs in TestCase

2013-07-04 Thread Tomas Ehrlich
Hi there, it's probably silly bug, but I can't figure it out: I have one test: ### # app/tests_functional/test_app.py from django.core.urlresolvers import reverse from django.test import TestCase class TestApp(TestCase): urls = 'app.tests_functional.urls' def test_app(self): pri

Re: redirct page

2013-07-06 Thread Tomas Ehrlich
Hi there, you're certaily missing {% csfr_token %} in your form. If it doesn't solve the problem, you need to provide more info and be more specific about your "trouble". Dne Sat, 6 Jul 2013 17:44:04 +0530 Kakar Arunachal Service napsal(a): > Hi, > I am having trouble with redirecting the logi

Re: django statics

2013-07-15 Thread Tomas Ehrlich
Hi there, first, there's a difference between MEDIA files and STATIC files (since 1.3, I think). Media files are files uploaded by users, while static files are usually persistent files on the server from the beginning, eg. stylesheets, images, javascripts, robots.txt, etc. It's good to keep these

Django/Python based webmail

2013-07-29 Thread Tomas Ehrlich
Hi there, I'm looking for django (or python) based webmail, similar to RoundCube and SquirrelMail. I tried djangopackages.com and google search, but it doesn't seem to be an alive project out there. How you ever wondered why? :) Seems to me like useful app. Thanks in advance Cheers, Tom --

Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread Tomas Ehrlich
This isn't possible. The problem is with cookies: You have to bind them to certain domain ('example.com') or set of subdomains ('.example.com'). About a month ago I've created app to bypass this limitation: - There is one "master" domain, where new session keys are created. - When user access any

Re: SESSION_COOKIE_DOMAIN on multiple domains.

2013-08-01 Thread Tomas Ehrlich
Ah, sorry, I understand now. You can set up middleware, which modifies SESSION_COOKIE_DOMAIN based on request.get_host() and put it before session middleware. I did similar thing to set SITE_ID. Only think you have to take care of is thread safety. You need to override settings.SESSION_COOKIE_DOM

Re: Does Model.save() write back all the field values?

2013-08-14 Thread Tomas Ehrlich
Hi, I apologize for possible off-topic, but since Jacob already answered your question, please allow me to add another hint: Book.objects.filter(published=False).update(published=True) would do the same in single query, updating "published" field only (even in <1.5). Cheers, Tom Dne Wed, 1

Re: db queries made twice

2013-08-31 Thread Tomas Ehrlich
Hi, disable Template panel in debug_toolbar and try again. Debug toolbar hits database when evaluating template context. Cheers, Tom Dne Sat, 31 Aug 2013 12:09:00 +0100 Marcin Szamotulski napsal(a): > Hello, > > I am using django-1.6.b2 on a localserver (./manage.py runserver) and > for e

Re: djangojobs.com

2013-09-20 Thread Tomas Ehrlich
I wonder if licence agreement applies for this case, since domain was clearly bought before Django project finished it's trademark policy. Dne Fri, 20 Sep 2013 08:23:27 -0400 Karen Tracey napsal(a): > Please note any use of djangojobs.com domain would need to conform to the > Django trademark l

Re: Django Templates: Using the "with" statement and "block.super" together

2013-09-24 Thread Tomas Ehrlich
I use it too. Maybe it would be nice to document it somewhere. Cheers, Tom Dne Tue, 24 Sep 2013 10:59:27 -0700 (PDT) Warren Smith napsal(a): > On occasion, I've used the following technique in my django templates: > > # parent.html > > {% block someblock %} > …stuff… > {% if cool_opti

Re: django debugger

2013-11-05 Thread Tomas Ehrlich
Hi Harjot, try https://github.com/Kozea/wdb if you want debugger like pdb or simple https://github.com/django-debug-toolbar/django-debug-toolbar which provides lots of useful informations. Unfortunately, I don't use pdb nor wdb, so I can't help you with any of them. Cheers, Tom Dne Tue, 5 Nov

Re: Streaming images with HttpResponse?

2013-11-15 Thread Tomas Ehrlich
Hi there, I don't know if it's relevant, I've never used it, but the name sounds promising: StreamingHttpResponse https://docs.djangoproject.com/en/dev/ref/request-response/#streaminghttpresponse-objects Cheers, Tom Dne Fri, 15 Nov 2013 12:53:23 -0500 Javier Guerra Giraldez napsal(a): > On

Re: Creating a list off a model based on time delta

2014-07-20 Thread Tomas Ehrlich
Use __gte lookup: latest_articles_list = Article.objects.filter(pub_date__gte=thirty_days_ago) and take a look at other lookups: https://docs.djangoproject.com/en/1.6/ref/models/querysets/#field-lookups Cheers, Tom Dne Sun, 20 Jul 2014 20:50:53 -0700 (PDT) Conner DiPaolo napsal(a): > I've b

Initial data in 1.7

2014-07-21 Thread Tomas Ehrlich
Hi there, as pointed in documentation [1], automatic loading of initial data from initial_data.[xml/yaml/json] is deprecated since 1.7 in favor of data migrations. However, there are several drawbacks and differencies: 1. Data migration is executed only once (unless migrations are rewinded

Deployment of django project using setuptools

2014-05-02 Thread Tomas Ehrlich
Hi there, when I deploy my django projects I always run several commands after pulling latest code from repository. I've started using setup.py few weeks ago which adds manage.py script into $VENV/bin. Basicaly, I always do: source $VENV/bin/activate export DJANGO_SETTINGS_MODULE=... git pull py

Re: Programatically reverse an url to other language

2014-05-15 Thread Tomas Ehrlich
Hi, use ugettext_lazy for translation of urls, models and other stuff which is loaded before language is determined (it's usually done in Middleware or later in view, otherwise all strings will be translated into default language). You can also write: url(_(r'^about$'), views.about, name='about

Re: Question about moving code to product from local or development server.

2014-06-10 Thread Tomas Ehrlich
Hi there, since all have already mentioned Fabric, take a look at Ansible which is a bit more sophisticated tool, but can be used efficiently even for small setups. Depends on your requirements, you can create simple "deployment" playbook, which just takes your code, push it to the server, update