Saturday, April 23, 2016

Django | __init__() got an unexpected keyword argument 'maxlength'

TypeError: __init__() got an unexpected keyword argument 'maxlength'

This problem arises when you are using a newer version of Django. Since 1.0 (or actually, somewhere in 0.97) Django switched to max_length instead of maxlength.

So, replace maxlength with max_length




If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Django default Admin Username and Password


In earlier versions of Django, when syncdb command is run, it used to ask for super user creation. But the latest versions are not using syncdb command. Here is an article related to it.

We need to create admin user after using python manage.py migrate command. I have checked and found that there are no default users created automatically.


  1. $ python manage.py createsuperuser
  2. Enter your desired username and press enter.
    • Username: admin
  3. You will then be prompted for your desired email address:
    • Email address: admin@example.com
  4. The final step is to enter your password. You will be asked to enter your password twice, the second time as a confirmation of the first.
    • Password: **********
    • Password (again): *********

Superuser created successfully.









If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Django | DoesNotExist at /admin/login/ Site matching query does not exist

When typed  http://127.0.0.1:8000/admin/ into browser's address bar, I've encountered the following error.


I found that this is due to incorrect configuration inside settings.py file.

You don't really need the sites framework if you only run one site from the project, so the easiest fix would be to remove the following item from your INSTALLED_APPS and the error should go away:

'django.contrib.sites' ( It is a good practice to comment it and not to delete it )





If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

AttributeError: 'AdminSite' object has no attribute 'root' | Django

Your url for admin should be:
url(r'^admin/', admin.site.urls)

This would be available by default in urls.py file unless you or some program change it.


It should not  be
(r'^admin/(.*)', admin.site.root)

This is a change implemented in latest versions of Django.




If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Unknown command: 'syncdb' in Python | Django


If you try to use python manage.py syncdb in latest version of Django, it throws the following error.

Unknown command: 'syncdb'
Type 'manage.py help' for usage.

You won't find any syncdb command in help too. This is because syncdb command is deprecated in Django 1.7.

Use  python manage.py migrate instead.




If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Add to PYTHONPATH


If you're using bash (on a Mac or GNU/Linux distro), add this to your ~/.bashrc

export PYTHONPATH=$PYTHONPATH:/my/other/path

Make sure the directory you point to has at the topmost init.py file in your directory structure.



For example, I tried export PYTHONPATH=$PYTHONPATH:/Users/joey/repos but it did not work because my repos directory did not have _init_.py

Going down one directory further: /Users/joey/repos/specificRepo did the trick. Now python can traverse any downward directory connected to the specificRepo directory that contains a init.py !



If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Monday, April 4, 2016

Connectify for Ubuntu | Works for Android

The pre-installed Network Manager in Unity does not support Access Point (AP) mode which is required for Android devices. Fortunately, KDE’s connection editor support this mode.

Below is how to do it yourself:

1. Click the link below to bring up Ubuntu Software Center and install kde-nm-connection-editor:

2. Once installed, press Alt+F2 and run command to launch the app:
kde-nm-connection-editor

3. Click Add button and choose “Wireless (shared)” from the drop-down list.
4. Type in a name, ssid, and select Access Point mode. If want, set up a password under Wireless Security tab. Finally, click OK.
5. Click Network Manager applet on Unity panel and then choose “Connect to Hidden Wi-Fi network”, choose the connection you created in previous step and click Connect button.

Turn on WLAN on your Android phone and you’ll see the access point in the list. Click connect and enjoy!





If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

Source