Django - filters
Hello all, In my django application, all the data of different clients are entered. Sometimes data of even same client is also entered. Now what I require is to get all the data of the client when it asked for. The views I used is: def old_client(request): if request.method == 'POST': form = OldClientadd(request.POST) if form.is_valid(): from TCC11_12.automation.functions import * cd = form.cleaned_data name_and_address = cd['name_and_address'] title = get_object_or_404(Variable, pk='1') sign = get_object_or_404(Variable, pk='3') from TCC11_12.automation.choices import * client = ClientJob.objects.filter(name_and_address=name_and_address) amount = Amount.objects.all() suspence = Suspence.objects.all() total_temp = Amount.objects.aggregate(Sum("total")) total = int(total_temp['total_sum']) net_total_temp = Amount.objects.aggregate(Sum('net_total')) net_total= int(net_total_temp['net_total__sum']) template ={'form':form, 'total':total,'title':title ,'sign':sign, 'net_total':net_total, 'client':client,'amount':amount,'suspence':suspence,'name_and_address':name_and_address ,} return render_to_response('automation/oldclient.html',locals(), context_instance=RequestContext(request)) else: form = OldClientadd() return render_to_response('automation/client.html', {'form': form}, context_instance=RequestContext(request)) Here I get filtered the data of the client I require, from amount and client table. But when I go for the sum, it add all the data in amount field without providing any filter. Is there any way to find aggregate sum of only those amounts that are previously filtered ? I cannot give filter on amount as name and address field is not there in Amounts table. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Views in django
Can I apply some operations on the views ( of database) that are created by me? Eg: to do sum of some filtered entries. If yes, then how? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Views in django
On Fri, Feb 3, 2012 at 7:52 PM, Weldan wrote: > Entries.objects.count() > That will be applicable if I want to his for only 1 table's entry. But here I have views as : cd = form.cleaned_data name_and_address = cd['name_and_address'] title = get_object_or_404(Variable, pk='1') sign = get_object_or_404(Variable, pk='3') from TCC11_12.automation.choices import * client = ClientJob.objects.filter(name_and_address=name_and_address) amount = Amount.objects.all() suspence = Suspence.objects.all() and for this I have template as : {% if client %} {% for clients in client %} {% for amounts in amount %} {% if clients.job_no == amounts.job_no %} {% if clients.name_and_address == clients.name_and_address %} {{ clients.receipt_no }} {{ clients.date }} {{amounts.total}} {{amounts.net_total}} {% endif %} {% endif %} {% endfor %} {% endfor %} {% endif %} When all this is applied, it creates a view out of 2 tables i.e Amount and ClientJob without using foreign key. Now I want to have sum of the total and net_total fields for the views generated. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Views in django
On Sun, Feb 5, 2012 at 1:33 AM, Peter of the Norse wrote: > You should look into making a foreign key relationship if there actually is > one. That way you can just annotate the the sums. Opted for the same now. > Otherwise you should calculate the sum in the view (NOT the template) and add > it to the client. Python allows you to add any value you >want to any object. > Thank you for your suggestions. :-) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Foreign Key + Primary key
Is there any way of having a field in table, declared both as foreign key as well as primary key? I want something like this in models: publisher = models.ForeignKey(Publisher,primary_key=True) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Implementing Foreign Key without admin interface
I am using forms, to make the entries from the user. But when it comes to using foreign key in a table and then making entries to it, I am unable to do so. See my code: models.py: class ClientJob(models.Model): """ :ClientJob: ClientJob Class is define all field reqiued to submit detail about new Job. """ job_no = models.AutoField(primary_key=True) receipt_no = models.CharField(max_length=15, editable=False) ... class Amount(models.Model): id = models.AutoField(primary_key=True) job_no = models.ForeignKey(ClientJob) . and my views.py is def report_calculation(request): id = ClientJob.objects.aggregate(Max('job_no')) maxid =id['job_no__max'] if request.method == 'POST': form =AmountForm(request.POST) if form.is_valid(): cd = form.cleaned_data job_no_id = client.job_no ... form.save() return render_to_response('automation/job_ok.html', {'form': form, 'maxid':maxid}, context_instance=RequestContext(request)) else: form = AmountForm() return render_to_response('automation/job_add.html', {'form': form, 'maxid': maxid}, context_instance=RequestContext(request)) Am I wrong somewhere? How should I do this? Please help!! -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Implementing Foreign Key without admin interface
On Fri, Mar 9, 2012 at 4:31 AM, Ramiro Morales wrote: > On Thu, Mar 8, 2012 at 4:44 PM, Sandeep kaur wrote: >> job_no_id = client.job_no >> ... >> Am I wrong somewhere? How should I do this? Please help!! > > Yes, that client variable appears magically. Please paste working code, > an abridged version but working code. > Sorry for very late reply. See my code at : https://github.com/sandeepmadaan/TCC11_12_1/tree/master/TCC -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Tables with Foreign Key does not get filled
In my application, I am using forms for the users to enter the information. In this, I have linked two tables by using foreign key. Here are the 2 tables: models.py> - class ClientJob(models.Model): """ :ClientJob: ClientJob Class is define all field reqiued to submit detail about new Job. """ job_no = models.AutoField(primary_key=True) receipt_no = models.CharField(max_length=15, editable=False) type_of_consultancy = models.CharField(max_length=15,choices=CONSULTANCY_CHOICES) date = models.DateField(default=datetime.date.today()) site = models.CharField(max_length=600, blank=True ) type_of_work = models.CharField(max_length=20,choices=ORGANISATION_CHOICES) letter_no = models.CharField(max_length=100, blank=True,) letter_date = models.CharField(blank=True, max_length=15 ) file_disposal = models.CharField(max_length=20, choices=MATERIAL_CHOICES) report_type = models.CharField(max_length=20,choices=REPORT_TYPE) class ClientJobForm(ModelForm): class Meta : model = ClientJob widgets = { 'name_and_address': TextInput(attrs={'size': 60}), 'site': TextInput(attrs={'size': 60}), } class Amount(models.Model): job_no = models.ForeignKey( ClientJob) date = models.DateField(default=datetime.date.today(), editable=False) lab = models.CharField(max_length=100, choices=LAB_CHOICES) field = models.CharField(max_length=100,choices=FIELD_CHOICES) other_field = models.CharField(max_length=100,blank=True,null=True) type = models.CharField(max_length=10, choices=PAYMENT_CHOICES) def __unicode__(self): return self.id() class AmountForm(ModelForm): class Meta : model = Amount --- and for these fields to be filled I have views as: views.py> - def report_calculation(request): id = ClientJob.objects.aggregate(Max('job_no')) maxid =id['job_no__max'] if request.method == 'POST': form =AmountForm(request.POST) if form.is_valid(): cd = form.cleaned_data #job_no = cd['job_no'] type = cd['type'] #sandeep lab = cd['lab'] field = cd['field'] other_field = cd['other_field'] id = ClientJob.objects.aggregate(Max('job_no')) client = ClientJob.objects.get(job_no=maxid) p = Amount(job_no=client,date=datetime.date.today(),type=type,lab=lab,field=field,other_field=other_field,) p.save() return render_to_response('automation/job_ok.html', {'form': form, 'maxid':maxid}, context_instance=RequestContext(request)) else: form = AmountForm() return render_to_response('automation/job_add.html', {'form': form, 'maxid': maxid}, context_instance=RequestContext(request)) ------ But unfortunately these fields are not filled in Amount. However when job_no is not taken as foreign key, everything works fine. Please help me figure out the error. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Foreign Key don't work for me
In my Django application, I am using forms for the users to enter the information. In this, I have linked two tables namely, ClientJob and Amount, by using foreign key. Here are the 2 tables: models.py> - class ClientJob(models.Model): """ :ClientJob: ClientJob Class is define all field reqiued to submit detail about new Job. """ job_no = models.AutoField(primary_key=True) receipt_no = models.CharField(max_length=15, editable=False) type_of_consultancy = models.CharField(max_length=15,choices=CONSULTANCY_CHOICES) date = models.DateField(default=datetime.date.today()) site = models.CharField(max_length=600, blank=True ) type_of_work = models.CharField(max_length=20,choices=ORGANISATION_CHOICES) letter_no = models.CharField(max_length=100, blank=True,) letter_date = models.CharField(blank=True, max_length=15 ) file_disposal = models.CharField(max_length=20, choices=MATERIAL_CHOICES) report_type = models.CharField(max_length=20,choices=REPORT_TYPE) class ClientJobForm(ModelForm): class Meta : model = ClientJob widgets = { 'name_and_address': TextInput(attrs={'size': 60}), 'site': TextInput(attrs={'size': 60}), } class Amount(models.Model): job_no = models.ForeignKey( ClientJob) date = models.DateField(default=datetime.date.today(), editable=False) lab = models.CharField(max_length=100, choices=LAB_CHOICES) field = models.CharField(max_length=100,choices=FIELD_CHOICES) other_field = models.CharField(max_length=100,blank=True,null=True) type = models.CharField(max_length=10, choices=PAYMENT_CHOICES) def __unicode__(self): return self.id() class AmountForm(ModelForm): class Meta : model = Amount --- and for these fields to be filled I have views as: views.py> - def report_calculation(request): id = ClientJob.objects.aggregate(Max('job_no')) maxid =id['job_no__max'] if request.method == 'POST': form =AmountForm(request.POST) if form.is_valid(): cd = form.cleaned_data #job_no = cd['job_no'] type = cd['type'] #sandeep lab = cd['lab'] field = cd['field'] other_field = cd['other_field'] id = ClientJob.objects.aggregate(Max('job_no')) client = ClientJob.objects.get(job_no=maxid) p = Amount(job_no=client,date=datetime.date.today(),type=type,lab=lab,field=field,other_field=other_field,) p.save() return render_to_response('automation/job_ok.html', {'form': form, 'maxid':maxid}, context_instance=RequestContext(request)) else: form = AmountForm() return render_to_response('automation/job_add.html', {'form': form, 'maxid': maxid}, context_instance=RequestContext(request)) ---------- But unfortunately these fields are not filled in Amount. However when job_no is not taken as foreign key, everything works fine. Please help me figure out the error. -- Sandeep Kaur -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Foreign Key don't work for me
On Thu, May 17, 2012 at 6:09 AM, Jon Paugh wrote: > Ah. I believe, the Amount.job_no (i.e. the foreign key) should not be filled > with the id of the Client object, but with the actual client object, that > is, > > job_no = Client.objects.get(cd['job_no']) > > That matches the abstract relationship of, "This Client corresponds to this > Amount.", then Django takes care of the db details, i.e. finding the pk. > Changed the views, even then, tasted no success. I have changed the views to: def report_calculation(request): id = ClientJob.objects.aggregate(Max('job_no')) maxid =id['job_no__max'] if request.method == 'POST': form =AmountForm(request.POST) if form.is_valid(): cd = form.cleaned_data #job_no = cd['job_no'] type = cd['type'] #sandeep lab = cd['lab'] field = cd['field'] other_field = cd['other_field'] job_no = ClientJob.objects.get(cd['job_no']) p = Amount(job_no=job_no,date=datetime.date.today(),type=type,lab=lab,field=field,other_field=other_field,) p.save() return render_to_response('automation/job_ok.html', {'form': form, 'maxid':maxid}, context_instance=RequestContext(request)) else: form = AmountForm() return render_to_response('automation/job_add.html', {'form': form, 'maxid': maxid}, context_instance=RequestContext(request)) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Database Query in Shell
I have a table Amounts which has 2 columns field and other_field. These columns are filled in such a way that either other_field is null or other_field = field. I want to make a database query such that if field == other_field : field = "OTHER" else: field = field That means the entries in table where 2 columns are equal, there field should be assigned a string "OTHER" and other_field should remain as such. How can I give such query in shell. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Database Query in Shell
On Sun, May 27, 2012 at 6:05 PM, wrote: > To get a queryset containing all the objects where field == other_field > should be something like the following: > > from django.db.models import F > > Amounts.objects.filter(field = F("other_field")) > > to then update all those objects with "OTHER" as the value for field would > be: > > Amounts.objects.filter(field = F("other_field")).update(field="OTHER") > > Note that this won't execute the "else" portion above, but as it is not > making any change (field already equals field), I assume this isn't an > issue. > You are great, sir. Thank you. The query successfully updated the field column as was required. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: to add counter in the project
On Tue, Jul 3, 2012 at 11:55 AM, Bharati Sharma wrote: > I want to add counter in my project so that the value in the table increases > as the data is put in the database. Can anyone help me plz. > If you want a counter in database, you can make it auto-increment. Like I want job_no as a counter field in a table, then in models.py, add this : job_no = models.AutoField(primary_key=True) But if you want the counter in tables in the template file then add {{forloop.counter}} as your table field. Correct me if I am wrong anywhere. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django TypeError
I want to have different views for my application for different types of users. For this I have this code for my views.py file : def index1(request): u = User.objects.all() if u.is_staff ==1 and u.is_active == 1 and u.is_superuser == 1: return render_to_response('tcc11_12/index1.html', context_instance=RequestContext(request)) elif u.is_staff == 1 and u.is_active == 1 and u.is_superuser == 0: return render_to_response('tcc11_12/index2.html', context_instance=RequestContext(request)) else: return render_to_response('index3.html', context_instance=RequestContext(request)) But it gives TypeError as : "cannot convert dictionary update sequence element #0 to a sequence" Is there anything wrong in above code? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django TypeError
On Tue, Jul 17, 2012 at 11:59 AM, @@ wrote: > u = User.objects.all() > u is not a user. > Oh yes, thank you for pointing. Please help me with this : How can I get the user id or 'u' of the user who has login using Django inbuilt authentication, so that I can give different views to the users based on there permissions ? Thanks in advance. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django TypeError
On Wed, Jul 18, 2012 at 3:13 PM, kenneth gonsalves wrote: > On Wed, 2012-07-18 at 14:10 +0530, Sandeep kaur wrote: > request.user Thank you sir , this was helpful. :) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Dynamic forms
I want to have a form, with drop down list and then multiple select checkboxes dynamically filtered based on drop down selection. I have searched a lot but did not find a complete solution for my requirement. Also I want to ask that can we do this without apply java query ? Means if a browser doesn't support java, how would our could run? Help would be really appreciated. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Dynamic forms
On Tue, Jul 31, 2012 at 11:59 AM, Satinder Goraya wrote: > Lets say that you need a form with a drop-down list that have dynamic > values. With Django this can be done simple and fast. > my_choice_field). With this code get_my_choices is called on every > form load and you will get your dynamic drop-down. This code is useful for bringing the drop down options from the database. But I want to have the dynamically filtered options from the last selected options without refreshing the page. I have used the following code but it is not working according to my requirement. Please check and point out where I am making mistake. from django import template register = template.Library() @register.inclusion_tag("field_test_select.html") def field_test_select(request): field_list = Field.objects.all() return render_to_response('field_test_select.html', {'field_list' : field_list}, context_instance=RequestContext(request)) def all_json_tests(request, field): current_field = Field.objects.get(id=field) test = Test.objects.all().filter(field=current_field) json_test = serializers.serialize("json", test) return HttpResponse(json_test, mimetype="application/javascript") (r'^add_job/$', 'field_test_select'), (r'^field/(?P[-\w]+)/all_json_tests/$', 'all_json_tests'), Select a field {% for field in field_list %} {{ field.name }} {% endfor %} Select a test $(document).ready( function() { $("select#field").change(function() { if ($(this).val() == 'Z') { $("select#test").html("<option>Select a test</option>"); $("select#test").attr('disabled', true); } else { var url = "/field/" + $(this).val() + "/all_json_tests"; var field = $(this).val(); $.getJSON(url, function(tests) { var options = '<option value="Z">Select a test</option>'; for (var i = 0; i < tests.length; i++) { options += '<option value="' + tests[i].pk + '">' + tests[i].fields['name'] + '</option>'; } $("select#test").html(options); $("select#test option:first").attr('selected', 'selected'); $("select#test").attr('disabled', false); }); //} }); $("select#test").change(function(vent) { if ($(this).val() == -1) { return; } myAwesomeFunctionToCallWhenAtestIsSelected(); }); }); } -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Calculations in Queries
On Thu, Aug 16, 2012 at 2:31 AM, Callum Bonnyman wrote: > I am creating a popular page for my app and for the most part this is just > to gain an understanding. > Any ideas? I know its something to do with query expressions and looking at > this page confuses the hell out of me. Any guidelines, or is this even > achievable? > Why don't you use sessions for the same. That is, in a session find number of clicks on the pages by a user, then save it in database. Then just get the page that has maximum clicks, that will be the most popular page. Just a wild idea. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Using sessions in Django
I am using session foreign key in my table. class ClientJob(models.Model): #models.py . sess = models.ForeignKey(Session) And in order to save its value in database, I used ,. def add_job(request) #views.py ... if not request.session.exists(request.session.session_key): request.session.create() profile.sess = request.session.session_key profile.save() But when I execute my form and click on submit button, I get error as : ```Cannot assign "'b593c61453d7aad199078c66b9ad6b30'": "ClientJob.sess" must be a "Session" instance. I am a bit unclear about using sessions in django, so be a little elaborative. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using sessions in Django
On Fri, Aug 17, 2012 at 1:42 PM, Thomas Orozco wrote: > Session key is the session 's primary key. Not the session itself. > > What you want to assign to your field is a session, not its key. So use > request.session. > > However. > > Please very careful when using FK' s to sessions, sessions are meant to be > short lived, and could / should be deleted once they expire (ie. When the > user logs off or after a specific duration), depending on your backend. > > I'm not sure what you're trying to achieve, but I think that FKing to > sessions is, at the very list, pretty risky. > > Especially given that the default on delete behavior of a ForeignKey is > cascade. You are right. Actually, I want a cart like system. Like in my project's case, if a client want to test multiple material in one job, it should generate one bill and receipt. But for each different material, different jobs are created. So, I thought it could be achieved by storing the session in which the user logged and then get the bill generated based on that session. If you find it a vague solution, do tell the most optimum solution. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using sessions in Django
On Fri, Aug 17, 2012 at 1:39 PM, Amyth Arora wrote: > I think this is because you are passing it the "Session Key" instead > of the "Session Instance", you need to get the session instance and > then pass it to your function, Something like this: > > profile.sess = Session.objects.get(session_key=request.session.session_key) > Thanks a lot. This worked. :) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using sessions in Django
On Fri, Aug 17, 2012 at 1:28 PM, Sandeep kaur wrote: > I am using session foreign key in my table. > if not request.session.exists(request.session.session_key): > request.session.create() > profile.sess = request.session.session_key > profile.save() > > But when I execute my form and click on submit button, I get error as : > > ```Cannot assign "'b593c61453d7aad199078c66b9ad6b30'": > "ClientJob.sess" must be a "Session" instance. > Problem solved!! Used this code : if not request.session.exists(request.session.session_key): request.session.create() profile.sess = Session.objects.get(session_key=request.session.session_key) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Saving the form containing checkboxes
I want to have checkboxes in my form. For that I took the table field as ManyToManyField. When the template renders the form as its models, it correctly save the values in database, but when I create the form with same fields myself i templates, it does not save the values. I don't know where I am going wrong. My code is : views.py-> def search(request): query =request.GET.get('q', '') field_list = Material.objects.all() if query: material =Material.objects.get(id=request.GET['q']) test = Test.objects.all().filter(material_id = query) if request.method=='POST': form = JobForm(request.POST) if form.is_valid(): cd = form.cleaned_data site =cd['site'] test = request.POST.getlist('test') type_of_work = cd['type_of_work'] profile = form.save(commit=False) id = ClientJob.objects.aggregate(Max('job_no')) maxid =id['job_no__max'] if maxid== None : maxid = 1 else: maxid = maxid + 1 profile.job_no = maxid profile.client = request.user profile.save() form.save_m2m() form.save() return render_to_response('tcc/new_client_ok.html', {'form': form,}, context_instance=RequestContext(request)) else: form = JobForm() return render_to_response('tcc/search.html', {'form': form,"query": query,"test":test,"material":material,"field_list":field_list}, context_instance=RequestContext(request)) else: results = Material.objects.all() return render_to_response('tcc/tags.html',{'field_list':field_list}, context_instance=RequestContext(request)) -- search.html--> Search{% if query %} Results{% endif %} Search {% for field in field_list %} http://localhost/automation/tcc11_12/search/?q={{field.id}}";>{{field.name}} {% endfor %} {% csrf_token %} {% if query %} Tests for "{{ material.name}}": Name : {{ material.name}} Site: check testsTest NameQuantityCosts {% if test %} {% for tests in test %} {{tests.name }}{{tests.quantity }}{{tests.cost }} {% endfor %} {% endif %} {% else %} No material found {% endif %} Please do point me out where I am going wrong. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Conditions in template slows down the software
I have used many condition in my templates, in order to filter my results. My template file uses this code : {% for clients in client %} {% for amounts in amount %} {% for suspences in suspence %} {% for tadas in tada %} {% for transports in transport %} {% if clients.job_no == amounts.job_no%} {% if clients.job_no == suspences.job_no %} {% if clients.job_no == tadas.job_no %} {% if clients.job_no == transports.job_no %} {{ clients.job_no}} {{ clients.date }} {{ clients.receipt_no }} {{clients.name_and_address}} {{amounts.field}} ... ... This code slows down the system to a great extent. Please suggest me an alternate and better solution. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with formset
On Fri, Nov 2, 2012 at 1:41 AM, Lachlan Musicman wrote: > > I think you are saying you don't understand my response? I'm asking if the > problem is fixed by replacing formset.save() - with cd.save(), since you > have cd = formset.cleaned_data but no other instances of cd, making it kinda > useless? > > should here be a cd = ObjectName() in there? > According to me, he need not to assign cd, because it is then not used anywhere to clean the form data. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: no Polls in the admin page
On Fri, Nov 2, 2012 at 12:29 AM, Mihail Mihalache wrote: > I have followed the django tutorial up to part 2 - > https://docs.djangoproject.com/en/1.4/intro/tutorial02/ . > Everything worked fine, until I couldn't see the Polls entry on the admin > page. I have checked that I have done everything mentioned in the tutorial. > I get no error whatsoever. I have no idea what's wrong. > There is a polls entry INSTALLED_APPS. > Your admin.py file should have this code : - from mysite.polls.models import Poll from django.contrib import admin from mysite.polls.models import Choice class ChoiceInline(admin.TabularInline): model = Choice extra = 3 class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), ('Date information', {'fields': ['pub_date']}), ] inlines = [ChoiceInline] list_display = ('question', 'pub_date') list_filter = ['pub_date'] search_fields = ['question'] admin.site.register(Poll, PollAdmin) - -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ViewDoesNotExist'module ' object has no attribute 'Form'
On Fri, Nov 16, 2012 at 11:00 AM, muhammed riyas wrote: > > while using django forms i gt an error 'view does not exist' > > from django import forms > > class Employeeprofileform(forms.Form): > employee_name = forms.CharField(max_length=100) > employee_number = forms.IntegerField() > employee_email = forms.EmailField() > employee_mobilenumber = forms.IntegerField() > employee_address = forms.CharField() > .? > iam using django 1.2 > I think you are using old version of Django. Try this : python manage.py shell >>> from django import forms #input >>> forms.Form #input #output If you don't get this output, you are using old version of Django. Use new version. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Adding rows to the form
On Thu, Nov 15, 2012 at 4:53 PM, Satinderpal Singh wrote: > Hi friends, > I want to create a form so that the tables related to the form accepts > the multiple values by adding rows in the form, just like in gmail > only the first entry of the first row but not saved the entries of the > rows that can be added by the add button. > Can anybody tell me how would i solve this problem. Any help would be > highly appreciated. > This may be helpful : http://stellarchariot.com/blog/2011/02/dynamically-add-form-to-formset-using-javascript-and-django/ -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ModelForm excluded one field but it excludes another field
On Tue, Nov 13, 2012 at 1:17 PM, Rohit Banga wrote: > Hi All > > model = ConcreteModel2 > exclude = ('field3_test') > > > Now as you can see there are parallels between the two model forms. > The problem is that in my template field1 is visible for ConcreteModel1Form > (expected behavior) > But in another template field3 is not visible for ConcreteModel2Form > (unexpected behavior). > > If I comment out exclude=('field3_test') then field3 is visible in the > template (expected behavior) but form validation fails since field3_test is > None and is a required field. > > What am I missing? This seems to be a problem with my code that i can't > figure out. This behavior is clearly inconsistent and I am not able to see > the difference in my code. > > Any ideas how to debug this? What could be the problem? > When we exclude a field from a form, that field become invisible. But as we know, that it is mandatory to fill the foreign key value (else the form will become invalid), so you should by some way give some value to foreign key field. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
On Fri, Nov 16, 2012 at 10:59 AM, Cj Taylor wrote: > Hello all, > I'm new to Django and somewhat Python (a PHP refugee). I have been > learning Python 3.0 so decided to give 1.5 a run. I tried to run the > command below and mysqldb is missing. I noticed on > http://mysql-python.blogspot.com/ that mysqldb won't be ready for 3.0 until > the 1.3 release. So I guess the question is if there's any kind of > workaround at the moment? > > raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: > No module named MySQLdb > Try this : sudo apt-get install python-mysqldb -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
On Sun, Nov 18, 2012 at 4:11 AM, Cj Taylor wrote: > That package installs into my python directory but not python3. I'm > currently trying to get Django 1.5 to work with python3. Are there other > ways currently to get mysql to work with django and the python3 environment? See if this helps : https://github.com/vsajip/MySQL-for-Python-3 -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: why the else statement {% else %} is not working...?
On Mon, Nov 19, 2012 at 1:46 PM, muhammed riyas wrote: > > > > Employee List > {% if employees %} > {% for employee in employees %} > {{ > employee.employee_name }} > {% endfor %} > Click here to remove > all employees > {% else %} > Sorry there is no employees yet :( > {% endif %} > > > I don't find any errors here. I think you are always getting employees, that's why only if part works and else part doesn't work. :p -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: why the else statement {% else %} is not working...?
On Mon, Nov 19, 2012 at 4:24 PM, muhammed riyas wrote: > no even there is no employees i didnt got it > Show your views too. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Editing model instance
I edit value of a table using model instance, however after editing I want the values to be saved in some other table with same structure. For this to happen I have used following code in views.py : def editjob(request): clientjob = ClientJob.objects.get(job_id = query) if request.method == "POST": jform = editJobForm(request.POST, instance=job) sform = editClientJobForm(request.POST, instance=clientjob) if jform.is_valid() and sform.is_valid(): jform.save() sform.save() return render_to_response('tcc/succes.html',context_instance=RequestContext(request)) else: jform = editJobForm(instance=job) sform = editClientJobForm(instance=clientjob) return render_to_response('tcc/edit_job.html', {'jform': jform,'sform':sform},context_instance=RequestContext(request)) where : class editJobForm(forms.ModelForm): class Meta : model = EditJob exclude= ['client','job_no','id'] class editClientJobForm(forms.ModelForm): class Meta : model = ClientEditJob exclude= ['job'] However this code saves the value in same instance itself. What I want is to get old values from table: Job and ClientJob and then after editing get saved in tables: EditJob and ClentEditJob. Is this possible? Your help will be appreciated. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Editing model instance
On Thu, Nov 22, 2012 at 4:54 PM, Sergiy Khohlov wrote: > Have you tried to change instances to your new tables ? > If I try instance of new table, I won't get the old values that I need to edit. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Editing model instance
On Thu, Nov 22, 2012 at 5:32 PM, Sergiy Khohlov wrote: > you can set values in form via form __init__ > Values of some other instance? How? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Editing model instance
On Fri, Nov 23, 2012 at 7:25 PM, Victor Rocha wrote: > For starters, I see more than one thing wrong with your code. I hope thats > not the one your actually using and it was just a typo when you asked the > question. > + jform = editJobForm(request.POST, instance=job) # job has not being > defined. > Also when you instantiate your form, you want to use and instance of the > class your want to use, for instance. gi > clientjob = ClientEditJob.objects.get(job_id =query) > job = EditJob.objects.get(job_id=query) > If I do this I won't get previously filled values of ClientJob table which I need for editing. ClientEditJob table is empty. > Right now you using this: clientjob = ClientJob.objects.get(job_id = query). > ClientJob is not a model for any of the two forms you are using. > I think you haven't understood what I want. I don't say my code is correct, Because if it would be, I would have got my results. Please help me change it to correct one. What I want to do : Get instance of one table, which after editing get saved to some other table. What I get : I get values of one table and after editing it get saved to the same table. :( -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: IntegrityError
On Tue, Dec 18, 2012 at 2:48 AM, Satinderpal Singh wrote: > I created a search box for searching the information about the client > so that this information uses to create the report. add these lines : > def search(request): > {% endfor %} > > i want to get job id to be saved through header view: > def header(request): job =Job.objects.get(id=request.GET['q']) > if request.method=='POST': > form = headForm(request.POST) > if form.is_valid(): > cd = form.cleaned_data profile = form.save(commit=False) profile.job = job profile.save() form.save() > HttpResponseRedirect(reverse('Automation.report.views.result')) > > But get the following error: > IntegrityError at /report/header/ > (1048, "Column 'job_id' cannot be null") > > Please anybody tell me where i am wrong? > Hope this helps you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with django sitemap
On Sun, Dec 16, 2012 at 10:55 PM, Frankline wrote: > > I'm having a problem implementing the sitemaps in my application. I'm > > ImportError at /sitemap.xml > > No module named django.contrib.sitemaps > > Request Method: GET > Request URL: http://localhost:8000/sitemap.xml > Django Version: 1.4.2 > Exception Type: ImportError > Exception Value: > > No module named django.contrib.sitemaps > > Exception Location: > /home/frank/Projects/python/django/techjobsea.com/baseline27/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py > in import_module, line 35 > Python Executable: > /home/frank/Projects/python/django/techjobsea.com/baseline27/bin/python > Python Version: 2.7.3 > Are you sure, you followed all the installation steps, especially step 3 in : https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/ -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with django sitemap
On Tue, Dec 18, 2012 at 1:17 PM, Frankline wrote: > But the sites framework has already been installed, as you can see from my > settings file. > According to me, If that is true then it should not have thrown Import error. To install the sitemap app, follow these steps: 1. Add 'django.contrib.sitemaps' to your INSTALLED_APPS<https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-INSTALLED_APPS>setting. 2. Make sure 'django.template.loaders.app_directories.Loader' is in your TEMPLATE_LOADERS<https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATE_LOADERS>setting. It’s in there by default, so you’ll only need to change this if you’ve changed that setting. 3. Make sure you’ve installed the sites framework<https://docs.djangoproject.com/en/dev/ref/contrib/sites/#module-django.contrib.sites> . -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: ImportError at/ No module name
Make installed apps as : INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', 'djangopractice.blog', ) Hope this helps. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Database Transaction
Hello Django users, I have created a django application whose database is totally different(different foreign keys, fields, tables etc.) from that of old application. But now when I have created the application I require the data from old application too. How can I do the data transaction among the two applications? Your help will be appreciated. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: saving get objects to models
On Tue, Jan 22, 2013 at 8:39 PM, Satinderpal Singh wrote: > How to save the objects to models without using form. I tried to save > the name object to the model, but unable to do so, > > material = Material.objects.get(name=request.GET['material']) > I think this will help you : p = table(material =material, ...[other fields of table to be saved]) p.save() Here table is your table where you want object value to be saved. Hope this helps you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Database Transaction
On Tue, Jan 22, 2013 at 7:32 PM, Javier Guerra Giraldez wrote: > On Mon, Jan 21, 2013 at 10:03 PM, Jian Chang wrote: >> you can't do the transaction between two different databases. > > i think the OP is talking about translation and not transaction. as > in translating the data from an old representation to the new one. a > better word might be migration. > Yes, sorry for creating gap in communication. > of course, that's totally specific to his own code. i don't think > there's much generic advise to give, beyond trying South's > datamigration facilities. (which might not be the easiest way if the > representations are so different) > Yes, I also thought south will be helpful but when we need to do complete migration like old table is without foreign keys but new table has foreign keys etc. then I could not understand how to use south. Can you provide me some tutorial for the same. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Database Transaction Migration
-- Forwarded message -- From: Javier Guerra Giraldez Date: Wed, Jan 23, 2013 at 3:34 AM Subject: Re: Database Transaction To: django-users@googlegroups.com On Tue, Jan 22, 2013 at 11:54 AM, Sandeep kaur wrote: > Yes, I also thought south will be helpful but when we need to do > complete migration like old table is without foreign keys but new > table has foreign keys etc. then I could not understand how to use > south. Can you provide me some tutorial for the same. I haven't used South for complex data migrations, but I think it's most useful just after (or simultaneously to) doing the schema migration with South. In your case, you sound like you haven't done any real schema migration, more like a reimplementation. (( unless it is just a change to the application and your talk about "new application" and "old application" means just that you're not using any version control system. in that case, no matter what i advice here, you're already in deep trouble )) if you've done a real reimplementation, then I don't think there's any tool to do much help. you have to write a third application that reads data in the old representation and writes in the new one. and run that app once. of course, if both old and new applications are written with Django and handle data via the Django ORM, then you can do things like: import oldapp.models import newapp.models for oldrec in oldapp.models.MyModel.objects.all(): newapp.models.MyNewModel.create (newfield=oldrec.oldfield,..) and so on. -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Database Transaction Migration
> I haven't used South for complex data migrations, but I think it's > most useful just after (or simultaneously to) doing the schema > of course, if both old and new applications are written with Django > and handle data via the Django ORM, then you can do things like: > > > import oldapp.models > import newapp.models > > for oldrec in oldapp.models.MyModel.objects.all(): > newapp.models.MyNewModel.create (newfield=oldrec.oldfield,..) > Sorry, this mail was sent by mistake. And thank you Javier, I think this is the only solution now. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: forign key no forms
2013/2/11 Carlos Andre : > Olá pessoal! > Olha, preciso que um foreign key seja acessível com o forms! > Tentei de algumas maneiras e não consegui! materiais também não tão > sucintos! > alguém pode me ajudar com essa questão? > Obrigado pela a atenção! > The foreign key is by default acessible in the forms in the form of drop down. You just need to define the form of your model and the in template file write this : {% csrf_token %} {{ form.as_table }} -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: How do I get the current user in a model?
On Mon, Feb 11, 2013 at 7:42 PM, frocco wrote: > Hello, > > I have some logic I want to put in a model, but it requires know the current > user logged in. > Is there a way to get this? > This gets the current logged in user : current_user = request.user -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Extending the base file depending on User type
I want to extend the base template file into the child file depending on the condition, like if the user is superuser or staff or active user, the file to extended should ll be different. For Eg : {% if user.is_superuser %} {% extends "base.html" %} {% else if user.is_active %} {% extends "base_client.html" %} {% else %} {% extends "base_noclient.html" %} However this code doesn't work. What should be done. Your help will be highly appreciated. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Extending the base file depending on User type
On Wed, Mar 6, 2013 at 2:39 AM, Shawn Milochik wrote: > Instead of extends, you could use the "include" directive. > "include" worked but destroyed all the structure of the template. :-/ -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Extending the base file depending on User type
On Wed, Mar 6, 2013 at 10:55 PM, Sam Solomon wrote: > Tom Evans has probably the correct answer for you, but another thing that > def some_view(request): > return render(request, "path/to/template.html", {"view_context": ...}) # > The "render(request" portion will automatically send the base_template > variable into your template. > Thanks a lot. You explained everything so gracefully. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Django Shopping Cart
On Thu, Feb 28, 2013 at 2:32 AM, vijay shanker wrote: > hey, i want to write a shopping cart app, please provide some inputs, useful > information, suggestions etc for doing it right . Have a look at this too. https://github.com/bmentges/django-cart -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: No module named wsgi
On Thu, May 23, 2013 at 8:29 PM, Luggaz wrote: > I don't know what I dd but it seems to work now! > mod wsgi installation could have also solved he purpose, using this command : $sudo apt-get install apache2 libapache2-mod-wsgi -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Application Migration form Django 1.3 to Django 1.5
I have this Web application made in Django 1.3. And now when I use it on Django 1.5, it does not work. It give error as no module simple. So, Is there any migration tool to make my application work easily on 1.5 version without manually making lot of changes? You help will be appreciated. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Application Migration form Django 1.3 to Django 1.5
On Mon, Jun 17, 2013 at 11:23 AM, Some Developer wrote: > On 16/06/2013 21:24, Andreas Kuhne wrote: >> >> Apart from that there are a couple of small things that didn't work. We >> had procedure based views, they had to be migrated to class based instead. > > > You can still use function based views in Django 1.5. There is no need to > migrate unless you really want to. If you have an already existing app that > uses function based views you might find that migrating is just an > unnecessary waste of time. > Yes there are barely few changes that need to be made. There is a urls.py file where we need to change the direct_to_template to template_view and in html file change the ones with like {% url login %} to {% url 'login ' %}. Thank you @Andreas and some developer for helping me out. Or to make it little easy for other apps, we can make a script for this. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Selecting values from database
Suppose I have following table in my database : activity1 | activity2 | activity3 | activity4 | activity5 6| 7 | 5| 9 | 8 The first row are the field names and the second row are the data entries. How can I get 3 maximum values out of each row of this table? Like from this row, I should get 7,8,9. Eagerly waiting fro your reply. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: [GD 40883] Re: Haystack
On Tue, Jul 30, 2013 at 8:24 PM, Kamal Kaur wrote: > > I have created the template for haystack search and can open it, enter > any query. But there is no connectivity with database yet and its not > giving results. What I have uderstood is that, in haystack, indexes > for models are created. In documentation they say that indexes are > created after running that command. But its not happening. > Also there was a command (./manage.py build_solr_schema ), whose > result was to be placed in schema.xml file ( > solr-4.4.0/example/example-DIH/solr/solr/conf) And it was not given > whether to append the file or replace the content. So, did it place the results in schema.xml file? Is there any such file and it has appropriate permissions to write the content. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Iterating over fields in Formset
I have my code for formset here : {% csrf_token %} {{ FAtestform_formset.management_form }} {% for form in FAtestform_formset.forms %} {% if forloop.first %} {% for field in form.visible_fields %} {{ field.label|capfirst }} {% endfor %} {% endif %} {% for students in student %} {% for field in form.visible_fields %} {# Include the hidden fields in the form #} {{ field.errors.as_ul }} {{ field }} {% endfor %} {% endfor %} {% endfor %} With this I get something like this on the browser : http://devplace.in/~sandy/screen.png But the problem with this is that all the fields does not get saved in the database. Only the last row of the screenshot get submitted. How can I do it right so that all the multiple rows get submitted at once? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Iterating over fields in Formset
On Fri, Aug 9, 2013 at 2:50 PM, Sandeep kaur wrote: > I have my code for formset here : > > {% csrf_token %} > Your help would be really appreciated. Waiting. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Iterating over fields in Formset
On Sat, Aug 10, 2013 at 9:00 PM, Satinderpal Singh wrote: > > I think in the your views you are trying to save it under the formsets, try > to save the formsets under the form to save all the required rows. > What should be changed? This is my code : def add_result(request): class RequiredFormSet(BaseFormSet): def __init__(self, *args, **kwargs): super(RequiredFormSet, self).__init__(*args, **kwargs) for form in self.forms: form.empty_permitted = False clas = Class.objects.get(id=request.GET['class']) test = Tests.objects.get(id=request.GET['test']) student = Student.objects.filter(std=clas.id) #for students in student: # student_id = Student.objects.get(id=students.id) if test.id == 3 or test.id == 6: pass else : FAtestFormSet = formset_factory(FAtestForm, max_num=30, formset=RequiredFormSet) if request.method == 'POST': FAtestform_formset = FAtestFormSet(request.POST, request.FILES) if FAtestform_formset.is_valid() : for form in FAtestform_formset.forms: marks = form.save(commit=False) marks.test = test marks.save() return render_to_response('report/marks_filled.html', {'student':student}, context_instance=RequestContext(request)) else: FAtestform_formset = FAtestFormSet() temp = {'FAtestform_formset': FAtestform_formset, 'student':student, 'test':test } return render_to_response('report/add_marks.html', temp, context_instance = RequestContext(request)) -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Iterating over fields in Formset
On Mon, Aug 12, 2013 at 5:47 AM, Dan Gentry wrote: > What is the purpose of checking test.id for a value of 3 or 6? > For test.id == 3 or 6, some other code will be executed, else this code. I am currently doing for else part. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.
Re: Editing forms in django
On Fri, Oct 18, 2013 at 1:09 PM, amanjot kaur wrote: > What should I need to do in django, if I want to edit the information > filled in django, like we edit our profile in facebook after filling > once? That means editing the already saved data? Assuming you are using a ModelForm, use the instance keyword argument, and pass the model you are updating. So, if you have MyModel and MyModelForm, then your code might look like: my_record = MyModel.objects.get(id=XXX) form = MyModelForm(instance=my_record) And then, when the user sends back data by POST: form = MyModelForm(request.POST, instance=my_record) Documentation is here: http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/ -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3rp5YHFCb6exXfj3m1RRvxyfG1oPUzw58UYY2EnChOMA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: django difference between - one to one, many to one and many to many
On Tue, Oct 29, 2013 at 12:36 AM, Aamu Padi wrote: > > So, this is my first time learning computer language. And I chose python and django. Now, I got many of the basic concepts of python and also django. I can create new page with the views and all other stuff. But I am still confused with the relations, i.e. one to one, many to one, and many to many. Will someone please please please explain it to me. How can I use it? I really need to know many to one : This relationship is used as foreign key. In this one table can be used as a parent for many children. Eg : class Manufacturer(models.Model): # ... pass class Car(models.Model): manufacturer = models.ForeignKey('Manufacturer') # ... class Bus(models.Model): manufacturer = models.ForeignKey('Manufacturer') # ... Here there is one base table Manufacturer which acts as base for 2 other tables. many to many : When you want many rows of a table to be linked to many rows of another table, we use manytomany field. class Vehicle(models.Model): # .. manufacturer = models.ManyToManyField(Manufacturer) For more : http://charlesleifer.com/blog/describing-relationships-djangos-manytomany-through/ Application : For making checkboxes one to one : This is similar to foreign key, except that one parent has only one child. Conceptually, this is similar to a ForeignKey with unique=True, but the “reverse” side of the relation will directly return a single object. class Car(models.Model): manufacturer = OneToOneField('Manufacturer') # ... Hope this helped. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG01aUyofi4jTRnpTzvne8Ao2Aiczm8DTEfa_TAUw%2B%3DOSA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Deploying Django apps with nginx
Hi, I want to deploy multiple django apps on a server with nginx. When we do it on apache we do it in /etc/apache2/httpd.conf and following content : WSGIScriptAlias /django /home/sandy/django_app/apache/django.wsgi Order allow,deny Allow from all Thus this app can be accessed by example.com/django or if any other app on same server then with example.com/django2. How can we do this with nginx? Your help will be appreciated. :) Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3e34QLWBHvpPO%2B72JAA9FbK3Oo%3DRNO-YuyLvb2LU-aFw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Django views
Hello all, I want to include background images and gallery images to my django project and I am unable to do so.Images do not get displayed. please help me out -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django views
@Rodrigo Gomes Thank you , my problem is solved. @Jagdeep Singh Malhi Yes , in templates. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
django-variables
I want to make some of my data in django-templates, variable. And separate single file to define the variables. How can I do this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Extending the User form
On Thu, Jul 28, 2011 at 4:39 PM, Sheogora wrote: > > I have extended the User Profile by adding my own field, > how do I change the New user form in the admin, to show the new field? > This can be done by simply adding your new field in list display under User Profile of admin.py file. And by doing this you will get your new field in admin. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Image in Form Field
Greetings, I want to have the thumnails of images with the names in the dropdown field of form. To return the image as foreign key field, I have used this code : def __unicode__(self): image_data = open("/home/sandy/whats-fresh-api/media/images/download.jpg", "rb").read() return '%s' % (self.name) + HttpResponse(image_data, content_type="image/jpg") But it give following error : Exception Value: coercing to Unicode: need string or buffer, HttpResponse found Is it possible to do this ? Thanks. -- Sandeep Kaur Blog: sandymadaan.wordpress.com SCM: https://github.com/sandeepmadaan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG1ezfRCwXbLmMv%2BHk64SsvDPorxs-VCqwgMwtpNZtdZAg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Image in Form Field
Anybody please help. On Sun, Mar 22, 2015 at 3:07 PM, Sandeep kaur wrote: > Greetings, > I want to have the thumnails of images with the names in the dropdown > field of form. To return the image as foreign key field, I have used this > code : > def __unicode__(self): > image_data = > open("/home/sandy/whats-fresh-api/media/images/download.jpg", "rb").read() > return '%s' % (self.name) + HttpResponse(image_data, > content_type="image/jpg") > > But it give following error : > Exception Value: > > coercing to Unicode: need string or buffer, HttpResponse found > > > Is it possible to do this ? > > Thanks. > > -- > Sandeep Kaur > Blog: sandymadaan.wordpress.com > SCM: https://github.com/sandeepmadaan > > > > -- Sandeep Kaur Blog: sandymadaan.wordpress.com SCM: https://github.com/sandeepmadaan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG00kpdSJqW-2D7W_HYR4e%3DVEeW3E81KMHBoU-OhDbUFNA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: nginx server not reflecting changes
On Wed, Jul 9, 2014 at 5:50 PM, Amar Kamthe wrote: > > Me too having the same issue. > I tried all the above things like reloading the nginx server and restarting the gunicorn but the changes are not reflected. > Using command ps -aux | grep gunicorn. I found 1 gunicorn master and 3 worker threads running. I my case few of the files are reflecting but few of them don't. Is it that there is an issue with the code files which is not allowing to get loaded in nginx?. Also if I try using shell, it do shows the changed code and all these thing works perfectly with apache and mod wsgi. Can you help me in getting this issue resolved. Well my issue is resolved. All I do after making the changes is : $ service supervisord reload $ service nginx reload -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG0fUUtjcEaJ%3DgUo%2BWydhBZDCtvmmYoTQRVBu9%2B0Fv9Rmg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: deploying django on gunicorn
On Fri, Sep 5, 2014 at 3:44 PM, ngangsia akumbo wrote: > > 11:13:37 web.1 | return util.import_app(self.app_uri) > 11:13:37 web.1 | File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 356, in import_app > 11:13:37 web.1 | __import__(module) > 11:13:37 web.1 | ImportError: No module named hellodjango.wsgi Your application is not able to find the module hellodjango.wsgi. Did you make the wsgi.py file? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG2G_%3DpnO%3DGJ%3DdcerNGJ6PDa5R0FYjXqX126jsM5iB3_sg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: django problem with mysql and apache
On Wed, Dec 24, 2014 at 6:54 AM, wrote: > > 3 during the installation i have this probleme about mysql > > > > root@linux-pc:/home/siteweb# python3.4 manage.py migrate > Traceback (most recent call last): > File "/usr/local/lib/python3.4/dist-packages/django/db/backends/mysql/base.py", line 14, in > import MySQLdb as Database > ImportError: No module named 'MySQLdb' About this, try installing MySQLdb using this command: apt-get install python-mysqldb -- Sandeep Kaur Blog: sandymadaan.wordpress.com SCM: https://github.com/sandeepmadaan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3UEWJPvXFw44ih0LE%3DDLtOZfzyGpJOEbwBGF-4MKNxMg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Django application
Hello, I installed a django app "zebra" in my django site. This application is working with runserver but not on host server. I want it running on host server ASAP. What could be the probable reason for this behavior of app? Your help will be appreciated. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3YmdR%2B3iYNvGWtJ%2BYwnS8VGR7bWTG947L3hrMc1k9SEg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Django application
On Thu, Dec 5, 2013 at 9:37 AM, Lachlan Musicman wrote: > > Which web server are you using to serve it on the host server? > > Apache, nginx are the most likely... > It's nginx. > And how do you have that web server configured? I configured it using gunicorn and supervisor. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG211KJ4vo84kZnyChrv8PFiTto0k%3D9fwun14iMYHaTnaQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Django application
On Thu, Dec 5, 2013 at 9:39 AM, Lachlan Musicman wrote: > > > Have you read this part of the documentation? > > https://docs.djangoproject.com/en/1.6/howto/deployment/ Everything is fine with deployment of project on server with nginx. Its only with the new app I added to the project which is not working. Do I need to start the app with gunicorn or something like this? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG2zVTgB09eqEH5P_hpvWoOOQmxRqcH5HvRax5QzweUXSQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
nginx server not reflecting changes
Hello, I have deployed my Django site with nginx server, gunicorn and supervisor and it is working fine. But recently I made some changes in settings file of the project and that changes are not visible on the nginx server, however same changes reflect on runserver. What can be the possible reason for this? -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3JpZgwv%3DQ7BDyB8cafOJmRTZRajp7cerLR5JPsfHAmrQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: nginx server not reflecting changes
On Sun, Jan 12, 2014 at 9:48 PM, Manu wrote: > > Try to reload nginx. > >> sudo nginx -s reload > > > or stop it and restart > >> sudo nginx -s stop >> sudo nginx > These doesn't make any change. > > if it's still not reflecting those changes, check which settings.py is being used by runserver and the gunicorn. Or, the problem could be that you have to restart gunicorn > >> sudo supervisorctl restart [gunicorn-program-name] > When I use $ps -aux command to see which gunicorn program is running. It shows no job running, but server is nicely configured and is running. I am new to nginx and gunicorn deployment. Though deployment has been done but am not able to understand why the changes are not visible and which program is running which is behind the deployment. Your help will be highly appreciated. Thank you. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG1yuqXCv%2BRDpKnm0y1En5k%2BrwLC62wE5bi9Wnv5SLUM8w%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Error when using apache 2.4.6
On Fri, Jan 17, 2014 at 2:29 PM, Jasvir Singh wrote: > > I am using apache 2.4.6 as web server and django-1.5.2 as framework. > Here are my httpd.conf file and wsgi script: > http://paste.ubuntu.com/6766758/ > http://paste.ubuntu.com/6766759/ According to me, in your wsgi file, change sys.path.append('/home/jass') to sys.path.append('/home/jass/') that means add slash at the end. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG2VRh_Dyv4g7ZXscWSYA5EQ2h2ySU0m750fr9kda7Ncsw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: where is base.html located?
On Mon, May 5, 2014 at 9:53 AM, Venkat Subbiah wrote: > > Trying to follow the generic views from this tuotorial. Where would be "base.html" be located. > https://docs.djangoproject.com/en/1.6/topics/class-based-views/generic-display/ > > publisher_list.html contains the line > > {% extends "base.html" %} Inside the template folder. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG0Shoi%2BWrNPRdOL3Kd9RxZ9zFQVDa2-y9a2A0Cyu%3DZQTg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: how to saven models dynamically inputted by user in form
On Wed, Jul 2, 2014 at 11:03 AM, Aashita Dutta wrote: > > here is my model- > from django.db import models > import useraccounts > from librehatti.catalog.models import * > from django.contrib.auth.models import User > > class QuotedOrder(models.Model): > quote_buyer_id = models.ForeignKey(User) OMG. What do want to say? Can you please use some other medium to show your code? Github may be one. -- Sandeep Kaur E-Mail: mkaurkha...@gmail.com Blog: sandymadaan.wordpress.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3Rh6OLaukfTm3OTruFFnZ%3Dk%3D9J2egLpjJjBqJUqUohzw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
No module named _mysql
Greetings, I am using Python3.4 for the Django app on CentOs. The application is working perfectly fine with runserver, but when it is configured with apache and wsgi.py, I get this Internal Server error and error long says : [Wed Sep 16 11:38:30 2015] [error] [client 101.56.225.177] File "/usr/local/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 27, in [Wed Sep 16 11:38:30 2015] [error] [client 101.56.225.177] raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) [Wed Sep 16 11:38:30 2015] [error] [client 101.56.225.177] ImproperlyConfigured: Error loading MySQLdb module: No module named _mysql MySQLdb module is working perfectly fine. I tried to install MySQL-python and then found MySQLdb doesn't have Python 3 support. Then tried to used Python -mysql connector but that too gives error. I don't know why the MySQL is not working with apache. Your help will be highly appreciated. -- Sandeep Kaur Blog: sandymadaan.wordpress.com SCM: https://github.com/sandeepmadaan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG3jHPXhABeuq8Uw3UMV9vdPTg9PET5LdYSZZHY5sg8x1A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: No module named _mysql
On Thu, Sep 17, 2015 at 3:19 AM, Cliff Peng wrote: > > http://stackoverflow.com/questions/26560973/python3-mysql-error-loading-mysqldb-module-no-module-named-mysqldb > > Can this help you? I have already implemented this solution, but still the error.log goes like this : [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] from django.contrib.auth.models import Permission [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/contrib/auth/models.py", line 41, in [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] class Permission(models.Model): [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 139, in __new__ [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] new_class.add_to_class('_meta', Options(meta, **kwargs)) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 324, in add_to_class [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] value.contribute_to_class(cls, name) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/models/options.py", line 250, in contribute_to_class [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/__init__.py", line 36, in __getattr__ [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] return getattr(connections[DEFAULT_DB_ALIAS], item) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 240, in __getitem__ [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] backend = load_backend(db['ENGINE']) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 111, in load_backend [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] return import_module('%s.base' % backend_name) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] __import__(name) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] File "/usr/local/lib/python3.4/site-packages/django/db/backends/mysql/base.py", line 27, in [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) [Thu Sep 17 05:27:38 2015] [error] [client 123.239.71.95] ImproperlyConfigured: Error loading MySQLdb module: No module named _mysql -- Sandeep Kaur Blog: sandymadaan.wordpress.com SCM: https://github.com/sandeepmadaan -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF66xG2PCknXqG8509TgMcCTk7d_WE3cffV2JcLYrCiKxz6YzQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.