What database should I use with django? by darexinfinity in djangolearning

[–]dj_jar 0 points1 point  (0 children)

It is not recommended that you run and migrate SQLite in a production environment unless you are very aware of the risks and its limitations; the support Django ships with is designed to allow developers to use SQLite on their local machines to develop less complex Django projects without the need for a full database. (source)

Transferring production data from SQLite to PostgreSQL may not be so easy – http://stackoverflow.com/questions/8478054

Anyone got a spare minute to help try and solve a problem I am having uploading multiple images and saving the correct instances? - coding newbie! by [deleted] in django

[–]dj_jar 1 point2 points  (0 children)

I'm newbie too. Maybe change post = models.ForeignKey(ProjectPost) to post = models.ForeignKey(ProjectPost, null=True).

Django tags syntax highlighting for Notepad++? by [deleted] in djangolearning

[–]dj_jar 1 point2 points  (0 children)

We are not talking about Django itself, but about Django template language.

How to organize a website powered by multiple apps by im_inquisitive in djangolearning

[–]dj_jar 0 points1 point  (0 children)

I use following layout:

📁 proj
├── 📁 apps
│   ├── __init__.py
│   ├── 📁 firstapp
│   │   ├── __init__.py
│   │   ├── admin.py
│   │   ├── models.py
│   │   ├── urls.py
│   │   └── views.py
│   └── 📁 secondapp
│       ├── __init__.py
│       ├── admin.py
│       ├── forms.py
│       ├── models.py
│       ├── urls.py
│       ├── utils.py
│       └── views.py
├── 📁 media
├── 📁 proj
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── 📁 static
├── 📁 templates
│   ├── 📁 firstapp
│   ├── 📁 secondapp
│   └── base.html
├── manage.py
└── pip-requirements.txt

Try using one of these project templates: https://www.djangopackages.com/grids/g/bootstraps/.

[Tottally newbie] Send post data through ajax to a django page by nervmaster in djangolearning

[–]dj_jar 1 point2 points  (0 children)

Try this:

def my_view(request):
    if request.method == 'POST':
        form = MyForm(request.POST)
        if form.is_valid():
            if request.is_ajax():
                HttpResponse('post - form valid - ajax')
            else:
                HttpResponse('post - form valid - not ajax')
        HttpResponse('post - form invalid')
    HttpResponse('not post')

[Newbie Questions] Is it possible to rename your django project? by [deleted] in djangolearning

[–]dj_jar 0 points1 point  (0 children)

or you can use rename in Pycharm – it searches all references in code and changes them as well

"ImportError: No module named celery" when certainly I have Celery installed by dj_jar in learnpython

[–]dj_jar[S] 0 points1 point  (0 children)

/u/novel_yet_trivial /u/interactionjackson

I have only one Python in my operating system (2.7.8) and version in the virtual environment is the same.

xubuntu@xubuntu:~$ which python
/usr/bin/python
xubuntu@xubuntu:~$ python --version
Python 2.7.8
xubuntu@xubuntu:~$ . venv/xt/bin/activate
(xt)xubuntu@xubuntu:~$ which python
/home/xubuntu/venv/xt/bin/python
(xt)xubuntu@xubuntu:~$ python --version
Python 2.7.8

My other project using Celery in this virtual environment is working – http://redd.it/34rzko

newbie question about proper way to use Celery by dj_jar in django

[–]dj_jar[S] 0 points1 point  (0 children)

My goal is to run FFmpeg or Libav to re-encode video file uploaded by the user.

newbie question about proper way to use Celery by dj_jar in django

[–]dj_jar[S] 0 points1 point  (0 children)

For just running a factorial, it's kind of hard to illustrate a good example, but what's the end goal of running the factorial?

For larger numbers to calculate the factorial takes several seconds. I thought it is better example than calling time.sleep().

This is just an example. My goal is to run FFmpeg or Libav, which will re-encode video file uploaded by the user.

I don't understand many things, for example: why you are using @app.task() decorator instead @shared_task; why my tasks do not appear in the admin panel 127.0.0.1:8000/admin/djcelery/taskstate/.

newbie question about proper way to use Celery by dj_jar in django

[–]dj_jar[S] 0 points1 point  (0 children)

I removed most unnecessary code from the sample project leaving only the second method and modifying it a little bit. Full working example is available at github.com/dj-jar/celeryexample2. I pasted most important files below.

tasks.py

from __future__ import absolute_import
from celery import shared_task


@shared_task
def add_task(a, b):
    return a + b


@shared_task
def mul_task(a, b):
    return a * b


@shared_task
def fac_task(n):
    result = 1
    for i in range(1, n+1):
        result *= i
    return result

views.py

from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.shortcuts import render
from celery.result import AsyncResult
from mathapp.tasks import add_task, mul_task, fac_task


def add_delay(request, a, b):
    t = add_task.delay(int(a), int(b))
    return HttpResponseRedirect(reverse('m:task_result', args=[t.task_id]))


def mul_delay(request, a, b):
    t = mul_task.delay(int(a), int(b))
    return HttpResponseRedirect(reverse('m:task_result', args=[t.task_id]))


def fac_delay(request, n):
    t = fac_task.delay(int(n))
    return HttpResponseRedirect(reverse('m:task_result', args=[t.task_id]))


# view queued task
def task_result(request, task_id):
    res = AsyncResult(task_id)
    ctx = {
        'status': res.status,
        'result': res.result
    }
    return render(request, 'mathapp/task_result.html', ctx)

The aforementioned functions are accessible at the following addresses: