"django.db.models.query.QuerySet" vs "django.db.models.QuerySet"

2015-09-29 Thread Ilya Kazakevich
In Django 1.6 it QuerySet was in package "django.db.models.query.QuerySet". But since 1.7 it also may be imported with "django.db.models.QuerySet". Is "django.db.models.query.QuerySet" deprecated since 1.7? What is the "official" way to import QuerySet? I can't find any documentation regard

Re: Adding a one field to user model: trying not to create custom one)

2015-05-19 Thread Ilya Kazakevich
set FIELDS=["last_name", "first_name"] in my settings.py and it works. I have the same for "get_absolute_url" method as well. It is not very pythonic way to do something, but it works. > -James > On May 18, 2015 3:58 PM, "Ilya Kazakevich" <ka

Re: Adding a one field to user model: trying not to create custom one)

2015-05-19 Thread Ilya Kazakevich
Hello. > I am not aware of a good solution to this problem other than manually > adding the .select_related() to your query on the list-of-users page. > Oh :(( > > > I am really unhappy with idea of using custom user model. > > Why? > > If it's because this is an existing project and the

Adding a one field to user model: trying not to create custom one)

2015-05-18 Thread Ilya Kazakevich
Hello, I want to add just a one field to my model, and this field participates in user representation ( I use monkeypatch to change __str__). Django manual tells me to create profile with one-to-one relation in this case. Well, it may work. But if I have with 250 users, I face 250 "SELECT"

Re: best way change template base my app

2015-05-15 Thread Ilya Kazakevich
You also may use widgets instead of "extends": http://sniplates.readthedocs.org/en/latest/ On Friday, May 15, 2015 at 6:50:40 AM UTC+3, sacrac wrote: > > Thank Andre Luis :) > > On Wed, May 13, 2015 at 1:41 PM, André Luiz > wrote: > >> extends should always be on first

Re: What is the ideal web server to use with Django?

2015-05-15 Thread Ilya Kazakevich
Hi. I believe the best installation is Apache + wsgi and nginx for static. In some scenarios Apache performance may be your bottleneck, but: 1) there are a lot of ways to tune it. Read about "Multi-Processing Modules" for example. 2) 99% of web applications do have different bottlenecks, not

forcing user model to return first_name last_name if exists

2015-04-28 Thread Ilya Kazakevich
Hello, I have many places in my app where user (from user model) is displayed: templates, forms, fliters, tables etc. It is displayed as username everywhere. I want it to be displayed as first_name/last_name. I can do that with monkey patching: @receiver(request_started) def patch(*args,

Re: Form to create several objects with one-to-one relation

2015-04-23 Thread Ilya Kazakevich
``. It looks silly. I will create custom form or review my model structure. On Wednesday, April 22, 2015 at 3:38:30 PM UTC+3, Ilya Kazakevich wrote: > > Thank you, that may work, but I feel that I reinventing wheel here. > > Actually, there are inline_formset and CreateWithInlinesView (fr

Re: Best practice for passing JSON objects to a template

2015-04-22 Thread Ilya Kazakevich
What about putting it into ? On Thursday, April 9, 2015 at 8:50:50 PM UTC+3, Eric Plumb wrote: > > Hi Djangoers! > > Sometimes in the course of human events it becomes necessary to encode a > JSON object directly into a template. We all prefer AJAX and REST APIs and > the rest of the TOFLAs,

Re: Form to create several objects with one-to-one relation

2015-04-22 Thread Ilya Kazakevich
. On Wednesday, April 22, 2015 at 2:40:56 AM UTC+3, Vijay Khemlani wrote: > > What about and old-school DetailView? > > def get_context_data -> Creates the two forms and puts them in the context > > def post -> Validates and process the forms > > > > On Tue, Apr 21, 2015

Form to create several objects with one-to-one relation

2015-04-21 Thread Ilya Kazakevich
Hello, I have several models with one-to-one relation. For example class Task(models.Model): initial_comment = models.OneToOneField('Comment') # A pack of other fields class Comment(models.Model) body = RichTextField() # A pack of other fields I want to create "create view"

Re: best way to pass options to django views?

2015-04-02 Thread Ilya Kazakevich
This tutorial is about client-side (JavaScript) while Python/Django is server side:) What are you trying to do? Pass all options from HTML page to server side? What for? In most cases you want to pass the option selected by user to server. You must first read about HTML forms and how to submit

Re: Saving Contionus Data through Django

2015-04-02 Thread Ilya Kazakevich
You can't just store stream in database. You need to buffer it first, and then save to field like blob: http://www.postgresql.org/docs/9.1/static/datatype-binary.html I am not sure that relational database is the best place to store binary data coming from devices. On Thursday, April 2, 2015

Re: setup.py for project?

2015-04-02 Thread Ilya Kazakevich
Simon is right. I recommend this http://martinfowler.com/books/continuousDelivery.html On Thursday, April 2, 2015 at 1:57:40 PM UTC+3, guettli wrote: > > > > Am 02.04.2015 um 03:13 schrieb Ilya Kazakevich: > > Hello. > > > > What exactly are you trying to achie

Re: encode url

2015-04-01 Thread Ilya Kazakevich
Why do you need it? Web-browser encodes your data using Percent-encoding (http://en.wikipedia.org/wiki/Percent-encoding) by default. You may base64 your code on client side using JS and decode it on server side using python, but it seems useless for me. base64 is used to eliminate special

Re: setup.py for project?

2015-04-01 Thread Ilya Kazakevich
Hello. What exactly are you trying to achieve? If you have some part of functionality that is interesting for other people/projects and hence should be shared via pypi, you should extract it as reusable app. Projects, how ever, are not reusable. If you need a fast way to install al project

Re: Enterprise software patterns for django/Python ?

2015-03-30 Thread Ilya Kazakevich
Hello. Django is full-stack *web* framework, so it has some web-specific shortcuts, and probably does not fit ideally in enterprise patterns. For example, it does not encourage you to have "backend server" and "frontend server" connected via SOAP/XML/ESB like in "classical" enterprise

Re: {{STATIC_URL }} or {% static "...." %} What`s the correct to use?

2015-03-20 Thread Ilya Kazakevich
This one "{% static "" %}" is MUCH better than {{STATIC_URL }}. It is recommended way. You almost never need to use {{STATIC_URL }}. On Friday, March 20, 2015 at 3:59:08 AM UTC+3, Fellipe Henrique wrote: > > Hi, > > In my template, when I made a reference to my Static folder.. what's the

Re: django beginner

2015-03-13 Thread Ilya Kazakevich
django-admin creates infrastructure required for your project, and there should be more than 3 files. On *nix systems django-admin is py script with shebang, but due to windows command processor limitations (cmd) on windows there is executable file which actually calls django-admin. So, you

Re: Django structure

2015-03-08 Thread Ilya Kazakevich
There are 2 types of Apps in Django: 1) reusable one with clear, documented interface 2) not reusable one, because it depends on current project heavily. Ideally, project consists of several reusable-apps, and project-specific data is stored in project-specific places like URLConf or filesystem

Re: Sharing templates across multiple projects

2015-03-06 Thread Ilya Kazakevich
I like Simon's ideas about shared location and separate app (Django encourages us to use apps to share anything), but you also may share them on VCS level. SVN supports "external" checkout, in git you may add one repository to another. \project1\templates\shared_temps

Re: Fixing a poorly written Django website (no unit tests)

2015-03-06 Thread Ilya Kazakevich
You may start from highest level testing: 1) create "usage scenarios" for your website. Like "customer opens page 'foo', and should see 'bar'". You use such scenarios for manual testing, right? 2) code such scenarios against Django project. You may use BDD testing tools (like lettuce or

Re: how to deal with not translated strings in html

2015-03-06 Thread Ilya Kazakevich
What is the point of NOT translating "month" to English? There are several solutions: 1) Create custom templates / custom tags and include them based on language. For example you may have "foo.nl.html" and "foo.en.html" and include "foo..html". But I believe using different HTMLs for

Re: Future for Django, Jobs, Confused :/

2015-03-06 Thread Ilya Kazakevich
You never know what would be popular in next several years. In late 90th Perl was the main web development language. In 2000th it was PHP. Now it is Ruby and Python. If you love Python, use Django but study Ruby/RoR in background. Ruby is not rocket science and you should not have any serious

Re: Python / Django slow ? Deciding my next technological stack

2015-03-06 Thread Ilya Kazakevich
In modern world any heavy loaded site should have HORIZONTAL SCALING. That means it should support scale by adding new servers to cluster. With horizontal scaling you should not care about how python is slow on each node, until you have traffic like Facebook or Guthub have. I believe 99%

RE: Django and Python-Ldap with Active Directory Question

2014-07-18 Thread Ilya Kazakevich
9; ldp = ldap.initialize(LDAP_URL) print ldp.bind(LOGIN, PASSWORD) for (dn, entry) in ldp.search_s(GROUP_DN, ldap.SCOPE_ONELEVEL): # Scope!!! print(entry) ldp.unbind() Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleas

RE: Django newbie issues

2014-07-08 Thread Ilya Kazakevich
night Commander. But I believe you need to read some books or tutorials about Ubuntu before. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >

RE: Multiple projects on one server

2014-07-02 Thread Ilya Kazakevich
Hello, Do you have different versions of python or libs? Use virtual env. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[

RE: Static Analysis Tool

2014-06-24 Thread Ilya Kazakevich
PyCharm will support DjangoLint inspections soon, I believe: http://youtrack.jetbrains.com/issue/PY-4554 Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@

RE: Chat application

2014-06-19 Thread Ilya Kazakevich
Hello, You may use websockets on client and asyncio on serves as it is done here: https://github.com/throwable-one/chat-async/ But websockets require modern client and asyncio require python 3.4 (but asyncio is standard and worth using, anyway) Ilya Kazakevich, JetBrains PyCharm (Best Python

RE: Language code issue - Django thinks default is en-us?

2014-06-18 Thread Ilya Kazakevich
Oh, sorry, I forgot it is about manage command. Try to disable USE_I18N (USE_I18N = False) and check if it works. See "django\utils\translation\__ini__.py" in your site-libs for details (class Trans, its getattr and get_language() function) Ilya Kazakevich, JetBrains PyCharm (B

RE: Language code issue - Django thinks default is en-us?

2014-06-18 Thread Ilya Kazakevich
LocaleMiddleware sets your language to one, provided by your webbrowser. Tty to disable LocaleMiddleware or configure your browser to use different language (http://stackoverflow.com/questions/7769061/how-to-add-custom-accept-languages-to-chrome-for-pseudolocalization-testing) Ilya Kazakevich

RE: Language code issue - Django thinks default is en-us?

2014-06-18 Thread Ilya Kazakevich
to depend on LANGUAGE_CODE. You should use get_language() to support I18N Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-use

RE: Who are using Aptana Studio 3? Please respond.

2014-06-18 Thread Ilya Kazakevich
s download database drivers automatically (like 0xDBE or PyCharm), it is sad that Aptana does not do it) Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@google

RE: Database problem in Django

2014-06-18 Thread Ilya Kazakevich
You probably need to have "insert_date" field and store entry created date there. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups

RE: Is it possible to get working django transaction with django multiple databases

2014-06-16 Thread Ilya Kazakevich
I believe you need software that supports distributed transaction coordination protocols ("X/Open XA" Is good example) and both DBs should support this protocol and two-phase commit. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm

RE: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Ilya Kazakevich
Instead of from holes.models import HoleImage write from holes.models import HoleImage, Hole Please read https://docs.python.org/2/tutorial/modules.html Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >

RE: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Ilya Kazakevich
_before_ zend/phpcacke/joomla or wordpress, right?:) ) Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-users@googlegroups.com] On

RE: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Ilya Kazakevich
To use any symbol (including " HoleImage" class) you need to import it first. You've imported Hole (from holes.models import Hole), but you forgot to import HoleImage. So, you got " name 'HoleImage' is not defined " error. It is better to use IDE, because it helps you in su

RE: implementing a ticket submission system

2014-06-11 Thread Ilya Kazakevich
Hello, Use Primary Key: https://docs.djangoproject.com/en/dev/topics/db/models/#automatic-primary-key-fields Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@

RE: Django Python roop

2014-06-11 Thread Ilya Kazakevich
Hello, What are you trying to do? Split string? Copy array? You probably need to use builtin functions for that. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >Fr

RE: error

2014-06-11 Thread Ilya Kazakevich
Hello, Try to use debugger. https://docs.python.org/2/library/pdb.html or http://www.jetbrains.com/pycharm/features/#debugger Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >Fr

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

2014-06-09 Thread Ilya Kazakevich
Hello, There are a lot of ways to do that: from simple "rsync" or "checkout periodically with cron" (in both cases you need to move your settings to environment vars) to engines like Fabric. Even books are written: (http://continuousdelivery.com/) Ilya Kazakevich, Jet

RE: safari ios 7 and django app - function not being called to serve video

2014-06-05 Thread Ilya Kazakevich
What algorithm is used for keys in HTTPS on your installation? AFAIK, Safari@iOS does NOT support DSA keys (only RSA keys are supported). Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Messa

RE: safari ios 7 and django app - function not being called to serve video

2014-06-05 Thread Ilya Kazakevich
://httpd.apache.org/docs/2.2/logs.html ) 3) NEVER hardcode urls! Use URL tag (https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url) Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Messa

RE: How to install psycopg2 using Pip?

2014-06-04 Thread Ilya Kazakevich
ind your postgres installation. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-users@googlegroups.com] On Behalf Of D

RE: URLs: mymodel_id vs object_id vs pk ....

2014-06-04 Thread Ilya Kazakevich
this field whatever you want. I believe "id" is nice. I use DetailView unless I need really custom logic, so I use "slug" almost always. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!"

RE: newbie with models - user-defined function raised exception

2014-06-03 Thread Ilya Kazakevich
ly, you should start with Django 1.6 or even 1.7 (1.5 is outdated!) and use official Django tutorial (https://docs.djangoproject.com/en/dev/intro/tutorial01/) instead of this book. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pl

RE: Startproject opens django-admin.py

2014-06-03 Thread Ilya Kazakevich
Hello, Shebangs are not supported by windows command processor (cmd). Try: C:\Python27\python.exe django-admin.py Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >Fr

RE: [OT] Web application and image scanner

2014-05-28 Thread Ilya Kazakevich
Hello, * Silverlight * JavaFX * Flash * ActiveX (Windows only) Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-use

RE: Adding models from one app to another app

2014-05-28 Thread Ilya Kazakevich
as 'app_name.model_class_name'. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-users@googlegroups.com] On Behalf Of Inderpreet Singh &g

RE: How to pass URL to a view

2014-05-28 Thread Ilya Kazakevich
://stackoverflow.com/questions/12758786/redirect-return-to-same-previous-page-in-django See also: https://docs.djangoproject.com/en/dev/ref/request-response/ Be sure to check this header exists. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "De

RE: ASP .NET web service and Django

2014-05-26 Thread Ilya Kazakevich
Hello, For web services (I believe you speak about SOAP web services) check: * https://wiki.python.org/moin/WebServices (SOAP section). It has info about Python SOAP client and server libraries. * For .NET (client) : http://stackoverflow.com/questions/1302525/how-to-use-a-wsdl Ilya Kazakevich

RE: function to create objects in a given model

2014-05-20 Thread Ilya Kazakevich
Hello, Try managers: https://docs.djangoproject.com/en/1.6/topics/db/managers/ Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[

RE: Best practice - evolving from one to several sites using Django

2014-04-30 Thread Ilya Kazakevich
all Django and try to move one site to it. Then, move next one. Ilya Kazakevich, JetBrains PyCharm (Best Python/Django IDE) http://www.jetbrains.com/pycharm/ "Develop with pleasure!" >-Original Message- >From: django-users@googlegroups.com >[mailto:django-users@googl

RE: Http request with multiple files is not able to read by django server

2014-04-25 Thread Ilya Kazakevich
Hello, There may be some web-proxy between client and server that limits request size or time. Server may limit it as well. * Remove all proxies between client and server * Try to use different client (browser for example) * Check your server configuration for request size and timeout. Ilya