Django directory plugin - python

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.

Related

Referencing multiple Django projects from a single monorepo

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.

What do I need to know to make a basic Django website?

As the title states, I am curious what I need to know to make a website with Django.
My Attempts:
I am familiar with Python, but despite my attempts to begin work on a webpage(attempted some Django tutorials online and purchased "2 Scoops of Django" and started to work with some of its recommendations) I always feel like it points me at something else to learn. (PostgreSQL, git, virtualenv, VirtualBox, Vagrant, and more.) I understand that some of these are tools I just need to implement, but I feel as if I could delve into these much further and don't understand when I should stop trying to learn more about these.
My Goal:
I want to be able to develop a webpage with Django, and understand the steps and tools I am implementing.
My Question:
What tools do I need to learn, and how much about them do I need to learn to be able to begin working effectively with Django?
This is a very broad question but I can try to answer it as clearly as possible.
You said you are familiar with Python, that's a good thing. The next thing you should know is the MVC framework that Django is based on and uses extensively.
You can refer to Django tutorial here: https://docs.djangoproject.com/en/1.9/intro/tutorial01/ (as already mentioned)
I can give you a TLDR of how this can work:
1. Create a django project : $ django-admin startproject mysite
2. In the file structure that is created, the most important things would be:
a. models.py - your database models or schema defined as classes and objects
b. views.py - the view you are trying to display (mainly rendering .html in your case)
c. settings.py - you path, app setting, permissions, etc
d. urls.py - how you will be calling your specific views (redirect urls)
Once you write a basic app, try to run it using $python manage.py runserver and voila!
For the website part, there a few easy ways. You can download twitter bootstrap and try to attempt a simple page that you can find online with django http://getbootstrap.com/2.3.2/
As far as technologies go:
venv: is so that you do not mess up your other python, etc versions on your laptop, it isn't necessary
git: this is something you should learn irrespective of a project requirement. There are basic 3 commands that will be enough.
You might have to learn basics of HTML and CSS for manipulating your own website. Most of the backend can be handled on Django using objects of models you created.
Try these things out and let me know if you need anymore information.

Want to run a python script on a django application

I'm working on a project that takes a web url and prints a summary of the text contents of the web page. I've written a program that does that in python and now I want to make it a web application so I decided to try django.
I've been reading the official tutorial(I'm not done, I've only gotten up to Models) but when I try to apply what I've learned and actually make the application I find myself lost.
"Where do I actually put the python code that will run on the backend?" I'm not using a database so I don't think it should be in the models.py file. Do I import it in views.py? Should I even be using django? I'm beginning to feel like it's overkill.
As you probably have seen in the tutorial, a Django project usually have several apps. Each app typically has models.py, views.py, admin.py, etc. Where to store the script depends on your project structure:
if only one app needs it, just put the script under the app
if there're several apps need the script, I mostly like will start an app called "common" or "utils", and put it there
if the script is used in multiple projects, and updated actively, I will consider make it a standalone Python package. And install it in the project's virtualenv
And where to import the script, also depends:
if the app is not complicated, no other dependency, views.py is the place to go
if the app is quite complicated that you even need to separate them into multiple views, I may create a common.py under the app to import the script
About Django or not, it depends our your (potential) project complexity:
if you project may grow big or you will use Python to write big web project, Django is worth to learn, as it's the most powerful web framework in Python
if you only need a simple web application that even doesn't need DB, Flask is simpler to learn, as Paulo said

Auction site with Django

If one is to build an online auction site using Django, then would it be a good idea to modify an existing CMS? If so, could someone suggest a CMS for the scaffolding?
Thanks
You could starting building with django-cms which is a great CMS that is very much aimed at extensibility. It has a plugin architecture which allows you to integrate your existing (or third party) apps.
If you are making an auction site though, it mightn't so much be a CMS you are after as much as a app-platform for builing off. So i'd recommend that you have a look at pinax which is a project that allows you to start your own project with a lot of the common requirements of web apps already satisfied (like profiles, email auth, social authentication, commenting etc.)
I suggest Pinax instead of customizing an existing CMS according to your needs.If you want more choices then there's also a project called Satchless

Where can I download a sample Django template?

I just started working at a place as a front end developer where I need to build Django templates. I never worked with these before, does anyone know where I can download a sample template so I can look through the code structure?
I won't be doing any application development using the Django framework, only taking the variables the developer gives me and incorporating the in the html/css templates I build.
There are lots of Open Source django apps that you could look at for inspiration. One example is Zinnia which is a blogging application - there are dozens of templates in this project, see this directory. There are many other open source django projects on http://github.com and http://bitbucket.org
You should also take a look at the official template documentation, there are lots of snippets there that are very useful.
Here's a nice little tutorial.
http://www.webmonkey.com/2010/02/use_templates_in_django/
Also, Check out the Django Docs.
http://docs.djangoproject.com/en/1.3/ref/templates/builtins/

Categories