Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mpdaugherty/ratebeers
Rate your favorite beer!
https://github.com/mpdaugherty/ratebeers
Last synced: 10 days ago
JSON representation
Rate your favorite beer!
- Host: GitHub
- URL: https://github.com/mpdaugherty/ratebeers
- Owner: mpdaugherty
- Created: 2012-07-09T11:28:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-07-20T07:20:23.000Z (over 12 years ago)
- Last Synced: 2024-10-30T21:12:01.426Z (about 2 months ago)
- Language: Python
- Size: 5.35 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: readme.org
Awesome Lists containing this project
README
* RateBeers
RateBeers is a very simple, relatively ugly Django application.
** Use Case Description
Using RateBeers, you can vote for your favorite beers! The homepage
shows a list of popular beers, along with their current likes and
dislikes.Clicking ‘Like’ or ‘Dislike’ will register your vote. You can also
click on the title of the beer to view only that beer and send the
link to your friends.** Installation
If your system has python 2.7 installed, installation should be very easy:
#+BEGIN_SRC shell
git clone
cd
sudo easy_install pip
sudo pip install -r requirements.txt
python manage.py syncdb
python manage.py runserver
#+END_SRCYou can now visit [[http://localhost:8000/][http://localhost:8000/]] to view and rate your beers!
** Code overview
RateBeers is written in Python, using the Django framework. This is a
quick overview of how a Django application works:*** Models
Models define the data and represent the information stored in the
database. We have one model, Beer, which is located in
ratebeers/beers/models.py.*** Views
Views are Python functions that perform an action or calculate a
result in response to an HTTP request. These are located in
ratebeers/beers/views.py. They are mapped to specific URLs via
ratebeers/urls.py.Generally, a view renders a template to generate HTML at the end of
the function. When it does that, it passes a “context” dictionary to
the template, which provides data that the template can use.*** Templates
Django templates are just HTML with a little extra syntax. Anything
inside of {{ }} is calculated using the context provided by the
view and is output into the HTML. Anything inside {% %} is also
interpreted specially, but not output directly. {% %} can be used for
for…in loops, etc.*** Static files
Images, CSS, JavaScripts, etc. are all located in ratebeers/beers/static/.
If you add an item to the static directory, you can get its URL in a
template via {% static path/to/item %}.** Django & Python Links
- http://python.org/
- https://docs.djangoproject.com/en/1.4/
- https://docs.djangoproject.com/en/1.4/ref/templates/