My Tweets
- I'm not liking the attitude of Mr.President. Lots of Sarcasm, but, I'm not smiling. Looks like arrogance. 7 months ago
- Giveaway: New Relic Has Four More Free Disrupt SF Tickets For All You #DataNerds techcrunch.com/2012/09/05/giv… via @techcrunch 8 months ago
- #django Playing with Django. 1 year ago
- TechCrunch Giveaway: Last Free Ticket To Disrupt NYC, Plus Free iPod Touch #TechCrunch tcrn.ch/kncPnr via @techcrunch 2 years ago
- Why Facebook Needs Sheryl Sandberg - BusinessWeek buswk.co/mDNjtY via @BW 2 years ago
-
My Recent Voice
My Archives
- May 2012 (3)
- April 2012 (2)
- December 2011 (2)
- December 2010 (2)
- September 2010 (1)
- August 2010 (5)
- May 2010 (1)
- April 2010 (4)
- March 2010 (10)
My Tag Clouds
301 Error while Installing Rails Acegi Security Architecture BDD CakePHP Custom Homepage django Error Fitnesse Functional Testing Hibernate IndexError J2EE Java Lazy Loading Mac OS X Mikado Model API mysql database MySQL Django Python MySQL Windows 7 Database OpenID ORM PHP Programming Python Re-Factoring Reviews Ruby Ruby Gems Ruby on Rails Screen Cast SOAP UI Softwares for Screen Cast Solution Spring Spring Security SQLFeatureNotSupportedException Test Automation Testing Tutorial Tutorials WindowsMy Frequent Voice
Fitnesse – Slim : Could not invoke constructor for : Java Solution
I was trying to install fitnesse and get some basic fixtures(Decision Table) going. I was faced with ”Could not invoke constructor for”. I tried a couple of solutions like,
- Setting the !Path “Location of the .class file”. I got the location of the .class file wrong. I pointed it to actual directory where .class file was, even though it was in a Java Package.
So the solution was,
!Path “Point to bin directory (Simple Java Project ) or target directory (Maven Project)”
and then create a Import table which specifies the package of the Fixture class. For example:
|import |
|com.om.example.dvr.fixtures|
This will make sure that Fitnesse can find your fixtures. I’m currently using this tutorial, which is turning out to be a wonderful Fitnesse-Slim resource.
I’m going to show my fixture properties. Might be helpful , If you are facing this error.
!contents -R2 -g -p -f -h
!define TEST_SYSTEM {slim}
!path C:\Users\ddd\JavaWorkspace\fitnesse-tutorials\my-project\bin
|import |
|com.om.example.dvr.fixtures|
!define COLLAPSE_SETUP {true}
!define COLLAPSE_TEARDOWN {true}
Django : Python : Models Base.py IndexError: list index out of range
This page has the solution to IndexError Django throws when you try to access the model API from a standalone script.
I tried to import the model class after setting the PYTHONPATH and DJANGO_SETTINGS_MODULE Environment Variables
>>> from models import Player
This is the error I got,
.....
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 52, in __new__
kwargs = {"app_label": model_module.__name__.split('.')[-2]}
IndexError: list index out of range
After some googling and code search, the base.py expects the app name and its not available when you try to access the model API from a standalone script.
So you have to add the meta information APP name to all the model classes under the models.py. That will get rid of this error.
class xxx(models.Model):
name = models.CharField(max_length=200)
country = models.CharField(max_length=200)
twitter_handle = models.CharField(max_length=100)
followers = models.IntegerField('number of twitter followers')
def __unicode__(self):
return self.twitter_handle
class Meta:
app_label = 'appname'
class yyy(models.Model):
xxx= models.ForeignKey(xxx)
conversation = models.CharField(max_length=10000)
teaser = models.CharField(max_length=50)
views = models.IntegerField('popularity')
likes = models.IntegerField()
published_date = models.DateTimeField('date_published')
def __unicode__(self):
return self.teaser
class Meta:
app_label = 'appname'
Posted in Django, Python, Solutions, Technology, Tutorials, Uncategorized, Windows
Tagged django, IndexError, Python, Windows
ImportError: Could not import settings xxx.settings : Django : Python : Windows
Recently, I built an application using Django. I wanted to create a standalone script that used the My App’s model API to insert data into Database.
The Django Document says:
“If you’d rather not use manage.py, no problem. Just make sure mysiteandpollsare at the root level on the Python path (i.e., import mysiteandimport pollswork) and set theDJANGO_SETTINGS_MODULE environment variable tomysite.settings.”
I was little confused about those statements.
So what is PYTHONPATH? In general, it’s the collection of all searchable paths where python would search for modules that you might use in your programs.
Initially, I screwed up the environmental variables and this is the error that I got.
......self._wrapped = Settings(settings_module) File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 89, in __init__ raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'LearnPython.settings' (Is it on sys.path?): No module named LearnPython.settingsSo this is what I did:
1) Set the PYTHONPATH environment variable to point to the directory of your django app.PYTHONPATH = “C:\path\to\myapp\”
this is the path under which you’ll have the models.py
2) set the DJANGO_SETTINGS_MODULE environmental variable. This is the settings module that your app will use to determine the database user,password , host etc.
In my case I set DJANGO_SETTINGS_MODULE = “myapp.settings”
To confirm that everything worked, after setting the environmental variables , I logged into a new command prompt ,
C:\Users\xxx>python Python 2.7.2 (default, Jun 12 2011, 14:24:46)..... 32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> print os.environ['DJANGO_SETTINGS_MODULE'] cricketweet.settings >>> from models import Player >>>So Now I can access the model classes from a stand alone app. Happy coding
![]()
April 29, 2012 in Django, Python, Solutions, Technology, Tutorials, Windows
Tagged Model API, MySQL Django Python, Python, Windows
Improperly Configured MySQL DB Module-Exception – Django – Windows 7
I had this error after I installed Django, created a project, modified the settings.py to use the MySQL database and while I tried to create the necessary tables in the MySQL by running the following command.
python manage.py syncdb
I got this exception
.......
backend = load_backend(db['ENGINE'])
File "c:\Python27\lib\site-packages\django\db\utils.py", line 33, in load_backend
return import_module('.base', backend_name)
File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "c:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 14, in
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I was using Python 2.7 , so the solution was to use the MySQL Python connector. I downloaded it from here
After , I Installed the MySQL Python Connector, I created the MySQL database,(make sure you commit it) This seemed to work fine.
$ python manage.py syncdb Creating tables ... Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_user_permissions Creating table auth_user_groups Creating table auth_user Creating table auth_message Creating table django_content_type Creating table django_session Creating table django_site You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): yes Username (Leave blank to use 'test'): E-mail address: test@gmail.com Password: Password (again): Superuser created successfully. Installing custom SQL ... Installing indexes ... No fixtures found.
Hopefully this helps.
Posted in Solutions, Uncategorized
Tagged django, mysql database, MySQL Django Python, Python
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061) – MySQL- Windows
This happened to me while I was installing MySQL on my Windows 7 box. I had struggle installing the mysql daemon, because my User Access Control on Windows 7 Was not letting me install mysqld. After disabling UAC , I was able to issue the following commands.
mysqld –install followed by mysqld –start
After executing the above commands, I had issues while trying to connect to mysql prompt.
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
I went to services UI and started the MySQL Service. Then i was able to get into MySQL Prompt

