Skip to content

Commit 2f58b1e

Browse files
authored
Merge pull request #62 from agiliq/remove_homepage_mongo_dependency
Removed mongo dependency from homepage.
2 parents 2f6b067 + d52dc93 commit 2f58b1e

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ Graphos is a Django app to normalize data to create beautiful charts. It provide
9393

9494
python manage.py migrate
9595

96-
* Make sure mongo server is running(You should have mongodb properly setup for this)
97-
98-
mongod --dbpath ~/data/db
99-
10096
* Run server
10197

10298
python manage.py runserver
10399

104100
The installed demo app shows the various suported chart types.
105101

102+
In case you want to use mongo data while charting, you must have mongodb properly setup and **pymongo** installed. Make sure mongo server is running.
103+
104+
mongod --dbpath ~/data/db
105+
106106

107107
### Overview of Plot generation
108108

demo_project/demo/templates/demo/home.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ <h2>Google charts<h2>
2929
{{ g_chart.as_html }}
3030

3131

32-
<h2>Mongo Data with LineChart</h2>
33-
{{ m_chart.as_html }}
34-
3532
<br />
3633
</div>
3734
{% endblock %}

demo_project/demo/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pymongo
2-
31
from .models import Account
42

53

@@ -8,13 +6,15 @@
86

97

108
def get_db(db_name):
9+
import pymongo
1110
DB_HOST = ["localhost"]
1211
DB_PORT = 27017
1312
db = pymongo.Connection(DB_HOST, DB_PORT)[db_name]
1413
return db
1514

1615

1716
def get_mongo_cursor(db_name, collection_name, max_docs=100):
17+
import pymongo
1818
db = pymongo.Connection(host=DB_HOST,
1919
port=DB_PORT)[db_name]
2020
collection = db[collection_name]

demo_project/demo/views.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import markdown
2929
import datetime
30-
import pymongo
3130
from dateutil.parser import parse
3231

3332
class MongoJson(FlotAsJson):
@@ -158,16 +157,20 @@ def get_context_data(self, **kwargs):
158157
def home(request):
159158
chart = flot.LineChart(SimpleDataSource(data=data), html_id="line_chart")
160159
g_chart = gchart.LineChart(SimpleDataSource(data=data))
160+
context = {'chart': chart,
161+
'g_chart': g_chart}
162+
return render(request, 'demo/home.html', context)
163+
164+
165+
def other(request):
161166
cursor = get_mongo_cursor("graphos_mongo",
162167
"zips",
163168
max_docs=100)
164169
m_data = MongoDBDataSource(cursor=cursor, fields=['_id', 'pop'])
165170
m_chart = flot.LineChart(m_data)
166-
167-
context = {'chart': chart,
168-
'g_chart': g_chart,
169-
'm_chart': m_chart}
170-
return render(request, 'demo/home.html', context)
171+
context = {}
172+
context['m_chart'] = m_chart
173+
return render(request, 'demo/other.html', context)
171174

172175

173176
@cache_page(60*60*24)

0 commit comments

Comments
 (0)