Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Unable to run local Celery worker, no module named myapp
I have a Django 1.11 project, with Celery 3.1.25, laid out like: env myproject myapp myotherapp settings settings.py __init__.py celery_init.py My __init__.py contains: from .celery_init import app as celery_app and my celery_init.py contains: from __future__ import absolute_import import os import sys import traceback from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings.settings') from django.conf import settings app = Celery('myproject') # Using a string here means the worker will not have to # pickle the object when using Windows. app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) @app.task(bind=True) def debug_task(self): print('Request: {0!r}'.format(self.request)) When I go to start a local Celery worker for development testing, with: env/bin/celery worker -A myproject -l info -n sr@%h -Q somequeue it fails with the exception: ImportError: No module named myapp What's causing this? I assume it's some path problem and not being able to properly load my project's settings, but I don't see the problem with my configuration. I just upgraded to Django 1.11, and these settings were working fine in the prior version. What am I doing wrong? I tried adding print statements at the end of my celery_init.py, to ensure it's loading everything, and every line completes without error. -
Template Tag values not rendering
I am creating a blog as practice for learning how to use django. I have created the blog list and created links to the blog detail page. On the blog detail, along with the blog_Content, post_date, blog_Title information that should be on the page I am to also attempting to render the comments attached to the specific blog created by the writer/user Issue : The comments attached to the specific writer/user are not being rendered. Here is the repository if you care to take a look Here is all the code : models.py from django.db import models from datetime import date from django.urls import reverse from django.contrib.auth.models import User class Writer(models.Model): user = models.ForeignKey(User, on_delete = models.SET_NULL, null = True) writer_description = models.TextField(max_length = 400, help_text = "Enter your description here.") def get_absolute_url(self): return reverse('blog:writer-detail', args = [str(self.id)]) def __str__(self): return self.user.username class Blog(models.Model): blog_Title = models.CharField(max_length = 200) writer = models.ForeignKey(Writer, on_delete=models.SET_NULL, null=True) blog_Content = models.TextField(max_length = 2000, help_text="Create content here.") post_date = models.DateField(default = date.today) class Meta: ordering = ['-post_date'] def get_absolute_url(self): return reverse('blog:blog-detail', args = [str(self.id)]) def __str__(self): return self.blog_Title class Comment(models.Model): writer = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) comment = models.TextField(max_length=1000, help_text="Create comment here.") post_date = models.DateTimeField(auto_now_add=True) class … -
launch sphinx commands "make clean" and "make html" from django.core.management call_command
Is there any way to launch sphinx commands "make clean" and "make html" from from django.core.management call_command? I need to refresh docs generated by sphinx every day, so I was thinking to use django-crontab to set a daily job. This job would call "make clean" and "make html" to automatically generate doc. But, maybe there is a simpler way to refresh docs generated by sphinx every day? Thanks! -
Django, get initials data from field in formset with shell
I'm using formset in Django 1.11, and in template rendering all works done. Now I want test formset in python shell. So I make a simple form and then a formset (2) with initials data: >>> from django import forms >>> class my_formset(forms.Form): ... my_field_1=forms.IntegerField() ... my_field_2=forms.IntegerField() ... >>> values=[{'my_field_1':10,'my_field_2':15}, {'my_field_1':84,'my_field_2':6}] >>> values [{'my_field_2': 15, 'my_field_1': 10}, {'my_field_2': 6, 'my_field_1': 84}] Building formset: >>> from django.forms import formset_factory >>> formset=formset_factory(my_formset,extra=0) >>> my_data_fs=formset(initial=values) Result formset: >>> my_data_fs <django.forms.formsets.my_formsetFormSet object at 0x7fdb688dda90> >>> my_data_fs.forms [<my_formset bound=False, valid=Unknown, fields=(my_field_1;my_field_2)>, <my_formset bound=False, valid=Unknown, fields=(my_field_1;my_field_2)>] Now I want get initials data: >>> my_data_fs.forms[0] <my_formset bound=False, valid=Unknown, fields=(my_field_1;my_field_2)> >>> my_data_fs.forms[0].fields OrderedDict([('my_field_1', <django.forms.fields.IntegerField object at 0x7fdb688dd7b8>), ('my_field_2', <django.forms.fields.IntegerField object at 0x7fdb688dd710>)]) but if I see single field, I get this: >>> my_data_fs.forms[0].fields['my_field_1'] <django.forms.fields.IntegerField object at 0x7fdb688dd7b8> >>> my_data_fs.forms[0].fields['my_field_1'].value Traceback (most recent call last): File "<console>", line 1, in <module> AttributeError: 'IntegerField' object has no attribute 'value' And if I use initials I get empty response >>> my_data_fs.forms[0].fields['my_field_1'].initial >>> What I have to do for get my initials data? -
Displaying ForeignKey attributes in DRF
When I run the api, instead of getting category name and subcategory name, I get their id, [ { "id": 1, "name": "StrawBerry", "category": 1, "subcategory": 1 } ] I actually want something like this: [ { "id": 1, "name": "StrawBerry", "category": "Fruits", "subcategory": "Berries" } ] Note: I already have category and subcategory. I just want to know how to access them. models.py from django.db import models class Category(models.Model): category = models.CharField(max_length=200) parent = models.ForeignKey('self', blank=True, null=True, related_name='children') class Meta: unique_together = ('parent' , 'category') def __str__(self): return self.category class SubCategory(models.Model): subcategory = models.CharField(max_length=200) category = models.ForeignKey('Category', null=True, blank=True) parent = models.ForeignKey('self', blank=True, null=True, related_name='subchilren') class Meta: unique_together = ('parent' , 'subcategory') def __str__(self): return self.subcategory class Product(models.Model): name = models.CharField(max_length=200) category = models.ForeignKey('Category', null=True, blank=True) subcategory = models.ForeignKey('SubCategory', null=True, blank=True) def __str__(self): return self.name serializers.py class GetProductSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ('id', 'name', 'category', 'subcategory') views.py class GetProductViewSet(viewsets.ModelViewSet): serializer_class = GetProductSerializer queryset = Product.objects.all() -
Django formset: Unable to to submit formset due to errors
Following is my model: class ContentLineConfig(models.Model): content_template = models.ForeignKey(ContentTemplate, null=False, verbose_name="Content template") line_x_start_cord = models.IntegerField(null=False, verbose_name="Line start X cordinate") line_y_start_cord = models.IntegerField(null=False, verbose_name="Line start Y cordinate") line_x_end_cord = models.IntegerField(null=False, verbose_name="Line end X cordinate") line_y_end_cord = models.IntegerField(null=False, verbose_name="Line end Y cordinate") line_fill_color = models.CharField(max_length=10, default="WHITE", choices=COLOR_CHOICE, verbose_name="Line fill color") line_width = models.IntegerField(null=False, verbose_name="Line width") archive = models.BooleanField(default=False) Form: class ContentLineConfigForm(ModelForm): class Meta: model = ContentLineConfig fields = '__all__' exclude = ['id','archive','content_template',] View: class ContentLineConfigView(ModelFormSetView): model = ContentLineConfig form_class = ContentLineConfigForm success_url = reverse_lazy('content_templates_list') template_name = 'formtemplates/test_formset.html' def form_valid(self,form): instance = form.save(commit=False) instance.content_template_id = self.kwargs.get('pk') return super(ContentLineConfigView, self).form_valid(form) def form_invalid(self,form): return super(ContentLineConfigView, self).form_invalid(form) Template: <div class="container"> <form action="." method="post"> {% csrf_token %} {{ formset.management_form }} {% for form in formset %} {{ form.as_p }} {% endfor %} <input type="submit" value="Submit" /> </form> </div> URL: url(r'^ct/(?P<pk>[\w-]+)/lines/create/$', ContentLineConfigView.as_view(), name='content_line_create') When I am submitting the formset I get the following error: NOT NULL constraint failed: contenttemplates_contentlineconfig.content_template_id But when I see the error page in detail, I see the following: formset <django.forms.formsets.ContentLineConfigFormFormSet object at 0x10821e3d0> kwargs {'pk': u'1'} Why this error? Also, If I submit empty formset, I get redirected to success_url, there is not validation happening at all, why are the validations being skipped? -
So how can I do when user clicked like button to return only value of the post
11** and python3 I was trying to add my web site like button when I add like button I worked but when someone click like button It returns same value for every post. So how can I do when user clicked like button to return only value of the post. MY HTML CODE: <button id="" data-catid="{{ post.id }}" class="btn btn-primary likes" type="button"> <span class="glyphicon glyphicon-thumbs-up"></span> Like </button> <strong class="" id="like_count">{{ post.votes }}</strong> people like this category MY JS CODE: $(document).ready(function() { $('.likes').click(function(){ var catid; catid = $(this).attr("data-catid"); $.get('/home/like_post/', {post_id: catid}, function(data){ $('#like_count').html(data); }); return false; }); }); I use this URL.PY url(r'^like_post/$', views.like_post, name='like_post'), And this VIEWS.PY: def like_post(request): cat_id = None if request.method == 'GET': cat_id = request.GET['post_id'] likes = Post.votes if cat_id: cat = Post.objects.get(pk=cat_id) if cat: likes = cat.votes + 1 cat.votes = likes cat.save() return HttpResponse(likes) ANY IDEA? -
How to use django-registration with hashed email addresses?
I am developing a website that requires users are anonymous. I want users to log in with email address and password but I want to store them both as hashes to achieve anonymity. Is this straightforward to achieve using django-registration? I understand how to set django-registration up to use email address and password for log in and I know the password is hashed by default but I do not know if I will run into lots of problems if I want to store the email address as a hash too. I don't particularly care what hashing algorithm is used at this stage; I just need a simple example for now. At the very least I know I will need to set up a custom user class, a custom user form, and a custom authentication backend. I am unsure whether I will encounter big problems with getting django-registration to verify email addresses with its hmac workflow. Can anyone give me a simple example of how to do this or tell me the steps I need to take to get hashed email addresses working? Alternatively, I am not wedded to django-registration so please feel free to recommend a different approach if there … -
How to pass a custom schema to a drf detail_route?
I have the following route: @detail_route(methods=['post'], permission_classes=[IsOperator], schema=AutoSchema(manual_fields=[ coreapi.Field('size', location='query', schema={'type': 'number', 'example': 1024}), coreapi.Field('filename', location='query', schema={'type': 'string', 'example': 'telemetry.tlog'}) ])) def get_upload_url(self): # ... When I go to a view that shows my schema, I get: I get the following error: AttributeError: 'AutoSchema' object has no attribute '_view' Stack trace: File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view 58. return view_func(*args, **kwargs) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/django/views/generic/base.py" in view 68. return self.dispatch(request, *args, **kwargs) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/views.py" in dispatch 489. response = self.handle_exception(exc) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/views.py" in handle_exception 449. self.raise_uncaught_exception(exc) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/views.py" in dispatch 486. response = handler(request, *args, **kwargs) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework_swagger/views.py" in get 32. schema = generator.get_schema(request=request) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/schemas/generators.py" in get_schema 279. links = self.get_links(None if public else request) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/schemas/generators.py" in get_links 317. link = view.schema.get_link(path, method, base_url=self.url) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/schemas/inspectors.py" in get_link 166. fields = self.get_path_fields(path, method) File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/schemas/inspectors.py" in get_path_fields 237. view = self.view File "/Users/frederikcreemers/.virtualenvs/theproject/lib/python2.7/site-packages/rest_framework/schemas/inspectors.py" in view 123. assert self._view is not None, "Schema generation REQUIRES a view instance. (Hint: you accessed `schema` from the view class rather than an instance.)" -
Unable to filter Haystack SearchQuerySet by boolean field
I've got a view which renders objects to a table via Knockout, powered by a haystack search index which looks like this; class ResultsIndex(indexes.SearchIndex, indexes.Indexable): """ Results indexes for elasticsearch engine """ text = indexes.CharField( document=True, use_template=True ) owner = indexes.IntegerField( model_attr='owner_id', null=True ) category_year = indexes.IntegerField( model_attr='category_year_id', null=True ) event = indexes.CharField( model_attr='category_year__category__event__title' ) category = indexes.CharField( model_attr='category_year__category__name', null=True ) year = indexes.CharField( model_attr='category_year__year__year' ) cannot_claim = indexes.BooleanField( model_attr='category_year__category__cannot_claim', null=True ) def get_model(self): """ Model for the index """ return Results The SearchView attempts to filter this index so that the Result objects where cannot_claim is True aren't shown; class ClaimableResultsListView(SearchView): """ Results list view. """ form_class = ResultsSearchForm template_name = 'results/list.html' http_method_names = ['get'] ordering = ('event', 'category', '-year', 'place') def get_queryset(self): """ Get results """ queryset = super(ClaimableResultsListView, self).get_queryset() queryset.models(Results).exclude(cannot_claim=True) return queryset However the above queryset still contains all objects regardless of the cannot_claim value. I've also tried to do queryset.models(Results).filter(cannot_claim=False) but neither filter the paginated objects. In the javascript before the objects are passed to KO I do a final check to ensure that cannot_claim is False, which at the moment means whole pages of the list may not render because it's not being filtered on. -
How to write backends authentication for product table in django
As i am trying to add backend authentication for this model. can someone suggest how to add to this. models.py class Product(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=200) type = models.CharField(max_length=200) price = models.DecimalField(max_digits=6, decimal_places=2, default="") image = models.ImageField(upload_to='image/product/', blank="True") -
order_create() takes exactly 2 arguments (1 given)
I was trying to do a celery task, the code as follows. task.py from .models import OrderItem from cart.cart import Cart from .forms import OrderCreateForm @task(name="create_order") def create_order(request): cart = Cart(request) if request.method == 'POST': form = OrderCreateForm(request.POST) if form.is_valid(): order = form.save() for item in cart: try: OrderItem.objects.create(order=order, product=item['product'], price=item['price'], quantity=item['quantity']) except: pass cart.clear() return None else: form = OrderCreateForm() return None views.py from .models import OrderItem, Order from cart.cart import Cart from .tasks import create_order def order_create(request, order_id): order = Order.objects.get(id=order_id) cart = Cart(request) create_order.delay(order.id) return render(request,'orders/order_created.html', {'cart': cart, 'order': order}) urls.py from .views import order_create urlpatterns = [ url(r'^create/$',order_create, name='order_create'), ] When executing the code I am getting the error 'order_create() takes exactly 2 arguments (1 given)'. Hope somebody can help me to solve it. Thank you. -
Template Block Django run after pageload
I want to include/load/run some html on template only when the page is already loaded, without use another request using Ajax. Exemple: {% block_postpone %} load everything that is inside of this block after the page loaded, and everything that is outside load immediately{% endblock_postpone %} I thinking that I need to change the process code of the template. -
Poor performance using Django Q queries.
I'm seeing quite unexpected performance when using the Q object for queries in Django. Here's an example of the issue. I have a piece of code, which uses union and distinct. import time from webapp.models import MessageRecipient from django.db.models import Q id = ... time.time() MessageRecipient.objects.filter( recipient__pk=id ).union( MessageRecipient.objects.filter( content__sender__pk=id ) ).distinct() time.time() The two times printed are: 1509466150.170969 1509466150.43806 Aka. The query returns within 300 milliseconds. Now if I rewrite the query to use Q, I get the following: time.time() MessageRecipient.objects.filter( Q(recipient__pk=id) | Q(content__sender__pk=id) ) time.time() The two times printed are: 1509466165.580193 1509466187.030747 Aka. The query now takes almost 20 seconds. The database is a postgresql, and there's about one million entries in each table. The question isn't with regards to the specific code, but rather why the Q object has so poor performance? -
How to manually clear/update a cached view in django
My goal is to cache a view until an event occurs where the view's cache would need to expire, otherwise cache for 1 hour. This is what I have in urls.py url(r'^get_some_stuff/$', cache_page(60 * 60, key_prefix='get_some_stuff')(views.StuffView.as_view())), And this works fine. Now I'm trying to fetch the cached view to verify that there's something there and I tried this: from django.core.cache import cache cache.get('get_some_stuff') But this returns None. I was hoping to do something like this: from django.core.cache import cache #relevant event happened cache.delete('get_some_stuff') What's the right way to handle cache? -
How to apply windowing function before filter in Django
I have these models: class Customer(models.Model): .... class Job(models.Model): customer = models.ForeignKey('Customer') payment_status = models.ForeignKey('PaymentStatus') cleaner = models.ForeignKey(settings.AUTH_USER_MODEL,...) class PaymentStatus(models.Model): is_owing = models.NullBooleanField() I need to find out, for each job, how many total owed jobs the parent customer has, but only display those jobs belonging to the current user. The queryset should be something like this: user = self.request.user queryset = Job.objects.select_related('customer' ).filter(payment_status__is_owing=True).annotate( num_owings=RawSQL('count(jobs_job.id) over (partition by customer_id)', ()) ).filter(cleaner=user) I am using 'select_related' to display fields from the customer related to the job. Firstly I haven't found a way to do this without the windowing function/raw SQL. Secondly, regardless of where I place the .filter(window_cleaner=user) (before or afer the annotate()), the final result is always to exclude the jobs that do not belong to the current user in the total count. I need to exclude the jobs from displaying, but not from the count in the windowing function. I could do the whole thing as raw SQL, but I was hoping there was a nicer way of doing it in Django. Thanks! -
Adding Multi-tenancy to Django Viewflow App
I am creating a Django Viewflow application and I am trying to add multi-tenancy to it but I am not sure how to go about it. I am building the application on Django with MySQL (I cannot move from MySQL). The django-multitenant package provides a means to do this by using passing the tenant model to each of my custom models, i.e. class Products(TenantModel): .... Is there a way to configure Django Viewflow to do the same? Thanks for any help. -
Django: creating an empty file in views.py
I want to create a new file with the same name as the object I am creating. I want to create a new "structure object" with the name str in the database and at the same time a new file called str in the designated uploading folder. When I do that I get an AttributeError of 'file' object has no attribute '_committed' Here are my codes: views.py: def create(request): print request.POST filename = request.POST['name'] f = open(filename, "w") structure = Structure(name=request.POST['name'], file=f) structure.save() return redirect('/structures') models.py: class Structure(models.Model): name = models.CharField(max_length=120) file = models.FileField(upload_to='structures') created_at = models.DateTimeField(auto_now_add = True) updated_at = models.DateTimeField(auto_now = True) def __str__(self): return self.name urls.py: url(r'^create$', views.create), template: <div class="col-md-12"> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title">Créer une nouvelle structure</h3> </div> <div class="panel-body"> <form class="form-horizontal" action="/create", method="post"> {% csrf_token %} <fieldset> <div class="form-group"> <label for="name" class="col-lg-6 control-label">Nom de la structure</label> <div class="col-lg-6"> <input type="text" name="name" id="name"> </div> </div> <div class="form-group"> <div class="col-lg-10 col-lg-offset-2" align="center"> <button type="submit" value="Create" class="btn btn-primary">Créer</button> </div> </div> </fieldset> </form> </div> </div> </div> The code was working just fine until I added the file creating lines in the views.py And this is a screenshot of the error I am getting: Edit: I didn't … -
Is Django built-in authentication design for managing product's users?
Is is safe to use Django's built-in auth to manage product's users? Or should implement my own solution, or use a 3rd party one? -
Docker compose for production and development
So I use Python+Django (but it does not really matter for this question) When I write my code I simply run ./manage.py runserver which does the webserver, static files, automatic reload, etc. and and to put it on production I use series of commands like ./manage.py collectstatic ./manage.py migrate uwsgi --http 127.0.0.1:8000 -w wsgi --processes=4 also I have few other services like postgres, redis (which are common for both production and dev) So I'm trying to adapt here docker(+ -compose) and I cannot understand how to split prod/dev with it. basically in docker-compose.yml you define your services and images - but in my case image in production should run one CMD and in dev another.. what are the best practices to achieve that ? -
How to override Django Allauth password reset url
I am using an angular frontend with django-rest-auth. How do I override the password_reset_rul in the email message to an url of my choice ( the url to the frontend of the app). {% load i18n %}{% blocktrans with site_name=current_site.namesite_domain=current_site.domain %}Hello from {{ site_name }}! You're receiving this e-mail because you or someone else has requested a password for your user account at {{ site_domain }}. It can be safely ignored if you did not request a password reset. Click the link below to reset your password.{% endblocktrans %} {{ password_reset_url }} {% if username %}{% blocktrans %}In case you forgot, your username is {{ username }}.{% endblocktrans %} {% endif %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you for using {{ site_name }}! {{ site_domain }}{% endblocktrans %} Most of the answers I found didn't work or were not clear enough including an issue on this found on the project's github issues. This question seemed right but didn't work for me, I'm thinking there should be a cleaner way to do that. -
pull-right in bootstrap3 didn't work
"pull-right" class in bootstrap 3 didn't work in django templatepull-right here is my code {% block content %} <div class="row"> <div class="col-sm-4 pull-right"> <h1>{{ title }}</h1> <form method="POST" action=""> {% csrf_token %} {{ form|crispy }} <input class="btn btn-primary" type="submit" value="Sign Up!"> </form> </div> </div> {% endblock content %} -
How can I edit the NGINX configuration on Google App Engine flexible environment?
How can I edit the Google App Engine NGINX configuration? There doesn't seem to be much support in the Google docs in regards to the NGINX configuration for apps running in the Google App Engine flexible environment. My app is running fine, but I get this 413 error when I try and upload an audio file (.wav or .mp3). 413 Request Entity Too Large -- nginx My app is running Django (python 3), with Cloud Postgres SQL and Cloud Storage enabled. I researched the error, and it seems I can set a nginx.config file so that it includes "client_max_body_size 80M" - but like I said, there is no documentation regarding how to manually config NGINX on deploy. Any suggestions? -
Using the URLconf defined in SchoolnSkill.urls, Django tried these URL patterns, in this order:
Ok, this is a very common problem that Django people face, and there are a couple of articles already available on the internet,but none of them helps me. I do understand that I need to create my own URLPatterns in my "apps/url", and which I have created one. Below is the URLPatterns from my project"schoolnskill/url": from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^user_info/', include('user_info.urls', namespace='user_info')), ] Below is the url patterns from my apps user_info/url from django.conf.urls import url from . import views urlpatterns = [ url(r'^user_info/index/$', views.IndexView.as_view(), name='index'), url(r'^user_info/register/$', views.RegisterView.as_view(), name='sign_up'), url(r'^register/$', views.UserFormView.as_view(), name='register'), ] I am getting error for "user_info/index" even though I have added it in my URL Patterns. Below is the whole error stack: Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/user_info/index/ Using the URLconf defined in SchoolnSkill.urls, Django tried these URL patterns, in this order: ^admin/ ^user_info/ ^user_info/index/$ [name='index'] ^user_info/ ^user_info/register/$ [name='sign_up'] ^user_info/ ^register/$ [name='register'] The current path, user_info/index/, didn't match any of these My Python environment details: Python - 3.6 Django - 1.11.3 IDE - Spyder 3.2.4 -
django not showing post for non super users
so i am creating a blog and every thing was working fine until i logged in as normal user. no error is raised but the problem is that the post_body and title and every thing in the template are disappeared even when i inspect my code in the browser, the strange thing that the comment form is showing? the template: {% extends 'base.html' %} {% block extra_head %} {% load static %} {% load blog_tags %} <link rel="stylesheet" type="text/css" href="{% static 'highlight.js/styles/gruvbox-dark.css' %}"> <script src="{% static 'highlight.js/highlight.pack.js' %}"></script> <script>hljs.initHighlightingOnLoad();</script> {% endblock %} {% block body %} <style> @font-face { font-family: 'post_title' ; src: url('{% static 'FFF_Tusj.ttf'%}') format('truetype'); } #like:hover{ cursor: default; } </style> <style> blockquote { background: #f9f9f9; border-left: 10px solid #ccc; margin: 1.5em 10px; font-family: fantasy; font-size: large; } blockquote p { display: inline; } .post-header{ text-align: center; font-family: Times } .post-body{ font-size: large; } </style> <!-- ajax--> {% if not Post|like:request %} <script> $(document).ready(function() { $("#like").click(function(event){ $.ajax({ type:"POST", url:"{% url 'like' Post.id %}", success: function(data){ i = true; if (i){ var f = document.getElementById('likes'); f.innerHTML = ""; f.innerHTML = {{ Post.votes }} + 1; i = false } } }); return false; }); }); {% endif %} <div …