CREATING PROJECT django-admin startproject projectname eg:django-admin startproject myproject cd myproject myproject/ manage.py myproject/ init.py settings.py urls.py wsgi.py settings.py DEBUG = True for sqlite3 DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.sqlite3’, ‘NAME’: os.path.join(BASE_DIR, ‘db.sqlite3’), } } for mysql DATABASES = { ‘default’: { ‘ENGINE’: ‘django.db.backends.mysql’, ‘NAME’: ‘databasename’, ‘USER’: ‘root’, ‘PASSWORD’: ”, ‘HOST’: ‘localhost’, ‘PORT’: ”, }… Continue reading DJANGO FRAMEWORK BASICS
Tag: Django
Python code to insert CSV data fields to a local Database table using Django
We can use this code to insert the data in a CSV file to a local database table. Just change the table name, database name, and data fields with your respective field name and others.
Cron job in django
SET UP installation: using the following command pip install django-crontab add it to installed apps in django settings.py: INSTALLED_APPS = ( ‘django_crontab’, … ) now create a new method that should be executed by cron every 5 minutes, f.e. in myapp/cron.py: now add this to your settings.py: CRONJOBS = (‘*/5 * * * *’, ‘myapp.cron.cron’)