Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Loading Django FileField and ImageFields from the file system
Loading Django FileField and ImageFields from the file system -
FreshDesk Python API
FreshDesk is a great helpdesk system with a fully functional API. Recently a client asked to integrate FreshDesk into their Django based CRM. I created the Python interface to the API. Here's the gist. -
Parse cloud code, EmberJS & GetStream.io
Today we’ve released a small example app, which shows you how to integrate GetStream.io with Parse cloud code. The example is based on EmberJS and listens to changes in realtime. The demo shows a simple Facebook/Twitter style network where you can Share your View. Go ahead, try the demo and post a nice shot from the city you’re in right now.https://getstream.parseapp.com/#/ The cool bit here is that Parse Cloud code allows you to connect to other hosted platforms. In this case we’re integrating a scalable newsfeed with getstream.io, but you could for instance also hook up something like Algolia for search. The code for the integration, with explanations of how we’re using the Parse Cloud code can be found on Github/getstream/Stream-Example-ParseLet us know in the comments which other integrations you’d like to see. So far our Django, Rails and Laravel integrations are making it extremely easy to integrate a scalable newsfeed in your app. -
Django Dash & WSGI Wrestle Cancelled
Django Dash & WSGI Wrestle Cancelled -
Project Templates with Cookiecutter
When we start new projects we want to solve a problem, not write boilerplate. Cookiecutter helps you to stop writing boilerplate. In this video you will learn what cookiecutter is, and how to create templates so you can save yourself time and effort starting new projects.Watch Now... -
Handling Django's get_query_set rename is hard
Handling the rename of get_query_set to get_queryset in Django 1.6 is very tricky - much trickier than it might seem. For many 3rd party libraries, you will have a few aims: Maintain compatibility with older Django versions, and older projects (including libraries) that might call your code, or subclass it. Update your code to be compatible with latest versions of Django Stop getting warnings when running your code/tests. Warnings you've already addressed are a pain, as they drown out the ones you haven't addressed. Subclassing makes this much, much harder. Suppose you have: class FooManager(models.Manager): def active(self): return self.get_query_set().filter(active=True) def get_query_set(self): return FooQuerySet(model=self.model) How do you update this code? The tricky bit is that you need to consider a class that subclasses FooManager, which you don't control. That code might not be updated yet. A very important example is the RelatedManager class in Django, which dynamically subclasses the default manager on a model to provide access to related objects. You use this all the time, in ORM calls like person.schools.all() — roughly speaking schools returns a dynamic subclass of School.objects. In Django 1.5, this subclass overrides the get_query_set method so that it calls super.get_query_set (e.g. School.objects.get_query_set) and then adds some … -
Recommended Django Project Layout
Recommended Django Project Layout -
Summary of my "developer laptop automation" talk
Last week I gave a talk at a python meetup in Eindhoven (NL). I summarize Therry van Neerven's python desktop application development talk, but I didn't write one for my own "developer laptop automation" talk. Turns out Therry returned the favour and made a summary of my talk. A good one! -
Katie learns Angular.js
December 1st, I’m starting a new gig at SpeakAgent. A major part of the stack involves Angular.js, something I hadn’t really taken a hard look at before now. Sure, I’d heard the front-end devs chat about it, but it never occurred to me take a look. This series isn’t going to be a tutorial. If you’re looking for that, I’ll be keeping a list of resources that helped me greatly along the way. This is more a journal of learning, akin to my unfinished Roguelike series. Once again, I’m going to make a wee game. The idea is to revisit a previous project: Ten by Ten. The idea is to create a framework for making text adventure games. Some sort of Python framework (probably Django) will hold all the model data while Angular will control the the logic and presentation. What is AngularJs? Angular is an MVC framework written in JavaScript. Its primary aim appears to be making the creating of web applications less painful. I suppose I’ll be putting that to the test! Why not just jQuery? Well, first off, it’s what my new gig is using, so I’m learning it. Also, from what I can gather, Angular is … -
Uber and the Fourth Estate
Context: Uber Executive Suggests Digging Up Dirt On Journalists, The moment I learned just how far Uber will go to silence journalists and attack women. An old adage: “never pick a fight with someone who buys ink by the barrel”. Ignoring it, Uber shows they’re not just evil - they’re stupid. — jacobian (@jacobian) November 18, 2014 It’s more than an old adage, though: in targeting journos, Uber shows its utter contempt for even the concept of accountability. -
Easier integration with new API clients and data browser
In the past days we’ve updated our API clients for Python, Ruby, Node and PHP. Thanks for the great feedback which helped us made the API easier. Client improvements One thing which confused many new users was the syntax for getting a feed object. In the old syntax we would write client.feed(‘user:1’), which gives you access to the feed named “user” for user id “1”. Dozens of people emailed us with questions about this syntax. It was especially confusing that you have to setup the “user” part in the dashboard, but the user_id part is automatically created. The new syntax client.feed('user’, '1’) clarifies that there are 2 different arguments. The follow syntax has received a similar update, ie: flat1.follow('user’, '1’). You can use the new style syntax by upgrading your client library to the latest version. Framework integrations Furthermore we’ve added python 3 support to the Python client and Parse cloud support to the js client. In addition the framework integrations for Django, Rails and Laravel received a big cleanup. Data browser Last, we’ve released the data browser, which is a really nifty little debugging tool when you’re developing your application. You can access it via the dashboard. What’s next … -
Disqus and Disqus SSO
Outsourcing the comments and discussions part to a third party widget always helps us to save a lot of effort. When you feel that if it is okay to share your thoughts and discussions with someone out there who serves the capabilities of social integration and spam detection won't it be a cake walk? Disqus is such a kind of blog comment hosting service which is platform-agnostic and URL-agnostic. It is built with javascript and backend technology, Python using Django. Let us get to know how to add this to our Django app. Adding Disqus widget to a site is pretty straight forward and effortless. Here are the steps to follow: Create an account on Disqus and fill the details at https://disqus.com/admin/create/ Once you finish registration, access the universal code In the next following page, get the script and use it wherever we want to display comments Update the settings file with DISQUS_SHORTNAME The first step includes signing up in to Disqus and getting an account. Once we are done with it, we will be heading to a home page where we can find "Add disqus to your site" on top left. If we click it, we will be redirected … -
Bad Request 400 and Django Debug
Bad Request 400 and Django Debug -
Django under the hood: django REST framework - Tom Christie
(One of the summaries of a talk at the 2014 django under the hood conference). Tom Christie will give a two-part talk. The first is about django REST framework, the 3.0 beta will be out tomorrow. The second part is about API design in general. REST framework 3.0 They made a few fundamental changes in 3.0. Why did they do this? For instance for serializers. Serialization is from an object to a serialization format like json. It is is the deserialization that is the hard part: you have to do validation on incoming data and transform it if needed and convert it to an object. How it happened till now: serializer = ExampleSerializer(data=request.DATA, ...) serializer.is_valid() # serializer.object exists now This .is_valid() performs some validation on the serializer and it also instantiates an object. In 3.0, the validation still happens, but it only works on the serializer, not on an object. It returns validated data instead of an object. The validated data can afterwards be saved to an object explicitly. Another change is that there's a separate .create() and .update() method to split out the behaviour regarding creating new database objects or updating existing ones. The previous version determined itself whether … -
Django under the hood: Django ORM - Anssi Kääriäinen
(One of the summaries of a talk at the 2014 django under the hood conference). Anssi Kääriäinen is the "guardian of the ORM", he knows where all the bits and pieces are. He'll explain especially how QuerySet.filter() works. What is the Django ORM (object relational mapping)? It is a: Query builder. Query to object mapper. Object persistence. The operations the django ORM does are higher level than SQL by design. It doesn't have .join() and .group_by() operations exposed as an ORM operation. It'll do them behind the scenes, but you can't call them directly. Now about filters. For instance: Book.objects.filter(author__birth_date__year__lte=1981) This grabs the books with an author with a birth date's year that's 1981 or earlier. That year in the query isn't in django by default. Something new in django 1.7 are model transforms. This allows you to add such a specific year loookup: @some_registration_decorator class YearTransform(models.Transform): lookup_name = 'year' output_field = models.IntegerField() def as_sql(self, compiler, connection): # Some nice code that returns a bit of SQL Book.objects.filter(author__birth_date__year__lte=1981), what does it mean? Book is the model class. objects is the manager (models.Manager) filter is a method on the manager. It returns a models.QuerySet. It results in a models.sql.Query, which is … -
Django under the hood: django migrations - Andrew Godwin
(One of the summaries of a talk at the 2014 django under the hood conference). Andrew Godwin wrote south, the number one migrations framework for django. It is superseded by django's new built-in migrations, also written mostly by Andrew, hurray! The original idea was tho have a schema backend and hooks in the django ORM. The actual migration code would live outside of django in south2. In the end, everything is now in django. The original distinction between "schema backend stuff" and "the actual migrations" is still there in the code, however. The schema backend is relatively simple and straightforward; the migration part is hard and hairy. The migration part contains: operations, loader/graph, executor, autodetector, optimiser, state. He'll talk about some of them here. What about the old syncdb? It is a one-shot thing: you add tables and then you add the foreign keys. When migrating, you have dependencies. You cannot add foreign keys to tables you haven't added yet. There is automatic dependency-detecting code, now, but that was added quite at the last moment in the 1.7 beta 2... Basic dependencies means the obvious stuff. Some examples: Like creating a model before adding a foreign key to it. Most … -
Django under the hood: internationalisation - Jannis Leidel
(One of the summaries of a talk at the 2014 django under the hood conference). Jannis Leidel tells us about django internationalisation (or should that be internationaliZation? Well, Jannis confessed to changing it to an S on purpose :-) ) Jannis used to maintain django's translations a few years ago. Now he works on the mozilla developer network website, which has translations into more than 30 languages. He showed a picture of the Rosetta stone. That stone turned into a tool to transmit the previously-unknown egypt hyroglyphs to our times. It was the vessel that brought lots of Egypt culture to the present time. Isn't what we do with our Django websites something that similarly can transfer knowledge and culture? But there is a problem... 56% of the web is English. 5% is a native speaker. Only 20% of the world population has a basic knowledge of English! Another example? 0.8% of the web is Arabic. 4% is a native speaker. 0.1% is Hindi, with 5% native speakers. Multilingual and multicultural... There are huge differences. The future is a global web, with lots of fresh new internet users coming online in the coming years. Users that don't speak English and … -
Django under the hood: model _meta - Daniel Pyrathon
(One of the summaries of a talk at the 2014 django under the hood conference). Daniel Pyrathon talks about django's Model._meta and how to make it non-disgusting. He worked on it via the google summer of code program. His task was to "formalize the Meta object". The Meta API is an internal API, hidden under the _meta object within each model. It allows Django to inspect a model's internals. And.... it makes a lot of Django's model magic possible (for instance the admin site). What's in there? For instance some real metadata like "model name", "app name", "abstract?", "proxy model?". It also provides metadata and references to fields and reletaions in a model: field names, field types, etc. Which apps use it? The admin. Migrations. ModelForms. ... other developers. Developers have always used it, even though it is not an official API! Developers shouldn't be using it as it is internal. You really need it however for things like django-rest-framework. So... There's a big need for a real, public API. There is an important distinction between fields and related objects. A field is any field defined on the model, with or without a relation. Including foreign keys. Related objects are … -
Django under the hood: python templating - Armin Ronacher
(One of the summaries of a talk at the 2014 django under the hood conference). Armin Ronacher is the maker of many non-Django things such as Flask and Jinja2. His initial thought was "why are we even discussing templates in 2014"? In 2011 everyone started making single-page applications. But a year later it turned out not to be too good an idea: the cloud is much faster than your mobile phone. So server-side rendering is hip again. Django in 2005 had one of the few available template languages that were any good. It got imitated a lot, for instance in Jinja2. Which is fast. He doesn't really like looking at his own Jinja2 code. For him, it is pretty early Python code and it could be so much nicer. Feature-wise Jinja2 hasn't changed a lot in the recent years. There are a couple of problems, but they're not big enough to warrant a fix, as any fix will invariably break someone's template. The template language is mostly the same, but Jinja2's and Django's internal design differs greatly. Django has an AST ("abstract syntax tree") interpreter with made-up semantics. Jinja2 compiles into python code ("transpiles" he calls it). Rendering is mostly … -
Django under the hood one-day conference this friday
Hurray, tomorrow morning (friday) I'll go to Amsterdam for the first one-day django under the hood conference. The tickets sold out quickly, but I convinced the company where I work (Nelen & Schuurmans) to sponsor the event, so we had three tickets reserved for us :-) If, by this evil strategem, I managed to snatch away your ticket: I'll provide a little bit of atonement by providing summaries of all the talks. (I'll tag them with djangocon to keep them together with my other django summaries). We as Nelen & Schuurmans use a lot of Django, so we're happy to do a bit in return by sponsoring the conference. We're certainly not a pure IT company, as our main focus is water management. 40 of us are experts in ecology, water management, hydrology etcetera, 12 of us are programmers. And most of our work is done with Python and Django. That makes us one of the biggest Django shops in the Netherlands, which is fun for a company mainly associated with water :-) I'm looking forward to the talks tomorrow. The conference aims at giving us a better understanding of Django's internals so that we'll hopefully contribute more to Django's … -
We've Won Two W3 Awards for Creative Excellence on the Web!
We’re honored to announce that we’ve won two W3 Silver Awards for Creative Excellence on the Web. The awards were given in recognition of our homepage redesign and DjangonCon 2014. Many thanks to Open Bastion and, by extension, the Django Software Foundation for selecting us to build the DjangoCon website. Also many thanks to our hardworking team of designers, developers and project managers that worked on these projects: Dan, Daryl, David, Michael, Rebecca, and Trevor! Here’s a quote from Linda Day, the director of the Academy of Interactive and Visual Arts (the sponsors of the award): “We were once again amazed with the high level of execution and creativity represented within this year’s group of entrants. Our winners continue to find innovative and forward- thinking ways to push the boundaries of creativity in web design.” We’re particularly humbled to learn that there were 4,000 entries this year and to be in the company of winners like Google, ESPN, Visa, and Sony and the many other wonderful companies that received recognition. We’re looking forward to continuing to build great web experiences! The official press release: http://www.prweb.com/releases/2014-CaktusGroup/11/prweb1234567.htm -
Python desktop application development - Therry van Neerven
(Summary of a talk at a python meeting in Eindhoven, NL. I also gave a presentation (just the slides)). He's the author of the "sendcloud client", a desktop app of the company he works for. It steers a barcode scanner and prints out packaging slips. Why a desktop app? They wanted to make it look like a native windows app. But especially, they wanted to do two things that a browser app cannot do: printing without a dialog and scanning barcodes! So they needed to. Why in python? He wanted to learn more about python. And python allowed him to work quickly. There are quite a lot of libraries that helped him a lot (examples: requests, pywin32, pyusb). There are a couple of GUI frameworks for python. Some don't look too good, others are nicer. Kivy is a nice one. As is PyQt/PySide. PyQt might mean some licensing costs. Kivy has less features and it is not native looking. Kivy does have a more innovative UI as it is build on PyGame. It also supports android and ios. Tip by Therry: if you're interested, simply get your hands dirty. Try out something! Important for desktop applications is to "freeze" your … -
Using Amazon S3 to Store your Django Site's Static and Media Files
Storing your Django site's static and media files on Amazon S3, instead of serving them yourself, can make your site perform better. This post is about how to do that. We'll describe how to set up an S3 bucket with the proper permissions and configuration, how to upload static and media files from Django to S3, and how to serve the files from S3 when people visit your site. S3 Bucket Access We'll assume that you've got access to an S3 account, and a user with the permissions you'll need. The first thing to consider is that, while I might be using my dpoirier userid to set this up, I probably don't want our web site using my dpoirier userid permanently. If someone was able to break into the site and get the credentials, I wouldn't want them to have access to everything I own. Or if I left Caktus (unthinkable though that is), someone else might need to be able to manage the resources on S3. What we'll do is set up a separate AWS user, with the necessary permissions to run the site, but no more, and then have the web site use that user instead of your … -
Using Amazon S3 to Store your Django Site's Static and Media Files
Editor's note: This post was updated in September 2017. Using Amazon S3 to Store your Django Site's Static and Media Files Storing your Django site's static and media files on Amazon S3, instead of serving them yourself, can improve site performance. It frees your servers from handling static files themselves, lets you scale your servers easier by keeping media files in a common place, and is a necessary step to using Amazon CloudFront as a Content Delivery Network (CDN). -
[Scaling Celery] Sending Tasks To Remote Machines!
Celery:Celery is an asynchronous task queue/job queue based on distributed message passing. It hasCelery Application/Client/Producer: It adds tasks to the queue. Celery Worker/Server/Consumer: It executes the tasks given to it.Broker: It is just a transport mechanism which connects the above two.For simple tasks you can setup them in the same machine. But, if you have a lot of jobs which consume lot of resources, then you need to scale them. In this tutorial lets move our celery workers into a remote machine keeping producer and broker in same machine.What You Should Know:You should know how to setup up Celery and how to Create celery tasks: @app.task def add(x, y): return x + y Put that task in a queue: add.apply_async(args=[1,2])Run a worker to consume the task: celery worker -A my_app -l infoSending Tasks To Another Machine:On Machine A:1. Install Celery & RabbitMQ.2. Lets configure rabbitmq so that Machine B can connect to it.# add new usersudo rabbitmqctl add_user <user> <password># add new virtual hostsudo rabbitmqctl add_vhost <vhost_name># set permissions for user on vhostsudo rabbitmqctl set_permissions -p <vhost_name> <user> ".*" ".*" ".*"# restart rabbitsudo rabbitmqctl restart3. Create a new file remote.py with a simple task. Here we have broker installed in …