Skip to main content

a Django app to inject adsense ad code inside ckeditor body.

Project description

django_adsense_injector

django_adsense_injector is a Django app to inject adsense ad code inside ckeditor body. easy to intergrate and and show ads to the users.

Detailed documentation is in the "www.instandblog.xyz" website.

Quick start

  1. Add "polls" to your INSTALLED_APPS setting like this::

    INSTALLED_APPS = [
        ...
        'django_adsense_injector',
    ]
    
  2. Add this line under templates settings in settings.py

    TEMPLATES = [
        {
            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [os.path.join(BASE_DIR,'templates')],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                    'django.template.context_processors.debug',
                    'django.template.context_processors.request',
                    'django.contrib.auth.context_processors.auth',
                    'django.contrib.messages.context_processors.messages',
    
                    'social_django.context_processors.backends',
                ],
                'libraries':{
                    'adsense_tags': 'django_adsense_injector.templatetags.adsense_tags' #<---------
                }
            },
        },
    ]
    
  3. Include the template tags load tag like this inside the template::

    {% load adsense_tags %}
    
  4. Filter your ckeditor body field like below to inject your adsense code::

    {{post.body|inject_adsense_after_paragraph:"your_template_directory/your_html_file_name.html"|safe}}
    
  5. create your_html_file_name.html file inside the template directory and paste your adsense code.

  6. Start the development server http://127.0.0.1:8000/

  7. Visit http://127.0.0.1:8000/your-post-url/ to see the outputs(you can't view adsense ad in the development time, but if you inspect the page you can see the injected code).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_adsense_injector-0.2.1.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file django_adsense_injector-0.2.1.tar.gz.

File metadata

  • Download URL: django_adsense_injector-0.2.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for django_adsense_injector-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e05e4f3ecf3a0c925f46e2af7a40f30b55e8806888e15b949457d637f4802881
MD5 d00b46b83d5940bfb126b643983b12cc
BLAKE2b-256 2ae4a61f9b201198ef0d49f56695fa9f887d37cd00db6c5f5d8180d69f218740

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page