Using 3rd party Apps in Django, some questions - django

I am new to Django.
I have some doubts about installing 3rd party Apps in Django.
A specific example. The "django-registration" App in https://bitbucket.org/ubernostrum/django-registration/src. Reading the instructions the doc tell us to install this app with PIP(pip install django-registration), doing this the App will be installed in Python Site-packages, right?
My question is: The App must to be installed in that way? Why not put the 'django-registration' folder in our Project as an App?
PS: This is a starter Django Question.
Best Regards,

The App must to be installed in that way?
No.
As long as python can find it (ie: it's on the PYTHONPATH) you can put it any place you like.
Why not put the 'django-registration' folder in our Project as an App?
Why not indeed? If you plan on modifying it substantially that's perhaps quite reasonable. If you aren't, then keeping it separate will keep it plain as to what is your code and what is not; and ease the updates to either.

Related

How to run migrations in a forked django app?

I know it sounds like a dumb question and I myself felt terribly bad when I faced this unforgivable lack of knowledge about a framework that I use basically every day...but so it is!
I had the necessity of forking a django package to add some fields to some of its models. Everything fine, I forked the project on github, cloned locally and then realized that: any django package does not include a common django setup so how am I supposed to run the migrations I need in order to complete my changes and push back to the repo the new version of the app?
I thought of course of starting another django project and cloning the fork as an app but doesn't that feel a bit over the top for a process like this? What would be the correct way of doing this?
Your app ships without any project environment, but in development you need a project environment. Be it for making migrations, running tests, running the server or running checks.
Creating a django project is the way to go. Unless you decide to write migrations yourself and discard tests.
I guess django apps repositories to not provide a django project environment because it's up to the developer to configure it.

Can we install django application without source code?

I have a requirement where I need to develop a Point of Sale system.
I want to know if it is possible to install that small point of sale app
on some machine without source code ?
Thanks for all suggestions.
I just thought I'd mention this for anybody that finds this question useful in the future.
There was a discussion about turning a Django webapp into a local app here:
https://groups.google.com/forum/#!topic/django-users/-VGqvHew35g
They provide some interesting solutions for converting the webapp into a local/desktop app.
Django is a web framework. There's no need to install any code on a client machine, since you would access it via a web browser.

Modifying existing Django site

I am completely new to this Django world. I haven't tried it ever before.
Now the problem is as below;
One of my clients was hosting his site somewhere else that I don't know and they built the site using Django. The host company doesn't allow to make any changes on their server, instead they provided the zip file for all the files in the site to me; so that now I can host my client's site.
As I don't know anything about Django, can someone please shed a light where I should start from?
Thanks in advance.
Cheers.
Sach
First of all, install Django on the development machine. Start by trying to get the development server run on your machine.
Gather requirements: check the settings.py for installed apps against the default Django settings.py file. See if there are any popular django apps that site depends on. If there are any, then you probably will have to install them, too.
In which format was the database provided? Will you move to another more appropriate format? Python bindings for databases are required too.
Considering the fact that you have inherited this project and probably will need to make some changes, consider installing django-south, so you can easily make changes to the database schema.
If you get the site running properly on your own machine, consider deplyoment. Is there a lot of static content? (if so, consider nginx). Set up apache2 and install the mod_wsgi module. Deploy.
Work your way through the Django tutorial first. Then look into Django Book as has been mentioned. Django IRC channel (#django) on Freenode is also great for help.
Your best bet would be to learn about Django before trying to jump in head first - https://www.djangoproject.com/ contains documentation as well as tutorials on creating Django apps.
Django is fairly easy to setup if you already have the code written. You'll need to install the chosen database and then simply follow the tutorial on the Django website
Django comes with a built-in server so it's very easy to run the website for development without needing Apache, nginx or much else.
I learned using the Django Book. Django is an easy-to-use framework, you should be fine.
Also, in the short-term there's a file called views.py and separate folder containing templates. If you're familiar with MVC (MVT in Django) this contains the views for the site in function form. There's probably (but not always) a folder for templates which contains a lot of the HTML for the site. Just a good starting pointing for basic modifications.
You can perhaps start here. https://docs.djangoproject.com/en/dev/howto/deployment/
First, find out the django version required by your client. Install that on a server (not a production one), setup apache and mod_wsgi. The zip files may go to a dir which can be included in the mod_wsgi configuration.
Find about the static files and setup apache or any other lightweight webserver to server it.
You may not be a developer, but have a try with the django book. It can give you a good idea how its structured.

What steps do I take to integrate an (outdated) but working django application into my project?

I would like to integrate an existing application someone has on github into my site. What steps do I need to take to integrate it?
Would most people just download this entire thing and throw it inside of the project root, add it to the INSTALLED_APPS and modify urls.py? I would imagine there are some extra steps I'd have to take to get it to work.
In addition, since it was written in Jan 09-esque, and I'm using the latest 1.2 release I would probably have to modify and add some form csrf checking?
There are no generic instructions for integrating existing application into your django project because every application is different.
Generally most of the popular apps provide README/INSTALL docs which guides you through installation and How to use app. An app without documentation & tests is risky to use unless you are ready to own it and take pain of going through source code and figuring it out.
Also I don't think the application you posted above can be integrated into your project without modifying the code. It's a project by itself and can be used in standalone mode. (Well that's what I think after looking at source code)

Creating a redistributable django app

In Java world, a common way to distribute a web app is to package it along with Apache Tomcat.
What is the appropriate way to achieve something like that with Django (or any WSGI application for that matter)?
There are two camps for distributing apps in django. It also depends on what you mean by apps.
If you mean an apps is in django terms as in 'pluggable apps' that is separated from the project, then it would be best to use setuptools to package those 'pluggable apps'. Many django 'pluggable apps' are distributed like this. For example:
django-tagging
django-registration
etc.
But if you mean an apps is a full-blown apps (the whole war file) as in Java EE terms, then you would have all off your apps inside a your project, and you would just distribute the project in any forms. Normally you would just zip it. You don't need to install it with setuptools or what so ever, as you would run your project from the project folder. Examples in this camps are:
Pinax
Satchmo
The first way is convenient if you already have django project running and you want to re-use those pluggable apps in many other projects. This is really good if you are building non-monolithic web application or an in-house application/websites or a reusable application . It's also convenient if you are managing your project and those pluggable apps by yourself. It's sort of inconvenient (to some extent) if you want to sell an apps to a customer with this kind of approach because your project and your pluggable apps lives in a different directories. Some people said that they don't have any issues with this approach.
The second way would be more convenient if you are selling your apps to a client because all of the apps is inside your project and you would only extract your project when you are at the client side. This style is more often called the monolithic style. Java EE and Ruby on Rails have a monolithic deployment style. You wouldn't need to install your 'pluggable apps' one by one (assuming you don't use any external pluggable apps in your project) when you are at the client side. But again, you would have some issues if you want to reuse those small apps inside the projects. If you don't have any plan to re-use those small apps, then this way is good enough.
setuptools is a common way to distribute any Python packages, Django apps included, and many of the more substantial Django apps (Pinax comes to mind) will either distribute through the cheeseshop or as tarballs or zips with setuptools-produced setup.py files.
Less substantial reusable apps will just distribute as compressed files, which works fine as they should be highly portable.
A django app is not much different from a python module, which you can package using python's setuptools.