Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Stop playing MIDI file on events
This is the script that I run from my Django App. It plays the .mdi file that the user uploads to the site. import pygame as pg def play_music(music_file): clock = pg.time.Clock() try: pg.mixer.music.load(music_file) print("Music file {} loaded!".format(music_file)) except pg.error: print("File {} not found! {}".format(music_file, pg.get_error())) return pg.mixer.music.play() # check if playback has finished while pg.mixer.music.get_busy(): clock.tick(30) def play(file): # pick a midi or MP3 music file you have in the working folder # or give full pathname # music_file = "/home/abhay/Desktop/moz2.mid" music_file = "/home/abhay/Desktop/Django/MusicApp/" + file #music_file = "Drumtrack.mp3" freq = 44100 # audio CD quality bitsize = -16 # unsigned 16 bit channels = 2 # 1 is mono, 2 is stereo buffer = 2048 # number of samples (experiment to get right sound) pg.mixer.init(freq, bitsize, channels, buffer) # optional volume 0 to 1.0 pg.mixer.music.set_volume(0.8) try: play_music(music_file) except KeyboardInterrupt: # if user hits Ctrl/C then exit # (works only in console mode) pg.mixer.music.fadeout(1000) pg.mixer.music.stop() raise SystemExit It exits only when the music is complete, or if I press Ctrl+C. But I need it to stop either by placing a button on the webpage, or a keyboard press event. It doesn't seem to be catching any events from what … -
Generating and storing unique ID using uuid in Django
In my project, I am trying to generate a unique user ID using python's uuid and then storing it in my mysql database.I am confused when I should generate the ID. This is my forms.py: from django import forms from django.contrib.auth.models import models from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm import uuid class RegistrationForm(UserCreationForm): email = models.EmailField(required=True) user_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) class meta: model = User fields = ( 'first_name', 'last_name', 'email', 'password1', 'password2' ) def save(self, commit=True): user = super(RegistrationForm, self).save(commit=False) user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] user.email = self.cleaned_data['email'] user.user_id = uuid.uuid4() if commit: user.save() return user This is the registration portion of my views.py def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): form.save return redirect('/account') else: form = RegistrationForm() args = {'form':form} return render(request, 'accounts/registration.html', args) -
Django: Annotate Max Multiple Queries
Here's my code, data1 = Data.objects.filter(...).annotate(Max('receiver')).order_by('-receiver__max') data2 = Data.objects.filter(...).annotate(Max('sender')).order_by('-sender__max') How can I combine these 2 queries in just one single Query? -
How can I deploy a django project in apache
How can I deploy a django project in apache, I am using Xampp and I have tried to configure the virtual host, the wsgi module and finally bitnami django and it does not work for me, urges me, if anyone has an idea of how I can make it work I am going to thank you, ahh I am Cuban, I do not have access to google and I can not download the module wsgi for apache, the one I have is pirate and I do not know if it works. Thank you -
graphite-manage + graphite warning
we installed graphite on our Linux server and after we installed the graphite and running it we saw the following warning from graphite-manage script graphite-manage syncdb --noinput /usr/lib/python2.7/site-packages/graphite/settings.py:246: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security') Creating tables ... Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s how to avoid this warning ? what need to fix here ? -
Django bug on CRSF token
I am using django as web API for backend and React JS as web UI for frontend. User will sign up from web UI which will send a POST request to django to register with the user details. I want to protect the signup view with CSRF. Therefore I come out with steps below. First, once the sign up page is loaded, I fire a dummy GET request to store the csrf token with code below. handleSend(){ let req = { url: 'http://localhost:9000/vcubes/retrieve_token/', method : 'GET', withCredentials: true } axios(req) } Then, when user submit the signup form, another POST request will be fired. const data = JSON.stringify({ 'first_name': this.state.first_name, 'last_name': this.state.last_name, 'email': this.state.email, 'contact_number': this.state.contact_number, 'password1': this.state.password1, 'password2': this.state.password2, }) let req = { url: 'http://localhost:9000/vcubes/signup/', method : 'POST', headers: { 'Content-Type': 'text/plain' }, data: data } axios.defaults.headers.common['X-CSRF-TOKEN'] = this.getCookie('vcubes') With the code above, an OPTIONS will be sent to django first and then after django send back a 200 OK, then the actual POST request will be fired. Surprise! Django stated that I do not set CSRF cookie. Forbidden (CSRF cookie not set.): /vcubes/signup/ [30/Oct/2017 01:30:48] "POST /vcubes/signup/ HTTP/1.1" 403 2857 My settings.py is below. ( I only … -
Filtrar comentario por usuario logueado
Buenas tardes, Tengo dos tres modelos los cuales están relacionados entre sí; Perfil, Puesto y Tags. El perfil tira de AbstractUser el cual se utiliza para el registro del nuevo usuario. En este modelo se ha añadido una información adicional 'puesto de trabajo' que es creado con el otro modelo Puesto. models.py from django.db import models from django.contrib.auth.models import AbstractUser from apps.Tags.models import Tags class Puesto(models.Model): nombre_puesto = models.CharField(max_length=50) etiquetas = models.ManyToManyField(Tags, blank = True) def __str__(self): return '{}'.format(self.nombre_puesto) class Perfil(AbstractUser): nom_puesto = models.ForeignKey(Puesto, blank = True) def __str__(self): return '{}'.format(self.username) Por otra parte, el modelo de Tags está en otra aplicación, se muestra a continuación. models.py class Tags(models.Model): nombre = models.CharField(max_length=20) def __str__(self): return '{}'.format(self.nombre) Además tengo otra aplicación para crear comentarios con la posibilidad de añadirle también las etiquetas. El objetivo es conseguir mostrar sólo los comentarios que coincidan con los Tags del usuario, para ello: views.py class ComentarioListar (LoginRequiredMixin,ListView): login_url='/' redirect_field_name='redirigido' model = Comentario template_name = 'home/comentario_listar.html' def get_queryset(self): aa=Puesto.objects.filter(nombre_puesto=self.request.user.nom_puesto) return Comentario.objects.exclude(autor__id=self.request.user.id) b=Perfil.objects.filter(nom_puesto=self.request.user) c=Puesto.objects.filter(nombre_puesto=b) return Comentario.objects.filter(tag__id=c) Esto no funciona, por lo que me podrías echar una mano por favor? alguna idea de cómo puedo hacer que solo se visualicen los comentarios que contengan las etiquetas del usuario … -
NoReverseMatch Django favorite
I'm quite new to this Django stuff and i'm getting a NoReverseMatch at /cityinfo/ Exception Value: Reverse for 'user_favorites' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['cityinfo/(?P<fav_id>[0-9]+)/$'] basically what i'm trying to do is get all the users Favorited posts and display them when the user clicks on the favorite navigation link in base.html base.html <li class="#"> <a href="{% url 'cityinfo:user_favorites' fav_id.id %}"> <span class="glyphicon glyphicon-floppy-disk"></span>&nbsp; Favourites </a> </li> urls.py url(r'^(?P<fav_id>[0-9]+)/$', views.user_favorites, name="user_favorites"), views.py def user_favorites(request, fav_id): if not request.user.is_authenticated(): return render(request, 'cityinfo/login.html') else: favorites = get_object_or_404(user_favourite_spot, id=fav_id) context = { "favorites": favorites } return render(request, 'cityinfo/user_favorites.html', context) appreciate your help -
django celery delay function dont exetute
hello I want to use celery tasks in my Django project and I try to follow this very good tutorial from Mr.Vitor Freitas. but in my case and if try to run it that tutorial project i don't get results back the functions don't execute and in my case and in tutorial(i take message to wait and refresh and nothing after refresh). Any idea Why ? I think so the problem maybe is in RABBITQM server ?some configuration ? Just install Erlang(otp_win64_20.1.exe) and after RabbitMQ(rabbitmq-server-3.6.12.exe) here example code : settings.py CELERY_BROKER_URL = 'amqp://localhost' celery.py from __future__ import absolute_import import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') app = Celery('mysite') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() tasks.py import string from django.contrib.auth.models import User from django.utils.crypto import get_random_string from celery import shared_task @shared_task def create_random_user_accounts(total): for i in range(total): username = 'user_{}'.format(get_random_string(10, string.ascii_letters)) email = '{}@example.com'.format(username) password = get_random_string(50) User.objects.create_user(username=username, email=email, password=password) return '{} random users created with success!'.format(total) _ _init_ _.py from .celery import app as celery_app __all__ = ['celery_app'] views.py from django.contrib.auth.models import User from django.contrib import messages from django.views.generic import TemplateView from django.views.generic.list import ListView from django.views.generic.edit import FormView from django.shortcuts import redirect from .forms import GenerateRandomUserForm from .tasks import create_random_user_accounts class … -
django modelform foreignkey update
I have my model as this: class Event(models.Model): EventId = models.UUIDField(primary_key=True) Winner = models.ForeignKey('Participant', on_delete=None) class Participant(models.Model): ID = models.UUIDField(primary_key=True) Name = models.CharField() I am trying to update an existing instance of the Event object using this in form.py class UpdateWinner(ModelForm): def __init__(self, *args, **kwargs): e = kwargs.pop('e', '') super(UpdateWinner, self).__init__(*args, **kwargs) self.fields['Winner'] = forms.ModelChoiceField(queryset=e)) class Meta: model = Event fields = '__all__' and in views.py def update_winner(request, event_id): if request.method == 'POST': form = UpdateWinner(request.POST, instance=Event.objects.get(EventId=event_id)) if form.is_valid(): else: event_par = Participant.objects.filter(some query) form = UpdateWinner(instance=event, e=event_par) I did check by printing the eventid, correct value is getting passed. but for some reason Winner field is causing some error with the form.is_valid() function and I am getting an error "'str' object has no attribute 'model'". Can anyone help me out here -
How to deny permission to a user of one kind from accessing the view of other user through url in django?
In my project, I've got different types of Users like this: User |-Client |-Employee |-Technical Manager |-Service Manager |-Production Manager No user can access the view of other user by url. A client cannot access profile of a Technical Manager through the url /officer/profile which is assigned for Technical Manager's profile. In order to do so, In my Client class in the models.py, I used this code snippet: class Client(models.Model): class Meta: permissions = ( ('view_client', 'view_Client'), ) Then for each view I used a decorator like this: @permission_required(lambda u: u.has_perm('authentication.view_client')) Then I'm logging in as a technical manager and trying to access with this url: /client/profile Then I got the error function object is not iterable. I was creating my user in an app called authentication. The models,py looks like this: ' @python_2_unicode_compatible class Profile(models.Model): user = models.OneToOneField(User) user_sex = (('MALE', 'Male'), ('FEMALE', 'Female')) sex = models.CharField(max_length=6, default='Male', choices=user_sex) address = models.CharField(max_length=250, null=True, blank=True) city = models.CharField(max_length=250, null=True, blank=True) state = models.CharField(max_length=250, null=True, blank=True) country = models.CharField(max_length=250, null=True, blank=True) phone = PhoneNumberField(blank=True) zip = models.IntegerField(null=True, blank=True) about = models.CharField(max_length=250, null=True, blank=True) email_confirmed = models.BooleanField(default=False) account_type = models.IntegerField(default=-1) class Meta: db_table = 'auth_profile' class Employee(models.Model): user = models.OneToOneField(User) manager = … -
How to run Django App using nginx server
I am completely beginner and would like to know how to run django app on nginx. What I did: I already have django app I have already installed nginx While I am executing nginx restart then my page is displaying standard view. How to redirect it to my app ? what should I change in nginx.conf file ? I will be really thankful for your help, Thanks -
Django: Custom field after deleting still in cleaned_data
I've created a quite complex custom model field (including a custom from field and custom widget). Normally when I delete a field in my view (del form.fields['my_field']) it doesn't appear in cleaned_data afterwards. But when I del my custom field it's still in there. As a result Django still tries to use this field but it's not there any more. See construct_instance in django/forms/models.py. I've reread the Django documentation but couldn't find a hint. Any idea where to start searching or which methods are involved in this? Here is the model field: from django.contrib.postgres.fields.jsonb import JSONField class CustomField(JSONField): def from_db_value(self, data, expression, connection, context): if data is None: return data return Kit(data, self.model) def to_python(self, data): if isinstance(data, Kit): return data if data is None: return data return Kit(data, self.model) def get_prep_value(self, data): return data.as_json() def value_to_string(self, obj): return self.value_from_object(obj).as_json() def formfield(self, **kwargs): defaults = {'form_class': CustomFormField} defaults.update(kwargs) return super(CustomField, self).formfield(**defaults) Traceback: Traceback (most recent call last): File "…django/mysite/myapp/tests_views.py", line 88, in test_… }, follow=True) File "…/lib/python3.5/site-packages/django/test/client.py", line 541, in post secure=secure, **extra) File "…/lib/python3.5/site-packages/django/test/client.py", line 343, in post secure=secure, **extra) File "…/lib/python3.5/site-packages/django/test/client.py", line 409, in generic return self.request(**r) File "…/lib/python3.5/site-packages/django/test/client.py", line 494, in request six.reraise(*exc_info) File "…/lib/python3.5/site-packages/django/utils/six.py", line 686, … -
Making FileField link through ForeignKey object
How can i create a link to the particular file? models.py class Post(models.Model): .... class Presentation(models.Model): pres_id = models.AutoField(primary_key=True) description = models.CharField(max_length=100) upload = models.FileField(upload_to='presentation', null=True) def __str__(self): return self.description class Participant(models.Model): conference = models.ForeignKey(Post, related_name = 'members', on_delete=models.CASCADE, null=True, blank=True) #Post class presentation = models.ForeignKey(Presentation, related_name = 'pres', on_delete=models.CASCADE, null=True, blank=True) views.py def post_detail(request, pk): post = get_object_or_404(Post, pk=pk) return render(request, 'plan/post_detail.html', {'post': post}) post_detail.html {% for part in post.members.all %} <a href="{{presentation.upload.url}}">{{part.presentation}}</a> {% endfor %} part.presentation returns only Presentation description. But I need also a file link. How can i solve this problem. Thanks. (Structure: there is a post with information about conference participants, presentations, etc. Presentation descriprion link should open a pdf file in browser) -
string concatenate in django template include
is this possible to do like this in django templates? {% for filename in filenames %} {% include filename+".html" %} {% endfor %} as you see i have list of filenames and i want to include all of them with for loop, i think i explained it well. and second question if filename is and integer can i convert to string? llike this: {% for filename in filenames %} {% include str(filename)+".html" %} {% endfor %} thanks. -
RelatedObjectDoesNotExist Error
Here is the model. I have created my own user model class Profile(models.Model): user = models.OneToOneField(User) favorite_food = models.CharField(max_length=100) def set_password(self, raw_password): self.user.set_password(raw_password) Here is the view: class UserFormView(View): form_class = UserForm template_name = 'templates/core/profile_form.html' def get(self, request): form = self.form_class(None) return render(request, self.template_name, {'form': form}) def post(self, request): form = self.form_class(request.POST) if form.is_valid(): user = form.save(commit=False) username = form.cleaned_data['username'] password = form.cleaned_data['password'] user.set_password(password) user.save() return render(request, self.template_name, {'form': form}) Here is UserForm class UserForm(forms.ModelForm): username = forms.CharField(max_length=10) password = forms.CharField(widget=forms.PasswordInput) class Meta: model = Profile fields = ['username', 'password', 'favorite_food'] Where seems to be the problem here? It also says that Profile has no user I have tried changing it to AbstractUser however, it also displays about an error about reverse accessor -
ModelForm disable imageField if empty
I have a form that allows users to upload an image. If they don't upload an image a default image is displayed. I want it that if they don't upload an image, the image field is disabled. I thought the if statement at the end of the form would work - but it didn't. Here's the form forms.py: class ProductForm(forms.ModelForm): class Meta: model = Product fields = ['name', 'description', 'url', 'product_type', 'price', 'image', 'image_url'] labels = { 'name': 'Product Name', 'url': 'Product URL', 'product_type': 'Product Type', 'description': 'Product Description', 'image': 'Product Image', 'image_url': 'Product Image URL', 'price': 'Product Price' } widgets = { 'description': Textarea(attrs={'rows': 5}), } if Product.image is None: form.fields['image'].disabled = True and here's the models.py: class Product(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=100) description = models.CharField(max_length=300) price = models.DecimalField(max_digits=10, decimal_places=2) url = models.CharField(max_length=200) product_type = models.CharField(max_length=100) image = models.ImageField(upload_to='product_images', default='product_images/default.png', null=True) image_url = models.CharField(max_length=200, blank=True) likes = models.IntegerField(default=0) def __str__(self): return self.name def get_absolute_url(self): return reverse('index', kwargs={}) I tried removing the default='product_images/default.png' - that didn't seem to work. I tried null=True and that seemed to crash the page. What am I missing? -
How to implement one-time tutorial for new users? Django + JS
I want to activate one-time scenario, for users who created their accounts first time, explaining things. As I guess, the only way is to add one more boolean to UserProfile and check in template and activate scenario in JS, if it's true or false. But the only disadvantage I see it that after first time this peace of code (if (first_time=True){..}) will be totally unnecessary. Am I right? This is the way most websites implement first-time-users tutorials? -
Adding a new html page in django app
Newer to django... and I'm trying to new html page in my django app and it doesn't seem to be rendering. I'm receiving a 404 error. Output of 404 error I've successfully added other pages using this method, but for some reason it's not working anymore. Steps I took: Added new html file to dashboards/templates folder Added new class to views.py Imported new class into urls.py and added to urlpatterns Troubleshooting: I've restarted Apache views.py from django.http import HttpResponse from django.conf import settings from django.views.generic import View from django.shortcuts import render from django.contrib.auth.models import User #from Minerva.backend.backend import CustomLDAPAuthBackend from django.contrib.auth.backends import RemoteUserBackend import logging #logger = logging.getLogger(__name__) ## Main Dashboard page class DashboardsView(View): def get(self, request): return render(request, "Dashboards.html") ## Documentation class DocumentationView(View): def get(self, request): return render(request, "Documentation.html") urls.py from django.conf.urls import url from Dashboards.views import DashboardsView from Dashboards.views import AmbulatoryQualityView, CancerCenterView, DecisionSupportView from Dashboards.views import EnterpriseQualityView, HumanResourcesView, IPAnalyticsView, ManagedCareView, DocumentationView from django.views.generic import TemplateView app_name = 'Dashboards' urlpatterns = [ url(r'^$', DashboardsView.as_view(), name='Dashboards'), url(r'^/Ambulatory Quality$', AmbulatoryQualityView.as_view()), url(r'^/Cancer Center Service Line$', CancerCenterView.as_view()), url(r'^/Decision Support$', DecisionSupportView.as_view()), url(r'^/Enterprise Quality$', EnterpriseQualityView.as_view()), url(r'^/Human Resources$', HumanResourcesView.as_view()), url(r'^/IP_Analytics$', IPAnalyticsView.as_view()), url(r'^/Managed Care$', ManagedCareView.as_view()), url(r'^/Documentation$', DocumentationView.as_view()), ] -
Why does Django create an index for ForeignKey with db_constraint=False
I want to shard my database so I can't use foreign key constraints. I have following models from django.db import models class A(models.Model): b_one_to_one = models.OneToOneField( 'B', on_delete=models.SET_NULL, db_constraint=False, null=True ) b_one_to_many_null = models.ForeignKey( 'B', on_delete=models.SET_NULL, db_constraint=False, null=True, related_name='+' ) b_one_to_many_nothing = models.ForeignKey( 'B', on_delete=models.DO_NOTHING, db_constraint=False, related_name='+' ) class B(models.Model): pass python manage.py makemigrations command generates following sql code BEGIN; -- -- Create model A -- CREATE TABLE `a` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY); -- -- Create model B -- CREATE TABLE `b` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY); -- -- Add field b_one_to_many_nothing to a -- ALTER TABLE `a` ADD COLUMN `b_one_to_many_nothing_id` integer NOT NULL; -- -- Add field b_one_to_many_null to a -- ALTER TABLE `a` ADD COLUMN `b_one_to_many_null_id` integer NULL; -- -- Add field b_one_to_one to a -- ALTER TABLE `a` ADD COLUMN `b_one_to_one_id` integer NULL UNIQUE; CREATE INDEX `a_b_one_to_many_nothing_id_4fca4209` ON `a` (`b_one_to_many_nothing_id`); CREATE INDEX `a_b_one_to_many_null_id_e498aa17` ON `a` (`b_one_to_many_null_id`); COMMIT; I understand that Django might want to create an index for b_one_to_many_null field due to on_delete=models.SET_NULL setting, but I don't understand why there is a need for an index for b_one_to_many_nothing field. Is there a way to turn this automatic index creation off or it's … -
How to schedule an email notification report with django-sql-explorer?
I'm searching for a reporting plugin for a soon to be developed django app and I checked some packages available in django. I am particularly interested in using django-sql-explorer because of its flexibility with the queries. But I can't seem to find a setting to allow me to schedule a report and then send to email the reports. There is an option to send reports to S3 but that is not really what I need. There is an option to email results via email but this only happens when the report is triggered manually. Would there be another way to allow me to schedule a report to be generated and then send the result to email recipients? -
Django - custom tags with assigning values
I am trying to build my own tags in django. this is my code when defining the tag: @register.inclusion_tag('post/templates/comment_block') def limit_amount_in_a_page(starting_index, topic_id=1, amount=5): comments = Comment.get_item_with_topic_id(topic_id) selected_comments = [] for index in range(starting_index, starting_index+amount): selected_comments.append(comments[index]) return {'selected_comments': selected_comments} this is how I use it: <div class="past_comments"> {% limit_amount_in_a_page starting_index=0 topic_id=1 amount=5 %} </div> this is the template: <ul> {% for comment in selected_comments %} <li> <div class="comment_body"> <div class="user_info_block"> <div class="content"> <div class="photo_profile"></div> <div class="user_info"></div> </div> </div> <div class="content_block"> <p>{{comment.content}}</p> </div> </div> </li> {% endfor %} However, I get this exception: get_item_with_topic_id() missing 1 required positional argument: 'topic_id' I tried to use the tag in the block without variable name, but still have the same error. -
Mocking Celery `self.request` attribute for bound tasks when called directly
I have a task foobar: @app.task(bind=True) def foobar(self, owner, a, b): if already_working(owner): # check if a foobar task is already running for owner. register_myself(self.request.id, owner) # add myself in the DB. return a + b How can I mock the self.request.id attribute? I am already patching everything and calling directly the task rather than using .delay/.apply_async, but the value of self.request.id seems to be None (as I am doing real interactions with DB, it is making the test fail, etc…). For the reference, I'm using Django as a framework, but I think that this problem is just the same, no matter the environment you're using. -
Django Channels send message from python websocket-client module
I have a Django Channels server which I intend to use as a websocket server. I am trying to send message to websocket with https://pypi.python.org/pypi/websocket-client I can pass the handshake phase and can see connect log in the terminal. However, when I send message to server, I can not see in consumers.py ws_message function that prints message. Also, I can not see the message in frontend. How can I send message to websocket ? -
django celery delay function errror
i use some math function where i create.this function take some images from html form and calculate some results,all in views.py, that calculation take long time to finish and this time the page stay on reloading ... i want to avoid that long time reloading and user I want to take that result where the function complete(results just update user table in specific column result) i try to follow this tutorial for this case but take this error message any time to put run button in html page error message : UnicodeDecodeError at /myslug/ 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128) Request Method: POST Request URL: http://127.0.0.1:8000/my-slug/ Django Version: 1.11.3 Exception Type: UnicodeDecodeError Exception Value: 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in range(128) Exception Location: C:\python27\Lib\site-packages\redis\connection.py in _error_message, line 552 Python Executable: C:\python27\python.exe Python Version: 2.7.5 main --__init__.py --apps.py --test.py --celery.py --tasks.py --models.py --form.py --views.py --admin.py mysite --settings.py --urls.py --__init__.py --wsgi.py here my code celery.py from __future__ import absolute_import import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') app = Celery('mysite') app.config_from_object('django.conf:settings') # Load task modules from all registered Django app configs. app.autodiscover_tasks() settings.py # REDIS related settings REDIS_HOST = …