Where is settings.py in django-cms? - python

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.

Related

Copy Django App to a New Project but Model Data is Lost

I made a development django project on my pc, and I added a bunch of data for one of the apps "things" by logging in the ADMIN panel. When I copy and paste this app folder into a new project on Ubuntu, add this app in setting, then I find all the data in the model is gone. I used "makemigrations, migrate". Still nothing. What should I do to have those data in this new project?
Based on the comments it seems that some kind of a solution has already been found. Here I'd like to give my 2 cents.
Django offers command line tools for exporting and importing data. With
python manage.py dumpdata app_label > backup.json
you can export all the data for the app app_label and save it into a file backup.json.
Later you can use this file to load the data:
python manage.py loaddata backup.json
There are many other options, please check the official documentation for further info, like for example using XML instead of JSON and much more.
EDIT:
If you search for dumpdata in the questions tagged with django here at SO, you'll get many hundreds results.

Is it possible to change the 'migrations' folder's location outside of the Django project?

what i'm trying to do is to change the default path for migrations for a specific application in a django project to put it outside the project itself but keeping it transparent, keeping use of makemigrations and migrate.
Is it possible? if yes, how?
Django has a MIGRATION_MODULES setting. It allows you to specify a different module for migrations per app. The module can be outside of the Django project, it just needs to be on your python path.
MIGRATION_MODULES = {'myapp': 'othermodule.db_migrations'}

Installing django-userena: userena.compat.SiteProfileNotAvailable when trying to create accounts app

Running Django 1.9 I'm trying to follow the install instructions for django-userena, to add it to an existing django project.
When I try to create the Accounts app:
python manage.py startapp accounts
I get this error:
userena.compat.SiteProfileNotAvailable
Other questions indicate that I need to set AUTH_PROFILE_MODULE, as directed in the installation instructions. However, these assume I already have an Accounts app created, within which I've created a Profile model.
So I seem like I'm stuck in a circular dependancy where I can't create the Accounts app without a Profile model, but I can't create the Profile model without the Accounts app!
Also, from the instructions, it doesn't appear the AUTH_PROFILE_MODULE should be required yet at this step, in order to create the Accounts app.
How do I solve this?
Make sure to that userena and the other apps are not yet installed, since
manage.py startapp accounts is the first step in the installation instructions.

DjangoCMS: where does it search for plugins?

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

Pydev error while creating new django project

I keep getting this error every time i create a new django project using titanium (eclipse) with pydev.
Actually, it did create the file settings.py
I wonder what make this error and how to fix it?
It's really a PyDev issue with Django 1.4. A new release (2.5.0) will be done later this week properly supporting the layout changes in Django 1.4.
You can still use the project created this way, but you have to do some manual things:
Move the contents inside of the folder that was created to your module (this was the structural change done in django 1.4)
The settings.py won't have the details you entered in the wizard (i.e.: manually edit the settings.py)
In the project django's properties (right click project > properties and check the django properties page), you have to put the proper settings to the settings module and manage.py.
I updated my pydev today to the last version and now it seems to be working beautifully...

Categories