Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to check 3 conditions at the same time in django template
I have 3 category in category field. I want to check it in django template and assign appropirte urls for 3 distinct category. I am tried: {% for entry in entries %} {% if entry.category == 1 %} <a href="{% url 'member:person-list' %}"><li>{{ entry.category }}</li></a> {% elseif entry.category == 2 %} <a href="{% url 'member:execomember-list' %}"><li>{{ entry.category}}</li></a> {% else %} <a href="{% url 'member:lifemember-list' %}"><li>{{ entry.category}}</li></a> {% endif %} {% empty %} <li>No recent entries</li> {% endfor %} But I know python only check first matching condition with if. Therefore it gave only one desired result. How do I get all three entries with their correct links? -
django-haystack combine two models
MODELS class Product(models.Model): name = models.CharField(max_length=255) description = models.TextField() price = models.IntegerField() price_fixed = models.BooleanField(blank=True, default=False) monthly_payments = models.BooleanField(blank=True, default=False) attribute_values = models.ManyToManyField( 'Entity', through='AttributeValue') class AttributeValue(models.Model): attribute = models.ForeignKey('Entity') value = models.CharField(max_length=255) product = models.ForeignKey('Product') I've already got the query with the basic django queryset filtering: listings = Product.objects.all() for key,val in request.POST.items(): listings = listings.filter(name_contains=val) if key=='q' else listings.filter(attributevalue__value=val) My goal is to get all the Products that are connected to all the values in the POST request ( which are saved in the AttributeValue table) First approach Is there some way to combine the first filter: self.queryset.filter(name=val).models(Product) -> with Haystack SearchQuerySet() with the second filter, staying the same: listings.filter(attributevalue__value=val) so the final query would be: listings = self.queryset.filter(name=val).models(Product) if key=='q' else listings.filter(attributevalue__value=val) Second approach To use only the haystack SearchQuerySet() like this: listings = self.queryset.filter(name=val).models(Product) if key=='q' else self.queryset.filter(attributevalue__value=val) -
NoReverseMatch (Error during template rendering)
I am getting this Exception in my browser, I have seen upto 20 posts related to this error but I could not have found any solution. I am new to Django, Please help me, Thanks in advance. my projectname/urls.py urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'', include('blog.urls')), ] My views.py def blog_list(request): return render(request, 'blog/blog_list.html', {}) blog_list.html Hello my models.py class Attenance(models.Model): name = models.CharField(max_length=200) entryTime = models.DateTimeField() breakIn = models.DateTimeField() breakOut = models.DateTimeField() exitTime = models.DateTimeField() def __str__(self): return self.name my appname/urls.py urlpatterns = [ url(r'', views.blog_list, name='blog_list'), ] Error in Browser : Django Version: 1.10 Python Version: 3.4.3 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blog'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Template error: In template C:\Users\benq\djangogirls\mysite\blog\templates\blog\blog_list.html, error at line 0 Reverse for 'blog_new' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] 1 : <!-- {% extends 'blog/base.html' %} 2 : 3 : {% block content %} 4 : {% for post in posts %} 5 : <div class="post"> 6 : <div class="date"> 7 : {{ post.name }} 8 : </div> --> 9 : <!-- <h1><a href="{% url 'blog_detail' pk=post.pk %}">{{ post.name }}</a></h1> --> 10 : Traceback: File "C:\Python34\lib\site-packages\django\core\handlers\exception.py" in … -
'unicode' object has no attribute 'utcoffset'
In my admin, I am getting errors for only one class, 'unicode' object has no attribute 'utcoffset'. I have looked at a few other similar questions and have been unable to solve it. Any ideas on how to fix it? The traceback is below the class. class PartRequest(models.Model): pub_date = models.DateTimeField('date published', default = '2016-08-10', blank=True) user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1) part_request_number = models.CharField(_('Part Request Number'),max_length=10, default = number) serialnumber = models.CharField(_('Serial Number'),max_length=10, default= snumber) partnumber = models.CharField(_('Part Number'), max_length = 500, default = 'e.g. 002109_1') build_type = models.ForeignKey(buildtyp, related_name='BuildType', null=True) project_manager = models.ForeignKey(Person, related_name = 'Manager', null = True) requester = models.ForeignKey(Person, related_name = 'Requester', null = True) project_id = models.ForeignKey(Project, related_name = 'Project', null=True) ordernumber = models.PositiveIntegerField(_('Order Number'), default=0) description = models.CharField(_('Description'), max_length=500) quantityrequired = models.PositiveIntegerField(_('Quantity'), default=0) sensitivity = models.ForeignKey(sens, related_name='Sensitivity', null=True) build_risk = models.ForeignKey(buildrisk, related_name= 'Risk', null=True) daterequired = models.DateField(_('Date Required'), default = '2000-08-16') image_or_pdf_upload = models.FileField(upload_to = upload_location, null=True, blank = True) material = models.ForeignKey(mat, related_name = 'Material', null=True) other_requirements = models.CharField(_('Other Requirements'), max_length = 100, default ='') cert = models.CharField(_('Certificate of Conformity'), max_length=50, default ='') location = models.ForeignKey(locat, related_name='Location', null=True) identification_method = models.ForeignKey(MOI, related_name= 'MOI', null=True) packing = models.CharField(_('Packing Specified by End User'),max_length=100, default = 'Please … -
How can I implement delete object using ajax in Django?
I already implemented Create, GET(Retrieve) using django-rest-framework and ajax. But have some problems in implementing Delete. (Delete API is ready) Here is my idea : html <div class="comment-meta"> <a id="commmet-delete" href="/api/posts/notice/2/comments/4/delete/"> 삭제 </a> </div> jqeury var commentMetaElement = $(".comment-meta"); var commentDeleteElement = $(commentMetaElement).find("#comment-delete"); var commentDeleteURL = $(commentDeleteElement).attr('href'); $(commentDeleteElement).click(function(){ alert($(this).attr('href')); $.ajax({ url: commentDeleteURL, type: "DELETE", success: function(data){ alert("done!"); }, error: function(data){ console.log(textStatus); } }); }); And When I click the a tag, alert doesn't occur. Also, When insert the code, alert(commentDeleteURL); after var commentDeleteURL = $(commentDeleteElement).attr('href');, it shows undefined. I wonder whether I'm implementing it in right way. First of all, I wonder it is right to create a tag for deleting... Thanks :) -
ionic push messages not recieved but send message is a success 201
i am using app in ionic version 1 and using ionic servers to register and send push notification, which is a success (201) but i am not recieving any push message, i have use app id in config from ionic servers and gcm project number then i am sending notification through django server, i cant figure out what went wrong, please help me here app.js angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.directives','app.services', 'ngCordova', 'ionic.cloud']) .config(function($ionicCloudProvider) { $ionicCloudProvider.init({ "core": { "app_id": "my_app_id" }, "push": { "sender_id": "my_gcm_project_number", "pluginConfig": { "ios": { "alert": true, "badge": true, "sound": true }, "android": { "iconColor": "#343434" } } } }); }) .run(function($ionicPlatform, $state, $http, $cordovaSQLite, $cordovaDevice, $cordovaNetwork, $ionicPush) { $ionicPlatform.ready(function() { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.disableScroll(true); } if (window.StatusBar) { // org.apache.cordova.statusbar required StatusBar.styleDefault(); } $ionicPush.register().then(function(t) { return $ionicPush.saveToken(t); }).then(function(t) { //console.log('Token saved:', t.token); $http.post( host+'/send_user_notification/', { ionictoken: t.token } ).success(function(res2, status, headers, config) { console.log('register successful'); }).error(function(res2, status,headers,config) { //alert( JSON.stringify(res2) ); console.log('register failed'); }); }); } } Django post method to ionic def post(self, request, format='application/json'): try: string_token = request.data['ionictoken'] … -
Pesky server error on Python web app
I've been having a problem with a website that I'm working on not attaching pictures to html emails. Thought I had it fixed but then every time someone tries to register on it I get a Server Error (500). I've only changed a couple of references so no idea what went wrong there, anyways error log is as follows: 2016-08-31 08:26:15,757 :Internal Server Error: /register/ Traceback (most recent call last): File "/home/asranet/.virtualenvs/testenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response response = self.process_exception_by_middleware(e, request) File "/home/asranet/.virtualenvs/testenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "./register/views.py", line 14, in index form.save(commit=True) File "/home/asranet/.virtualenvs/testenv/local/lib/python2.7/site-packages/django/forms/models.py", line 451, in save self.instance.save() File "./register/models.py", line 35, in save email_client(self, site_settings.site_name + "Conference Registration", "You are officially registered for AdWind 2017") File "./adWind/email_functionality.py", line 31, in email_client fp = open(os.path.join(os.path.dirname(file), f), 'rb') IOError: [Errno 2] No such file or directory: u'./adWind/static/Images/asranetLogo.jpg' I checked and the file is there. No idea how to proceed, could really use some help. Thank you in advance! -
Passing Django variable to `<div>` tag
I want to pass a Django variable to a tag. In my case I would like to pass it to the <div> tag. I want to set the <div> tag id with the variables returned by my view. For example (template): <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#{{ pools }}"> <div id="{{ pools }}" class="collapse"> When I click the button, it should expand the div, but it doesn't. Meaning the variable syntax is wrong (that's my assumption at least). The first variable that my view returns is: ('test pool id',) It should be assigned to target of the button (which includes the hash before the variable) and the id of the div. Any help or direction would be appreciated, Thanks -
geodjango check PointField in PolygonField
I have two django models: class Region(models.Model): geometry = models.PolygonField() class Position(models.Model): coordinates = models.PointField() I am trying to check if a Position is geographically contained inside a Region: def check(region, position): return position.coordinates.intersect(region.geometry) But it always return False, even when the Position is contained inside the Region (I am rendering both the PointField and the RegionField with django-leaflet). I also tried using: def check(region, position): return position.coordinates.within(region.geometry) but no results so far. Here is the test data that I am using (geojson): {"coordinates": [46.2071762, 11.1245718], "type": "Point"} {"coordinates": [[[11.102371215820312, 46.21939582902924], [11.106491088867188, 46.22111800038881], [11.134214401245117, 46.22188999070486], [11.140050888061523, 46.21791115519151], [11.141080856323242, 46.21422899084459], [11.137990951538086, 46.207695510993354], [11.13412857055664, 46.20122065978115], [11.12485885620117, 46.198844376182535], [11.102371215820312, 46.21939582902924]]], "type": "Polygon"} Any hint on what the problem could be? Thanks in advance! -
VariableDoesNotExist while rendering: Failed lookup for key [object]
I am using django-haystack and elasticsearch on my Ubuntu server and finding that certain search queries just raise an error page, and I have no idea why this is happening.. Any help appreciated! :) model.py : class EnActress(models.Model): name = models.CharField(max_length=100, null=True) image_urls = models.CharField(max_length=200) images = models.TextField(null=True) actress_image = models.TextField(null=True) class EnMovielist(models.Model): content_ID = models.CharField(max_length=30) release_date = models.CharField(max_length=30) running_time = models.CharField(max_length=10) actress = models.CharField(max_length=300) series = models.CharField(max_length=30) director = models.CharField(max_length=30) label = models.CharField(max_length=30) image_urls = models.CharField(max_length=200, null=True) images = models.TextField(null=True) image_paths = models.TextField(null=True) search.indexes.py : class EnActressIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField(document=True, use_template=True) en_name = indexes.CharField(model_attr='name') def get_model(self): return EnActress def index_queryset(self, using=None): return self.get_model().objects.all() class EnMovielistIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField(document=True, use_template=True) content_ID = indexes.CharField(model_attr='content_ID') release_date = indexes.CharField(model_attr='release_date') actress = indexes.CharField(model_attr='actress') label = indexes.CharField(model_attr='label') def get_model(self): return EnMovielist def index_queryset(self, using=None): return self.get_model().objects.all() This is an Error massage in Django VariableDoesNotExist at /search/ Failed lookup for key [actress_image] in 'EnMovielist object' Failed lookup for key [%s] in %r In template /home/ubuntu/venv/avdict/dmmactress/templates/search/search.html, error at line 122 112 {% load staticfiles %} 113 <table class="table table-striped table-hover" cellspacing="0" id='result_table'> 114 <thead> 115 <tr> 116 <th>phto</th> 117 <th>name</th> 118 </tr> 119 </thead> 120 <tbody> 121 <tr class="active"> 122 {% with image='enActress/'|add:result.object.actress_image %} 123 … -
Installed SSL successfully But Not able to access the WebPages
Everything is working fine, it's loading https connection But the URL which I want to access at that moment it gives error! For example - When I just enter https://example.com It gives Apache Default page giving a success message and this https://example.com/example_page gives error :The Requested URL was not found on this server And I have written code in django which is used to access webpages So Is there a problem in django code or some settings in Apache server ?? This question is all ready posted on Stackoverflow by me with a different account, Posting it again to get a better response. Am I missing some steps? Any help would be appreciated Thanks -
Django: Random ManyToMany relation is added on User connect
Strangest bug I ever encountered User model is the regular one from conrtib.auth.User Let's say I have the following model: python class Region(model.Model): name = models.CharField(max_length=256) rakazim = models.ManyToManyField(settings.AUTH_USER_MODEL) goal = models.IntegerField(default=0) and someplace else I have: python user_model = get_user_model() rakaz = user_model.objects.create_user(username, email, password) Then Immediately after the user creation method is called the "rakaz" instance has a random region connected python rakaz.region_set.all() = [<random_region>] It also sometimes connects to another model that has a similar ManyToManyField to AUTH_USER_MODEL I debugged with pdb into the user creation method (in auth contrib) and immediately after calling save inside this happens. AFAIK it happens only on the staging server, but until I find the reason I'm afraid to deploy to prod.. Django version 1.84. server using mariabdb on RDS I don't use signals in my code (and at all :) ) and can't find relevant third party code doing this, (And if so it would happen on my machine also) Any Ideas? -
detail not found when overriding get_queryset in ModelViewSet
I'm overriding get_queryset in a ModelViewSet to support "me" as filter and multiple pk search: class UserViewSet(viewsets.ModelViewSet): queryset = UserProfile.objects.all() serializer_class = UserProfileSerializer def get_queryset(self): qs = UserProfile.objects.all() if 'pk' in self.kwargs: pk_user = self.kwargs['pk'] if ',' in pk_user: # Multiquery pk_users = pk_user.split(',') qs = qs.filter(pk__in=pk_users) elif pk_user == "me": qs = qs.filter(pk=self.request.user) else: qs = qs.filter(pk=pk_user) # By default return all the items return qs I'm using the following serializer: class UserProfileSerializer(serializers.ModelSerializer): avatar_thumbnail_small = serializers.ImageField(read_only=True) avatar_thumbnail_medium = serializers.ImageField(read_only=True) id = serializers.CharField(source='user.id') username = serializers.CharField(source='user.username') firstname = serializers.CharField(source='user.first_name') lastname = serializers.CharField(source='user.last_name') class Meta: model = UserProfile fields = ('id', 'username', 'firstname', 'lastname', 'karma', 'avatar_thumbnail_small', 'avatar_thumbnail_medium', 'contacts', 'suggested_contacts') and I've registered the url in urls.py router.register(r'users', app.views_rest.UserViewSet, base_name="users") but when I tried to GET the url /api/users/2,3/ or /api/users/me/ it gives a json message saying that detail is not found. /api/users/2/, /api/users/3/ and /api/users/ works fine. Thanks for the help. -
Sidebar tab in django
I want to create a sidebar tab/menu. I already have dropdown menu in nav header, which is as follows: I want to show this dropdown menu item to the home page sidebar. Therefore in my sidebar either Alumnai tab contains all the dropdown items or they individually show in stacked tabs. And naturally when I click them they should give correct output as it working now. I have three Models. My present urls: #Member url(r'^person/$', views.PersonListView.as_view(), name='person-list'), # Executive Member url(r'^execomember/$', views.ExeCommListView.as_view(), name='execomember-list'), My related views: class PersonListView(generic.ListView): model = Person context_object_name = 'persons' class ExeCommListView(generic.ListView): model = ExecMember context_object_name = 'members' How can I make my sidebar? -
Develop mobile app and web application with Django, Firebase and Ionic
I want to develop a project with a mobile app and a web application where users can login and add different things from a web interface. What is a good way to develop this project? I consider to use Firebase( New on Firebase) as database, Django as backend to the web and ionic for app prototype, later with native languages. Or I should use a relational database? Is Django easy/good with Firebase? There will be many relational tables. I heard from sometimes ago, Firebase is not so good with relations. -
Django CMS absolute url for Elasticsearch
i write a command for django app like this : for p in Article.public.all(): data += '{"index": {"_id": "%s", "_type": "article"}}\n' % p.pk data += json.dumps({ "title": p.title, "category": p.category.category, "content_type": p.content_type, "duration": p.get_audio_duration(), "thumbnail": p.get_thumbnail(), "date": datetime.strftime(p.date, '%d.%m.%Y'), "url": p.get_absolute_url(), "content": p.content }) + '\n' response = requests.put('{}/radio_index/_bulk'.format(settings.ES_URL), data=data) get_absolute_url method looks like this: def get_absolute_url(self): return reverse('tv_article_hook:article_tv_detail', kwargs={'slug': self.slug}) When i am using get_absolute_url in template or in REST api it works fine. But when i run command via manage.py feed_index code fails on p.get_absolute_url with error: django.core.urlresolvers.NoReverseMatch: Reverse for 'article_tv_detail' with arguments '()' and keyword arguments '{'slug': 'some slug'}' not found. 0 pattern(s) tried: [] How can i solve this problem ? -
Django filter objects
I am fetching the users who did login today as follows: today_login_count= User.objects.filter(last_login__startswith=timezone.now().date()).count() I want to further filter results and fetch only those users whose username starts with yg_ How can I modify my code? -
Inclusion templatetag with counter
What I want Inclusion Templatetag which returns number of uses and don't break when using template inheritance. I tried to storage counter in context, but it does not work as I intended. base.html {% block body %} {% my_tag %}<br> {% my_tag %}<br> {% endblock %} page.html {% extends 'base.html' %} {% block body %} {{ block super }} {% my_tag %}<br> {% my_tag %}<br> {% endblock %} rendered result: 1 2 3 4 What I tried @register.inclusion_tag('tagtemplate.html', takes_context=True) def my_tag(context): counter = context.get('tag_counter', 1) ctx = {'tag_counter': counter} context['tag_counter'] = counter + 1 return ctx And result: 1 2 1 2 -
"CSRF token missing" with PUT/DELETE meethod rest-framework
I'm using using django rest framework browsable api with ModelViewSet to do CRUD actions and want to use permissions.IsAuthenticatedOrReadOnly, but when I'm logged and try to DELETE or PUT I get "detail": "CSRF Failed: CSRF token missing or incorrect." My view looks like this class objViewSet(viewsets.ModelViewSet): queryset = obj.objects.all() serializer_class = objSerializer permission_classes = (permissions.IsAuthenticatedOrReadOnly,) Settings.py REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.AllowAny', ), Serializer is just class ObjSerializer(serializers.ModelSerializer): class Meta: model = Obj Although when I delete permission_classes (so the default allowAny triggers) I can it works just fine. -
How to name model's foreignkey field in Django?
In Django, I can name each field of model like this(In Korean): description = models.CharField("설명", max_length=100, blank=True) image = ImageField("이미지", upload_to=upload_location) but in case of ForeignKey, it doesn't work. album = models.ForeignKey("앨범", Album) Why does it not work only on ForeignKey? -
how to login by instgram api python
Hello i want to login with instagram from my python apps. When i try to login i got error "redirect url not matched with registered url" and i set redirect URIs is "http://127.0.0.1:8000/accounts/instagram/login/callback/" and "http://127.0.0.1:8000/complete/instagram" i got same error. Please help me how we connect with my apps to instagram api -
Django Logging error
I am using the default logger in Django in models.py like this. import logging logging.basicConfig(filename='models.log',level=logging.INFO) logging.info('Staring execution. Models for db tables') It is working in the Django server and logs are getting written. When the app is being deployed on Apache, I get a 500 Internal Server error and cannot even load the home page. The OS is RHEL7. I have changed the file permission of "models.log" to read-write". Still I face the issue. In apache conf file, I have granted permissions as well. -
I/O operation on closed file: Django Imagekit & Pillow
I am using django imagekit and pillow to upload images which was working fine in django 1.7. Recently we shifted to django 1.10 and now the image upload is not working. Code snippet is: class Images(models.Model): image = ProcessedImageField(upload_to='main', processors=[ResizeToCover(640, 640)], format='JPEG', options={'quality': 90}) image_thumbnail = ProcessedImageField(upload_to='thumbnails', processors=[SmartResize(128, 128)], format='JPEG', options={'quality': 70}) user = models.ForeignKey(User) def upload_image(self, image, user): if len(image.name) > 30: image.name = image.name[:20] i = Images.objects.create(image=image, image_thumbnail=image, user=user) return i The traceback is: File "C:\Python35\lib\site-packages\imagekit\specs\__init__.py" in generate 149. img = open_image(self.source) File "C:\Python35\lib\site-packages\pilkit\utils.py" in open_image 21. target.seek(0) During handling of the above exception (I/O operation on closed file.), another exception occurred: File "C:\Python35\lib\site-packages\django\core\handlers\exception.py" in inner 39. response = get_response(request) File "C:\Python35\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response 249. response = self._get_response(request) File "C:\Python35\lib\site-packages\django\core\handlers\base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "C:\Python35\lib\site-packages\django\core\handlers\base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "C:\Python35\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view 23. return view_func(request, *args, **kwargs) File "C:\Users\sp\industryo\nodes\views.py" in set_logo 173. i = Images.objects.create(image=image, user=user, image_thumbnail=image) File "C:\Python35\lib\site-packages\django\db\models\manager.py" in manager_method 85. return getattr(self.get_queryset(), name)(*args, **kwargs) File "C:\Python35\lib\site-packages\django\db\models\query.py" in create 399. obj.save(force_insert=True, using=self.db) File "C:\Python35\lib\site-packages\django\db\models\base.py" in save 796. force_update=force_update, update_fields=update_fields) File "C:\Python35\lib\site-packages\django\db\models\base.py" in save_base 824. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "C:\Python35\lib\site-packages\django\db\models\base.py" in _save_table 908. result … -
Atomic transaction on django queryset.update(**kwargs)
It seems Django's queryset.update method execute under transaction.atomic context manager. When would I need to do that explicitly in my code during update? Or what will be the benefits doing it, or problems not doing it? Code try: queryset = Model.objects.filter() if queryset.count(): with transaction.atomic(): queryset.update(**kwargs) # seems like queryset will [] after this. for item in queryset: item.emit_event('Updated') except: logger.info('Exception') My question is do I really need to have transaction.atomic(): here? Secondly, after .update my queryset gets empty. how to retain the values in my case as I want to emit an event on the individual objects. -
Request.Post or None django
In this youtube video In minute 17:52 he have some staff on the screen. First, This line: form = SignUpForm(request.POST or None) And second line: print request.POST['mail'] i didnt undarstanad his enlish to understand two things: What are the two parameters in the constructor are doing? Why he say its not good to print the data like he did? what that does to the form sending?