These are chat archives for django/django

4th
Jul 2017
Michele Gatti
@mikeleg
Jul 04 2017 07:12
i need to schedulate a custom command inside a docker image there is any tips?
Joseph Christopher
@josephcs
Jul 04 2017 12:03
@mikeleg Have you tried https://github.com/efrecon/dockron?
Nishant Suman
@Nishant23
Jul 04 2017 12:56
@Dexter_Deter_twitter You are including your project urls.py. Instaed you have to include your app urls.py file. url(r'^$', include(app.urls)). You have create a urls.py in your app and then add urls for that app there.
Michele Gatti
@mikeleg
Jul 04 2017 14:21
@josephcs thanks i'll try it
smrati
@smrati
Jul 04 2017 14:55
In django rest framework , how we can implement pagination , my api respond with array of objects in json, how i can implement a count and offset based pagination?
Hassen ben tanfous
@HassenPy
Jul 04 2017 14:57
smrati
@smrati
Jul 04 2017 15:07
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
    ),
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 100
}
i added this to my settings.py , doesn't seem to be working
do i need to make some changes to my views.py , i am using function based views
smrati
@smrati
Jul 04 2017 15:22
@HassenPy thanks
Hassen ben tanfous
@HassenPy
Jul 04 2017 15:22
welcome :)
delirious44
@delirious44
Jul 04 2017 15:46
hey guys, how would I go about adding a like functionality to my app ?
one user can make infinite likes if he has time to theoretically in my app as it stands now .. because i dont check anything except the authentication
and the user is able to like
and just spam
how would I go about making the functionality that way that you like once, and its acknowledged that the post is liked and when you click the button again, it will be unliked
?
Anish Shrestha
@annshress
Jul 04 2017 16:59
post_user_liked flag may be.
Job Matheka
@jobm
Jul 04 2017 17:51

Hey guys,
I have deployed a django app to an ec2 instance running ubuntu and am using apache2 to load my site.
but for some reason my app wont find the templates, i get TemplateDoesNotExist exception.
here is my TEMPLATES in settings.py:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
            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',
            ],
        },
    },
]

my main urls:

urlpatterns = [
    # core application urls
    url(r'^', include('core.urls', namespace="core")),

    # user login n logout
    url(r'^accounts/login/$', django.contrib.auth.views.login, name="login"),
    url(r'^logout/$', django.contrib.auth.views.logout, {'next_page': '/'}, name='logout'),

    # admin
    url(r'^admin/', admin.site.urls),
]

and my app urls:

urlpatterns = [
    url(r'^$', IndexView.as_view(), name="index"),
    url(r'^save_data$', SaveDataToDBView.as_view(), name="save_data"),
    url(r'^export_data$', ExportDataView.as_view(), name="export_data"),
    url(r'^oauth-redirect$', OAuthView.as_view(), name="oauth_redirect"),
]

templates tree:

└── templates
    ├── base.html
    ├── core
    │   └── Index.html
    └── registration
        └── login.html

template_name = ‘core/index.html’ in my TemplateView.
What could be the problem.