Re: Getting the "Real" Foreign Key from a ModelForm

2014-07-28 Thread llanitedave
Ahhh...  That sounds good.  Too easy, in fact.  I can't wait to give it a 
try!

Thanks!

On Monday, July 28, 2014 11:17:16 AM UTC-7, Daniel Roseman wrote:
>
> On Monday, 28 July 2014 15:46:11 UTC+1, Tom Evans wrote:
>>
>> 
>>
>> You can use kwargs, but it is much cleaner and less typing to use 
>> Model.objects.create() as you can omit the subsequent save() as 
>> create() creates valid objects (they have pks). 
>>
>>
> You're right as far as that goes, but note that OP is using a ModelForm: 
> so there is an even easier method.
>
> form = create_insp_m(request.POST)
> if form.is_valid():
> insp = form.save()
>
> that way they can get rid of all the stuff involving `cleaned_data`, and 
> even the querying for the Pad object, as the ModelForm does it all already.
> --
> DR.
>

-- 
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/d7acd90f-eb02-420e-9db1-ea8c9372b162%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie Stuck on Django Tutorial 3 - Django Template system

2014-07-28 Thread Chou Sunny

i had the same problem by just copying the text on the web, pasting on 
textedit, and saving it into html.
when i open html by Xcode, you will see extra lines, more than the text on 
the web.
simply re-edit html by Xcode, the problem is solved.

-- 
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/7cc3cb58-aa98-4fcd-90bf-24f0ec2bdb63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


checkbox in Django

2014-07-28 Thread dharmi patel
Hi,

As I am a new for Django and I use Django for making web application.
My problem is:
I have product list and i have to select more than one product. once i have 
select the products. I have to compare those selected product but there are 
few criteria of comparison like compared by name , version ,release.
notes: product has number of packages and package has package name, 
version, release,.
In short the logic I have to implement is,  if i select 2 product and i 
will compare these 2 product by package version then they should display 
the all common packages of both product which have same packages with same 
version.


Can any one help me , how can i implement this logic?

-- 
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/4c49-0c37-46f5-8bd8-41988a2b6fc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


I don't understand whats wrong with the way im passing django list to json

2014-07-28 Thread G Z
so I'm trying to display some vm performance data on javascript charts. It 
needs the information as a list, I have tried passing a json list from 
django and a django list like below in the javascript i ahve the one they 
tell me to use and the one im trying the one they tell me to use works 
obviously and i kept it there as reference to see how it needs to be input. 
How do I get the variables between django and javascript in an acceptable 
way?




 for stat in vm_stats:
 cpu_values.append(stat[4])
  cpu_json = simplejson.dumps(cpu_values)
  
  context = Context({'user.is_superuser':user.is_superuser, 
'customers':customers,
'vms': vms,
'vm_stats': vm_stats,
'customer_id': customer_id,
'cpu_json':cpu_json,
   

 })




var randomScalingFactor = function(){ return Math.round(Math.random()*100)};
var lineChartData = {
labels : ["January","February","March","April","May","June","July"],
datasets : [
{
label: "My First dataset",
fillColor : "rgba(220,220,220,0.2)",
strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(220,220,220,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(220,220,220,1)",
data : [{{cpu_json}}]
},
{
label: "My Second dataset",
fillColor : "rgba(151,187,205,0.2)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
pointHighlightFill : "#fff",
pointHighlightStroke : "rgba(151,187,205,1)",
data : 
[randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor(),randomScalingFactor()]
}
]

}

window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true
});
}




-- 
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/ba87232e-783d-4b15-ba72-570026fdcb5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django upload image

2014-07-28 Thread Conner DiPaolo
I had a serious problem doing this. If your problem is similar to how mine 
was (static folder works but media folder doesn't) look at my Stack 
Overflow Question 


Best luck, Conner DiPaolo

On Monday, July 28, 2014 2:58:27 AM UTC-7, ngangsia akumbo wrote:
>
> please i need some help getting around with upload images
>
> i can put a background image on my site 
> i can style it with css and others
>
> but when i upload images on my admin page , it does not get loaded on the 
> page 
>
> please need some help here
>

-- 
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/30928973-d80e-4ac8-b18a-edd0f77a95b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Search via Form Redirect to URL

2014-07-28 Thread Conner DiPaolo


On Monday, July 28, 2014 11:49:12 AM UTC-7, Branko Majic wrote:
>
> I have tried hacking your code on top of one of my search pages, and 
> definitively managed to get it working once I added the name for the 
> input. 
>
> Without the name, the search view would otherwise just fall through and 
> I'd get something in the lines of the following error: 
>
> The view project.views.search didn't return an HttpResponse object. 
>
> I'd suggest maybe putting in a couple of debug print messages in your 
> view to figure out where your code ends-up in the end. 
>
> Best regards 
>
> -- 
> Branko Majic 
>

Ok I did what you said and played around for a while and got it working! 
Thanks! Another issue I had which I think was the main one (as well as the 
namespace in my input) was that I needed to change my action to link to a 
url which validated my search view. I ended up just using 
/beacon/search/search_query/ but anything instead of search_query would 
have worked. This way Django runs through the search view no matter what 
page you are on. Ironically changing that also implemented my search 
function on the whole site because the form is in my base.html .

Seriously thanks for the help dude!

-Conner DiPaolo 

-- 
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/3d0f0c9a-d4a0-44c7-b17b-62d974f5a7d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django tut 01

2014-07-28 Thread Glyn Jackson
You need to be a little more detailed about your error. When you say "Can't 
access database sqlite3" are you referring to permissions? Please post your 
settings. 

In the mean, time check you have the correct read/write permissions on the 
directory.Try "sudo python manage.py syncdb" (notice the word sudo). If 
this works you don't have the correct permission setup.  

On Monday, July 28, 2014 9:48:21 AM UTC+1, atul...@iiitd.ac.in wrote:
>
> Can't access database sqlite3. I am beginner . I cant use the database 
> when i run command " python manage.py syncdb".
> Please help!
> P.s. Can anyone please tell how to use sqlite3 database ( I know nothing 
> about it )
> Thankyou
>
>

-- 
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/63273411-53e1-4ba1-b90a-9d657464a460%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Search via Form Redirect to URL

2014-07-28 Thread Branko Majic
On Mon, 28 Jul 2014 07:41:23 -0700 (PDT)
Conner DiPaolo  wrote:

> 
> 
> On Monday, July 28, 2014 4:42:07 AM UTC-7, Branko Majic wrote:
> >
> >
> > In your search method, if the request method was POST, you are trying 
> > to retrieve submitted data via key 'search_string'. However, if you 
> > look at your HTML form, there does not seem to be any kind of input 
> > field called 'search_string'. 
> >
> > Try adding name="search_string" parameter to the input element, for 
> > example: 
> >
> >  > placeholder="Search Article Text"> 
> >
> > On a side-note, why are you even using POST method for a search? I 
> > _think_ that GET should be sufficient, and probably more correct thing 
> > to use, unless your searches are actually altering data (which could be 
> > considered a bad practice). 
> 
> 
>  Thanks for the response. I tried putting a name into the text input field 
> but nothing changes- I am still redirected to /project/search/ and not 
> /project/search//   . I have also tried to just use the default 
> Django form link template tag with {{ form.search_string }} with the same 
> result, which leads me to think that the issue has to do with maybe the 
> submit button? I'm not sure, though...
> 
> I agree that POST is probably the less 'correct' thing to do here, the 
> perfect example for using GET is ironically (in the Django docs themselves) 
> a search bar. That said, I get so confused and frustrated when I have to 
> use forms that I want to have a working prototype before I change it as 
> most of the form tutorials out there use POST because they change models or 
> something.
> 
> Seriously thanks for the response!
> Conner DiPaolo
> 

I have tried hacking your code on top of one of my search pages, and
definitively managed to get it working once I added the name for the
input.

Without the name, the search view would otherwise just fall through and
I'd get something in the lines of the following error:

The view project.views.search didn't return an HttpResponse object.

I'd suggest maybe putting in a couple of debug print messages in your
view to figure out where your code ends-up in the end.

Best regards

-- 
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.


signature.asc
Description: PGP signature


Re: Getting the "Real" Foreign Key from a ModelForm

2014-07-28 Thread Daniel Roseman
On Monday, 28 July 2014 15:46:11 UTC+1, Tom Evans wrote:
>
> 
>
> You can use kwargs, but it is much cleaner and less typing to use 
> Model.objects.create() as you can omit the subsequent save() as 
> create() creates valid objects (they have pks). 
>
>
You're right as far as that goes, but note that OP is using a ModelForm: so 
there is an even easier method.

form = create_insp_m(request.POST)
if form.is_valid():
insp = form.save()

that way they can get rid of all the stuff involving `cleaned_data`, and 
even the querying for the Pad object, as the ModelForm does it all already.
--
DR.

-- 
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/cbf9eb43-f3cf-43cc-8733-df40c801ac97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pass variable value store in dictionary to url parameter

2014-07-28 Thread pattinson


I pass dict

addon_id_value_mapping = 
  {'menu': '1', 'opening_hour': '2', 'books': '3', 'doctors': '4'}

and

addon_list = [{u'menu': [{u'price': 50, u'name': u'Momo', u'price_level': 
u'cheap'},
 {u'price': 510, u'name': u'potato', u'price_level': 
u'expensive'},
 {u'price': 100, u'name': u'Chowmein', u'price_level': 
u'expensive'}]},
  {u'opening_hour': [{u'close': 17, u'open': 9, u'day': 0}, 
 {u'close': 17, u'open': 9, u'day': 1},
 {u'close': 16, u'open': 8, u'day': 2}]}]

from view to django-template. I can access the value of the dict using 
template-tags 

 to 
display but I couldn't able to pass in url field. What should I need to do 
to pass variable value that store in dict in url parameter

{% if addon_list %}

{% for addon_name in addon_list %}
{% for key, values in addon_name.iteritems %}



{{ key }}{# title- menu #}





update

{#todo #}





{% for value in values %}
{% for k,v in value.iteritems %}

{{ k }}
{{ v }}

{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}{% endif %}

I'm using Django 1.6.5

-- 
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/11e60ab4-be7f-4d83-a308-001c0916f13a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Search via Form Redirect to URL

2014-07-28 Thread Conner DiPaolo


On Monday, July 28, 2014 4:42:07 AM UTC-7, Branko Majic wrote:
>
>
> In your search method, if the request method was POST, you are trying 
> to retrieve submitted data via key 'search_string'. However, if you 
> look at your HTML form, there does not seem to be any kind of input 
> field called 'search_string'. 
>
> Try adding name="search_string" parameter to the input element, for 
> example: 
>
>  placeholder="Search Article Text"> 
>
> On a side-note, why are you even using POST method for a search? I 
> _think_ that GET should be sufficient, and probably more correct thing 
> to use, unless your searches are actually altering data (which could be 
> considered a bad practice). 


 Thanks for the response. I tried putting a name into the text input field 
but nothing changes- I am still redirected to /project/search/ and not 
/project/search//   . I have also tried to just use the default 
Django form link template tag with {{ form.search_string }} with the same 
result, which leads me to think that the issue has to do with maybe the 
submit button? I'm not sure, though...

I agree that POST is probably the less 'correct' thing to do here, the 
perfect example for using GET is ironically (in the Django docs themselves) 
a search bar. That said, I get so confused and frustrated when I have to 
use forms that I want to have a working prototype before I change it as 
most of the form tutorials out there use POST because they change models or 
something.

Seriously thanks for the response!
Conner DiPaolo

-- 
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/25167e59-eefb-4582-80fd-a31546456156%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting the "Real" Foreign Key from a ModelForm

2014-07-28 Thread Tom Evans
On Mon, Jul 28, 2014 at 2:39 PM, llanitedave
 wrote:
>
> This is my first attempt at a work Django Application since the tutorial, so 
> my odds of missing something obvious are pretty high.  Still, I've been as 
> far as I can in the documentation, and I can't find anything that addresses 
> this.  Using Python 2.7 and Django 1.6.5, in a ModelForm containing a foreign 
> key, rather than returning the key value itself the form returns an object 
> that represents the __unicode__(self) value of the model.  So it isn't an 
> integer of a string, and I get a TypeError when I try to save it.
>
> class Pad_info(models.Model):
>
> site_id = models.IntegerField(primary_key=True)
> name = models.CharField('Pad Location', max_length=40, unique=True)
> ...
> (irrelevant fields snipped...)
>
>
>
> def __unicode__(self):
> return u'%s, %s' % (self.site_id, self.name)
>
> def ID(self):
> return self.site_id
>
> class Meta:
> db_table = 'pad_info'
> verbose_name = 'Pad Info'
>
>
> class Inspections(models.Model):
> of_pad = models.ForeignKey(Pad_info)
> insp_date = models.DateField('Inspection Date')
> agency = models.CharField('Agency/ Organization', max_length=40)
> lead_inspector = models.CharField('Lead Inspector', max_length=40)
> accepted = models.BooleanField(default=False)
> comments = models.TextField('Comments/ Notes')
>
> def __unicode__(self):
> return self.agency
>
> def ID(self):
> return self.id
>
> class Meta:
> db_table = 'inspections'
> verbose_name = 'Pad Inspection'
>
>
> Here's my form:
>
> from django import forms
> from django.forms import ModelForm
> from django.forms.fields import DateField
> from reclamationdb.models import Inspections
>
>
> class create_insp_m(ModelForm):
> class Meta:
> model = Inspections
> fields = ['insp_date', 'of_pad', 'agency', 'lead_inspector', 
> 'accepted',
> 'comments']
>
>
> And here's my view, still under construction:
>
> def inspectioncreate_m(request):
> if request.method == 'POST':
> form = create_insp_m(request.POST)
> if form.is_valid():
> # create new inspection record
> insp_date = form.cleaned_data['insp_date']
> of_pad = form.cleaned_data['of_pad']
> agency = form.cleaned_data['agency']
> lead_inspector = form.cleaned_data['lead_inspector']
> accepted = form.cleaned_data['accepted']
> comments = form.cleaned_data['comments']
>
> # find if there is a record that matches pad_id
> try:
> checkPad = Pad_info.objects.get(pk=of_pad)
> newrecord = Inspections(of_pad, insp_date, agency, 
> lead_inspector, accepted,
> comments)

This is where your code is going wrong - you should not create a model
instance by passing positional arguments. The docs instruct you to use
kwargs, and then Django can assign to the correct fields.

Hence "of_pad" is of the correct type, it is just being applied to the
wrong field.

You can use kwargs, but it is much cleaner and less typing to use
Model.objects.create() as you can omit the subsequent save() as
create() creates valid objects (they have pks).

Cheers

Tom

-- 
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/CAFHbX1J_imqWbX552LPhbdpzjVr-Cr3GPt-w4VJ4Zy%2BS%2Bp_Gdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Getting the "Real" Foreign Key from a ModelForm

2014-07-28 Thread llanitedave
This is my first attempt at a work Django Application since the tutorial, 
so my odds of missing something obvious are pretty high.  Still, I've been 
as far as I can in the documentation, and I can't find anything that 
addresses this.  Using Python 2.7 and Django 1.6.5, in a ModelForm 
containing a foreign key, rather than returning the key value itself the 
form returns an object that represents the __unicode__(self) value of the 
model.  So it isn't an integer of a string, and I get a TypeError when I 
try to save it.

class Pad_info(models.Model):

site_id = models.IntegerField(primary_key=True)
name = models.CharField('Pad Location', max_length=40, unique=True)
...
(irrelevant fields snipped...)
   


def __unicode__(self):
return u'%s, %s' % (self.site_id, self.name)

def ID(self):
return self.site_id

class Meta:
db_table = 'pad_info'
verbose_name = 'Pad Info'


class Inspections(models.Model):
of_pad = models.ForeignKey(Pad_info)
insp_date = models.DateField('Inspection Date')
agency = models.CharField('Agency/ Organization', max_length=40)
lead_inspector = models.CharField('Lead Inspector', max_length=40)
accepted = models.BooleanField(default=False)
comments = models.TextField('Comments/ Notes')

def __unicode__(self):
return self.agency

def ID(self):
return self.id

class Meta:
db_table = 'inspections'
verbose_name = 'Pad Inspection'


Here's my form:

from django import forms
from django.forms import ModelForm
from django.forms.fields import DateField
from reclamationdb.models import Inspections


class create_insp_m(ModelForm):
class Meta:
model = Inspections
fields = ['insp_date', 'of_pad', 'agency', 'lead_inspector', 
'accepted', 
'comments']


And here's my view, still under construction:

def inspectioncreate_m(request):
if request.method == 'POST':
form = create_insp_m(request.POST)
if form.is_valid():
# create new inspection record
insp_date = form.cleaned_data['insp_date']
of_pad = form.cleaned_data['of_pad']
agency = form.cleaned_data['agency']
lead_inspector = form.cleaned_data['lead_inspector']
accepted = form.cleaned_data['accepted']
comments = form.cleaned_data['comments']

# find if there is a record that matches pad_id
try:
checkPad = Pad_info.objects.get(pk=of_pad)
newrecord = Inspections(of_pad, insp_date, agency, 
lead_inspector, accepted, 
comments)
newrecord.save(force_insert=True)

except Pad_info.DoesNotExist:
# display error message and blank the pad_id field
pass

return render(request, 
'reclamationdb/inspectioncreate_mobile.html', {'form' : form,})
#return HttpResponseRedirect('/index/')

else:
# invalid form
pass
else:
# do something else
form = create_insp_m()
#return render(request, 
'reclamationdb/inspectioncreate_mobile.html', {'form' : form,})

return render(request, 'reclamationdb/inspectioncreate_mobile.html', 
{'form' : form,})

The form appears in a web page, and displays all the required information, 
including the data from the related one record in the foreign key.
But when I save, I get a Type Error, reading "int() argument must be a 
string or a number, not 'Pad_info'".

The traceback that's highlighted is the line "checkPad = 
Pad_info.objects.get(pk=of_pad)"

 And in the list of local variables, the relevant one seems to be:
"of_pad  "

It's an object rather than a string, and I can't seem to filter out just 
the number 41, which is the actual content of pad_id, and the value I'm 
trying to save in the foreign key field. This is really driving me crazy!

Thanks!

Dave


-- 
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/69a68b66-8433-4998-9f62-4df3f13c7b03%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django tut 01

2014-07-28 Thread ngangsia akumbo
paste on here the setting files, and the error you are having.

On Monday, July 28, 2014 9:48:21 AM UTC+1, atul...@iiitd.ac.in wrote:
>
> Can't access database sqlite3. I am beginner . I cant use the database 
> when i run command " python manage.py syncdb".
> Please help!
> P.s. Can anyone please tell how to use sqlite3 database ( I know nothing 
> about it )
> Thankyou
>
>

-- 
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/0d920c48-f1b6-42f2-80fc-aa108adcfcf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Search via Form Redirect to URL

2014-07-28 Thread Branko Majic
On Sun, 27 Jul 2014 15:11:20 -0700 (PDT)
Conner DiPaolo  wrote:

> 
> 
> I already have a valid search function mapped in my Django project, you 
> type in a url '/project/search//' and it responds the corresponding search 
> results on a page. I want to have a search box in my nav-bar that was 
> created in my base.html and have users type in a query and it will redirect 
> them to the search url. When I type into the search bar and click submit, 
> however, the I am just directed to '/project/search/' with no relation to 
> the query. How do I connect the form to redirect to the URL, *properly*??
> 
> Thanks in advance.
> 
> Here is my view definition and form class:
> 
> class SearchForm(forms.Form):
> search_string = forms.CharField(max_length=100)def search(request, 
> search_query):
> if request.method == 'GET':
> form = SearchForm()
> context = RequestContext(request)
> search_string = search_query.replace('_',' ')
> search_terms = search_query.split('_')
> search_results = Article.objects.all()
> for term in search_terms:
> search_results = search_results.filter(article__icontains=term)
> 
> context_dict = {
> 'search_string':search_string,
> 'search_results':search_results,
> 'form':form,
> }
> 
> 
> if request.method == 'POST':
> form = SearchForm(request.POST)
> if form.is_valid():
> search_string = form.data['search_string']
> search_query = search_string.replace(' ','_')
> ###return HttpResponseRedirect(reverse('search', 
> args=(search_query,)))
> search_url = '/beacon/search/' + search_query + '/'
> return HttpResponseRedirect(search_url)
> else:
> return render_to_response('search.html', context_dict, context)
> 
> My base form html is (yes it is from bootstrap):
> 
>  method='POST'>
> 
> {% csrf_token %}
> 
> 
> Submit
> 

In your search method, if the request method was POST, you are trying
to retrieve submitted data via key 'search_string'. However, if you
look at your HTML form, there does not seem to be any kind of input
field called 'search_string'.

Try adding name="search_string" parameter to the input element, for
example:



On a side-note, why are you even using POST method for a search? I
_think_ that GET should be sufficient, and probably more correct thing
to use, unless your searches are actually altering data (which could be
considered a bad practice).

Best regards


-- 
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.


signature.asc
Description: PGP signature


django tut 01

2014-07-28 Thread atul13025
Can't access database sqlite3. I am beginner . I cant use the database when 
i run command " python manage.py syncdb".
Please help!
P.s. Can anyone please tell how to use sqlite3 database ( I know nothing 
about it )
Thankyou

-- 
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/f9fc3faf-c094-40c5-a09a-1bc832122514%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sending mass email in Django

2014-07-28 Thread Kevin Ndung'u

Hi people,

I am currently maintaining a website where at times I may need to send 
around 10,000+ emails at a time.

I just want to ask on what methods you may consider Django best practices 
e.g. in efficiency when sending mail to a list of this size?

I am currently handling this as a celery task and sending the emails 
through Mandrill  transactional email service 

Currently, this is how I am handling it:

from django.core.mail import EmailMultiAlternatives, get_connection
from models import Subscriber

connection = get_connection()
recipients = [i.email for i in Subscriber.objects.all()]

for sub in subscribers:
msg = EmailMultiAlternatives(title, content, sender, [sub])
msg.attach_alternative(content, "text/html")
recipient_list.append(msg)

connection.send_messages(recipients)

Is it better to split the list into smaller chinks to reduce the size of 
the requests or which other implementation methods can I consider?

Thanks

-- 
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/16702abe-7923-4cf7-b51d-15fb19438d6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django upload image

2014-07-28 Thread ngangsia akumbo
please i need some help getting around with upload images

i can put a background image on my site 
i can style it with css and others

but when i upload images on my admin page , it does not get loaded on the 
page 

please need some help here

-- 
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/de141bd1-8b71-4797-a74b-29f08e975c80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Different objects returned when filtering with a ValuesListQuerySet

2014-07-28 Thread Marc Kirkwood
Yeah that's what I was thinking it could be. cheers Russ.

-- 
Legal status: Any views or opinions are solely those of the sender and do 
not necessarily represent those of SF Software Ltd unless expressly stated 
in the body of the text of the email, this email is not intended to form a 
binding contract.

Confidentiality: this communication may contain information that is 
confidential and/or privileged and is for the exclusive use of the intended 
recipient(s). Any form of distribution, copying or use of this 
communication by anyone else is strictly prohibited. If you have received 
this communication in error, please reply to this message or telephone +44 
(0)845 310 1788 and delete this communication and destroy any copies. 

Security: this communication has been created and sent in the knowledge 
that internet e-mail is not secure. We strongly advise you to understand 
and to be aware of the lack of security when e-mailing us. If you 
communicate with us via e-mail, we will assume that you accept the security 
risk and that you authorise us to communicate with you in the same format. 
The sender therefore does not accept liability for any errors or omissions 
in the contents of this message, which arise as a result of e-mail 
transmission. 

Warning: Although we take reasonable precautions to ensure no viruses are 
present in this email, we cannot accept responsibility for any loss or 
damage arising from the use of this email or attachments. 

-
In compliance with Directive on Disclosure, The Companies Regulations 2006, 
effective 01 January 2007 talktopebble.co.uk,schoolfund.co.uk, 
schoolfundfinder.co.uk, easyusbooks.co.uk, clubfund.co.uk are domain names 
registered to SF Software Limited.

SF Software Limited is a company registered in England and Wales with 
company number: 05580540. Our trading name is Pebble our trading address 
and registered office is: Media Exchange Three, Coquet Street, Newcastle 
upon Tyne, NE1 2QB
VAT Registration number is: GB 873 5186 95

-- 
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/f327ed97-ee2f-4ca8-9045-d8bcebd170a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to django-registration (unmaintaned since September 2013)

2014-07-28 Thread rush
Hi guys,Looks like django-signup ( https://bitbucket.org/fcoelho/django-signup/ ) may be interesting for you. It is based on django-registration and as for now the last commit was about a 5 days ago.-- wbr,rush.   24.07.2014, 19:21, "Oscar Carballal" :Same for me in my personal projects and in our company, we fully switched to django-allauth and we are quite happyRegards,Oscar-- Oscar Carballal Prego - Senior Software Developerhttp://oscarcp.com | @pizte2014-07-23 8:15 GMT+01:00 Santiago L :El sábado, 19 de julio de 2014 02:17:24 UTC+2, Russell Keith-Magee escribió:On Fri, Jul 18, 2014 at 8:31 PM, Santiago L  wrote:Hi, Some weeks ago I noticed that django-registration is not longer maintained byits creator: quoting https://bitbucket.org/ubernostrum/django-registration/wiki/Home> django-registration> I stepped down as maintainer of this application in September 2013. Pull> requests, issues and comments sent to this repository will be ignored.  As I'm currently using this app in my project, I wonder if there is anyalternative for django-registration? Maybe someone knows about a fork. I'm not aware of an active fork. If you're looking to step into open source contribution, this would be a good project to adopt - the code base is stable, so the management overhead should be relatively low.   I like the idea about contributing and get in charge of a fork, but I'm not sure about my availability...   Besides that, I found a related issue report (rejected because is not the goodplace to ask this question, but relevant anyway)[2] [2] https://code.djangoproject.com/ticket/13164 Because there's no single answer to the question. Authentication is a topic that is hard to get right, and there's a very limited number of "right" answers. Passwords *must* be done well, or you risk vulnerability, and what constitutes "well" requires considerable expertise.  However, the requirements for registration and signup will vary between projects, and will depend on project requirements. Some projects will need a fully verified personal profile before you can continue; some only require a verified email address; some will allow an email address, but allow later verification, and some will require completely anonymous profiles that are filled in at a critical point in workflow (e.g., at checkout in an e-commerce site). There's also nothing especially technically complex about these workflows - unlike Authentication, there aren't any real land mines that could lead to vulnerabilities (beyond those that are inherent in building *any* web page). So, the Django project has made the decision to keep Authentication as a core piece of functionality, but keep registration as a third-party thing. This means that the wider community can contribute alternate approaches. It also means that the core team isn't a bottleneck on progress - django-regsistration has it's own release cycles, bug tracking processes, and so on. This arrangement has worked well for 8 years; it's only because James has stepped down and nobody has volunteered to take over that a problem now exists.  Thanks for your explanation!!  --  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/a8450ee8-96a0-4a1e-9071-2740544e5533%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. --  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/CA%2BXe2iaED-arSkS7R1zTrZyTpkLEUBTz_hmJmubT%3Db7%3DaQc9fQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.



-- 
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/502341406527661%40web23h.yandex.ru.
For more options, visit https://groups.google.com/d/optout.