Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
display dictionary file inside for loop in django template
I have the following dictionary: d = {'21': 'test1', '11': 'test2'} {% with '18 17 16 15 14 13 12 11 21 22 23 24 25 26 27 28' as list_upper %} {% for x in list_upper.split %} {% if x in dental_position %} <input type="text" placeholder = "{{ x }}" class="form-control" name="tooth[]" value="{{display dict.value here}}"> {% else %}<input type="text" placeholder = "{{ x }}" class="form-control" name="tooth[]"> {% endif%} {% endfor %} I want to display the d[value] inside input text value attribute when values from d[key] is found in list_upper How can I call {% if d.keys in x %} in django template? -
How to setup Django logging to log to console and Debug Toolbar same time?
I try to setup logging in Django to use console and Django Debug Toolbar. By default this line logger.debug('XXXXX') log to DDT and console stay empty. With this setup LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'level':'DEBUG', 'class':'logging.StreamHandler' }, }, 'loggers': { '': { 'handlers': ['console'], 'level': 'DEBUG', }, }, } logs appear in console, but disappear from DDT How to make it works in both destinations? -
What's the meaning of order in a django request processing?
OVERVIEW Consider the below urls.py: from django.contrib import admin from django.urls import re_path, include from django.conf.urls.static import static from django.conf import settings from django.contrib import admin from django.urls import path # a) urlpatterns = [ path('admin/', admin.site.urls), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # b) # urlpatterns = [ # path('admin/', admin.site.urls), # ] print(urlpatterns) As you can see we got 2 url lists, whose __str__ representation is: a) [<URLResolver <URLPattern list> (admin:admin) 'admin/'>] b) [<URLResolver <URLPattern list> (admin:admin) 'admin/'>, <URLPattern '^media\/(?P<path>.*)$'>] PROBLEM If I make the same request to localhost:8000 it's producing 2 different outcomes for the abovementioned url lists: Using a) , I'll get a 200 response: Using b) , I'll get a 404 response: QUESTION After reading the section "How django processes a request" I've observed it says in point 3): Django runs through each URL pattern, in order, and stops at the first one that matches the requested URL. What does the concept of "order" means in this context? For instance, let me put you an analogy of what I understand of "order processing", if i declare a couple of lists (b is extended from a), a=[0,1,2,3]; b=a+[4,5,6] and then i do a.index(2)=2, b.index(2)=2, that type of order … -
Upon running "python manage.py startapp blog" shows the following error
I'm learning from djangogirls tutorials and when inside myenv(virtual environment) I'm running the python manage.py startapp blog it shows me the following error and can not run anything at all error is Traceback (most recent call last): File "manage.py", line 15, in <module> execute_from_command_line(sys.argv) File "c:\Users\Divyesh\djangogirls\myenv\lib\site-packages\django \core\management\__init__.py", line 371, in execute_from_command_line utility.execute() File "c:\Users\Divyesh\djangogirls\myenv\lib\site-packages\django\core\management\__init__.py", line 347, in execute django.setup() File "c:\Users\Divyesh\djangogirls\myenv\lib\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "c:\Users\Divyesh\djangogirls\myenv\lib\site-packages\django\apps\registry.py", line 112, in populate app_config.import_models() File "c:\Users\Divyesh\djangogirls\myenv\lib\site-packages\django\apps\config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "C:\Program Files (x86)\Python36-32\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "C:\Users\Divyesh\djangogirls\dpblog\models.py", line 2, in <module> from utils import timezone ModuleNotFoundError: No module named 'utils' Also after that while running python manage.py makemigrations blog it shows almost identical error I don't know how to tackle this please help. Learning Django for the first time. -
django context processor form not showing errors when submitting
I`m using context processor to render form to the base template in my project and the form seems to work ok, except it doesnt show any errors for required fields being blank and etc. The page is simply reloaded even if fields are not filled in. I used this approach in other project before, and it worked just fine, but now I cant really figure out what happened and why it is like so. Here is my forms.py: from django import forms class VersionSelectorForm(forms.Form): mode = forms.ChoiceField(widget=forms.RadioSelect(), choices=(('live', 'Live'), ('history', 'History')), initial='live', required=True, help_text='Required') date = forms.DateField(widget=forms.TextInput(attrs={'class': 'datepicker'}), required=True, help_text='required') def clean(self): cleaned_data = super(VersionSelectorForm, self).clean() mode = cleaned_data.get('mode') date = cleaned_data.get('date') if mode == 'history' and not date: msg = 'Date should be picked if \'History\' mode selected' self.add_error('date', msg) view.py: from django.shortcuts import redirect from .forms import VersionSelectorForm def select_version(request): if request.method == "POST": form = VersionSelectorForm(request.POST) if form.is_valid(): print('I am valid') mode = form.cleaned_data["mode"] date = form.cleaned_data["date"] if mode == "History": request.session['selected_date'] = date else: request.session['selected_date'] = None else: form = VersionSelectorForm() return redirect(request.META['HTTP_REFERER']) context_processors.py: from .forms import VersionSelectorForm def VersionSelectorFormGlobal(request): return {'version_selector_form': VersionSelectorForm()} urls.py: from django.contrib import admin from diagspecgen import views urlpatterns = [ url(r'^admin/', … -
jQuery not found with Django RGBField
The project I'm working on uses an RGBField, which inserts this script into the template (which is deep in the bowels of django somewhere because I can't find where it lives): <script type="text/javascript"> (function($){ $(document).ready(function(){ $('#id_color').each(function(i, elm){ // Make sure html5 color element is not replaced if (elm.type != 'color') $(elm).colorPicker({"colors": ["f1c40f", "2ecc71", "9b59b6", "e74c3c", "34495e", "3498db", "1abc9c", "f39c12", "d35400"]}); }); }); })('django' in window && django.jQuery ? django.jQuery: jQuery); </script> In the console I'm getting an error: Uncaught ReferenceError: jQuery is not defined I'm unable to inspect where the error is happening, but removing the RGBField prevents the issue. Jquery is used in the project, and if I use jQuery in the template itself it works fine (so it's not a problem with the template per se). I've added django-jquery to the project, and included {% load staticfiles %} at the start of the template. Does not resolve the problem. I've been ignoring the whole thing happily but now I need to write a cypress test with this page and the error is blocking the test. Is there a way in cypress to ignore this error? Or is there a way to prevent the error from happening in the … -
Django formset - validate input based on user cookie?
I have a Django form (TestForm) that contains a single field, quantity. I also have a Django formset (TestFormset) that contains multiple instances of my TestForm. I want to write a custom clean() method for my TestFormset that validates that the sum of the quantities specified within my multiple TestForms is equal to a number, max_quantity, stored in a session variable. I know that I am able to perform this validation within views.py (for example, after my formset is validated and cleaned, I could manually sum up the 'quantity' variables in my TestForms and check to ensure that they are equal to request.session['max_quantity'], throwing an error if any problems are found). But ideally I'd love to move all my form validation logic into the clean() method of forms.py. However, I can't figure out how to pass an external value into my Formset that is not linked to one of its individual forms. Is this possible to do? forms.py from django.forms import BaseFormSet class TestForm(forms.Form): quantity = forms.IntegerField() class BaseTestFormset(BaseFormset): def clean(self): if any(self.errors): # Don't bother validating the formset unless each form is valid on its own return quantity = 0 for form in self.forms: quantity += form.cleaned_data['quantity'] # IF … -
Django keep logged in lost when going outside to paypal payment
I'm kinda new to django, i'm having an issue to keep the logged in user still logged after he make payment via paypal. So, the user purchase something on my platform via paypal payment, he redirect to paypal (currently to sandbox paypal domain), execute the payment and redirect back to my platform using redirect_url i'm generating when sending payment request's json to paypal api. after the user is redirected back to my platofrm he is not logged in anymore. for example, in another scenario, lets say the user logged in and closing the browser, after that open the platform again he is still logged in. what i'm missing here? -
Django - Null value in column "imageLink" violates not-null constraint
I've been trying to setup an upload possibility for a form (with the intent to upload pictures) to a database, which is linked to other data in the list but every time I try to run it, it won't ignore the null that is suppose to be the picture. I've been reading up and trying to get this fixed for a solid day and a half but there isn't a lot of documentation to be found on this subject. Am I missing a place where the file needs to be uploaded to and/or is there a way to ignore the null if there hasn't been a photo added to the list? Error message: IntegrityError at /createproduct/ null value in column "imageLink" violates not-null constraint DETAIL: Failing row contains (81, Comedy, Comic, DC, 5, Engels, 5, Henk, haHAA, null, 808, 2000-04-02). Form snippet 1: class PRegistrationForm(ModelForm): ProductsEntry = Products(prodNum=products.id, prodName=products.prodName, prodPrice=products.prodPrice, prodStock=products.prodStock) ProductsEntry.save() ProdData = ProductDetails(prodNum=products(prodNum=products.id), genre=products.genre, type=products.type, publisher=products.publisher, totalPages=products.totalPages, language=products.language, rating=products.rating, author=products.author, desc=products.desc, imageLink=products.imageLink, pubDatum=products.pubDatum) ProdData.save() if commit: products.save() return products Form snippet 2: class ProductDetails(forms.Form): products_prodName = forms.CharField(required=True, max_length=200) products_prodPrice = forms.DecimalField(required=True, max_digits=5, decimal_places=2) products_prodStock = forms.IntegerField(required=True, max_value=5000, min_value=1) products_genre = forms.CharField(required=False, max_length=15) products_type = forms.CharField(required=False, max_length=15) products_publisher = … -
Unique Email for signing up
I've got some code: def signup(request): if request.method == 'POST': form = SignupForm(request.POST) if form.is_valid(): #### i suppose to put here function for email check user = form.save(commit=False) print(user) user.is_active = False user.save() current_site = get_current_site(request) mail_subject = 'Activation' message = render_to_string('acc_active_email.html', { 'user': user, 'domain': current_site.domain, 'uid':urlsafe_base64_encode(force_bytes(user.pk)).decode(), 'token':account_activation_token.make_token(user), }) print(message) to_email = form.cleaned_data.get('email') email = EmailMessage( mail_subject, message, to=[to_email] ) email.send() return HttpResponse('Check your email') else: form = SignupForm() return render(request, 'signup.html', {'form': form}) I need to make a check the email for uniqe. Am i right, that i can put function inside if form.is_valid? Can you please tell me what can I put there where can i find more examples with someones working code for registration, log in, and so on. It makes education so much easier and fun. Thanks. -
Access a function of view.py in from.py
How do I access a result of a view.py function inside form.py? I am trying to use the results of a function of view as input of a form field -
Django rest framework writable nested relations: data in list and unactive fields
this is my first project in Django Rest Framework and I stucked. I try to do writable nest relations to achieve this type of data: data = { 'name': 'Tom', 'Surname': 'DangerMouse', 'skills' : ['Python', 'Django'], 'employment_history' : [ {'copmany' : 'Jemset', 'role' : 'developer', 'from' : '12:06:2017', 'to' : '24:07:2017'} ], 'education' : [ {'university': 'CSbGU', 'year_of_graduation': '12:06:2017'}, ], } but in local host page data is in lists and arise "Lists are not currently supported in HTML input" problem. my models class Developers(models.Model): name = models.CharField(max_length=50) surname = models.CharField(max_length=30) class Education(models.Model): university = models.CharField(max_length=50) year_of_graduation = models.IntegerField() developers = models.ManyToManyField(Developers, related_name='education') class Empl_history(models.Model): company = models.CharField(max_length=50) role = models.CharField(max_length=30) fr = models.DateField(verbose_name='from') to = models.DateField() developers = models.ManyToManyField(Developers, related_name='employment_history') class Skills(models.Model): skills = models.CharField(max_length=100) developers = models.ManyToManyField(Developers, related_name='skills') my serializers class EmpSerializer(serializers.ModelSerializer): class Meta: model = Empl_history fields = ('company', 'role', 'from', 'to') class EduSerializer(serializers.ModelSerializer): class Meta: model = Education fields = ('university', 'year of graduation') class SkSerializer(serializers.ModelSerializer): class Meta: model = Skills fields = ('skills_choices', 'other skills') class DevSerializer(serializers.ModelSerializer): skills = SkSerializer(many=True) employment_history = EmpSerializer(many=True) education = EduSerializer(many=True) class Meta: model = Developers fields = ('name', 'surname', 'skills', 'education', 'employment_history') def create(self, validated_data): employment_history_data = validated_data.pop('employment_history') sk_data … -
Trying to learn inline formsets, not going well
I'm trying to get a very minimal inline formset added to a existing form. Basically I have the model Builing and Gallery with a foreign key to Building. I have already set up a basic BuildingCreateView that specifies the form building_form via form_class. I have created a simple GalleryFormSet but I can't get it show in the template. Is it really "necessary" to overwrite the view? # views.py from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import CreateView from .forms import BuildingForm from buildings.models import Building class BuildingCreateView(LoginRequiredMixin, CreateView): form_class = BuildingForm template_name = 'cms/building_form.html' # forms.py from django.contrib.gis.forms import OSMWidget, ModelForm, inlineformset_factory from buildings.models import Building, Gallery class BuildingForm(ModelForm): class Meta: model = Building fields = ['field', 'point', ...] widgets = { 'point': OSMWidget( attrs={ 'default_lat': 56, 'default_lon': 10, 'default_zoom': 7, } ) } class Media: css = { 'all': ( 'https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.css', 'gis/css/ol3.css', ) } js = ( 'https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js', 'gis/js/OLMapWidget.js', ) GalleryFormSet = inlineformset_factory(Building, Gallery, fields=('image',)) # building_form.html {% extends "base.html" %} {% block head %} {{ block.super }} {{ form.media }} {% endblock %} {% block content %} <form enctype="multipart/form-data" method="post" action=""> {% csrf_token %} <ul> {{ form.as_ul }} </ul> <input type="submit" value="Submit"/> </form> <form method="post" action=""> {{ gallery_form.management_form }} … -
Google Chrome opens empty new window when clicking Django dev server link
I had a Django project running perfectly using Python 2.7. Now I switched to Python 3 and whenever I click the link shown when I start the Django development server, google chrome opens a new, empty window where previously it opened a new tab in the existing window (which also contained the web application I was trying to run). I'm not sure this has anything to do with switching Python versions because I remember seeing this issue before when I wasn't doing anything with Python. Does anybody have clue? It's probably something very simple. Cheers -
What is a modern approach to deploy Django app?
I am developing a django application and reached the stage where the app has to be deployed to the production. I do not have too much DevOps experience and hence was doing some research. However, most of the proposed methods were 6-7 years old. Therefore I was wondering if anyone could suggest the modern approach to ship the django-based product given my requirements: The application will be used by companies with 1-1000 employees. Each company will store sensitive data. There should be no more than 100 different companies. We have a scheduler to execute a few machine learning tasks in the background. Business logic is quite trivial, no fancy algorithms. More specifically: Should every company have its own instance running with separate database? If I run everything on a single server and DB, is it okay to store sensitive data of all companies on the same DB? If I run everything on a single server and DB, will the server be able to cope with the traffic given my requirements? Who would provide the best service? Which one is the easiest to set up and run? I have deployed a few apps on AWS, but it was quite clumsy and … -
Django 2, python 3.4 cannot decode urlsafe_base64_decode(uidb64)
i am trying to activate a user by email, email works, encoding works, i used an approach from django1.11 which was working successfully. In Django 1.11 the following decodes successfully to 28, where uidb64 = b'Mjg' force_text(urlsafe_base64_decode(uidb64)) In django 2 (2, 0, 0, 'final', 0) the above code decode does not work and results in an error django.utils.encoding.DjangoUnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 1: invalid continuation byte. You passed in b'l\xc8\xe0' (<class 'bytes'>) I am also posting my views just in case from django.utils.encoding import force_bytes, force_text from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save(commit=False) user.is_active = False user.save() # auth_login(request, user) message = render_to_string('user_activate_email.html', { 'user': user, 'domain': Site.objects.get_current().domain, 'uidb64': urlsafe_base64_encode(force_bytes(user.pk)), 'token': account_activation_token.make_token(user), }) mail_subject = 'Activate your blog account.' to_email = form.cleaned_data.get('email') email = EmailMessage(mail_subject, message, to=[to_email]) email.send() messages.info( request, 'Activation link has been sent to your email!') # return redirect('home') return render(request, 'index.html') else: form = SignUpForm() return render(request, 'user_action.html', {'form': form}) def activate(request, uidb64, token): try: import pdb;pdb.set_trace() print('uidb64={}'.format(uidb64)) uid = force_text(urlsafe_base64_decode(uidb64)) user = User.objects.get(pk=uid) except(TypeError, ValueError, OverflowError, User.DoesNotExist): user = None if user is not None and account_activation_token.check_token(user, token): user.refresh_from_db() user.is_active … -
Dependencies reference nonexistent parent node
I was advised to delete the migration files as I am trying to run 'makemigrations' and 'migrations' as I have a new model. I deleted only the last migration file and now it is throwing an error: Migration core.0099_book dependencies reference nonexistent parent node ('incentives', '0012_auto_20171214_1059') -
Obtain the username of a logged user in Django, inside a Form
I would like to obtain the name of the logged user inside a form of a Django App. I know how to do this in the views.py user_name = request.user.username How can I do the same inside the forms.py? Or there is a way to pass this information to access it in the forms.py? -
File Upload Handler gives chunk with size less than specified
A very unusual thing is happening with Django file upload handler. I followed the documentation to write a custom handler so I could encrypt raw_data as I received it and write it to the file object. I didn't change the default chunk_size which is 64KB. My code worked fine with small files. But when I send files greater than the chunk size, the raw_data I receive does not have a length of 65536 as it should be for 64 KB chunk size, rather it is somewhere between 64000 to 65000. This hurdle is preventing me from being able to encrypt large files. Help. -
Nose does not creating test databases
I am trying to run unittests using nose framework (command test specific desktop -x), but after starting I'm getting this: [14/Dec/2017 14:36:14 +0000] settings DEBUG DESKTOP_DB_TEST_NAME SET: hue_test [14/Dec/2017 14:36:14 +0000] settings DEBUG DESKTOP_DB_TEST_USER SET: hue_test [14/Dec/2017 14:36:14 +0000] manager DEBUG DefaultPluginManager load plugin flaky = flaky.flaky_nose_plugin:FlakyPlugin [14/Dec/2017 14:36:14 +0000] manager DEBUG DefaultPluginManager load plugin windmill = windmill.authoring.nose_plugin:WindmillNosePlugin nosetests desktop -x --cover-package=about,beeswax,filebrowser,hbase,help,impala,jobbrowser,jobsub,metastore,oozie,pig,proxy,query_history,rdbms,schema,search,security,spark,sqoop,useradmin,zookeeper,indexer,metadata,notebook,aws,hadoop,liboauth,liboozie,libopenid,librdbms,libsaml,libsentry,libsolr,libzookeeper --no-path-adjustment --traverse-namespace -x --verbosity=1 [14/Dec/2017 14:36:14 +0000] manager DEBUG DefaultPluginManager load plugin flaky = flaky.flaky_nose_plugin:FlakyPlugin [14/Dec/2017 14:36:14 +0000] manager DEBUG DefaultPluginManager load plugin windmill = windmill.authoring.nose_plugin:WindmillNosePlugin Creating test database for alias 'default'... Traceback (most recent call last): File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/bin/hue", line 9, in <module> load_entry_point('desktop==3.12.0', 'console_scripts', 'hue')() File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/desktop/core/src/desktop/manage_entry.py", line 59, in entry execute_from_command_line(sys.argv) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line utility.execute() File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/core/management/__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/desktop/core/src/desktop/management/commands/test.py", line 108, in run_from_argv ret = test_runner.run_tests(nose_args) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/desktop/core/src/desktop/lib/test_runners.py", line 102, in run_tests result = self.run_suite(nose_argv) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/local/lib/python2.7/site-packages/django_nose-1.3-py2.7.egg/django_nose/runner.py", line 165, in run_suite addplugins=plugins_to_add) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__ **extra_args) File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__ self.runTests() ... I skipped part of traceback... File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/apps/useradmin/src/useradmin/models.py", line 244, in get_default_user_group return _get_user_group(useradmin.conf.DEFAULT_USER_GROUP.get(), is_add_permission, **kwargs) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/db/backends/util.py", line 53, in execute return self.cursor.execute(sql, params) File "/home/bdemydov/Projects/roku/roku-hue-3-12/hue-3.12.0/build/env/local/lib/python2.7/site-packages/Django-1.6.10-py2.7.egg/django/db/backends/mysql/base.py", line 124, in execute return … -
Django: How to set a property in a model using @property
I'm trying to assign two properties to my User class. The first assigned property will be used in assigning the second property. Is this correct? I'm using the @property decorator but should I be using @my_attr.setter (like, @apps.setter) after I use @property? class User(n): group = models.ForeignKey(Brand, null=True, blank=True) is_admin = models.BooleanField(default=True) # assign the apps property (User.apps) @property def assign_apps(self): self.apps = get_user_apps(self.group, self.is_admin) # do I need to now assign the property? @apps.setter self.apps = get_user_apps(self.group, self.is_admin) # with User.apps, assign the apps_meta property (User.apps_meta) @property def assign_apps_meta(self): self.apps_meta = get_user_apps_meta(self.apps) # do I need to now assign the property? @apps_meta.setter ... -
Find field name that matches the passed string and set its value
In Django how can i find a field name in a model? Here's what i mean : my_field = 'message' MyTable.objects.filter(pk=user_id).update(my_field='new message') The MyTable model has a field named message. -
Django redirect with non-URL parameter
I have a view class FooDetailView(View): def get(request, *args): foo_id = int(args[0]) foo = Foo.objects.get(pk=foo_id) // do something and render the page And now I would like to add some message into this page. For example class FooFuncView(View): def get(request): // do something return redirect('foo-detail', foo_id, 'call Func successfully') Since my urls.py is simply url(r'^foo-detail/([1-9][0-9]*)/', FooDetailView.as_view(), name='foo-detail'), I get the error message becuase no reverse match Reverse for 'foo-detail' with arguments '(<id>, 'call Func successfully')' not found. 1 pattern(s) tried: ['tournament-detail/contestant/([1-9][0-9]*)/'] But I dont want the message shown in the url because it could be too long. I just want to simply render the page as FooDetailView does, and add extra message after different operation. It there any good way to achieve this? If not, any explantions for that? -
Django Foreign Key. Remove connection after one exact date
For example i have 2 models products.py class Product(models.Model): name = models.CharField(max_length=255) clients.py class Client(models.Model): name = models.CharField(max_length=255) client_product = models.ForeignKey(Product) client_product_expiry_date = models.DateTimeField() Now: Product name = Chocolate Client name = John client_product = Chocolate client_product_expiry_date = 2017.12.17 (after 3 days) After certain days (which was set in field client_product_expiry_date) This connection between client and product should be removed Is there any way how to realize it? -
How to gather data from cx_oracle and shown as bar chart in djangi
I have application use cx_oracle for connect to db Data fetched but i have problem in shown multiline barchart with data gather from sql My sample data : Day hour value 20171228 0 43645 20171228 1 674436 20171227 0 464556 20171227 1 466744 Bar chart must draw one line for each day I works with highchart but cannot sent data with this format