Django can't load ckeditor in the admin page - django

This is my settings.py file
INSTALLED_APPS = [
'search.apps.SearchConfig',
'user.apps.UserConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django_node_assets',
'ckeditor',
'ckeditor_uploader',
]
CKEDITOR_BASEPATH = "./search/static/ckeditor/ckeditor/"
CKEDITOR_UPLOAD_PATH = "/media/"
This is the models.py file
from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField
class Content(models.Model):
heading = models.ForeignKey(SubTopics, on_delete=models.CASCADE)
content = RichTextField()
def __str__(self):
return self.heading.heading
This rich text editor is not showing on the admin page. Even no text field is shown on the page, just blank space.
I got the solution.
remove CKEDITOR_BASEPATH and it will work

you need to collect the static files. Use the command below in the terminal
python manage.py collectstatic

Related

AUTH_USER_MODEL reference in settings.py Django

I have a installed an app called 'Login', who have a folder 'models' inside, with a custom_user model. The problem occurs when I tried to configure settings.py, specially auth_user_model.
in installed apps I have the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'project_app.login'
]
and below
AUTH_USER_MODEL = 'login.models.CustomUser'
But I have the following error: "Invalid model reference. String model references must be of the form 'app_label.ModelName'." I put the .models in AUTH_USER_MODEL, because I want to reference the app that the CustomUser is inside the folder "models" in Login.
Also, I tried with declare like this:
AUTH_USER_MODEL = 'login.CustomUser'
but the error is this: 'AUTH_USER_MODEL refers to model 'login.CustomUser' that has not been installed'
The issue is with the way that your app is installed - based on your AUTH_USER_MODEL, login should be the name of the app. It is acceptable to contain Django apps within folders for organisation purposes - however, your parent folder is project_app which from the name also appears to be an app. It's hard to say for certain what the issue is without knowing your project structure but I would expect changing your installed apps to just project_app and your AUTH_USER_MODEL to project_app.CustomerUser should work.
If your app name is "login", you can proceed as follows:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
#apps
'login.apps.LoginConfig']
I think the model in your login application is as follows:
class CustomUser(AbstractBaseUser):
#some fields for customuser
and in settings.py:
AUTH_USER_MODEL = 'user.CustomUser'
AUTH_USER_MODEL = 'app_name.ModelName'

ValueError - How to Extend OAuth2 Application Model - Django

I want extend Application model of django oauth toolkit. They have given intsructions here link
But i am not getting how to do it. I have created one app inside apps folder and inside models i have added the following code.
from django.db import models
from oauth2_provider.models import AbstractApplication
class MyApplication(AbstractApplication):
logo = models.ImageField()
agree = models.BooleanField()
Resgitered the app inside installed_apps as 'apps.oauth2', and added the following line:
OAUTH2_PROVIDER_APPLICATION_MODEL='apps.OAuth2'
But it giving me error
LookupError: No installed app with label 'apps'.
Installed Apps [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'apps.commons',
'apps.company',
'apps.oauth2',
]
According this manual link model in OAUTH2_PROVIDER_APPLICATION_MODEL should be class name not app

django oscar model customization : model change is not reflected while makemigrations

I am trying to customize Products and few other models in the catalogue app following the documentation.
I have forked catalogue app (to myproject/boscar/catalogue) as per documentation documentation and my updated boscar/catalogue/models.py:
from django.db import models
from oscar.apps.catalogue.abstract_models import AbstractProduct
class Product(AbstractProduct):
is_active = models.BooleanField(default=False)
from oscar.apps.catalogue.models import *
I have already included the modified catalogue app, in the INSTALLED_APPS in settings.py as an argument for get_core_apps function.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'django.contrib.sites',
'django.contrib.flatpages',
'bmigrate',
'compressor',
'widget_tweaks',
'boscar'
] + get_core_apps(['boscar.catalogue'])
Migrations are automatically copied to my local app when I executed this command manage.py oscar_fork_app catalogue boscar.
My issue is when I execute the makemigrations command (python "manage.py makemigrations boscar"), it shows "No changes detected in app 'boscar'". But I already made a change to add is_active field in product table.
I believe you need to refer to the catalogue app when migrating:
python manage.py makemigrations catalogue

Django CMS 3.1.3, Python 3.4 and Django 1.8 CustomUser

I have found similar post but none of the answers helped me. I'm getting a "LookupError: Model 'email_user.EmailUser' not registered." when trying to run a makemigrations or migrate. Any help or suggestions would be greatly appreciated.
ProjectStructure
ProjectRoot/
- email_user/
-- __init__.py
-- admin.py
-- models.py
- djangocms/
-- static/
-- templates/
-- __init__.py
-- urls.py
- manage.py
- settings.py
- wsgi.py
settings.py
INSTALLED_APPS = (
'djangocms_admin_style',
'djangocms_text_ckeditor',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'email_user',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_flash',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'reversion',
'djangocms',
)
AUTH_USER_MODEL = "email_user.EmailUser"
email_user/admin.py
from django.contrib import admin
from email_user.models import EmailUser
admin.site.register(EmailUser)
email_user/models.py
class EmailUser(AbstractBaseUser, PermissionsMixin):
email = models.EmailField('email address', max_length=255, unique=True)
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
def get_short_name(self):
return self.email
def get_full_name(self):
return self.email
Ugh,
After hours of digging around I tracked down the problem. The Django CMS Installer will automatically setup the settings.py file for you and the INSTALLED_APPS area.
So for some reason some of the dependencies are not setup correctly and following the documentation will result in hours of banging your head on the table.
The Installed apps should look like this:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'djangocms_admin_style', # MOVED THIS HERE
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'email_user',
'djangocms_text_ckeditor', # MOVED THIS HERE
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_flash',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'reversion',
'securepal',
)
Hopefully this might save someone from having to track this down

Django Celery and Django Debug Toolbar confilcts

I have followed the celery documentation. yesterday i am able to update the Djcelery models in my Django admin. But today i am not able to update those models. I installed Django toolbar yesterday does it have any impact on functionality
Below is the Django admin screen shot with DDT included in settings.py
Below is the screenshot of Django admin without DDT included in setting.py
Installed Apps
INSTALLED_APPS = (
# django stuff
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# plugins
'precompressed', # https://github.com/jhmaddox/django-precompressed
'social.apps.django_app.default', # http://python-social-auth.readthedocs.org/en/latest/configuration/django.html
'rest_framework', # https://github.com/tomchristie/django-rest-framework
'djcelery', # https://github.com/celery/django-celery
'celery_admin', # https://github.com/mattcaldwell/django-celery-admin-ext
'taggit', # https://github.com/alex/django-taggit
'south', # http://south.readthedocs.org/en/latest/
'storages', # http://django-storages.readthedocs.org/en/latest/
'redactor', # https://github.com/douglasmiranda/django-wysiwyg-redactor
'haystack', # http://django-haystack.readthedocs.org/en/latest/toc.html
'boomers.apps.djangoratings', #https://github.com/dcramer/django-ratings
'crowdsourcing',
# apps
'apps',
'apps.billing.chase',
'apps.billing.paypal',
'apps.billing.amazon',
'apps.config',
'apps.users',
'apps.learn',
'apps.community',
'api.careerbuilder',
'apps.care',
'apps.go',
'apps.play',
'apps.plan',
'apps.uplus',
'apps.billing',
'apps.googleanalytics',
)
and i have appended this INSTALLED_APPS += ('debug_toolbar',)