Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to upload files to GAE through form data post in Django?
I have my django webapp that contains a method in one of my models to upload the user chosen file (from form) to a specified file directory. But i am not able to use the model after i have deployed my app on Google App Engine (using gcloud). I am using the Google MySQL db for my django app. Also, I am not able to use os.makedir() method in my app as the server prompts there is Read-Only-Permission MODELS.PY def upload_to(instance, filename): now = timezone_now() base, ext = os.path.splitext(filename) ext = ext.lower() rootpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) return rootpath + f"/face_detector/static/face_detector/img/{now:%Y%m%d%H%M%S}{ext}" # Do add the date as it prevents the same file name from occuring twice # the ext is reserved for the file type and don't remove it class PicUpClass(models.Model): picture = models.ImageField(_("picture"), upload_to=upload_to, blank=True, null=True) I am a rookie in python so please suggest me some basic solutions. -
How to specify html tag attributes in Django auto-generated ModelForms?
I am new to Django and was wondering how to specify html tag attributes like class = "" or id = "" in ModelForms ? Also, if there is any workaround to AJAX in Django, allowing me to dynamically update web pages, I would be pleased to know about it. Here is my first ModelForm : class UserForm(ModelForm): class Meta: model = User fields = [ 'number', 'name', 'birth_date', 'sport_club', 'subscribe_date', 'license_number' ] -
Display blob data in django template
I'd like to display a blob on the page. I get the binary data, convert it to base64, prepare the image src attribute from the view. Then render it in the template like so: <img style="width:100%;" src="{{blob_encoded}}"> However, i get the following error: can only concatenate str (not "bytes") to str Note that i have tried this also in the template without concatenation in the view but doesn't work: <img style="width:100%;" src="data:image/jpeg;base64,{{blob_encoded}}"> My view: def display_blob(request,du_id): qs = File.objects.values('du_file').filter(du_id=du_id) enc = base64.b64encode(qs[0]['du_file']) return render(request, 'images/display.html', { 'blob_encoded': 'data:image/jpeg;base64,'+base64.b64encode(qs[0]['du_file']), }) -
Not displaying details in database even though made models ,views and ran migrations
I am not able to get the deatils of the beneficiary in the database when I fill up the form for beneficiary and husband the details of only the husband is shown in the database and the details of the beneficiary is somewhat lost.The fields of the beneficiary are all empty. <body ng-app=""> {% extends "pmmvyapp/base.html" %} {% load crispy_forms_tags %} {% load static %} {% block content%} <div class="col-md-8"> <form method="post" action="/personal_detail/" enctype="multipart/form-data" id="regForm"> <div class="group"> <div class="tab"> {% csrf_token %} <div class="form-group"> <div class=" mb-4"> <!--Beneficiary Details--> <h6><u>(*Mandatory Fields)Please Fill up the details below </u></h6> </div> <legend class="border-bottom mb-4" ,align="center">1.Beneficiary Details</legend> <label for="formGropuNameInput">Does Beneficiary have an Adhaar Card?*</label> <input type="radio" name="showHideExample" ng-model="showHideTest" value="true">Yes <input type="radio" name="showHideExample" ng-model="showHideTest" value="false">No <!--logic for yes--> <div ng-if="showHideTest=='true'"> <div class="form-group"> <label for="formGropuNameInput">Name of Beneficiary(as in Aadhar Card)*</label> <input name="beneficiary_adhaar_name" class="form-control" id="formGroupNameInput" placeholder="Enter name of Beneficiary as in Aadhar Card" required> </div> <div class="form-group"> <label for="formGropuNameInput">Aadhaar Number(Enclose copy of Aadhaar Card)*:</label> <input name="adhaarno" class="form-control" id="aadhar" pattern="[0-9]{4}[0-9]{4}[0-9]{4}" placeholder="Enter Aadhar Card number with proper spacing" required> </div> <input type="file" name="adhaarcopy" /> <div class="form-group"> <div class="form-check"> <input class="form-check-input is-invalid" type="checkbox" value="" id="invalidCheck3" required> <label class="form-check-label" for="invalidCheck3"> Give consent to collect adhaar card data </label> <div class="invalid-feedback"> You … -
Best practices for storing articles' texts in django website
New to Django here, please bear with me if this question seems silly. I'm in the process of designing (and afterwards developing) a blog website. I've identified three types of page that I will have on my blog (article, home, misc) each of these having a separate template. Every new article would have its own text and images. Presumably I'd be using a single .html template to display many article texts. Do I store the article texts and images in a separate model? If so, do I store the html of the article text (with all its formatting) in plain text and then render it in the view? What's the best way to do this? Alternatively, I'd create a new template for every article, but this seems redundant. -
Get value from django form and use to find data in sql
I want the user to insert name in the form and after submitting the program goes to the DB and find certain values for this specific name and return to the user. This view.py does not work. How can i make it work and be able obj to identify id based on inserted name and go and find the specific values? view.py def home(request): if request.method == 'POST': form=PersonForm(request.POST) if form.is_valid(): form1=form.save(commit=True) name=form1.name obj=School.objects.get(id=1) context={ 'name':name, 'object':obj } return render(request, 'first/results.html', context) else: form = PersonForm() return render(request, 'first/search.html', {'object':obj}) models.py class School(models.Model): student=models.CharField(max_length=200) schgroup=models.CharField(max_length=200) class Meta: managed=False db_table='school' class Person(models.Model): name= models.CharField(max_length=150) forms.py class PersonForm(forms.ModelForm): name = forms.CharField(max_length=150, label='',widget= forms.TextInput) class Meta: model = Person fields = ('name',) Could you please help me. I will be happy for any help and advise. -
Deploy Django project on Apache server Centos 7
I am pretty much a having trouble Django project on Apache server. The error says: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Here is the virtualHost <VirtualHost *:8000> DocumentRoot /var/www/reactive WSGIPassAuthorization On WSGIDaemonProcess reactive python-path=/var/www/reactive:/var/www/venv3/lib/python3.6/site-packages WSGIProcessGroup src WSGIScriptAlias / /var/www/reactive/src/wsgi.py ErrorLog /var/www/reactive/logs/error.log CustomLog /var/www/reactive/logs/custom.log combined <Directory /var/www/reactive/src> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> The thing is the server pretty much working when I run the it manually. python3 manage.py runserver 0.0.0.0:8000 But when I try to make it keep running as virtualHost Then the problem above popping up. Do I missing something with the code about virtualHost:8000 here is the folder structure of venv3 and reactive folders Additionally I check the systemctl status httpd.service Feb 28 16:25:44 cpanel.example.com systemd1: Starting The Apache HTTP Server... Feb 28 16:25:44 cpanel.example.com httpd[23540]: [Fri Feb 28 16:25:44.919001 2020] [so:warn] [pid 23540] AH01574: module wsgi_module is already loaded, skipping Feb 28 16:25:44 cpanel.example.com httpd[23540]: [Fri Feb 28 16:25:44.919548 2020] [so:warn] [pid 23540] AH01574: module php7_module is already loaded, skipping Feb 28 16:25:45 cpanel.example.com systemd1: Started The Apache HTTP Server. and looked okay. -
Appropriate way to apply Django Server
I am trying to create a server. Data sent from the wireless communication device enters the database through this server. Use Message Queue to prevent data loss (VernaMQ). I wonder if Django is the right server for sending and receiving data from multiple wireless devices and if there is a problem, is there an alternative to using Django? -
How we can use redis pipeline in django-redis?
I want to use Redis pipeline (execute multiple commands) in django-redis. We can use multi and exec command in Redis but how we can in django-redis ? One solution is : I have list of hash keys i want to get all hashes using of hash key. On every iteration command send to redis server to fetch one by one hash. for hashkey in feedlist: result = con.execute_command('hgetall',hashkey) print(result) This is not a good idea instead of this we can use redis pipeline. But how i can achieve Redis pipeline in django-redis ? -
Is there a way to automatically update the models of a django app every time a webpage is requested?
I was wondering if there was a way of automatically updating models in a django app when a request is made to the webpage as I need a database to be displayed but I would like the page to be updated along with the database. I tried placing the following code in my views.py file but it only creates the models and does not update them when the database is updated.(I used pandas to get the info off of my database) from django.shortcuts import render from CollectMail.models import Details from django.http import HttpResponse import pandas as p file = p.read_csv(r"C:\Users\Robert Chomba Mumba\Desktop\Project At Access Bank 2\Emails\test_data_final.csv") n = len(file['EMAIL']) j = 0 k = 1 while j != n: NewItem = file['EMAIL'][j] NewObject = 'ID' + str(k) NewObject = Details(email = NewItem) j +=1 k +=1 def index(request): return HttpResponse(Details.objects.all()) -
p5.js and p5.sound.js does not work with different machine
i just made one front-end HTML project which take audio from user using p5.js and p5.sound.js. Everything working fine with my HTML code. but when i integrated that HTML code with my DJANGO back-end. it works fine with only same computer(localhost:8000/). But when i try to access and run django app from different machine(like 192.168.0.43:8000) it raise following error in browser console. ` ` there are following code in sketch.js let mic, fft, level1, state, soundFile, recorder; let can1; var timer = null; /** first setup the microphone **/ function setup() { state = 0; window.onbeforeunload = null; can1 = createCanvas(400, 400); can1.parent('canvas-area'); noFill(); mic = new p5.AudioIn(); mic.start(); //start mic fft = new p5.FFT(); fft.setInput(mic); } /** when mic on draw the circle on canvas **/ function draw() { background(245, 247, 250); let spectrum = fft.analyze(); // strokeWeight(2); stroke(61, 191, 232); beginShape(); if (state == 1) { for (i = 0; i < spectrum.length; i++) { vertex(i, map(spectrum[i], 0, 255, height, 0)); } } else if ($('#record').text() == 'Resume') { textSize(32); text("Resume Recordering", 40, 180) } else { textSize(32); text("Click To Start Meeting", 40, 180) } endShape(); } /** run following code when documnet is ready **/ $(document).ready(function(){ /** … -
Django-mailer - autosend not working locally (maybe: bad localhost crontab path?)
I'm new to django and I've installed django-mailer 2.0. It's working when I manually send the queued mails: (venv)$ python manage.py send_mail, but when I set up the crontab (which is the first time I use a cron job), it's not working. I guess there might be some mistakes in the paths. Official documentation of django-mailer suggests: * * * * * (/path/to/your/python /path/to/your/manage.py send_mail >> ~/cron_mail.log 2>&1) Mine: # first I tried: * * * * * (/usr/bin/python3 /Users/username/Documents/GitHub/projectname/manage.py send_mail >> ~/cron_mail.log 2>&1) # then I tried: * * * * * (/Users/username/Documents/GitHub/projectname/venv/bin/python /Users/username/Documents/GitHub/projectname/manage.py send_mail >> ~/cron_mail.log 2>&1) Neither is working.. Help please! -
django.db.utils.IntegrityError: NOT NULL constraint failed: new__users_personal_detail.husband_adhaarcopy
I added new fields and file fields and when I ran migrations I got this error.Looks like I am getting error in a FileField .I don't know what's causing this issue.Please help! Applying users.0010_auto_20200228_1138...Traceback (most recent call last): File "C:\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "C:\Python\Python38\lib\site-packages\django\db\backends\sqlite3\base.py", line 396, in execute return Database.Cursor.execute(self, query, params) sqlite3.IntegrityError: NOT NULL constraint failed: new__users_personal_detail.husband_adhaarcopy The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "C:\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line utility.execute() File "C:\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python\Python38\lib\site-packages\django\core\management\base.py", line 369, in execute output = self.handle(*args, **options) File "C:\Python\Python38\lib\site-packages\django\core\management\base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "C:\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py", line 231, in handle post_migrate_state = executor.migrate( File "C:\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Python\Python38\lib\site-packages\django\db\migrations\executor.py", line 245, in apply_migration state = migration.apply(state, schema_editor) File "C:\Python\Python38\lib\site-packages\django\db\migrations\migration.py", line 124, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "C:\Python\Python38\lib\site-packages\django\db\migrations\operations\fields.py", line 110, in database_forwards schema_editor.add_field( File "C:\Python\Python38\lib\site-packages\django\db\backends\sqlite3\schema.py", line 328, … -
Image Encoding and Decoding. base64 String Image
'Basically I am trying to save image Captured from Camera to server. First picture is captured Converted to base 64 String and then sent to Django backend using Volley request. On django side I am using base64.decodebytes(String Name) to again convert it to image. the image is converted and saved but it is not returning a success response and the file is not being saved in the directory I want. I am using the imagefield to save image toa given path using ***** pic= models. ImageField(upload_to="Folder_name"). Kindly help me out in solving this server side error and guide me if I am not properly decoding it.' =====================Android===================== Function for Converting Image to String base64. public String getStringImage(Bitmap bm){ ByteArrayOutputStream ba= new ByteArrayOutputStream( ); bm.compress( Bitmap.CompressFormat.JPEG,100,ba ); byte[] imagebyte = ba.toByteArray(); String encode = Base64.encodeToString(imagebyte, Base64.DEFAULT ); // Toast.makeText( MainActivity.this,"String is"+encode,Toast.LENGTH_LONG ).show(); return encode; } Using Volley to send Parameters to Django: protected Map getParams() throws AuthFailureError { String image = getStringImage( photo ); Map params = new HashMap( ); Date date = new Date( ); long timeMilli = date.getTime(); params.put("IMG", image); params.put("tm", String.valueOf( timeMilli )); return params; ===============================Pycharm======================== URL: path('add_file', views.fileAdd, name='fil'), Function DEf: def fileAdd(request): pak = request.POST['IMG'] tim … -
Customizing Reponse in Serializer with Django Rest Framework
I have two models like, class ModelA(models.Model): counter = models.SmallIntegerField(db_column='counter', blank=False, default=0) class ModelB(models.Model): a = models.ForeignKey(ModelA, on_delete=models.CASCADE, null=False, related_name='relation_a') Serializer of ModelB. I am looking if there is already a row of ModelA in table ModelB. If there is any I increase the value in ModelA; otherwise, I create one and put the counter value 1 in ModelA. The response is the counter value coming from ModelA. The problem is, the response is the old value before executing this create function. class ModelBSerializer(BaseSerializer): a = serializers.IntegerField(read_only=True, source='a.counter') def create(self, validated_data): try: bInstance = ModelB.objects.get(a__id=validated_data.get('modelA').id) aInstance = ModelA.objects.get(pk=validated_data.get('a').id) aInstance.counter = 1 aInstance.save() except DealThumbsCounter.DoesNotExist: bInstance = ModelB.objects.create(**validated_data) aInstance = ModelA.objects.get(pk=validated_data.get('modelA').id) aInstance.counter += 1 aInstance.save() bInstance.save() return bInstance class Meta: model = ModelB fields = ['counter'] I am using drf-nested and url is POST /modelA/{model_a_id}/modelB/ How can I get the updated counter value? Thanks in Advance. -
read text from url line by line in python
I am trying to read data from url which is text file line by line, but i'm getting whole data instead of line by line.but when the size of row is large i'm getting the right data. url = request.GET.get('url') data = [] with closing(requests.get(url, stream=True)) as f: data = [list(map(int, line.split('\n'))) for line in f] The above code gives me right answer for files having large row size but it's not working for small data. -
Deploying VGG16 model into production
I have a trained VGG16 model which is around 512 MB. I want to deploy it to a Django website. Is there a way to upload the model into cloud and draw inference from it online? -
Unhandled exception in thread started by <function wrapper at 0x7f7491e1a050> TypeError: unhashable type: 'bytearray'
Platform: Ubuntu: 19.10.3, mysql: 8.0.19, django: 1-11.28, mysql-connector-python: 8.0.5 Hello experts, I am trying to set up mysql as an external db table in my application (HUE) and I keep getting the error TypeError: unhashable type: 'bytearray'. I tried all the suggestions that I can find from google and it has taken me weeks, but I am still not able to resolve this error. I even tried to insert .decode('utf-8') in introspect.py, but doesn't work. My mysql db are all utf-8 character set, so I don't understand where the problem is coming from. Could somebody please help me? Unhandled exception in thread started by Traceback (most recent call last): File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/commands/runserver.py", line 127, in inner_run self.check_migrations() File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/core/management/base.py", line 422, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/executor.py", line 20, in init self.loader = MigrationLoader(self.connection) File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/loader.py", line 52, in init self.build_graph() File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/loader.py", line 210, in build_graph self.applied_migrations = recorder.applied_migrations() File "/home/brandon/hue/build/env/local/lib/python2.7/site-packages/Django-1.11.22-py2.7.egg/django/db/migrations/recorder.py", line 66, in applied_migrations return set(tuple(x) for x in self.migration_qs.values_list("app", "name")) TypeError: unhashable type: 'bytearray' -
Is it possible to encrypt a bytes stream using PyCrypto?
I'm working on an app where users upload a file and the app processes it automatically for them. For data security, I want to encrypt these files. These files can be of varying sizes from small to very large (2MB to upwards of 30MB). I came across PyCrypto as the de facto encryption/decryption package. The files are read into io.BytesIO() after being processed and then a file is created from the bytes stream. I was wondering if it is possible to 'encrypt' the bytes stream and then create the file. So that when I read the file into io.Bytes(), I can decrypt it and serve the file to the user. -
How to get all instances in serializer method field
How to get all instances in serializer method field I have a serializer method field and I am passing list data in the form of context to serializer like below. name_list = [ "abc", "def",....] obj_list = abc.objects.all() Serializer = abcSerializer (obj_list, context=name_list, many=True) Class abcSerializer (serializers.ModelSerializer): class Meta: model = abc xyz = serializers.SerializerMethodField ("getXYZ", read_only=True) def getXYZ (self, data): # here I want all instanceses, but I got only one instance in data. I want to attach name_list data one by one to instace data with same index? How I can get all instanceses in my serializer method field? -
get_form_kwargs() from FromSet
>>> from django.forms import BaseFormSet >>> from django.forms import formset_factory >>> from myapp.forms import ArticleForm >>> class MyArticleForm(ArticleForm): ... def __init__(self, *args, user, **kwargs): ... self.user = user ... super().__init__(*args, **kwargs) >>> ArticleFormSet = formset_factory(MyArticleForm) >>> formset = ArticleFormSet(form_kwargs={'user': request.user}) The form_kwargs may also depend on the specific form instance. The formset base class provides a get_form_kwargs method. The method takes a single argument - the index of the form in the formset. The index is None for the empty_form: >>> from django.forms import BaseFormSet >>> from django.forms import formset_factory >>> class BaseArticleFormSet(BaseFormSet): ... def get_form_kwargs(self, index): ... kwargs = super().get_form_kwargs(index) ... kwargs['custom_kwarg'] = index ... return kwargs Ive taken the above code from the Django documentation, the documentation says that the form_kwargs which is the dictionary passed in when instantiating FormSet it may depend on a specific instance but it does not say how When get_form_kwargs() is called in FormSet class with an index, its parent class method get_form_kwargs() is called to retrieve supposedly kwargs from a form instance Where is kwargs defined for the form instance? Django documentation writers should be sacked -
Data not saving to database properly Django ManyToManyField
I have a webapp with a friends feature, which is all working except for the bit of saving the current user into the requested user's ManyToManyField Here is my model friends = models.ManyToManyField(User,blank=True,related_name='user_connections') And my view class AddFriendRedirect(RedirectView): def get_redirect_url(self,*args,**kwargs): username = self.kwargs.get("username") obj = get_object_or_404(UserProfileInfo,slug=username) url_ = obj.get_absolute_url() user = self.request.user if user.is_authenticated: print("User is authenticated") if user in obj.friends.all(): obj.friends.remove(user) user.user_connections.remove(obj) #this line isnt saving the obj to the database else: obj.friends.add(user) user.user_connections.add(obj) # this line isnt saving the obj to the database return url_ And finally my urls path('profile/<str:username>/add/',views.AddFriendRedirect.as_view(),name='add_friend'), Everything is working except for saving for the user.user_connections.add(obj). On obj.friends.add(user), it adds the current user to their Manytomanyfield, but it's just not working on the user.user_connections.add(obj) one. I have tried heaps of things, including user.friends.add(obj) user.userprofileinfo.friends.add(obj) user.userprofileinfo.user_connections.add(obj) UserProfileInfo is my custom UserProfile model I am just confused as to why this isn't working, and it's weirder because no errors are being thrown either. Thanks for any help -
Django Ajax Post with HTML content using JSON.stringify then json.loads error
I have a textarea within a form on a webpage that has "HTML" content. <!-- HTML --> <textarea id="my-textarea"> <div class="this">Content here &amp; here!</div> </textarea> I fetch the content with Javascript and use encodeURIComponent to safely encode the string for AJAX JSON. and store it into a key/value array. (python dict) // Javascript var textarea = document.getElementById('my-textarea').value; var data = {}; data['html'] = encodeURIComponent(textarea); console.log(data); // prints --> {html: "%3Cdiv%20class%3D%22this%22%3EContent%20here%20%26amp%3B%20here%3C%2Fdiv%3E"} // In AJAX function. var json = "data=" + JSON.stringify(data); I then send the data to Django class based view and in post I have # Python / Django if request.is_ajax(): print(request.POST) # prints --> <QueryDict: {'data': ['{"code":"<div class="this">Content here &amp; here</div>"}']}> data = request.POST.get('data', None) if data: data = json.loads(data) This throws an error as below: Traceback (most recent call last): File "/home/tr/dev/host-root/apps/trenddjango2/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/tr/dev/host-root/apps/trenddjango2/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/tr/dev/host-root/apps/trenddjango2/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/tr/dev/host-root/apps/trenddjango2/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 71, in view return self.dispatch(request, *args, **kwargs) File "/home/tr/dev/host-root/apps/trenddjango2/django/common/views/dashboard/mixins.py", line 56, in dispatch return super(TemplateDashboardMixin, self).dispatch(request, *args, **kwargs) File "/home/tr/dev/host-root/apps/trenddjango2/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 97, in dispatch return handler(request, *args, **kwargs) File "/home/tr/dev/host-root/apps/trenddjango2/django/common/views/dashboard/catalogue.py", line 550, in post data … -
it always gives false ,i used this hasGroup function in other apps in all the apps this function returns false
from django.contrib.auth.models import Group def hasGroup(user,groupName): group = Group.objects.filter(name=groupName) return True if group in user.groups.all() else Falseenter image description here -
In django without using pagination i want to display record page wise
I am trying to do is display record page by page but without using pagination.