Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to Iterate Over a List in Python
I have a simple for loop to iterate over a list of various dates. For each item in the list, I exclude the timezone by taking only the first 10 characters. However, when I pass the object to my template only the first value in the list is being returned for all values. views.py for opportunity in opportunities: temp = opportunity['expectedCloseDate'] time = temp[:10] context { 'time': time } return render(request, 'website', context) template.html <div class="control is-inline-flex"> <input class="input" name="close_date" id="close_date" type="date" value="{{ time }}" disabled> </div> -
Apache crashing from django.contrib class WKBWriter/Reader
I'm running a django application on an apache webserver. This application uses the django.contrib package, specifically django.contrib.gis.geos. Now sometimes this works out well for weeks, only to come crashing down multiple times a day with seemingly no direct correlation to user interaction. The log shows this: Traceback (most recent call last): File "[...]/lib/python3.4/site-packages/django/contrib/gis/ptr.py", line 37, in __del__ NameError: name 'AttributeError' is not defined [...] Exception ignored in: Exception ignored in: Exception ignored in: <bound method _WKBReader.__del__ of <django.contrib.gis.geos.prototypes.io._WKBReader object at 0x7ff4c2f92a58>> I have shortened the huge chain of Exception ignored in:s. After this, apache won't serve any more requests until it is restarted but also still remain active as a daemon. I am not sure which line exactly is responsible for this error. But I found this: https://docs.djangoproject.com/en/2.2/ref/contrib/gis/geos/#creating-a-geometry Under "My logs are filled with GEOS-related errors" it says that this could be avoided by not having any GEOS-Objects created on top level, so I tried to purge those occurrences but it didn't help. Also it seems weird to see NameError: name 'AttributeError' is not defined maybe that can hint to the root of this problem? If you do not know how to instantly solve this, can you give me some … -
save compressed image vs compress image before rendering
I am developing a webapp and need to render images in different sizes, for that I have one option to save images in different sizes and then render whatever needs. It will save time of compression but takes more storage because I need to save 6 different sizes of same image. Another one is compress image before rendering as per size needed, I am not sure but I think it will take more time to process and also takes more memory in ram. Is this make my ram overloaded ?? I want to go with second one but I think its bad. Can anyone tell which method can be more usefull in what case and what can be the technique for this? -
How can I render a plot in Django made on the server via matplotlib?
I'm developing a Django application where I'd like to be able to render a graph that updates when a user checks/unchecks checkbox inputs. I'm having trouble getting the data from the form to my server-side logic, and then rendering the plot (a histogram created via matplotlib) in the view. The data comes from a SQL query in the sqlite database that comes prepackaged in Django. I have verified that the SQL query returns the correct data, and have a script that will create the correct histogram. However, since there are many different options for the user to click to generate the histogram, I'd like to not save each potential histogram as a static file to be served. Ideally, the histogram would update when the user toggles a checkbox. I'm not opposed to using JavaScript/another plotting framework to render the histogram, however I'm not sure how I'd connect that to the database or to the view. Any help would be greatly appreciated! -
How to print this Json Returned object into Html template
output of json object [{"model": "demo.state", "pk": 1, "fields": {"state_name": "Gujarat", "country": 1}}, {"model": "demo.state", "pk": 2, "fields": {"state_name": "Rajsthan", "country": 1}}, {"model": "demo.state", "pk": 3, "fields": {"state_name": "Maharastra", "country": 1}}] I want to print the only state_name value in html template how to print that values in the template using Jquery //ajax code //I just print response using below alert(response) }, error: function(response) { alert("error"); } }); -
Django 2.1 Foreign Key set value based on previous form field value which is submitted to database
iam having a problem to assign my foreign key value to the first form field value. Model Startup is parent and Model Team is Child with a foreign key related to Startup model and the value of startup_name must be assigned to the startup foreign key field. however, the Team Model is a dynamic fields where multi Team members is inserted to the model and foreign key is only one field. i need help to get it right taking in place that am new to django programming forms.py: from .models import * from django import forms class StartupNameForm (forms.ModelForm): class Meta: model = Startup fields = ['startup_name',] models.py: from django.db import models class Startup (models.Model): startup_name=models.CharField('Startup Name', max_length = 100) def save(self , *args , **kwargs) : super ( Startup , self ).save ( *args , **kwargs ) # Call the "real" save() method. team = Team ( Startup = self , startup = self.startup_name ) team.save () def __str__(self) : return self.startup_name class Team (models.Model): name = models.CharField ( 'Name' , max_length = 100 ) position = models.CharField ( 'Position' , max_length = 100 ) startup = models.ForeignKey(Startup, on_delete = models.CASCADE) def __str__(self): return self.name views.py: def str_dashboard(request) : … -
Two Models pointing to One Database Table - Redundant Code [Django 2.1]
I'm working on a Django project that have two models on different apps using the same tables on database. The City and State tables are used in both apps. I want to know which is the best way to apply DRY concepts and use only one model for the two apps access these tables. The two apps are on the project folder and each one has his own models.py with the folowing code for city/state: from django.db import models from django.contrib.auth.models import User,Group from django.db.models.signals import post_save from django.dispatch import receiver class state(models.Model): class Meta: db_table = '"db_property"."state"' created_at = models.DateTimeField(db_column='created_at') updated_at = models.DateTimeField(db_column='updated_at') name = models.CharField(db_column='name',max_length=50) class city(models.Model): class Meta: db_table = '"db_property"."city"' created_at = models.DateTimeField(db_column='created_at') updated_at = models.DateTimeField(db_column='updated_at') name = models.CharField(db_column='name',max_length=50) state = models.ForeignKey(state,on_delete=models.CASCADE) Thanks in advance! -
How to send an object with other variables back to the client using json serialize?
How to add dict a to response and how can I get two objects at the ajax? view def abc(request): cp = Cp.objects.get(id=1) cp = serializers.serialize('json', [cp,]) cp = json.loads(cp) a = {'a': 'a', 'b': 'b'} return HttpResponse(data) js $.ajax({ // success: function(data){ } }) -
DjangoRestFramework: AttributeError: 'str' object has no attribute '_meta'
I traced this error and found that serializer.data is causing the problem. I have used similar code in my other Django apps and they are running perfectly fine. models.py from django.db import models class Category(models.Model): name=models.CharField(max_length=30) def __str__(self): return self.name class Subcategory(models.Model): category=models.ForeignKey(Category,on_delete=models.CASCADE) name=models.CharField(max_length=30) def __str__(self): return self.name class Products(models.Model): Subcategory=models.ForeignKey(Subcategory,on_delete=models.CASCADE) name=models.CharField(max_length=30) def __str__(self): return self.name serializers.py from rest_framework import serializers from .models import Category,Subcategory,Products class CategorySerializer(serializers.ModelSerializer): class Meta: model='Category' fields='__all__' class SubcategorySerializer(serializers.ModelSerializer): class Meta: model='Subcategory' fields='__all__' class ProductsSerializer(serializers.ModelSerializer): class Meta: model='Products' fields='__all__' views.py def post(self,request): action=request.query_params['action'] if action=='add': category_name=request.query_params['category_name'] category=Category(name=category_name) category.save() serializer=CategorySerializer(Category.objects.filter(name=category),many=True) return JsonResponse({"category details":serializer.data}) I went through all the posts on StackOverflow based on this error but none of those could help me resolve it. -
Django trailing slash in page
I have a problem if i add " / " at the end of the url and then the page 404 not found path('<slug:slug>',post_detail,name="post_detail"), Or if i delete " / " in the url then the page 404 not found path('news/',post_index,name="post_index"), I want to work whether have slash or not. -
ImportError: cannot import name 'PostListView' from 'main.views'
hello guys I'm beginner in learning Django, I got this error when I try to import PostListView from .views this project urls: from django.contrib import admin from django.urls import path, include from users import views as user_views from django.contrib.auth import views as auth_views from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('register/', user_views.register, name='register'), path('profile/', user_views.profile, name='profile'), path('/', include('main.urls')), path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) this is my app main urls: from . import views from django.urls import path from main.views import PostListView urlpatterns = [ path('', PostListView.as_view, name="blog"), path('about/', views.about, name='about'), ] and this is my views: from django.shortcuts import render from .models import Post from django.views.generic import ListView def blog(request): context = { 'posts': Post.objects.all() } return render(request=request, template_name='main/blog.html', context=context) class PostListViews(ListView): model = Post def about(request): return render(request=request, template_name='main/about.html') Thank you in advance :) -
How do I point my Django to my Vue files that are loaded via web pack?
I'm setting up a production server on digital ocean using Django and with MPA Vue. I load the Vue scripts and CSS via a webpack loader and it works fine locally. When I try to deploy it as production I get an error that I cannot 'get' the files of Vue I tried changing the webpack.config.js publicpath to the dir location and eventually changed it back to " " I tried changing the settings.py file's STATIC_URL and STATIC_ROOT to fit the dir's location of the Vue files myIp/:25 GET http://myIp/django_vue_mpa/static/vue/css/chunk-vendors.css net::ERR_ABORTED 404 (Not Found) myIp/:28 GET http://myIp/django_vue_mpa/static/vue/js/vue_app_01.js net::ERR_ABORTED 404 (Not Found) myIp/:27 GET http://myIp/django_vue_mpa/static/vue/css/vue_app_01.css net::ERR_ABORTED 404 (Not Found) myIp/:26 GET http://myIp/django_vue_mpa/static/vue/js/chunk-vendors.js net::ERR_ABORTED 404 (Not Found) myIp/:27 GET http://myIp/django_vue_mpa/static/vue/css/vue_app_01.css net::ERR_ABORTED 404 (Not Found) myIp/:28 GET http://myIp/dj ango_vue_mpa/static/vue/js/vue_app_01.js 404 (Not Found) -
How can i add a date/calender widget to django forms?
I tried following these links and this but it didn't work. the widget doesn't load in the form and the js files gives 404 error in the console while it's accessible from the link. I use crispy forms to render my form. forms.py DateInput = partial(forms.DateInput, {'class': 'datepicker'}) # patient Form class PatientForm(ModelForm): birth_date = forms.DateField(label='Birth Date',widget=DateInput()) class Meta: model = Patient exclude = ['user',] The Template <h2>Add Patient</h2> <form method="POST" action="{% url 'patients:patient_create' %}"> {% csrf_token %} {{ form|crispy }} <button type="submit" class="btn btn-primary" >Add Patients</button> <p></p> </form> </div> {% endblock %} <script> $(document).ready(function() { $('.datepicker').datepicker(); }); </script> The links of js files + CSS <script src=”https://code.jquery.com/jquery-1.12.4.js”></script> <script src=”https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script> <link rel=”stylesheet” href=”//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”> The errors in the console Not Found: /patients/”https://code.jquery.com/jquery-1.12.4.js” Not Found: /patients/”https://code.jquery.com/ui/1.12.1/jquery-ui.js” [18/Jul/2019 15:29:09] "GET /patients/%E2%80%9Dhttps://code.jquery.com/jquery-1.12.4.js%E2%80%9D HTTP/1.1" 404 6742 [18/Jul/2019 15:29:09] "GET /patients/%E2%80%9Dhttps://code.jquery.com/ui/1.12.1/jquery-ui.js%E2%80%9D HTTP/1.1" 404 6760 Not Found: /patients/”https://code.jquery.com/jquery-1.12.4.js” [18/Jul/2019 15:29:10] "GET /patients/%E2%80%9Dhttps://code.jquery.com/jquery-1.12.4.js%E2%80%9D HTTP/1.1" 404 6742 Not Found: /patients/”https://code.jquery.com/ui/1.12.1/jquery-ui.js” [18/Jul/2019 15:29:10] "GET /patients/%E2%80%9Dhttps://code.jquery.com/ui/1.12.1/jquery-ui.js%E2%80%9D HTTP/1.1" 404 6760 Not Found: /favicon.ico in my code i have many jquery versions can that cause the problem -
how to make dependent foreignkey in model admin (not front side)
I'm new to django.I have to create one Product class and that have two foreignkey product-categories and Attribute.Attribute also have foreignkey of product-categories. I have register this model in wagtail model-admin and create orderable attribute. class Products(ClusterableModel): name = models.CharField(max_length=20) stock = models.IntegerField(blank=True) price = models.FloatField(blank=True) product_type = models.ForeignKey(ProdCategory, on_delete=models.CASCADE) def __str__(self): return "%s"%(self.name) panels = [ FieldPanel('name'), FieldPanel('stock'), FieldPanel('price'), FieldPanel('product_type'), MultiFieldPanel([ InlinePanel('attribute', max_num =3), ], 'All Attributes'), ] class Meta: verbose_name_plural = 'Products' verbose_name = 'Product' from django.contrib.postgres.fields import HStoreField, JSONField class Attribute(Orderable): page = ParentalKey('Products', related_name='attribute') attribute = models.ForeignKey(ProductAttribute, on_delete=models.CASCADE,related_name='+') value = models.CharField(max_length=100) So, when i select category and then attribute can show only that attribute having selected category. Thanks in advance. -
App (Python Django, PostgreSql) is deployed successfully on Heroku, but I'm getting error when trying to open
I have successfully deployed Python/Django app called MyPortfolio in Heroku. But when I am trying to open it gives me an error: ModuleNotFoundError: No module named 'jobs' The project folder is 'MeryPortfolio-project'. The project name is 'MeryPortfolio'. Application name is 'jobs'. So Heroku can't find the module for the application. The case is: I have tried to make local and production settings. Local settings I use when I start the local server. Production settings are used in Heroku with the command: heroku config:set DJANGO_SETTINGS_MODULE=MeryPortfolio-project.MeryPortfolio.settings.production The directories are: 'MeryPortfolio-project' /'MeryPortfolio': _init.py settings.py urls.py wsgi.py /settings: init.py base.py local.py production.py These are logs when I try to open the app (heroku open) $ heroku logs 2019-07-18T12:54:14.328455+00:00 app[web.1]: spew: False 2019-07-18T12:54:14.328457+00:00 app[web.1]: check_config: False 2019-07-18T12:54:14.328459+00:00 app[web.1]: preload_app: True 2019-07-18T12:54:14.328461+00:00 app[web.1]: sendfile: None 2019-07-18T12:54:14.328463+00:00 app[web.1]: reuse_port: False 2019-07-18T12:54:14.328465+00:00 app[web.1]: chdir: /app 2019-07-18T12:54:14.328467+00:00 app[web.1]: daemon: False 2019-07-18T12:54:14.328469+00:00 app[web.1]: raw_env: [] 2019-07-18T12:54:14.328471+00:00 app[web.1]: pidfile: None 2019-07-18T12:54:14.328472+00:00 app[web.1]: worker_tmp_dir: None 2019-07-18T12:54:14.328474+00:00 app[web.1]: user: 36932 2019-07-18T12:54:14.328476+00:00 app[web.1]: group: 36932 2019-07-18T12:54:14.328479+00:00 app[web.1]: umask: 0 2019-07-18T12:54:14.328481+00:00 app[web.1]: initgroups: False 2019-07-18T12:54:14.328483+00:00 app[web.1]: tmp_upload_dir: None 2019-07-18T12:54:14.328485+00:00 app[web.1]: secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'} 2019-07-18T12:54:14.328487+00:00 app[web.1]: forwarded_allow_ips: ['*'] 2019-07-18T12:54:14.328489+00:00 app[web.1]: accesslog: - 2019-07-18T12:54:14.328491+00:00 app[web.1]: disable_redirect_access_to_syslog: False 2019-07-18T12:54:14.328494+00:00 app[web.1]: access_log_format: %(h)s %(l)s %(u)s … -
How to multiply succes_url in Django?
How to multiply succes_url in Django view? I tried this but it doesn't work: class ResetPasswordRequestView(FormView): template_name = "registration/password_reset_form.html" form_class = PasswordResetRequestForm def post(self, request, *args, **kwargs): form = self.form_class(request.POST) if form.is_valid(): data = form.cleaned_data["email_or_username"] if self.validate_email_address(data) is True: succes_url = '/reset/password/email/' else: succes_url = '/reset/password/username/' -
Why do I not get labels rendered from CharField when using DJANGO formset
I have a form with 2 CharFields. Both have label="xyz". If I use this form in a formset, the lables are not shown in the HTML I have tried looking at the rendered HTML and the label is missing. I have tried just a form and that works. Forms: class WindingVoltsSpecifier(forms.Form): winding_name = forms.CharField(max_length=20, label="Winding name") voltages = forms.CharField(max_length=20, label="Voltages") View: def add_mains_transformer_primary_configs(request): # Add a new config # Create the formset, specifying the form and formset we want to use. # From https://whoisnicoleharris.com/2015/01/06/implementing-django-formsets.html VoltsSpecifierFormSet = formset_factory(WindingVoltsSpecifier) if request.method == 'POST': pass else: mt_config_form = MainsTransformerConfiguration() volts_formset = VoltsSpecifierFormSet() context = { 'mt_config_form' : mt_config_form, 'volts_formset' : volts_formset, } return render(request, 'designer/mains_configs.html', context) Template: {% extends 'designer/base.html' %} {% load crispy_forms_tags %} {% block title %}configuration{% endblock %} {% block content %} {% load static %} <h1>Configuration</h1> <form method="post"> {% csrf_token %} {{ mt_config_form|crispy }} {{ volts_formset.management_form|crispy }} {% for volts_form in volts_formset %} <table> {% for form in volts_form %} {{ form }} {% endfor %} <table> <!--<div class="volts-formset"> {{ volts_form.winding_name }} {{ volts_form.voltages }} </div> --> {% endfor %} {% if volts_formset.non_form_errors %} {% for error in volts_formset.non_form_errors %} {{ error|escape }} {% endfor %} {% endif %} … -
Django and DRF: serializer for a user model
I am wrote a serializer for the User model in Django with DRF: the model: from django.contrib.auth.models import AbstractBaseUser from django.contrib.auth.models import BaseUserManager from django.db import models from django.utils.translation import ugettext class BaseModel(models.Model): # all models should be inheritted from this model created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) class Meta: abstract = True class User(AbstractBaseUser, BaseModel): username = models.CharField( ugettext('Username'), max_length=255, db_index=True, unique=True ) email = models.EmailField( ugettext('Email'), max_length=255, db_index=True, blank=True, null=True, unique=True ) USERNAME_FIELD = 'username' REQUIRED_FIELDS = ('email', 'password',) class Meta: app_label = 'users' the serializer: class UserSerializer(serializers.ModelSerializer): class Meta: model = models.User fields = ['email', 'username', 'password'] extra_kwargs = {'password': {'write_only': True}} def create(self, validated_data): user = super().create(validated_data) user.set_password(validated_data['password']) user.save() return user def update(self, user, validated_data): user = super().update(user, validated_data) user.set_password(validated_data['password']) user.save() return user It works. But I probably do two calls instead of one on every create/update and the code looks a little bit weird(not DRY). Is there an idiomatic way to do that? $python -V Python 3.7.3 Django==2.2.3 djangorestframework==3.10.1 -
for loop not iterating for second value
Some explaination about the code:- taking user's multiple input (comma separated) from CmdForm (django form)---> getting it in ipInsert ----> splitting it and stored in ipIns---> then Iteration but the issue is when i m taking comma separted value, the for loop is not iterating for the second time. displaying the result of input before comma. In views.py def form_name_view(request): if request.method == "POST": form = CmdForm(request.POST) if form.is_valid(): from netmiko import ConnectHandler ipInsert = request.POST.get('ip_address', '') ipIns = ipInsert.split(',') for ipIn in ipIns: devices = { 'device_type':'cisco_ios', 'ip':ipIn, 'username':'mee', 'password':'12345', 'secret':'12345', } cmd = request.POST.get('command', '') try: netconnect = ConnectHandler(**devices) except (AuthenticationException): re = 'Authentication failed.! please try again {}'.format(ipIn) print(re) return render(request,'first_app/forms.html', {'form': form, 'reprinting':re}) pass except (SSHException): re = 'SSH issue. Are you sure SSH is enabled? {}'.format(ipIn) print(re) return render(request,'first_app/forms.html', {'form': form, 'reprinting':re}) pass except (NetMikoTimeoutException): re = 'TimeOut to device {}'.format(ipIn) print(re) return render(request,'first_app/forms.html', {'form': form, 'reprinting':re}) pass except (EOFError): re = 'End of file while attempting device {}'.format(ipIn) print(re) return render(request,'first_app/forms.html', {'form': form, 'reprinting':re}) pass except Exception as unknown_error: re = 'Some other error {}' .format(unknown_error) print(re) return render(request,'first_app/forms.html', {'form': form, 'reprinting':re}) pass getIP = netconnect.send_command(ipIn) output = netconnect.send_command(cmd) now = time.strftime("%Y_%m_%d__%H_%M_%S") file = … -
Want to create PDF from template html in python django
I have template name in tempName in app django view by conditional check i want to choose matching template present at location app\dashboard\web\html\templates then i want to create pdf of that selected html template.To avoid library uncompatilbilty, i am using python 3.6. -
Set bucket gjango google storage in view
I have a view that is storing data in GoogleStorage. I have different buckets for different projects - so I cant use settings.GS_BUCKET_NAME. How I can set dynamically GS bucket name? I have following idea, but no idea if it will work class GStogare(GoogleCloudStorage): bucket_name = "" def set_bucket_name(self, somethig_with_bucket_name_id): self.bucket_name = SomethingWithBucketName.objects.\ get(pk=something_with_bucket_name_id).bucket gstogare = GStorage() class FileModel(models.Model): something_with_bucket_name = models.ForeighKey(....) file = models.FileField(storage=gstorage) def save(self, gstorage, force_insert=False, force_update=False, using=None, update_fields=None): gstorage.get_bucket_name(self.somethig_with_bucket_name) super().save(force_insert=False, force_update=False, using=None, update_fields=None) Basically - override GoogleCloudStorage class, make it set bucket_name dynamically in model save method. Could it work? -
How to get object at CreatView
There is a form that is rendered by url url(r'kredit/(?P<credit_slug>[-\.\w\d]+)/$', CreditDetail.as_view(), name='credit_detail'), urls url(r'kredit/(?P<credit_slug>[-\.\w\d]+)/$', CreditDetail.as_view(), name='credit_detail'), url(r'kredit_request/$', CreditOnlineRequestView.as_view(), name='credit_request'), The form is processed in the CreditOnlineRequestView(CreateView) view. It is necessary to pull out the credit_slug from CreditDetail view in it (here the form was drawn) views class CreditDetail(FormView): form_class = CreditPaymentForm template_name = 'credits/credit_detail.html' def get_initial(self): initial = super(CreditDetail, self).get_initial() initial['request'] = self.request return initial def get(self, *args, **kwargs): request_form = CreditOnlineRequestForm(self.request.GET or None, prefix="request") class CreditOnlineRequestView(CreateView): form_class = CreditOnlineRequestForm model = CreditOnlineRequest template_name = 'credits/credit_listing.html' prefix = 'request' def form_valid(self, form, **kwargs): credit_request = form.save(commit=False) credit_request.credit = credit #??? return super(CreditOnlineRequestView, self).form_valid(form) def form_invalid(self, form): errors = dict([(k, v[0]) for k, v in form.errors.items()]) return errors forms class CreditOnlineRequestForm(forms.ModelForm): class Meta: model = CreditOnlineRequest exclude = ['credit'] #вот это поле нужно определить def __init__(self, *args, **kwargs): super(CreditOnlineRequestForm, self).__init__(*args, **kwargs) #??? What are the options? I think, either through the cache, or through pulling out the previous page to do, but this is somehow not very humane, as for me. The best option, as for me, is to transfer the credit instance to a hidden form field in the CreditDetail view, but … -
How to create a list of objects by grouping them by a common name
i have a list of ungrouped objects and i want to return a list of grouped objects by a common value [{"name": "test", "group": "A"},{"name": "test2", "group": "B"},{"name": "test3", "group": "A"},{"name": "test4", "group": "B"}] I want to return this [{"group":"A","users":[{"name":"test},{"name":"test3"}]}] -
myModel has no 'object' member / How to setup pylint-django
In my view I want to store in a variables every object from myModel but I have the Class 'myModel' has no 'objects' memberpylint(no-member) error I have red that installing pylint-django as suggested by this similar topic : Class has no objects member but it didn't resolved my error then (in the same topic) I red that adding this "[python]": { "python.linting.pylintArgs": [ "--load-plugins=pylint_django" ], }, To my settings.json would do the trick but I have the warning : Unknown Identifier. Use language identifiers and the error on myModel.objects is still here -
There is a way to block return back to previous page after logout?
I am using my own authentification because i don't know how to extend django registration app to make me have a model user where user will have his login and password inside the model. when i logout i and click on the background firefox button i get the other page, when i refresh the page i have an session key error what is normal, i want to solve the problem like in the django admin where you can't go back after logout class User(models.Model): name = models.CharField(max_length=25) pwd = models.CharField(max_length=100) created = models.DateTimeField(_('created'), auto_now_add=True) active = models.BooleanField(default=False) def logout(request): from django.shortcuts import redirect for key in list(request.session.keys()): if key == 'id' : del request.session['id'] if key == 'code': del request.session['code'] if key == 'name': del request.session['name'] return redirect('/')