I recently switched from Django 1.6 to 1.7, and I began using migrations (I never used South). Before 1.7, I used to load initial data with a fixture/initial_data.json file, which was loaded with the python manage.py syncdb command (when creating the database). Now, I started using migrations, and this behavi…
Tag: python
Django 1.7 – “No migrations to apply” when run migrate after makemigrations
I use Django1.7 with Mezzanine. I create simple profile (according to Mezzanine documentation) stored in separate app “profiles”: Creation of migrations returns: When I run “migrate profiles”: The issue is, when I try to open any page related to mezzanine.accounts (for example update a…
pandas: Convert string column to ordered Category?
I’m working with pandas for the first time. I have a column with survey responses in, which can take ‘strongly agree’, ‘agree’, ‘disagree’, ‘strongly disagree’, and ‘neither’ values. This is the output of describe() and value_counts() for the c…
Object Oriented Python with Flask Server?
I’m using Flask to expose some data-crunching code as a web service. I’d like to have some class variables that my Flask functions can access. Let me walk you through where I’m stuck: When I run getSomeData() outside of Flask, it works fine. But, when I run this with Flask, I get 500 interna…
Append Text (Single Letter) to the end of each line in a text file
Below is an example of the text file I am working with: I am trying to add simply the letter ‘S’ to the end of every other line. So, above, there 3 total records. Right after 05/29/2014, I want to insert the S. So a every record would look like: I realize this would be Oh so simple converting to
ImportError: No module named ‘Tkinter’
For some reason, I can’t use the Tkinter or tkinter module. After running the following command in the python shell or I got this error ModuleNotFoundError: No module named ‘Tkinter’ or ModuleNotFoundError: No module named ‘tkinter’ What could be the reason for and how can we sol…
Installing psycopg2 in a virtualenv in ubuntu os
I using a virtualenv and I am trying to set up postgresql. I have psycopg2 installed on my system, but it appears that my virtual env does not recognize psycopg2. Is it possible to just copy the system wide psycopg2 files into my django project directory or is this a bad approach to take? This is the relevant…
Display numpy array in a for loop using matplotlib imshow
I have a numpy array whose elements are updated in a for loop: I want to display the array at each iteration, but imshow() doesn’t work, it just displays the image once the loop terminates. ps. I’m using an Ipython notebook I found different things on the web but none of them work on my computer (…
Function sequence error in PYODBC
I am using pyodbc to connect to a database and extract certain data from it. Here is my code: And I got following error after I run above code: pyodbc.Error: (‘HY010’, ‘[HY010] [Microsoft][ODBC SQL Server Driver]Function sequence error (0) (SQLFetch)’) May I know what caused such probl…
Flask-RESTful custom routes other than GET,PUT,POST,DELETE
In Flask-RESTful we add an api route like the below so that GET /api/kitty –> to CuteKitty.get() method; like this for all HTTP verbs Lets say that I need to provide my api consumers with a cute api like How can i achive the above routing with api.add_resource Like wise how to add route like /api/kit…