How to pull a random record using Django’s ORM?
I have a model that represents paintings I present on my site. On the main webpage I’d like to show some of them: newest, one that was not visited for most time, most popular one and a random one.
I have a model that represents paintings I present on my site. On the main webpage I’d like to show some of them: newest, one that was not visited for most time, most popular one and a random one.
I want to deploy an application with sqlite3 as the database on Heroku. However, it seems to be that Heroku doesn’t support applications with sqlite3 as the database. Is it true? Is there no way to deploy my sqlite3-backed application on Heroku?
I am trying to request.user for a form’s clean method, but how can I access the request object? Can I modify the clean method to allow variables input?
I need to execute a Python script from the Django shell. I tried:
The @cache_page decorator is awesome. But for my blog I would like to keep a page in cache until someone comments on a post. This sounds like a great idea as people rarely comment so keeping the pages in memcached while nobody comments would be great. I’m thinking that someone must have had this problem before? And this is different than caching per url.
Python’s getattr() method is useful when you don’t know the name of a certain attribute in advance.
I was following the first app tutorial from the official Django docs and got this error when trying to save some changes made through the admin page. I did some research on it, but the possible solutions I was able to find, such as migrating the db, simply won’t work. Just let me know if you want to see some specific part of my code.
I’ve set up PyCharm, created my virtualenv (either through the virtual env command, or directly in PyCharm) and activated that environment as my Interpreter. Everything is working just fine.
I’m trying to build a simple website with login functionality very similar to the one here on SO.
The user should be able to browse the site as an anonymous user and there will be a login link on every page. When clicking on the login link the user will be taken to the login form. After a successful login the user should be taken back to the page from where he clicked the login link in the first place.
I’m guessing that I have to somehow pass the url of the current page to the view that handles the login form but I can’t really get it to work.
I have a django project that structure is like this: