Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django css setup not working
I followed some tips from related questions in here, and tried the documentation but failed so far to get css file working. Note that css (obviously) works perfectly fine if I place it within the template, but I can't import it from static folder. So in my app folder, I created a static folder, within which I created another folder with the same name as my app: app->static->app->style.css When I run collectstatic, it gets style.css, and places it in: projectfolder->static->style.css All of this is working fine. My static settings were set automatically, I changed it based on some answers I read in related questions, but still didn't work: MEDIA_ROOT = u'/home/user/projectfolder/media' MEDIA_URL = '/media/' STATIC_ROOT = u'/home/user/projectfolder/static' STATIC_URL = '/static/' In my template, I have: {% load staticfiles %} .... <head> <link rel="stylesheet" href="{{ STATIC_URL }}style.css" /> .... Clearly I'm missing something, when I reload the website, no css is shown. In my css I have clearly set the body background to test it, but it doesn't change. Extra info: - Debug is set to true - Using the latest Django version .10 Any help or direction would be appreciated, thanks in advance. -
Python/Django convert/humanize specific dictionary items on django view?
I am creating a variable queryset and then passing the values into a dictionary context variable. I am able to convert dates but I'm not sure how to convert specific fields to currency (example: $1,000 instead of 1000) or even just humanize specific fields with commas (1,000 instead of 1000) below is my code from my view, the two methods are a part of a class: from datetime import date def get_context_data(self): context = super(MyView, self).get_context_data() context['myview_items'] = self.get_mymethod_items_context() return context def get_mymethod_items_context(self): context = {} items = table.objects.values('date_begun', 'price', 'item_number') context['items'] = items context['headers'] = ['Date', 'Price', 'Item'] context['fields'] = ['date_begun_date', 'price', 'item_number'] return context I was trying to do this for the item_number field: from django.contrib.humanize.templatetags.humanize import intcomma intcomma(items.values('burden_dollars')) -
Django and Twitter request_token
I am stuck with twitter signing in. By now I realized, that it is a several step thing (rather stupid in comparison with OAuth2): Make a POST request to /request_token endpoint in order to get the initial token Redirect user to /authenticate with token param from (1) in order to get another token Make another POST request to /access-token with token from (2) and finally get the desired token. Right now I am a bit stuck with (1): twitter API always returns ERROR 215, Bad Authentication Data. The code is like this: key = b"my_key&" raw_init = "POST" + "&" + quote("https://api.twitter.com/1.1/oauth/request_token", safe='') time_param = str(calendar.timegm(time.gmtime())) raw_params = quote('oauth_callback', safe='') + "=" + quote('http://example.com/twitter-auth/', safe='') raw_params += "&" + quote('oauth_consumer_key', safe='') + "=" + quote('consumer_key', safe='') raw_params += "&" + quote('oauth_nonce', safe='') + "=" + quote('aAbBcDadadwrwwrwrwr', safe='') raw_params += "&" + quote('oauth_signature_method', safe='') + "=" + quote('HMAC-SHA1', safe='') raw_params += "&" + quote('oauth_timestamp', safe='') + "=" + quote(time_param, safe='') raw_params += "&" + quote('oauth_version', safe='') + "=" + quote('1.0', safe='') # raw_params = quote(raw_params, safe='') raw_final = bytes(raw_init + "&" + raw_params, encoding='utf-8') hashed = hmac.new(key, raw_final, sha1) request.raw_final = hashed request.auth_header = base64.b64encode(hashed.digest()).decode() The code above make the signature … -
How to make 1 table scrollable with fixed header without affecting other tables in Bootstrap
I have spent over a day figuring out something very simple. I have a website where I use about 10 tables. I want only 1 of those 10 tables to have a fixed header and a scrollable bar. I found a good example online and modified it. I am able to have a table with fixed header and scrollable bar. .table-fixed tbody { display:block; max-height:625px; overflow-y: auto; } .table-fixed thead, tbody tr { display:table; width:100%; table-layout:fixed; } .table-fixed thead { width: calc( 100% - 1em ) } I add the table-fixed class to my table definition and it works. <table class = "table table-bordered table-hover table-striped table-condensed table-fixed"> The problem is that if I do not include the table-fixed in the other tables, the 9 other tables are all screwed up. For example: <table class = "table table-bordered table-hover table-striped table-condensed"> <table class = "table table-bordered table-hover table-striped table-condensed"> <thead> <tr> <th style="text-align: center; vertical-align: middle;">something</th> <th style="text-align: center; vertical-align: middle;">something</th> <th style="text-align: center; vertical-align: middle;">something</th> <th style="text-align: center; vertical-align: middle;">something</th> </tr> </thead> <tbody> <tr> <td style="text-align: center; vertical-align: middle;">something</td> <td style="text-align: center; vertical-align: middle;">something</td> <td style="text-align: center; vertical-align: middle;">something</td> <td style="text-align: center; vertical-align: middle;">something</td> </tr> <tbody> </table> How can … -
Django model queries outside of views
I've just recently been working with Django and have a question about preforming ORM queries. It looks like the standard procedure is to access your data by preforming a query through the ORM on the model directly in the view. While this is fine, I'm already running into a mess. My view now looks something like: from .model import Servers def server(request): servers = Servers.objects.only( 'id', 'name', 'url', 'alt_name' ).filter( url__isnull=False, test = 0, name__isnull=False ).order_by('name') This feels dirty to me. I'd rather make a method in the models to grab this info instead of querying it in the view. Something along the lines of: servers = Server.objects.getActiveServers() Am I wrong in thinking this? Is it bad practice in Django? How would I add a method in the model so I could access it like this? Thanks. -
What to do when searching on more than one word with django filter
I made a filter where you can search on different keywords and it works. My problem is that when i am trying to search on more than one keyword. How do I make it possible to filter the search so it can separate each word? Here is a picture how it looks: First picture shows when i only search on one key word, and second shows when i search on two: Here is my code for The model class: class Task(managers.Model): keywords = models.ManyToManyField('Keyword', blank=True, related_name='event_set') objects = managers.DefaultSelectOrPrefetchManager.from_queryset(managers.TaskQuerySet)() And here is my Filter class: class TaskFilterSet(BaseFilterSet): keywords = django_filters.MethodFilter(action="filter_keywords") class Meta: model = models.Task def filter_keywords(self, queryset, value): from django.db.models import Q return queryset.filter(Q(keywords__word__icontains=value)) -
Include one python file B inside file A where B uses variables defined in A
I have a Django project where I have multiple settings file which has lot of redundant data. The structure is as follows development.py app_one = 'http://localhost:8000' app_two = 'http://localhost:9999' abc_url = '{0}/some-url/'.format(app_one) xyz_url = '{0}/some-url/'.format(app_two) staging.py app_one = 'http://staging.xyz.abc.com' app_two = 'http://staging.pqr.abc.com' abc_url = '{0}/some-url/'.format(app_one) xyz_url = '{0}/some-url/'.format(app_two) production.py app_one = 'http://production.xyz.abc.com' app_two = 'http://production.pqr.abc.com' abc_url = '{0}/some-url/'.format(app_one) xyz_url = '{0}/some-url/'.format(app_two) In all the files abc_url and xyz_url are basically same url. The only thing that changes is the domain. What I am looking to is, Put all urls in separate file called app_one_urls.py and app_two_urls.py Find a way to include this app_one_urls.py and app_two_urls.py in my development, staging and productions file The final outcome can be as follows: app_one_urls.py abc_url = '{0}/some-url/'.format(app_one) app_two_urls.py xyz_url = '{0}/some-url/'.format(app_two) are two separate files in development.py I intend to do following app_one = 'http://localhost:8000' app_two = 'http://localhost:9999' somehow get urls from app_one_urls and app_two_urls Is it possible and feasible? If yes, I need help in understanding how. -
What is wrong with my Python SQL instruction?
The code below this inconsistent, sometimes returns a value, and sometimes returns no values def get_publicidade(value, slug): if value == "home": filtro = Q(status=1) #filtro = Q(status=True) #filtro.add(Q(exibir_home=True), Q.AND) filtro.add(Q(data_inicio__lte=data) & Q(data_termino__gte=data), Q.AND) publicidade = { 'publicidade1': Publicidade.objects.filter(filtro).filter(tipo=0).order_by('?').all(), 'publicidade2': Publicidade.objects.filter(filtro).filter(tipo=1).order_by('?').all(), 'publicidade3': Publicidade.objects.filter(filtro).filter(tipo=2).order_by('?').all(), } return publicidade -
Duplicate column name 'model_id' django mysql error on migrate
I'm using Django and MySQL on my VPS. Whenever I run python manage.py migrate I get an error. But on my development server, I use sqlite, and migrate works fine. Running migrations: Rendering model states... DONE Applying bloupergroups.0002_auto_20160826_1138...Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 198, in apply_migration state = migration.apply(state, schema_editor) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 123, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards field, File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 50, in add_field super(DatabaseSchemaEditor, self).add_field(model, field) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 396, in add_field self.execute(sql, params) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 110, in execute cursor.execute(sql, params) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/home/ashish/Env/bloup/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return … -
Django Photologue zip upload keep images names
I'm working on photologue and till now it's perfect. I just want to know how can I keep the images names when uploading zip images. It's changing the images names to the title. Please If you can help me in this -
Using Forms in Django - Adding people to a specific date
I've searched the site, which has been extremely helpful with other issues being that I'm new to Django. I can't seem to figure out how to add people to a date/event. My models are a PeopleList (which is people we'd invite to each event). The form for this works great and I can add people to this growing list. The Date model shows Dates that we will have events. The form for this works well since I can continue to add more dates of events. And the MeetingAttendance is the model where I'd like to add people to a date so I can see who went to the event, but when I create a form for it, it isn't coming out how I'd like. What I'm trying to do is be able to open up an event date (and I don't believe I'm routing the date to url correctly, but thats a separate issue), see a list of everyone on our PeopleList and then check-off if they attended to event or not. From there, on the same page (further down) I'd like to show the actual attendance to that specific event (PeopleList who attended that specific date). Any ideas on … -
EC2 t2.micro - high cpu utilization without any unusual use
I'm using EC2 micro to run simple django server. Although I haven't change a thing in my server it just started consuming the CPU. I read about a bug in the micro machines few months ago but couldn't find it now. What can I do? Thanks! -
Django Rest Framework exclude throttling
I have implemented throttling through the drf's inbuilt throttling solution which works very well. Now, I want some apis not to be throttled. Since there is a large number of api in my project I thought of creating a decorator and use it on the functions which are to be excluded. Something as: def exclude_throttle(func): @wraps(func) def wrapper(*args, **kwargs): for arg in args: if type(arg) == request.Request: arg.META['THROTTLE']= False result = func(*args, **kwargs) return result return wrapper and use the THROTTLE key in the below method to bypass throttling for the given method by: class PerMinuteThrottle(UserRateThrottle): scope = 'per_minute' def allow_request(self, request, view): try: if 'THROTTLE' in request.META and not request.META['THROTTLE']: return True ......... Now the issue is my decorator works after the throttling class is hit because of which the key is not set and the throttling happens. I want to intercept the request somewhere and set an attribute in it (a key works the same way). Or if there is a better way to achieve what I intend to do? Thanks -
Per-placeholder CKEDITOR settings
I am using CKEDITOR_SETTINGS variable in my settings.py to add custom styles to the markup generated by the CKEDITOR. I am aware of being able to use custom configuration when custom model is used, however, I cannot see any way to customise it on a per-placeholder basis. Is there any way to customise CKEDITOR_SETTINGS based on a placeholder? I imagine something along these lines would be ideal: CKEDITOR_SETTINGS = { "default": { 'skin': 'moono', 'stylesSet': [ { 'name': 'Normal', 'element': 'p', 'attributes': {'class': 'o-typography-body'}, }, { 'name': 'Lead paragraph', 'element': 'p', 'attributes': {'class': 'o-typography-lead'}, }, ], }, "landing_content": { 'skin': 'moono', 'stylesSet': [ { 'name': 'Normal', 'element': 'p', 'attributes': {'class': 'o-typography-body'}, }, { 'name': 'Special paragraph', 'element': 'p', 'attributes': {'class': 'special-class'}, }, ], } } -
Displaying only one field on form in combobox when editing ForeignKey
I am a django newbie so please forgive me the basic question. I have a class in my model that has a ForeignKey. I am using django.views.generic.UpdateView for editing the fields. For the ForeignKey a combobox is displayed which is exactly what I want but all the fields of the referenced table appear in the combobox. I want to display only 2 in the combobox, for example: "field1 [field2]". How can I control this behaviour? Thanks, V. -
How to search on multiple strings with filter
I made a filter where you can search on different keywords and it works. My problem is that when i am trying to search on more than one keyword. How do I make it possible to filter the search so it can separate each word? Here is a picture how it looks: First picture shows when i only search on one key word, and second shows when i search on two: Here is my code for The model class: class Task(managers.Model): keywords = models.ManyToManyField('Keyword', blank=True, related_name='event_set') objects = managers.DefaultSelectOrPrefetchManager.from_queryset(managers.TaskQuerySet)() class Keyword(managers.Model): word = models.CharField(max_length=120) disabled = models.BooleanField(default=False) objects = managers.DefaultSelectOrPrefetchManager.from_queryset( managers.KeywordQuerySet )() And here is my Filter class: class TaskFilterSet(BaseFilterSet): keywords = django_filters.MethodFilter(action="filter_keywords") class Meta: model = models.Task def filter_keywords(self, queryset, value): from django.db.models import Q return queryset.filter(Q(keywords__word__icontains=value)) -
Import erro when using makemigrations - django
Im new at django. Saw a tutorial and did like he did. Here is my settings: INSTALLED_APPS = [ 'showname.apps.ShownameConfig' 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] (I have directory called showname with modules whitch i want to convert tables in sql.) There is the module file: from __future__ import unicode_literals from django.db import models class Album(models.Model): name = models.CharField(max_length=100) singer = models.CharField(max_length=100) class Song(models.Model): album = models.ForeignKey(Album, on_delete=models.CASCADE) song = models.CharField(200) Now. when i trying to do : python manage.py makemigrations showname its giving me thats error: Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "C:\python27\lib\site-packages\django-1.10-py2.7.egg\django\core\management\__init__.py", line 367, in execute_fr om_command_line utility.execute() File "C:\python27\lib\site-packages\django-1.10-py2.7.egg\django\core\management\__init__.py", line 341, in execute django.setup() File "C:\python27\lib\site-packages\django-1.10-py2.7.egg\django\__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "C:\python27\lib\site-packages\django-1.10-py2.7.egg\django\apps\registry.py", line 85, in populate app_config = AppConfig.create(entry) File "C:\python27\lib\site-packages\django-1.10-py2.7.egg\django\apps\config.py", line 116, in create mod = import_module(mod_path) File "C:\python27\lib\importlib\__init__.py", line 37, in import_module __import__(name) ImportError: No module named ShownameConfigdjango.contrib -
Missing module when deploying Django on AWS Ubuntu EC2
I'm having some problems hosting a Django site on an ubuntu AWS server. I have it all running on local host fine. I am following these instructions: https://github.com/ialbert/biostar-central/blob/master/docs/deploy.md when i try and run it in aws console using: waitress-serve --port 8080 live.deploy.simple_wsgi:application i get import error: 1. No module named simple_wsgi Then if i use the base settings file (not the cut down one), i get import error 1. No module named logger I've tried moving settings files around and copying the settings files to deploy.env and deploy.py and then sample.env and sample.py and i can't get it running. Please help -
Gettting 403 when i try to login using alluth in django due to cookie containing un encoded dictionary
Gettting 403 when i try to login using alluth in django due to cookie containing un encoded dictionary . Cookies : task{"s":"d","we":"few"} How can ignore this type of cookies ? -
Django : authenticate() is not working for users created by register page, but working for those users who were created by admin
I want to make a register/login API for users. Problem is like this : If I create user via admin site, login is working properly. If I create user via register page made by me, login isn't working.(authenticate() function is returning None, even though that user is still in user table.) I go to admin site, go to the link to change password and give the same password again. After that I can login successfully. I think problem is either in saving password or login. I have crossed checked a lot but couldn't figure out. I am giving all files. You may go through important code. models.py from __future__ import unicode_literals from django.db import models from django.contrib.auth.models import User from datetime import datetime class Recruiter(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) company_name = models.CharField(max_length=120) HR_office_number = models.CharField(max_length=15) HR_mobile_number = models.CharField(max_length=15) def __str__(self): return self.user.username forms.py from django import forms from .models import Recruiter, User from django.core.exceptions import ValidationError class UserForm(forms.ModelForm): password = forms.CharField(widget=forms.PasswordInput(), max_length=128) confirm_password = forms.CharField(widget=forms.PasswordInput(), max_length=128) class Meta: model = User fields = ['first_name', 'last_name', 'username', 'email'] def __init__(self, *args, **kwargs): super(UserForm, self).__init__(*args, **kwargs) self.fields['first_name'].required = True self.fields['last_name'].required = True self.fields['email'].required = True self.fields['username'].help_text = None def clean_confirm_password(self): password1 = … -
Django Identical Testcases. One fails but the other one passes
Here is the code snippet: def test_get_config_data(self): url = self.config_entity_api_uri.format(installation=self.installation, config_id=self.config_id) print url resp = self.client.get(url) self.assertEqual(resp.status_code, 200) def test_update_config_data(self): url = self.config_entity_api_uri.format(installation=self.installation, config_id=self.config_id) print url resp = self.client.get(url) self.assertEqual(resp.status_code, 200) Output: in test_update_config_data self.assertEqual(resp.status_code, 200) AssertionError: 400 != 200 The first testcase passes, printing the data in the response... while the second fails -
The above exception (null value in column "post_id" violates not-null constraint DETAIL: Failing row contains
Integrity Error null value in column "post_id" violates not-null constraint DETAIL: Failing row contains (19, 2016-08-26 10:17:29.384037+00, null) Browser Error: Request Method: GET Request URL: http://127.0.0.1:8000/blog/40/delete/ Django Version: 1.10 Exception Type: IntegrityError Exception Value: null value in column "post_id" violates not-null constraint DETAIL: Failing row contains (19, 2016-08-26 10:17:29.384037+00, null). Exception Location: C:\Python34\lib\site-packages\django\db\backends\utils.py in execute, line 64 Python Executable: C:\Python34\python.exe Python Version: 3.4.3 Python Path: ['C:\\Users\\benq\\djangogirls\\mysite', 'C:\\Windows\\system32\\python34.zip', 'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34', 'C:\\Python34\\lib\\site-packages'] Server time: Fri, 26 Aug 2016 15:47:29 +0530 My Traceback: Internal Server Error: /blog/39/delete/ Traceback (most recent call last): File "C:\Python34\lib\site-packages\django\db\backends\utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.IntegrityError: null value in column "post_id" violates not-null constr aint DETAIL: Failing row contains (18, 2016-08-26 10:07:34.147991+00, null). The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Python34\lib\site-packages\django\core\handlers\exception.py", line 3 9, in inner response = get_response(request) File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 187, i n _get_response response = self.process_exception_by_middleware(e, request) File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 185, i n _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Users\benq\djangogirls\mysite\blog\views.py", line 46, in post_delete deletedPost=DeletedPost.objects.create() File "C:\Python34\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\Python34\lib\site-packages\django\db\models\query.py", line 399, in c reate obj.save(force_insert=True, using=self.db) File "C:\Python34\lib\site-packages\django\db\models\base.py", line 796, in sa ve force_update=force_update, … -
upload image using django rest framework
trying to upload the image using the django rest framework,I just do not know how to code the logic,,,here is my models.py .... class ProductsTbl(models.Model): .... class Upload(models.Model): thing = models.ForeignKey(ProductsTbl, related_name="uploads") ...... api/serializers.py ........ class UploadSerializers(serializers.ModelSerializer): image = serializers.ImageField(max_length=None, use_url=True) class Meta: model = Upload fields = ( 'id', 'image', 'thing', 'description' ) class ProductsTblSerializer(serializers.ModelSerializer): uploads = UploadSerializers(many=True, read_only=True) ...... class Meta: model = ProductsTbl fields = ( ..... 'uploads' ) ..... api/urls.py .... urlpatterns = [ url(r'^productsTbls/$', views.ProductsTblListView.as_view(), name='productsTbls_list'), url(r'^productsTbls/(?P<pk>\d+)/$', views.ProductsTblDetailView.as_view(), name='productsTbls_detail'), url(r'^productsTbls/(?P<slug>[-\w]+)/uploads/$', views.UploadDetailView.as_view(), name='uploads'), ] api/views.py ...... class ProductsTblListView(generics.ListCreateAPIView): queryset = ProductsTbl.objects.order_by('-created') serializer_class = ProductsTblSerializer class ProductsTblDetailView(generics.RetrieveUpdateDestroyAPIView): queryset = ProductsTbl.objects.all() serializer_class = ProductsTblSerializer class UploadDetailView(CreateAPIView): queryset = Upload.objects.all() serializer_class = UploadSerializers ...... I can upload the image only to the first ProductsTbl.id ok,,,however I have to let it upload to each ProductsTbl.id free ,for example I type the urls http://127.0.0.1:8000/api/v1/productsTbls/7/uploads/ <----it should upload the image to ProductsTbl.id <---(id = 7),,,how can it work? thank you -
Celery, Memory Leak in Application
After trying extensively though various forums none of the solutions seems to get the problem solved. Current setup celery 3.1.23 (Cipater) Python 2.7.6 Django 1.8.5 rabbitmqctl status {pid,1313}, {running_applications, [{rabbitmq_management,"RabbitMQ Management Console","3.2.4"}, {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.2.4"}, {webmachine,"webmachine","1.10.3-rmq3.2.4-gite9359c7"}, {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.2.4-git680dba8"}, {rabbitmq_management_agent,"RabbitMQ Management Agent","3.2.4"}, {rabbit,"RabbitMQ","3.2.4"}, {os_mon,"CPO CXC 138 46","2.2.14"}, {inets,"INETS CXC 138 49","5.9.7"}, {mnesia,"MNESIA CXC 138 12","4.11"}, {amqp_client,"RabbitMQ AMQP Client","3.2.4"}, {xmerl,"XML parser","1.3.5"}, {sasl,"SASL CXC 138 11","2.3.4"},{stdlib,"ERTS CXC 138 10","1.19.4"}, {kernel,"ERTS CXC 138 10","2.16.4"}]},{os,{unix,linux}},{erlang_version,"Erlang R16B03 (erts-5.10.4) [source] [64-bit] [smp:4:4] [async-threads:30] [kernel-poll:true]\n"},{memory,[{total,69475288}, {connection_procs,661184}, {queue_procs,1053848},{plugins,56592}, {other_proc,14051464}, {mnesia,76424}, {mgmt_db,905008},{msg_index,3227880}, {other_ets,2711664}, {binary,21907704}, {code,19586901}, {atom,703377}, {other_system,4533242}]},{vm_memory_high_watermark,0.4}, {vm_memory_limit,5040372121}, {disk_free_limit,50000000}, {disk_free,18427154432},{file_descriptors, [{total_limit,924},{total_used,13},{sockets_limit,829},{sockets_used,9}]},{processes,[{limit,1048576},{used,289}]}, {run_queue,0},{uptime,600576} ...done. Problems facing memory leak zombie process I am running periodic task only and have djcelery as part of my INSTALLED_APPS The detached process are predominantly happening in the functions where i invoke a sub-process call and fills up the whole memory in a days time data = subprocess.Popen(query, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) result = gdata.stdout.read() I start celeryd and celerybeat as a service with CELEDYD_OPS="--detach --time-limit=1500 --concurrency=8" (many forums pointed out that this would be the issue) Also tried setting CELERYD_MAX_TAKS_PER_CHILD=100 -
JavaScript is on - condition in Django template language
Is it possible to somehow check whether JS is on using Django template language? There is one page which requires JS in my project and I wan't to show table and buttons only if user uses JS. I have add this into the html but I want to hide original content too. <noscript> <h1><b>Please enable JavaScript to use this page!</b></h1> </noscript> So I'm curious if it's possible to do something like: {% if not js.is_on %} <show all html> {% else %} <show warning> {% endif %} EDIT: There is a one thing which could work - make the whole content hidden so JS would show it when document is ready and hide the alert but if there is a more simple option I would use it.