I'm new to django and I've been browsing around the djangopackages site. I'm wondering what is the difference between those "django" packages, and python libraries that are not django packages.
So for example sendgrid has a django package and also a few regular python libraries. If I want to use the sendgrid wrapper from a django app, what benefits do i get by using the django package rather than the other python libraries that are available and more frequently maintained?
A Django package has the general structure of a Django app (models.py, views.py, et cetera) and it can have additional settings to define in your settings.py file. Using the Django package makes it easier to integrate the functionality into your Django web application rather than simply calling a Python library.
Usually the Python library provides all the functionality and a Django package provides additional functionality to use it (such as useful template tags, settings or context processors). You'll need to install both as the Django package won't work without the library. But this can vary so you'll need to look into the provided functionalities by the Django package.
Related
I want to be able to write shared functions that can be accessed in one-off batch scripts and also by the running Django service (to use the ORM)
Currently, I have this in the _init__.py under the my_proj module.
if 'DJANGO_SETTINGS_MODULE' not in os.environ:
os.environ['DJANGO_SETTINGS_MODULE'] = 'my_proj.blah.blah.settings'
import django
django.setup()
This works fine for one django project. However, now I want to do reference the ORM functions from another django project, "other_proj" in the same repo from an independent script that lives outside both django projects.
Is there a way to "django.setup()" multiple projects at once?
Or, at least, a way to easily toggle the setup between the two projects?
Or is there a better way altogether? (I realize I could create a client library to hit the services while they are running, but would prefer to remove that overhead)
If you want a Django project to access functionality that resides in a different Django project, a client library is an option (as you noted). You could also consider packaging those sets of functionality as re-usable Django apps that you import into each project, or you could abstract them further into re-usable Python modules which get imported into each project. If you're hoping to use the Django ORM from one Project to access data from a different project, then you might be looking for this SO question: How to make two django projects share the same database
I think with more specifics in your question (such as, for example, function X in Project A you wish you could call from Project B) we might be able to be more specific with guidance.
I'm not sure I quite understand the case you're trying to implement here; two things that sound maybe-sort-of like what you're asking for are:
1) Running Django projects under uWSGI in Emperor mode allows you to serve multiple Django projects from one server simultaneously.
2) Django can be configured to run the same project under multiple domains simultaneously using the Sites framework.
I agree, though, that more detail about what you have and what you're trying to accomplish with it is probably necessary to give a satisfying answer.
Officially, Azure Django Websites only support Python 2.7 and Django 1.4, but I am wondering if it is possible to set up an Azure Django website using Python 3.3 and Django 1.6 instead. This official Azure tutorial states:
Note: Windows Azure web sites now come with Python 2.7 and wfastcgi handler
pre-installed. However, web frameworks such as Django are not included. You can
still use a different Python interpreter if you prefer. You just need to include
it in the Git repository and configure the web site to use that interpreter
instead of the Python 2.7 interpreter already installed.
That sounds to me like you can set it up to use a different Python interpreter, although you may have to also provide your own wfastcgi handler and Django installation if you do this. The tutorial also tells you how to point to the location of the interpreter you want to use.
The Python website provides installers, but how would I get everything needed for the Python interpreter into one folder to put in the git repo? Is everything needed already self-contained in /Library/Frameworks/Python.framework/Versions/3.3? What about for Django and wfastcgi? Has anyone else tried this?
It is working now: put python-3.4 in runtime.txt at the root of the project.
See: https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/
I'd like to use something like Django signals in non-Django projects. I thought I'd seen libraries like this in the past, but I've been unable to locate one via the usual searches.
Python's signal library doesn't offer the same capabilities.
There are a number of modules for this. Here are a few options, ordered by what I think their popularity is:
The blinker module provides a signal/event mechanism
PyDispatcher gives you event dispatch
The PySignals module is the Django signals module without any dependency on Django
SpiffSignal implements a signal/event framework, but its GitHub page seems to be missing
Is there any Django plugin or reusable app available that we can use to add online directory feature to our Django based website?
You will not find something like that, because using django means you can do that with just a few lines of code by yourself. Django is not a CMS, but a framework, which means you are one level deeper. A lot of the things where you would use a plugin in a CMS are common tasks for django programmers, so there really is no need for a plugin to display such stuff as you mentioned.
I'm looking to write a small web app to utilise a dataset I already have stored in a MongoDB collection. I've been writing more Python than other languages lately and would like to broaden my repertoire and write a Python web app.
It seems however that most if not all of the current popular Python web development frameworks favour MySQL and others with no mention given to MongoDB.
I am aware that there are more than likely plugins written to allow Mongo be used with existing frameworks but so far have found little as to documentation that compares and contrasts them.
I was wondering what in people's experience is the Python web development framework with the best MongoDB support?
Many thanks in advance,
Patrick
I have not tried MongoKit although it has been around for a while and retains a good reputation. I personally prefer MongoEngine and feel very comfortable with it (maybe because I like its nice homepage and good documentation). There is also a very good opensource project named Mumblr which demonstrates a Django-MongoEngine-MongoDB combination, which I think a very good starter for any project. I'm developing a CMS for my own company using this app.
I've used MongoKit with Pylons before and it worked out good.
You might want to refer to this post though: MongoDB ORM for Python?
There is no stable support for mongodb using django framework. I tried using mongoengine, but unlike models, provided for admin in django framework, there is no support for mongoengine.
Correct if I am wrong.
Flask is the best framework to use with MongoDB. It has a mongodb library called flask-pymongo
Make sure you run the following commands before starting your project.
$ pip3 install Flask
$ pip3 install Flask-PyMongo