Cannot you tell me, where and in what order does DjangoCMS search for plugins?
I know that I should add them to INSTALLED_APPS, but what DjangoCMS does with them next?
django CMS searches all cms_plugins.py files in your INSTALLED_APPS. It loads them, thus triggering all plugin_pool.register_plugin calls.
The relevant code is in https://github.com/divio/django-cms/blob/cb836a668b9e53a642a35b768bf60bda39ac03fa/cms/plugin_pool.py#L33 which triggers https://github.com/divio/django-cms/blob/cb836a668b9e53a642a35b768bf60bda39ac03fa/cms/utils/django_load.py#L48
While that is the preferred way of declaring plugins, note that modules imported by Django on startup can also cause plugins to be registered. Should you call plugin_pool.register_plugin in a models.py in an INSTALLED_APP it would also register that plugin, as the models.py file is automatically loaded by Django on startup.
Just like you mentioned INSTALLED_APPS and url configuration and other settings. There is an explanation for how the plugins works in this page plugins.html
Related
django-cms is a django project itself. So there must be a file called settings.py
But I couldn't find it, where it is? how is database connection taking place?
The settings.py file is created when you create your django project (the one that will host the django-cms application). Since django-cms is a django app (similar to django-tables2, django-filters etc) it does not provide a settings.py but will just use the one your project already has.
For more info check out the how to install: https://github.com/divio/django-cms/blob/ddd39215286971ca14f2608510d3e0ba5f4e0772/docs/how_to/install.rst#create-a-new-project - the same guide lists a bunch of required settings for django-cms installation.
I am trying to install disqus on my django project. I have followed these instructions:
First, add disqus to your INSTALLED_APPS. You don’t need to run syncdb as there are no models provided.
Next, add DISQUS_API_KEY and DISQUS_WEBSITE_SHORTNAME to your settings. You can get your API key here (you must be logged in on the DISQUS website). To see the shortname of your website, navigate to Settings->General on the DISQUS website.
Finally, you need to change the domain of your Site to the domain you’re actually going to use for your website. The easiest way to do this is to enable django.contrib.admin and just click on the Site object to modify it. If you don’t have contrib.admin installed (or don’t want to install it), you can run python manage.py shell and change the value in the cli:
I am trying to do the last part, the one which starts with the word Finally...
The easiest way to do this is to enable django.contrib.admin and just click on the Site object to modify it.
For this part, i already have django.contrib.admin under my INSTALLED_APPS, but what i dont understand is where is this Site object I am supposed to click. Because of this i tried to use the python manage.py shell approach. The instructions are as follows:
from django.contrib.sites.models import Site
Site.objects.all()
s = Site.objects.all()[0]
s.domain = 'arthurkoziel.com'
s.name = 'arthurkoziel.com'
s.save()
Site.objects.all()
Now the problem is when i type from django.contrib.sites.models import Site, i get the following error message:
Model class django.contrib.sites.models.Site doesn't declare an
explicit app_label and either isn't in an application in
INSTALLED_APPS or else was imported before its application was loaded.
Can anyone who understands the installation process help me out to interpret.
You need to ensure that 'django.contrib.sites' is in your INSTALLED_APPS setting. After this, the above error should go away, and you should also have a "Sites" section in your Django admin.
I am just curious, Is it okay to remove some of the default Installed Apps in DJango Settings? See image below.
These apps creates a new tables in my database and I don't know when can I use those tables.
Thank you!
You can, though if you're unsure the purpose of the app it would be best to leave it included.
In fact, the Django documentation mentions this in the very first tutorial:
Like we said above, the default applications are included for the common case, but not everybody needs them. If you don’t need any or all of them, feel free to comment-out or delete the appropriate line(s) from INSTALLED_APPS before running migrate. The migrate command will only run migrations for apps in INSTALLED_APPS.
https://docs.djangoproject.com/en/1.8/intro/tutorial01/
I have tried searching around for this, but searches including "django", "app", and "namespace" all bring up topics mostly relating to URLConf, not what I want to know.
In Django settings, apps included in a project are listed in the INSTALLED_APPS setting. Most community-released apps are not "namespaced" in that the app name consists of only letters, numbers, and underscores. There are official apps like "django.contrib.sites" that are "namespaced" with dot-syntax. What I cannot seem to find is: how do I do this? For example, if I want to create an app like "mycompany.app". The startapp command of manage.py does not allow naming like this if I try ./manage.py "mycompany.app", complaining of invalid characters.
So what Python and/or Django magic am I missing to create and use apps in this way? Or is there some reason why doing this is discouraged, and I should only make apps like "mycompany_app"?
Create a python package mycompany (i.e. folder with init.py file inside), inside create package app.
There is also namespace term in django urls, can be noticed in calls like reverse('namespace:view-name'), here is the doc for these: https://docs.djangoproject.com/en/1.7/topics/http/urls/#url-namespaces
What does this actually do? I recently branched out my project from 1 app into 6 different apps and forgot to update the INSTALLED_APPS part of my settings file. Everything still works even though I didn't list the new apps in. Is that supposed to happen? Do I need to include all my apps in INSTALLED_APPS?
yes.
INSTALLED_APPS helps django to sync the database, run tests, get the urls to work and more related issues.
Maybe your installed apps still works because the main one calls the others with imports, a django app is nothing more that a simple python module that is imported when called in the settings file, that's why you get a invalid syntax error after you run the development server because an import won't work with invalid syntax.