Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
简单几步, 将VIM打造成Python/Django开发的现代化IDE
编程常用的文本编辑器就那么几种常见的, 有人喜欢Vim, 有人喜欢emacs, 也有人喜欢IDE, 例如Pycharm, Aptana等. 今天我们不谈孰优孰劣, 只要适合自己就可以了. 如果你喜欢VIM, 又希望有IDE常见的自动补全, 语法高亮, 方便的文件切换等功能. 你完全可以将这些功能集成到Vim中, 但是, 对于一个初学者, 或像我一样的懒人, 一个一个的查找并试验配置这些插件未免有些太麻烦. 因此, 本文介绍一个Vim的设置分发系统, 可以简单的满足我们的需要: spf13-vim spf13-vim是一个vim设置分发系统, 适用于Vim, GVim和MacVim. spf13-vim是跨平台的, 它可以让我们既保留Vim的原汁原味, 又为我们增添了插件管理, 自动补全, tag管理等诸多功能. 1. 安装和升级 可以使用spf13-vim的简单安装功能, 一步安装好spf13-vim: curl http://j.mp/spf13-vim3 -L -o - | sh 如果需要升级, 则可以切换到spf13-vim安装目录(默认是~/.spf13-vim/), 运行: cd $HOME/to/spf13-vim/ git pull vim +BundleInstall! +BundleClean +q 如果要在windows安装spf13-vim, 首先需要安装和设置git和curl, 最后运行spf13-vim-windows-install.cmd, 详细信息参见spf13-vim官网 2. 设置 默认的.vimrc文件非常适合编程. 如果你查看.vimrc文件的内容, 你会发现其良好的组织既方便阅读, 又方便学习. 默认的.vimrc文件可以在跨平台系统中使用, 如果你还需要进一步的定制化设置的话, 则可以建立~/.vimrc.local实现. 3. 插件介绍 spf13-vim自带许多插件, 方便我们使用: Vundle Vundle是Vim的插件管理系统, Vundle将vim插件组织在同一目录中, 并可以方便的安装, 升级和删除vim插件. NERDTree NERDTree是一个文件浏览器, 在spf13-vim找中可以通过ctrl+e调出. ctrlp ctrlp是文件载入插件, 通过ctrlp可以方便的浏览系统中文件并打开. 默认情况下可以通过ctrl+p调出. NERDCommenter NERDCommenter可以用来方便的切换代码注释, 默认的快捷键是 , + c + 空格, (','是spf13-vim默认的leader键). 4. 定制化 添加插件 如果想添加新的插件, 则可以通过以下命令添加: echo Bundle \'spf13/vim-colors\' >> ~/.vimrc.bundles.local 修改默认设置 希望修改默认的设置, 例如修改颜色配置, 则可以通过以下方式: echo colorscheme ir_black >> ~/.vimrc.local -
Django 1.6 最佳实践: Django项目的布局结构和目录结构
不同的程序员对于项目布局都有着不同的见解, 在本文中, 我们会介绍我们使用的布局结构. 这种结构应该也是使用最为广泛的结构了. 1. Django默认的项目部局 当我们使用django-admin.py startproject mysite 和 django-admin.py startapp my_app 建立新的Django项目时, Django默认的结构如下: mysite/ manage.py my_app/ __init__.py admin.py models.py tests.py views.py mysite/ __init__.py settings.py urls.py wsgi.py 在Django默认的项目部局中, 存在着一些问题, 特别是在部署到真正的服务器时, 这些问题会越发的明显, 下面我们会一一阐述这些问题: 2. 最终的项目布局 我们使用三层结构来布局我们的Django项目: 最外层是git仓库, 中间层则是django-admin.py默认的生成的项目层, 最里层则是设置层: repository_root/ django_project_root/ configuration_root/ a. 最外层 最外层是整个项目的容器, 除了包括django程序外, 还包括README.rst, docs/, .gitignore, requirements.txt等用于部署到服务器的 必须文件或目录. 这样这些文件便可以通过git管理, 方便开发和维护的使用. README.rst文件和docs目录是用于介绍本项目的文档, 方便程序员了解项目的基本功能等, 我们会在今后详细介绍这一文档. .gitignore文件是git版本控制系统的设置文件之一, 用于设置本仓库中需要忽略的文件或目录, 既不需要保存版本记录文件或目录. requirements.txt则记录着本项目中用到的Python模块和版本的列表, 通常是通过pip freeze获取的. 我们会在今后详细介绍这一文档. b. 中间层 中间层则是由django-admin.py生成, 也就是django默认的项目布局, 中间层生成时, 也包括了最里层: 设置层. 这一层中包括了media目录, static目录, templates目录, 和Django app. c. 最里层 最里层设置层中, 包含了django-admin.py生成的设置文件, 包括settings.py, urls.py等文件. 3. Virtualenv 我们建议将所有virtualenv文件放在统一的目录下, 如果你使用virtualenvwrapper的话, 它位于~/.virtualenvs/中. 并且, 这些文件没有必要保存到git版本管理中, 因为我们已经保存了requirements.txt文件. -
Djangocon: open data on the sea shore - Richard Moch
(One of the summaries of a talk at the 2014 djangocon.eu). Richard Moch shows us open sea map, open street map for the sea! Light houses, shipping langes, etc. They're also trying to build up a sea depth map consisting of open data. See http://depth.openseamap.org/ . There's more: http://openweathermap.org/ . Yes, open weather data for current weather and forecasts. There is an open meteo foundation that tries to get it off the ground. Based on this open weather data, you can build apps, for instance http://meteo-parapente.com for showing good locations for doing paragliding. Open weather data? Then you need to measure it. They are working on an open source autonomous weather station. Modern French diesel unit in Kruth in 2007 -
Djangocon: The whys and hows of using django formsets - Shena Priscilla Makini
(One of the summaries of a talk at the 2014 djangocon.eu). Many people don't use or know about django formsets. She google for articles and found "formsets: the worst thing ever" and "formset gotcha: or how to lose your sanity". Ouch. What are form sets for? When you want to use the same form multiple times. For instance for a data grid. A table with one form per row, for instance. Django formsets help you put several of those forms on one page. The example she showed was of changing your "mailman" settings for a couple of mailinglists on one page. It is used in postorius, a new web UI (django) for mailman. It works something like this: SomeFormset = formsets.formset_factory(SomeForm, extra=5) formset = SomeFormset() And in the template it is just: {% formset %} This gives it to you as a table. You could also iterate over it and get the individual forms: {% for form in formset %} ... {% endfor %} (Personal note: oh blast, I didn't know about this feature! I know just the spot where I desperately need to use it. That one app where I do some manual field generation and mess about with … -
Djangocon: purist unit tests are a waste of time - Harry Percival
(One of the summaries of a talk at the 2014 djangocon.eu). Harry Percival, despite what you might guess due to the talk's title is very testing-oriented. Just look at his website http://www.obeythetestinggoat.com/ :-) He demoed a quick addition to a small TODO list app. Using outside-in TDD (test driven development). Outside-in? Just start at the outside (functional test that hits the TODO page). You try to click a not-yet-existing link. You add the link with a dummy url. You adjust the test. And so on. And slowly you dive into more detail. And slowly you get to write more detailed tests. And slowly you descent from the functional test level to the unit test level. A funny term for this is "programming with wishful thinking". "I wished I had a list of TODO items". So then you first mock it and then build it for real. "I wished I had a nice 'List' object". Repeat. Main "vallée de la Doller" French railway station Burnhaupt in 2007. -
Djangocon: Making angularjs play nice with django - Jacob Rief
(One of the summaries of a talk at 2014 djangocon.eu) Remark by Jacob beforehand: there's a bit of trend to put a lot of the UI in javascript. Fine for games and single page apps, but don't do it for ecommerce or CMS sites that you want to have indexed by google. Jacob Rief loves django. The three best parts according to him: Single source of truth. Model view control. Separation of concern. How about doing MVC on the client? A problem is that the browser UI is event-driven: you cannot do a simple one-way data binding from a model + a template to the html code. What you need is a two-way data binding. The model and the view are contiously updated both ways. The model is the single source of thruth. Changes to the view update the model; changes to the model update the view. This way of working is used by many javascript libraries. Angularjs is one of them. The view itself is compiled from a template inside the html code. You mark part of the html structure with angular directives (<div ng-something="bla">) and angular then turns that into the proper view (html DOM) that's bound in … -
Djangocon: introduction to docker - Amjith Ramanujam
(One of the summaries of a talk at the 2014 djangocon.eu). Amjith Ramanujam Why docker? Your site consists of a full stack. Django, database, apache, celery, etc. If you're a full stack deveoper, you need to be able to look at all of them. And ideally you'd have exactly the same environment locally as on the server. Docker calls itself "an easy, lightweight virtualized environment for portable applications". A portable, self-sufficient container. It is a sandboxing technique that is a bit similar to BSD chroots. It uses Linux containers, AUFS, Git-like versioning and a REST API. What is the difference with a normal virtual machine? A VM needs: Host OS Hypervisor Guest OS Libs The app Docker needs: Host Libs. Your app. The libs and the app are part of a docker image. It is faster and much more lightweight. It reuses the host OS (but it is completely isolated!). On OSX: use boot2docker plus an OSX docker client. It uses a virtualbox with linux, the docker client still runs on OSX, but talks to docker inside the virtualbox. Some terminology: an image is a base that contains libs, binaries, environment variables, files and so. When you instantiate ("run") it, … -
Djangocon: pytest helps you write better django apps - Andreas Pelme
(One of the summaries of a talk at the 2014 djangocon.eu). Andreas Pelme's slides are at http://speakerdeck.com/pelme . Django already provides some nice tools to make testing easier. The testing experience can become even better, for instance by using pytest. Pytest is quite popular. The ones using it don't want to use anything else. (He showed a couple of tweets of well-known django developers to prove it). Pytest is exensible. Andreas is the maintainer of the pytest-django plugin. The main advantage of pytest is that it allows you to write pythonic tests, without boilerplate. No more self.assertEquals(a, b) but simply assert a == b. Advantage: the error message when it doesn't match is much clearer than the regular test exception. You don't need to subclass from TestCase anymore. Just a function is enough. Django's TestCase would normally give you self.client. The function will look something like def test_something(client): .... The django extension for pytest recognizes "client" and passes in the correct object automatically. That auto-recognized "client" attribute? Pytest calls that a "fixture". No, that's something else than django's fixtures. Test fixtures are very handy for test dependencies. You run the tests with py.test. For this, you need to have your … -
Djangocon: challenges when building high profile news sites - Yann Malet
(One of the summaries of a talk at the 2014 djangocon.eu). Yann Malet talks about editorial sites (=newspapers). And especially high profile ones, so ones that see a lot of visitors. Multi layer cache to protect your database Django is web scale. No problem. Django won't be in your way regarding performance. Which means: if you use something else, you'll run into the very same problems. A news item on one of their sites got mentioned a lot on twitter and other sites. Their servers even didn't break a sweat. Caching for the win! You should add caching. You don't need to re-calculate the very same page in the very same way for every new visitor. That takes way too much time. Luckily, adding caching for a news site is relatively easy. Varnish is the first layer of defence. A "web application accelerator", also known as "a caching HTTP reverse proxy". A page coming out of the varnish cache will be 10-1000 times faster than calculating it fresh inside django. Note: building something that caches reliably is very hard. Don't build it yourself, don't re-invent it. Just use varnish and configure it. Some varnish tips: Strip the cookies. Increasing the … -
Djangocon: good schema design and why it matters - Andrew Godwin
(One of the summaries of a talk at the 2014 djangocon.eu). Andrew Godwin is a django core developer and he's the author of South and its successor, the database migrations inside django itself. Schemas can be explicit or implicit. Postgresql, mysql and so have explicit schemas, they're regular . Redis, ZODB, couchDB: implicit, you basically "just" put data in (which in probably does have some kind of structure, of course). A problem with implicit schemas is that you can get silent failures: a weight might be "85kg" instead of 74, so a string instead of an int. Schemas inform storage, which might help with performance. And they enforce structure upon the data. The drawback? It enforces structure upon the data. It is less flexible. When you add columns to your table or if you add an index, postgresql often behaves much better than mysql. It is faster and does much less locking. In case you use oracle or mssql, learn their strengths. Well. Schemas. They will need to change. You can put your schema into a vcs, but there's no guarantee that your data will survive the modification. Django has migrations build-in now. But migrations aren't enough: you can't automate … -
Djangocon keynote: the programmer's body - Daniele Procida
(One of the summaries of a talk at the 2014 djangocon.eu). Daniele Procida talks about diversity in our industry. Everybody seems to share the values and advantages of diversity as the python/django community. So he doesn't need to sell them to us now. What were the earliest computers? Women. The power of early computers was measured in "girl years": the work of how many computing women could it do? Women were highly prized for their manual computing work because they were paid half the salary of male colleagues. Programmers are now building the world. Anyone in the world will live in the world we build. The systems that govern us. The systems that govern our relations. The way we are educated. The way we are formed. Programmers are quite important. So a valid question is "who are these programmers?" But: does the question matter? Doesn't it matter more what we do rather than what we are? Liberalism says that what we do is much more important. Liberalism abstracts from "particulars". And it makes asusmptions and assertions of equality. It actually says that people should be equal. It asserts individual autonomy, responsibility and merit. In case you don't like those answers, … -
Djangocon: the power of natural language - Ilja Bauer
(One of the summaries of a talk at the 2014 djangocon.eu.) Ilja Bauer's talk has as subtitle "from ATDD to lean modeling". ATDD means Acceptance Test Driven Development. Constantine the African was an ancient physician and one of the first ones to use test driven development: he tested people's morning urine manually and could check whether they had diabetes or not. This is however a very manual process. In our test driven development, we can luckily automate a lot. Software development is a communication problem. He showed a picture of the biblical Tower of Babel where people couldn't understand each other anymore because they suddenly spoke different languages. It sometimes seems the same with the way our customers' requirements somehow doesn't quite end up in the software in the right way. Do we really understand each other? A solution can be acceptance test driven development: you write the acceptance tests together with the programmer. The client has a request. You write down the requirements as textual scenarios. You need to somehow convert the text into an automated acceptance test. He currently uses natspec, a plugin for Eclipse that is free for open source projects. You write the software and continuously … -
Djangocon keynote: devops, it is much more than just automation - Kevin van Wilder
(One of the summaries of a talk at the 2014 djangocon.eu.) Kevin van Wilder talks about devops. (Note: I changed the title from "your product is more than the application" to "devops, it is much more than just automation" as that covers the main message much better). Nothing good happens after 14:00 on friday. So don't do a friday deploy. He remembered a quick fix they needed to deploy one friday evening. It actually went OK and it even worked during the press conference demo. 10 days later the site died, though. Who's problem is it? "It worked in development". So, "it is an operations problem now?". Is devops the solution? You cannot really be a "devops person". It is more a movement, a philosophy: lets work together as dev and ops. Partially it is just a name for something that people have been doing for a long time. A useful acronym is CLAMS: Culture. How can we influence co-workers? You cannot directly change culture. But you can change behavior. And behaviour becomes culture. If you do it right, you'll start influencing others to do right, too. We've been influenced ourselves at this conference, right? Haven't we been shown The … -
Djangocon: django minus django - Jacob Burch and Jacob Kaplan-Moss
(One of the summaries of a talk at the 2014 djangocon.eu.) Jacob Burch and Jacob Kaplan-Moss say Django is awesome. It comes with basically everything you need to get your site started. But it doesn't come with everything. And sometimes you might want to rip something out and replace it with something else. You could rip out the template engine and put jinja2 in. Or remove the views and only use REST and lots and lots of javascript. And you add redis or so to make communication between the frontend and backend. And slowly it isn't so recognizable as a Django project anymore. Django's batteries-included nature is great, but sometimes those batteries hem us in. So they're going to talk about ripping things out of django. You can see what goes well and in which places django fights back. Templates Something that is often replaced is django's template language. You might want something more powerful or you might want a completely different template language. Jinja2 is a common candidate. More expressive and it is often quicker. You do need to pass a regular python dictionary as context to jinja, though, instead of a django context. You can use https://github.com/jbalogh/jingo to … -
Djangocon: really, really fast django - Christophe Pettus
(One of the summaries of a talk at the 2014 djangocon.eu.) Christophe Pettus works for http://pgexperts.com . So... postgresql expert! I've got two other talks of him postgresql when it is not your job and advanced postgresql in django. How fast django anyway? You hear things like "the orm is slow" or "the template engine is old". So... when in doubt, measure. How high-overhead are django's components? You'll need to have a good test. Just returning an empty response is nonsense. He did a bunch of tests and django holds up pretty well. The overhead is very low. Most ORM operations are O(N) on number of fields. So on average, a 1-field model will be 10 times faster than one with 10 fields. Updating an update? Use the ORM update method instead of looping over items. Much faster. Using manual SQL can be a little bit faster than the ORM, but it is neglegible. Django's basic request loop is plenty fast. Request/response cycles to the database generally swamp everything else. Always do bulk and batch operations instead of iterating. Don't use components you don't need. Often you load a lot of libraries. Do you really need a full REST library … -
Djangocon: from icontains to search - Honza Kral
(One of the summaries of a talk at the 2014 djangocon.eu.) Honza Kral talks about searching, which is a big topic. He'll focus on unstructured search: fulltext search. Search is an interface to your data. Textual search: $ grep -ri django * or: >>> Documents.objects.filter( ... Q(title__icontains='django') | ... Q(body__icontains='django')) Don't do this. None of them are going to scale. And you're going to miss things. If you search for "running" you'll miss "runs", for instance. The first index in world history was the 1230 bible concordance. Just a simple list of biblical words with pointers to the passages in which the words occurs. We can do the same. Technically it is an inverted index. We can do more than just looking up individual words. We can also look at phrases. In those cases you look both at the files the words occur in, but also at their place in those documents. We can do more things when storing words in our index: Leave out common words like 'a' and 'the'. Lowercase everything. Normalize words (normalize various verb variants to just one, normalize single/plural). Look for synonyms. (Fast is almost the same as rapid, for instance). All this happens at … -
Djangocon: gamers do REST - Angel Ramboi
(One of the summaries of a talk at the 2014 djangocon.eu.) Angel Ramboi works for a company, demonware that provides services for games, like leaderboards and so. They mostly use REST for communication. Interoperability and scalability are great. The whole web is one big REST API in a way, actually, so using REST is almost a guarantee that you can scale your service and that you can get it robust. Their stack: django 1.6, python 2.7, mysql 5.6 (sharded), CentOS and apache+mod_wsgi. So nothing really fancy and exotic. They take reliability very seriously. REST API design? Read Roy Fielding's thesis. Afterwards you'll be surprised at the elegance of it all. GET/POST/PUT/DELETE verbs for a CRUD API. HTTP for the communication protocol. JSON is handy for representation (they even use some light-weight schema validation). They use a pragmatic approach: "good enough" is better than "perfect". For development, they use github. Development is on branches. When everything is ready, they package it up as an RPM and deploy it. They do app configuration with YAML. It works better for them than python settings files as you can also use it for other applications. And in their case they can now also run … -
Djangocon: wednesday lightning talks
(One of the summaries of a talk at the 2014 djangocon.eu.) Lazy devops' guide to SSO with Kerberos - Aymeric Augustin The goal is to provide single sign on (SSO) to an internal application within your company network. You can use ksktutil to create a keytab. You then need to configure apache to look at that keytab. And you need to tell it to require a valid user. Django has support for such an externally set user that's send as a REMOTE_USER in the header. See https://docs.djangoproject.com/en/1.7/howto/auth-remote-user/ You next need to check if your browser works out-of-the-box or whether you need to do some more configuration There's more data in his notes: https://gist.github.com/aaugustin/10715655 A pycon in an African nation - Daniele Procida He hopes to get a pycon off the ground in sub-saharan Africa (not South Africa, as there's already a conference there). The goal: sustainability. They have to be able to build up skills locally. Skills shouldn't have to be imported. The only way forward is to use open source products. Through his university, he has some contacts. Nothing is fixed. There is much work to be done. And you cannot rush it: if you blow it, you could … -
Djangocon: taming complexity with django - Ustun Ozgur
(One of the summaries of a talk at the 2014 djangocon.eu.) Ustun Ozgur tells about someone's talk about simplicity, simpleness and complexity. What does "complexity" tell us as django developers? He quotes Richard Gabriel who talks about "habitability" as a characteristic of source code that enables developers that see a piece of code to understand it and to work on it, even if they haven't seen the code before. This is so for django. Complexity should be fought head-on. Look at domain driven design. Keep your architecture close to the actual domain. That helps. Django has a couple of layers of defense against complexity. URLs. Django routes various parts of the url to various applications. The division into seperate applications helps a lot to fight complexity. Models and managers. Django uses several well-known design patters that help structure your code in the right way. But... watch out for "fat" classes that do too much. You could look at mixins and compositions. Or you can move some of the fat class's methods to separate functions. Sometimes no code is the best code. You could put state machine state in a variable (a dict or so) and use that. Data is easier … -
Djangocon: introduction to user experience design - Meghan Reilly
(One of the summaries of a talk at the 2014 djangocon.eu.) Meghan Reilly is a user experience strategist. In the USA, they're slowly starting to cycle a bit more. And they're still learning how to share the road as cyclists and car drivers. When she's cycling, everybody else seems to be a bad car driver: they're all over the place. When she drives a car, the cyclists seem to be novices that are all over the road. (Personal comment: if you want to have more cyclists on your road, the cycling infrastructure needs to be good. Look for instance at Dutch junction design) She asked "who has been frustrated by bad websites". And afterwards "who ever implemented something in a website in the simplest way possible, thinking 'the user will figure it out or read the documentation'"... What is missing is empathy. Empathy is the ability to understand and share the feelings of the other. In user experience design we're putting the customer at the center. Not ourselves. For many, user experience design will be a totally new territory (just like she's now in new territory, never having visited Europe before). What is user experience? The experience you have, good … -
Djangocon: typography and the web, the state of the art - Idan Gazit
(One of the summaries of a talk at the 2014 djangocon.eu.) Idan Gazit is someone I really like to hear at django conferences. I'll simply point at two earlier talks. Design for developers (2010) and compass and less (2011). There's a nice book "thinking fast and slow". A general principle is that anything you can to to reduce cognitive strain is worthwhile. One of them is making your text readable. This is mentioned explicitly. The printing press was invented 600 years ago and we did a lot of writing beforehand, so we have a lot of experience. There are two kinds of factors: Micro. Typeface, kerning. Macro: measure ("width"), leading ("spacing"), flow of type on a page. There's a lot of common wisdom for books. How to lay it out, the ideal size of margins. But on the web we have a huge problem: we do not have control. There's no fixed page size, we have many screen sizes and screen resolutions and screen quality. But still... there's a lot that we can learn from the existing body of knowledge. Type size. 16 pixels is the default size in browsers. In books it is often smaller. But it is 16 … -
High Performance Django Kickstarter Project
I'm really excited to (finally) announce that we are writing a book! We've been working with Django professionally for a long time (over 7 years now). During that time, we've learned a lot about how to use the framework to build fast and scalable websites. We're bundling up all that knowledge into an e-book called High Performance Django and it is up on Kickstarter today. We're already well into the writing process, so we can tell you a little about what you'll get. The book is heavy on Django tips, but also reaches far beyond Python, showing you how to architect and tune the rest of your stack. It gives you an opinionated battle-tested blueprint utilizing many of the same techniques as high-profile Django sites like Disqus, Instagram, and Pintrest. We hope to get the first edition out in July, but we need your help to make that happen. Writing and editing the book is going to be a massive undertaking and you can help support our effort. Give us your vote of confidence by backing the project today! -
High Performance Django Kickstarter Project
I'm really excited to (finally) announce that we are writing a book! We've been working with Django professionally for a long time (over 7 years now). During that time, we've learned a lot about how to use the framework to build fast and scalable websites. We're bundling up all that knowledge into an e-book called High Performance Django and it is up on Kickstarter today. We're already well into the writing process, so we can tell you a little about what you'll get. The book is heavy on Django tips, but also reaches far beyond Python, showing you how to architect and tune the rest of your stack. It gives you an opinionated battle-tested blueprint utilizing many of the same techniques as high-profile Django sites like Disqus, Instagram, and Pintrest. We hope to get the first edition out in July, but we need your help to make that happen. Writing and editing the book is going to be a massive undertaking and you can help support our effort. Give us your vote of confidence by backing the project today! -
A break from the tutorial: Intuitive stuff
Hey guys! Let's take a break from the bombarding of information, and let's do something interesting. Let's talk about some of the features that are taken for granted in all the giant websites. You may already have noticed them. If not, double back and check them out. We'll also see how to implement them in your website.The "Keep me logged in":Many websites like Facebook and Gmail offer this option at the time of login. What it does is even if you close the browser/tab/window, the next time you open it it opens on your homepage. Even more fascinating, if you try to log in from some other device it you're not logged in, and you even get an alert that someone tried to access your account from an unknown location. Let's see how this is done in steps:When you log in, cookies with your username are stored in your browser. If you close it and reopen it, and access that site again, it checks for that-site-specific cookies. If they are there, they take you to your homepage. Else, you're redirected to the login page.To prevent multiple people accessing the account at the same type, the session is logged in to … -
Djangocon: web components in django - Xavier Dutreilh
(One of the summaries of a talk at 2014 djangocon.eu) Xavier Dutreilh talks about web development. You probably use libraries like jquery and backbone. And css frameworks like bootrap. And tools like bower, grunt, yeoman and jshint. One of the things you should care about is performance. Especially for mobile devices, you don't want to send over too much css/js. You don't want too exotic and hard technologies, as you as a web developer probably will lack the specialized knowledge. Accessibility is important. Cross-browser functionality, too. But... we often disregard the wishes we enumerated above and simply look for ready-to-use framework and pile them on top of each other. And we hope everything works as we hope and expect. Which it doesn't and we spend lots of time debugging. We inherit technical dept by piling everything up like this. What can we do? Well, we first have to stop making such a mess in the first place and have to start looking at the requirements we figured out. The best tip is to think about individual elements. We could also try to do it lean and mean: custom code. Start by looking at a web page. What does it consist …