Hi I'm reading the docs for using django-newsletter.
And it says to call the following admin command to actually send the emails:
./manage.py runjob submit
In other parts of the docs it says runjobs instead of runjob.
Anyways, I'm not seeing either runjob or runjobs in the list of commands ./manage.py help, even though the 'newsletter' app is in installed_apps and I can access it in the admin.
What am I missing?
I was missing django_extensions in INSTALLED_APPS. The actual requirements for django-newsletter in INSTALLED_APPS are:
INSTALLED_APPS = (
...
'sorl.thumbnail',
'django_extensions',
'newsletter',
...
)
Related
Hi I'm having an issue with restframework_simplejwt library.
When I add blacklisting to installed apps ir returns me an error.
settings.py file:
INSTALLED_APPS = [
...
'rest_framework_simplejwt.token_blacklist',
...
]
error:
django.db.utils.ProgrammingError: relation "token_blacklist_outstandingtoken" does not exist
LINE 1: INSERT INTO "token_blacklist_outstandingtoken" ("user_id", "...
I realized that after adding the app to INSTALLED_APPS I didn't migrate the changes .
python manage.py migrate and problem solved.
Simple JWT docs gives us the necesary steps for this action.
I am following this video tutorial to learn Django: https://www.youtube.com/watch?v=F5mRW0jo-U4&t=909s
I am at the "Your first app component" section where he creates an app and then migrates it. I have followed every one of his steps so far yet I keep getting the no changes detected error when I migrate the app
I have tried researching ways to fix this but it doesn't seem like there is any one right way to do it, it's more of a case by case basis. I've made sure my app is under the install_apps section in the settings. I've tried python manage.py makemigrations but that tells me there are no changes detected. I've tried "python manage.py makemigrations product" to be more specific but it tells me that App 'product' could not be found. Is it in INSTALLED_APPS?" even though it is in installed apps
currently this is my installed apps section:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'product',
after migrate and makemigrations command put your app name
like this
python manage.py migrate product
python manage.py makemigrations product
my case it's working
You didn't add your app name in 'Installed_Apps' in settings.py. Add this first and then run again.
for a proper migrations with 'python manage.py makemigrations' make sure that after creating your model class you save them before you typing any console code very important
I first ran
python manage.py syncdb
and it created the database and tables for me, then I tried to add more apps, and here's what I did:
create apps by
python manage.py startapp newapp
Then I added 'newapp' to INSTALLED_APPS in setting.py:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'newapp',
)
At last I ran syncdb:
python manage.py syncdb
and here's the result I get:
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
I checked my db and there is no table named newapp, no table's name including newapp.
I also ran into this issue, and was able to get around it by removing the migrations folder inside my app. Somehow that had already gotten created and was tricking syncdb into thinking that it was fully migrated already, but those migration scripts didn't actually do anything useful. Obviously don't try this if you actually have migrations you want to save, but I was working with a brand new app and models.
If you run:
python manage.py inspectdb > somefile.txt
You can get quickly check out if your database structure is matching your django models.
I tried most of the ideas above:
making sure the models.py is imported (verified that the module executed during a makemigrate),
deleting the migrations folder
setting managed = True (this is default anyways),
used the python manage.py inspectdb (which correctly dumped the table, if I had created it manually).
The key was simply to run a makemigrations on the app separately:
python manage.py makemigrations <app_name>
as part of performing the makemigrations step. Then you do
python manage.py migrate
afterwards as usual.
(applies to Django 1.10, using Postgres 9.5).
Django documentation
Credit, related post
i got same problem, but i didn't have any "migration" folder. I solved it like below.
I just added app_label with the model code,
class MyModel(models.Model):
...
class Meta:
managed = True # add this
app_label = 'myapp' # & this
Also, make sure it is discoverable by referencing it in myapp/models/__init__.py
from model_file.py import MyModel
You should be using this command
python manage.py migrate
where you were runing syncdb from the location where manage.py resides
I was having the same problem and noticed that it had created a db.sqlite3 file that didn't seem empty:
$ ls -l
-rw-r--r-- 1 sauron staff 122880 Jul 31 01:22 db.sqlite3
I tried running sqlite again using the filename as an argument and that worked:
$ sqlite3 db.sqlite3
SQLite version 3.7.13 2012-07-17 17:46:21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE "auth_group" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(80) NOT NULL UNIQUE
);
... many rows ...
I'm hoping to use a newer Django (1.7.dev) inside PyCharm 2.7.3... so it's the only Django version installed in my project's virtualenv.
But, the "Tools" -> "Run manage.py task" list isn't discovering the new commands included in Django itself, like migrate or makemigrations. (Based on prior experience with apps like South, I'd hoped all available tasks would be auto-discovered.)
Is there a way to help PyCharm 2.7.3 discover and use these new options?
the "Tools" -> "Run manage.py task" doesn't see the makemigration or migrate argument.
You can run manage.py with right click on manage.py file in you project.
with this output:
*
*Usage: manage.py subcommand [options] [args]
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
--settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Raise on exception
--no-color Don't colorize the command output.
--version show program's version number and exit
-h, --help show this help message and exit
Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[auth]
changepassword
createsuperuser
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runfcgi
shell
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlinitialdata
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
syncdb
test
testserver
validate
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver*
*
As you can see "makemigrations" and "migrate" are in the available subcommands for django
So you have to "Run" - > "Edit Configurations" and add "makemigrations" or "migrate" in the script parameters
Now run the script and it works
This is most likely because of how you have added apps in your INSTALLED_APPS tuple. So if it's something like this:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Third Party apps -------------------------------------->
'south',
'django_extensions',
'dajaxice',
'dajax',
# My apps ----------------------------------------------->
'blog',
)
Then there should be no problem, and you should be able to find the commands you're looking for, if not, then you have a bug. However, if you have arranged things to be like so:
DJANGO_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles')
THIRD_PARTY_APPS = (
'south',
'django_extensions',
'dajaxice',
'dajax',
)
MY_APPS = ('blog', )
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + MY_APPS
Then you have a problem, with 2.7 since PyCharm cannot understand this. So, my suggestion is that you make the tuple the way I showed you to begin with.
I am unable to get django-grappelli working.
Below is what I did -
Installed using pip install django-grappelli.
Added 'grappelli' in INSTALLED_APPS before the 'django.contrib.admin' .
In urls.py, added URL definition url(r'^grappelli/', include('grappelli.urls')), before admin url, ie. url(r'^admin/', include(admin.site.urls))
Executed syncdb and collectstatic commands.
Now when I run command runserver, and browse localhost:8000/admin/, surprisingly I am getting the default admin.
I checked the request traffic in Google Chrome Network tab (in Developers Tool), and I don't see any request for url starting with Grappelli.
I don't know what I am doing wrong. I am using Django 1.4.1-final in virtualenv on Windows 7 machine.
I found the issue. Actually I had previously overridden the Admin Templates for branding my admin login and top page headers. So, in my template dir, there is admin dir with some custom templates (which I copied from django/contrib/admin/templates and edited as per my requirement). Due to this, Grappelli was not showing any of my changes...
I got the hint from here - https://stackoverflow.com/a/12193858/1284552
When I removed it, it worked as expected.
Also, I just need to visit the admin path, not the grappelli path as defined in Urls.py.
Resolved this issue after adding 'grappelli' at the top of 'django.contrib.admin'.
Adding to Lucian's answer, the documentation itself says,
Insert 'grappelli' at the top of 'django.contrib.admin'.
So INSTALLED_APPS will be,
INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
)
Taken from : http://django-grappelli.readthedocs.org/en/latest/quickstart.html
I had the same thing, I changed the order of the rows and all earned
'grappelli',
'django.contrib.admin',
make sure that the string 'django.contrib.admin' written 1 times