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.
Related
I have an old project running (Django 1.6.5, Python 2.7) live for several years. I have to make some changes and have set up a working development environment with all the right django and python requirements (packages, versions, etc.)
Everything is running fine, except when I am trying to make changes inside the admin panel. I can log on fine and looking at the database (sqlite3) I see my user has superuser privileges. However django says "You have no permissions to change anything" and thus not even displaying any of the models registered for the admin interface.
I am using the same database that is running on the live server. There I have no issues at all (Live server also running in development mode with DEBUG=True has no issues) -> I can only see the history (My Change Log) - Nothing else
I have also created a new superuser - but same problem here.
I'd appreciate any pointers (Maybe how to debug this?)
Finally, I found the issue:
admin.autodiscover()
was commented out in the project's urls.py for some reason. (I may have done that trying to get the project to work in a more recent version of django) - So admin.site.register was never called and the app_dict never filled. index.html template of django.contrib.admin then returns
You don't have permission to edit anything.
or it's equivalent translation (which I find confusing, given that the permissions are correct, only no models were added to the admin dictionary.
I hope this may help anyone running into a similar problem
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.
I'd like to get rid of this warning the "right" way, by ensuring I'm ready to update to Django 1.9 when it arrives.
The deprecation warning I get is the following:
/Users/.../south/modelsinspector.py:20: RemovedInDjango19Warning: django.contrib.contenttypes.generic is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contrib.contenttypes.
from django.contrib.contenttypes import generic
I've done a complete search of my project for the phrase django.contrib.contenttypes, and the only place I can find it is in INSTALLED_APPS.
However, when I remove it from INSTALLED_APPS (not sure that I really should be doing that!), I get yet a different DeprecationWarning:
/Users/.../django/contrib/contenttypes/models.py:159: RemovedInDjango19Warning: Model class django.contrib.contenttypes.models.ContentType 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. This will no longer be supported in Django 1.9.
class ContentType(models.Model):
What is the right thing for me to do?
It looks like the message is telling you that the problem is coming from the app South, not your code base.
Usually, the correct way to prevent the deprecation error would be to upgrade the app to a version that has fixed the problem. Sometimes, that might not be possible if a new version hasn't been released yet.
However, in this case, I don't know why you have South installed at all. For Django 1.7+, you should be using Django's built in migrations. Have you tried removing 'south' from your installed apps?
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
I'm trying to use django-ios-notifications to server PUSH notifications via APNS (https://github.com/stephenmuss/django-ios-notifications). I've never used Django before. I've followed the instructions on the modules github page, but have'nt been able to get it working. I've done the following;
*installed required package and django
*added 'ios_notifications', to my INSTALLED_APPS settings file
*synced my local MySQL server with django (a load of new tables were created, for both django and django-ios-notifications, so it appears to be installed correctly, which I was thrilled about)
*start django server
However when I go to the modules config page (URL below) I just see the default 'It worked!
Congratulations on your first Django-powered page.' holding page, not the admin page I expected. (the tutorial on the github page descried a form)
http://127.0.0.1:8000/admin/ios_notifications/apnservice/add/
I guess I need to configure something in djange, I read over the first few pages on the django tutorial but I couldn't see any mention of using installed modules. I'm sure this is a very simple problem to solve, so if anyone could point me in the right direction that would be fantastic.
https://github.com/stephenmuss/django-ios-notifications
You don't seem to have activated Django's admin interface, which you need to access the admin forms. There are concise instructions in the documentation. You can switch to a different version of Django in the lower right corner, if you aren't using 1.5.