Subj
|
||||||
|
Recently I’ve read a book jQuery: Novice to Ninja. I was using jQuery for a long time, however I felt that I was using only a small part of this library, so I decided to read some books about it. The books is rather good and easy (and interesting) to read. Here I want to write some jQuery’s tips that I didn’t know and want to store for the future.
jQuery is a really great thing! I don’t know why this is not done by default, but..
In most cases when a user registers in your django application you need to know more than just user name, password and e-mail. To add custom fields to the registration form you should pass form_class parameter to the register view function – it’s easy, but saving additional data could be rather complex. There are solutions that show how to use a custom django registration backend – http://stackoverflow.com/questions/2601487/django-registration-django-profile-using-your-own-custom-form or http://groups.google.com/group/django-users/browse_thread/thread/00389648750c5867/59eef5c315b47f9b?lnk=raot&pli=1. G! This is so complicated! Likely, django has signals that are sent during the registration process and we can use them – http://docs.b-list.org/django-registration/0.8/signals.html#signals (the version of the doc is 0.8, however, it works with 1.2). We need user_registered signal. In my case I needed to add just one field to the registration form – user’s City.
Then pass this form to the register view in urls.py – register records should go before (r’^accounts/’, include(regUrls)),
Now we need to add a subscription to the user_registered signal. Assume that we have a custom profile with city information:
That’s it – much easier, right? Sorry, this entry is only available in Русский. I wrote a simple javascript function that draws an arrow on a Google Map (based on http://wtp2.appspot.com/BdccArrowedPolyline.js):
Where pt1, pt2 are GLatLng instances, map is GMap2 and color is a string representation of color. Unfortunately, this function does not support map’s zooming – arrows heads grow bigger when zooming in. The result looks like: Django has a great ORM, but it has some limitations while performing queries, e.g. it does not allow to do bitwise operation. Likely, django’s QuerySet has extra method (http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none). This method allows developers to write raw sql that will be included into the generated by ORM query. The tricky part is that all fields included in that raw sql must present in filter function.
Here we have a datatable with name table with a mask field called flags and an application called applicationName. If there was not filter(table__flags__isnull=False) this query would fail with “applicationName_table”.”flags” is unknown column. I could write any lookup expression with this filed that does not affect the result (checking that this filed is not null is quite OK for that). Hope, this will help you! Около месяца я активно использую твиттер и успел сформировать свое мнение о данном сервисе, коим и хочу поделиться. Как я вышел на твиттерНа конференции i-Community, на которой я не был, но информации с нее так или иначе стала доступна, в частности упоминалось, что за последний год число русскоязычных пользователей твиттера возросло в десятки раз и на данный момент составляет примерно 200 тысяч пользователей (http://www.interfax.ru/society/news.asp?id=126437). Мне, как активному человеку, было бы глупо не посмотреть на так бурно развивающийся в рунете тренд. Надо сказать, что аккаунт на твиттере у меня был зарегистрирован давно, но пребывал в заброшенном состоянии. НачалоНачал я с того, что зафолловил Константина Рыкова (http://twitter.com/rykov) – известного интернет-деятеля и политика, который в тот же день начал свой (очередной) уход из твиттера и вся лента была засорена обсасывванием этой темы. Затем я прошелся по тем, кого фолловит Максим Спиридонов (http://twitter.com/MaximSpiridonov), подкасты которого я нахожу очень полезными и интересными. В общем, дня за 3 я сформировал свою ленту. Что понравилось
Что не понравилось
Чего я жду от твиттера
Продолжение следует.. Мой твиттер: http://twitter.com/dmitko For almost the whole day this blog was down with fatal error Cannot allocate memory. After changing php.ini and setting memory_limit=32М instead of previous 8M the site became working. Recently there were several changes to my little sweet tracking service:) |
||||||
|
Copyright © 2010 Dmitko.ru - All Rights Reserved Powered by WordPress & the Atahualpa Theme by BytesForAll. Discuss on our WP Forum |
||||||