django - python - python

I am very new to django, python and ubuntu command line. I've been installing an application on PC's and this is my third one. Ive come across this error and am not sure where else to look. When I run
python manage.py syncdb
i receive the following error
django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version for database "winepad". GeoDjango requires at least PostGIS version 1.3. Was the database created from a spatial database template?
Any help would be greatly appreciated
Thanks

Check Your PostGIS Version. it must be atleast 1.3.

Have you gone through this character-building documentation:
http://docs.djangoproject.com/en/dev/ref/contrib/gis/install/
?
We need to know more about versions of things and what steps you took to come to this error. Otherwise, the error is pretty informative. The database that your settings refer to must not have been created with postgis 1.3+ from a spatial database template.

I wonder since you say that you are new,, Do you realize that you are attempting to install a Django package that has geo requirements and therefore assumes that you have a correct version of postgres-sql up and running (which is a somewhat difficult install itself)
You might want to start with something simpler that just uses the sql-lite database look in the Djano settings file to see what the database setting is....

Related

How to create a database in MySQL then link it to Python

I am trying to create a database that I can then read from / write to in Python. I've tried installing the recommended dev installation via this https://dev.mysql.com/downloads/windows/installer/8.0.html. I then went into the designer and added a table with some entities. However, the UX in MySQL is really terrible and I can't work out how to actually view the table in the database I've just created and add test values or whatever. I got frustrated and uninstalled MySQL completely because either I downloaded it incorrectly (I selected dev machine but I want to develop and run it on this machine, was that the wrong option?) or it's just terrible to deal with. However, it seems like there are no real alternatives unfortunately and so I would appreciate some help with regards to just setting up a simple database and connecting it to Python so I can perform SQL statements from my Python code. Also, another complication is that my normal Python installation (i.e. the one linked to PATH etc.) is 3.6, but I was forced to install 3.7 when I downloaded MySQL so I'm not really sure how that will work.
Thanks.

Upgrading Django Version: Best Practice

I've pretty big code base written on Django 1.5, it's about time to upgrade to the newest version (1.11.2) as many stuff don't work well.
I'm wondering if it's best to upgrade step by step: 1.5->1.6->1.7...
or just jump to 1.11.2
what method should be better and make the (hard) process easier? as my project has many dependencies?
Also what are good practices to do? I'm using virtualenv and aware of this Django article about upgrading
The document you found (“Upgrading Django to a newer version”) has a good guide.
An important part, before upgrading, is to have full branch coverage by the automated test suite for your application, before upgrading.
You want to be able to run a full automated test suite, see everything pass and know that all branches are exercised by the test suite.
This means that when you break something by porting to the new Django version, you'll be able to see which parts of your app are not behaving correctly any more.
Read about what changes you need to make by reading the release notes and deprecation timeline, for all of the relevant releases between your current and target Django versions.
See what dependencies you'll need to upgrade for Django; you might need to correct your code if it relies on incompatible features in an outdated third-party library.
All of those should be done before upgrading a single thing, in my opinion.
It depends on two things. How many people are using the Django app, and the extend of your test coverage.
If you are the only user, no worries, upgrade all the way. But if you have a lot of users you will quickly find out by upgrading all the way to 1.11.2 that some edge cases may not be covered by your tests.
Expect a lot of error 500 along the way.
If your coverage is close to 100% on all your apps, you may not have that problem.
Note that a lot has changed since 1.5.
I my case about: Data
I am using SQLite and i am sure that, the lastest version can kill you if you have only 1 conflict.
python manage.py makemigrations and so on had so many chance in it's method.
And if you change Python from 2x to 3x, it is a new case too =))

how to run(copy) django project from one system from another system?

i was working on a project on django using one of my system(win8) now i have changed my system.how do i continue working from where i left off on my new system(win7).i have a copy of the old django project file directory and nothing else,i have installed python and django on my new system and just copying that file directory and running python manage.py runserver on new system doesnt work(i wasnt hoping that it would work anyway) so what should i do?i am new in django and python so if anyone can explain me in detail.if my question arise any confusion please leave a comment.
django.db.models.loading was removed in Django 1.9. You need install the same version of Django on the old and new systems.
Django is pretty good about backwards compatibility, but you can't upgrade from one version to the next and assume that everything is going to work. You need to read through the release notes first (e.g 1.9), and make any required code changes.

Django and python3

I'm currently testing frameworks to create a big multiplayers game. I choose Django.
But I have a question about the version of Python. I should to create that project from scratch with Python 3.x or Python 2.x?
Python 3.x and Django compatibly is ok, or not production usable for now?
I wouldn't highly suggest going production with Python 3 with Django or for that matter any other framework that requires you to depend on many third party applications, although many have been ported to Python 3, you still may find bugs, which you will likely have to fix or wait awhile before maintainers get to it.
Also, there aren't many compelling reasons to move to Python 3 at the moment, but that I suspect that will change soon with all the asynchronous work being put into Python 3.
Django is compatible with Python 3.
There's at least one issue with Python3 + Django (1.6) + MySQL.
MySQLdb hasn't been ported to Python3 yet.
The other python-only mysql connector mentioned in the Django documentation (MySQL Connector/Python) has a bug in it which might stop it working with fixtures.
http://bugs.mysql.com/bug.php?id=72001
It looks like Oracle has closed this bug report by documenting that the problem may occur; so a real fix doesn't look likely any time soon.
So if you rely on fixtures and use MySQL, you'll likely have a problem.
Try using the latest GA version of mysql-connector-python.

What is PyMySQL and how does it differ from MySQLdb? Can it affect Django deployment?

I just solved some problems in my Django 1.3 app by using PyMySQL instead of MySQLdb. I followed this tutorial on how to make the switch: http://web-eng-help.blogspot.com/2010/09/install-mysql-5-for-python-26-and.html
Now I want to know what PyMySQL actually is and how it is different from MySQLdb.
I am using it on localhost and will then upload it to some hosting.
Is it fine to use PyMySQL on localhost and on hosting whatever they provide? Since I have changed "MySQLdb" in base.py and introspection.py to "PyMySQL", will I need to upload it to the server after changing these files? Or as it is Django's files, since Django will be uploaded there already, does it not matter much?
PyMySQL and MySQLdb provide the same functionality - they are both database connectors. The difference is in the implementation where MySQLdb is a C extension and PyMySQL is pure Python.
There are a few reasons to try PyMySQL:
it might be easier to get running on some systems
it works with PyPy
it can be "greened" and works with gevent
The proper way to use it with Django is to import it and tell it to impersonate MySQLdb in your top-level file, usually manage.py. Put the following code at the very top of your manage.py (or whatever file you call when starting your server):
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
pass
PyMySQL and MySQLdb are both database connectors for Python, libraries to enable Python programs to talk to a MySQL server.
You would normally never upload core Django files when deploying an app. If Django is working fine on your deployment server, you definitely don't need to change anything there. The DB driver is a step or two below the ORM even, and certainly none of the code you have written depends on which of these is in use.
Your first point:
According to pymysql wiki page:
MySQLdb, is a C extension module that has a reputation of being
difficult to compile, especially if you're on a Mac. Additionally,
end-users need to wait for new binaries to be compiled for each new
release of Python, and MySQLdb will never run on Jython, IronPython,
or PyPy (without something like cpyext or IronClad). We also maintain
100% compatibility between Python 2 and Python 3, so all advancements
made on the 2.x trunk will be immediately available on Python 3.
Your second point:
If django is working fine on your localhost, then it should be fine on
your development.
As per my experience I had difficulty in installing "MySQL-python" - (MySQLdb).
It made me search for more alternatives so I found pymysql, and it also got installed easily and worked in first go like a charm.
So I would suggest using pymysql only instead of MySQLdb.
I am starting with these topic, I only want to say an observation: PyMSQL has CPYTHON as a requirement(is optionall perhaps for performance https://pypi.org/project/PyMySQL/#requirements) to install, and Cpyhton depend on 'C', I tested Cpython and I had trouble when installed for the version of C too... then both implementation depend on 'C' [if you want performance], is the same thing for me...if the performance is not problem, perhaps PyMySQL is good without Cpython, free of 'C'. Perhaps we can start with PyMySQL alone with Python and switch Python to Cpython to gain in performance that could be a good thing we have all the things running and after that we can try to switch to Cpython,,,
We need to know the funcionality difference. Why in Django PyMySQL run better for you or give to you solutions for some problems, what problems? That is the important thing for change perhaps. MySQLdb perhaps depend directly from 'C' but PyMSQL indirectly thru Cpython(in case of similar performance), I prefer a direct dependence without limitations of jumps...Greetings.

Categories

Resources