Using ModelForms

2015-08-20 Thread Hugo Kitano
Hi, I'm a beginner using Django, and I'm having trouble using model forms 
to create instances of my model.
When a user submits a form, the database saves nothing.  Here's my code for 
the view

def submit(request): 

SubmissionForm = modelform_factory(Submission, fields=('sub_name', 
'sub_file'))

if request.method == "POST": 

form = SubmissionForm(request.POST)

if form.is_valid():

model_instance = form.save(commit=False)

model_instance.sub_date = timezone.now()

model_instance.save()

return HttpResponseRedirect('http://localhost:8000/stats/') 

else:

form = SubmissionForm()

return render(request, 'stats/submit.html', {'form': form})


And here's my template:


 Submit form: 

{% csrf_token %}
{{ form.as_p }}




I'd appreciate any help. Thansk!


Hugo

-- 
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/af4016f0-65e5-4a5c-99e9-7f544e7ced7c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-20 Thread Hugo Kitano
Could you elaborate on my form has some error?

On Thursday, August 20, 2015 at 1:43:32 PM UTC-7, Edgar Gabaldi wrote:
>
> The code seems right. Probably your form has some error. Try print 
> {{form.errors}} in your template to check.
>
> On Thu, Aug 20, 2015 at 4:45 PM, Hugo Kitano  > wrote:
>
>> Hi, I'm a beginner using Django, and I'm having trouble using model forms 
>> to create instances of my model.
>> When a user submits a form, the database saves nothing.  Here's my code 
>> for the view
>>
>> def submit(request): 
>>
>> SubmissionForm = modelform_factory(Submission, fields=('sub_name', 
>> 'sub_file'))
>>
>> if request.method == "POST": 
>>
>> form = SubmissionForm(request.POST)
>>
>> if form.is_valid():
>>
>> model_instance = form.save(commit=False)
>>
>> model_instance.sub_date = timezone.now()
>>
>> model_instance.save()
>>
>> return HttpResponseRedirect('http://localhost:8000/stats/') 
>>
>> else:
>>
>> form = SubmissionForm()
>>
>> return render(request, 'stats/submit.html', {'form': form})
>>
>>
>> And here's my template:
>>
>>
>>  Submit form: 
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>>
>> I'd appreciate any help. Thansk!
>>
>>
>> Hugo
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/af4016f0-65e5-4a5c-99e9-7f544e7ced7c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/af4016f0-65e5-4a5c-99e9-7f544e7ced7c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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/48cbf996-39ae-4b92-b7cf-4391916c3fce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-21 Thread Hugo Kitano
Do you have any idea what could be causing the problem, then?

On Friday, August 21, 2015 at 2:25:17 AM UTC-7, Hugo Osvaldo Barrera wrote:
>
>  
>  
>  
> On Thu, Aug 20, 2015, at 17:43, Edgar Gabaldi wrote:
>
> The code seems right. Probably your form has some error. Try print 
> {{form.errors}} in your template to check.
>
>  
> Shouldn't {{ form.as_p }} include errors as well? This seems to be what 
> the doc indicates:
>  
>
> https://docs.djangoproject.com/en/1.8/topics/forms/#working-with-form-templates
>  
>
> On Thu, Aug 20, 2015 at 4:45 PM, Hugo Kitano  > wrote:
>
> Hi, I'm a beginner using Django, and I'm having trouble using model forms 
> to create instances of my model.
> When a user submits a form, the database saves nothing.  Here's my code 
> for the view
>  
>
> def submit(request):
>
> SubmissionForm = modelform_factory(Submission, fields=('sub_name', 
> 'sub_file'))
>
> if request.method == "POST":
>
> form = SubmissionForm(request.POST)
>
> if form.is_valid():
>
> model_instance = form.save(commit=False)
>
> model_instance.sub_date = timezone.now()
>
> model_instance.save()
>
> return HttpResponseRedirect('http://localhost:8000/stats/')
>
> else:
>
> form = SubmissionForm()
>
> return render(request, 'stats/submit.html', {'form': form})
>
>
> And here's my template:
>
>
>  Submit form: 
> 
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
>
>
> I'd appreciate any help. Thansk!
>  
>
>
> Hugo
>  
>  
>
>
> -- 
> 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...@googlegroups.com .
> To post to this group, send email to django...@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/af4016f0-65e5-4a5c-99e9-7f544e7ced7c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/af4016f0-65e5-4a5c-99e9-7f544e7ced7c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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...@googlegroups.com .
> To post to this group, send email to django...@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/CAGjPPHn0f-rdRKDd4J9sA%3DVbH4R7zTvyPmMYv-dCb80%3DiLq%2Bsg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/django-users/CAGjPPHn0f-rdRKDd4J9sA%3DVbH4R7zTvyPmMYv-dCb80%3DiLq%2Bsg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>  
> --
> Hugo Osvaldo Barrera
>  
>

-- 
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/a1eaac7c-4fb5-4c1c-b06e-4efdfbbb4e2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Working with FileFields/FieldFiles

2015-08-21 Thread Hugo Kitano
Hi, I'm a beginner with Django, and I'm trying to figure out how to work 
with FieldFiles.

One of my models has a FileField in which the user must submit a .bed 
file.  I use another library in python to analyze the .bed file.
The .bed file is saved to a specific directory on disk, and I want

file_on_disk = Bed('/Users/.../media/statistics.bed')

where statistics.bed is the name of the file, and media is the directory 
all files are saved to.  How would I construct this line of code?

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/9b1f70f6-da94-487b-8db5-601ce5b4ea9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-24 Thread Hugo Kitano
It always redirects to the stats page, though the model instance isn't 
saved.
I suspect it has to do with the .save() function, but I can't tell why, 
since I even create the modelform in the views.py file.




Thanks,

Hugo

On Saturday, August 22, 2015 at 3:19:07 AM UTC-7, James Schneider wrote:
>
> On Aug 22, 2015 3:10 AM, "James Schneider"  > wrote:
> >
> >  Hi, I'm a beginner using Django, and I'm having trouble using model 
> forms to create instances of my model.
> >  When a user submits a form, the database saves nothing.  Here's my 
> code for the view
> >   
> >
> > So what exactly does happen? Based on the code you provided, you would 
> either end up on the same page with a blank form (in the event of errors), 
> or you would be redirected back to another page.
> >
>
> Sorry, it's late, it probably redirects to the same page, assuming that 
> this view serves the /stats/ URL. Also, the spacing for your code blocks 
> didn't come through so it's hard to tell whether or not you are handling 
> things correctly, or at least on my phone it doesn't.
>
> -James
>

-- 
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/cc2565fb-7af9-471a-90ab-44b70c7e9169%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-24 Thread Hugo Kitano
I'm actually now pretty certain that my html file is what's causing it to 
not work



On Monday, August 24, 2015 at 11:34:41 AM UTC-7, Hugo Kitano wrote:
>
> It always redirects to the stats page, though the model instance isn't 
> saved.
> I suspect it has to do with the .save() function, but I can't tell why, 
> since I even create the modelform in the views.py file.
>
>
>
>
> Thanks,
>
> Hugo
>
> On Saturday, August 22, 2015 at 3:19:07 AM UTC-7, James Schneider wrote:
>>
>> On Aug 22, 2015 3:10 AM, "James Schneider"  wrote:
>> >
>> > >>>> Hi, I'm a beginner using Django, and I'm having trouble using 
>> model forms to create instances of my model.
>> > >>>> When a user submits a form, the database saves nothing.  Here's my 
>> code for the view
>> > >>>>  
>> >
>> > So what exactly does happen? Based on the code you provided, you would 
>> either end up on the same page with a blank form (in the event of errors), 
>> or you would be redirected back to another page.
>> >
>>
>> Sorry, it's late, it probably redirects to the same page, assuming that 
>> this view serves the /stats/ URL. Also, the spacing for your code blocks 
>> didn't come through so it's hard to tell whether or not you are handling 
>> things correctly, or at least on my phone it doesn't.
>>
>> -James
>>
>

-- 
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/3ec1a91a-db17-4a1d-be15-28f38fc84ebd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-24 Thread Hugo Kitano
More specifically, what does the action="/stats/" field do and require?

On Monday, August 24, 2015 at 12:41:16 PM UTC-7, Hugo Kitano wrote:
>
> I'm actually now pretty certain that my html file is what's causing it to 
> not work
>
>
>
> On Monday, August 24, 2015 at 11:34:41 AM UTC-7, Hugo Kitano wrote:
>>
>> It always redirects to the stats page, though the model instance isn't 
>> saved.
>> I suspect it has to do with the .save() function, but I can't tell why, 
>> since I even create the modelform in the views.py file.
>>
>>
>>
>>
>> Thanks,
>>
>> Hugo
>>
>> On Saturday, August 22, 2015 at 3:19:07 AM UTC-7, James Schneider wrote:
>>>
>>> On Aug 22, 2015 3:10 AM, "James Schneider"  wrote:
>>> >
>>> > >>>> Hi, I'm a beginner using Django, and I'm having trouble using 
>>> model forms to create instances of my model.
>>> > >>>> When a user submits a form, the database saves nothing.  Here's 
>>> my code for the view
>>> > >>>>  
>>> >
>>> > So what exactly does happen? Based on the code you provided, you would 
>>> either end up on the same page with a blank form (in the event of errors), 
>>> or you would be redirected back to another page.
>>> >
>>>
>>> Sorry, it's late, it probably redirects to the same page, assuming that 
>>> this view serves the /stats/ URL. Also, the spacing for your code blocks 
>>> didn't come through so it's hard to tell whether or not you are handling 
>>> things correctly, or at least on my phone it doesn't.
>>>
>>> -James
>>>
>>

-- 
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/04d69aee-678f-481c-99e2-4c5dcd095dc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-24 Thread Hugo Kitano
Also, it looks like the request.method is always 'GET', not 'POST', which 
means the form is never saved.  How is this happening?

On Monday, August 24, 2015 at 12:56:39 PM UTC-7, Hugo Kitano wrote:
>
> More specifically, what does the action="/stats/" field do and require?
>
> On Monday, August 24, 2015 at 12:41:16 PM UTC-7, Hugo Kitano wrote:
>>
>> I'm actually now pretty certain that my html file is what's causing it to 
>> not work
>>
>>
>>
>> On Monday, August 24, 2015 at 11:34:41 AM UTC-7, Hugo Kitano wrote:
>>>
>>> It always redirects to the stats page, though the model instance isn't 
>>> saved.
>>> I suspect it has to do with the .save() function, but I can't tell why, 
>>> since I even create the modelform in the views.py file.
>>>
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Hugo
>>>
>>> On Saturday, August 22, 2015 at 3:19:07 AM UTC-7, James Schneider wrote:
>>>>
>>>> On Aug 22, 2015 3:10 AM, "James Schneider"  wrote:
>>>> >
>>>> > >>>> Hi, I'm a beginner using Django, and I'm having trouble using 
>>>> model forms to create instances of my model.
>>>> > >>>> When a user submits a form, the database saves nothing.  Here's 
>>>> my code for the view
>>>> > >>>>  
>>>> >
>>>> > So what exactly does happen? Based on the code you provided, you 
>>>> would either end up on the same page with a blank form (in the event of 
>>>> errors), or you would be redirected back to another page.
>>>> >
>>>>
>>>> Sorry, it's late, it probably redirects to the same page, assuming that 
>>>> this view serves the /stats/ URL. Also, the spacing for your code blocks 
>>>> didn't come through so it's hard to tell whether or not you are handling 
>>>> things correctly, or at least on my phone it doesn't.
>>>>
>>>> -James
>>>>
>>>

-- 
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/ac986da4-2700-4297-a041-b03462e46aad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Forms questions

2015-08-24 Thread Hugo Kitano
Hi, I'm trying to figure out what's wrong with my form:

I've noticed that every time I load my submit view, the request.method is 
GET not POST, so nothing gets saved to the database.


Here's views.py


models.py


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/5048622e-04ad-4c97-96a1-d0c875fa7096%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Forms questions

2015-08-25 Thread Hugo Kitano
Here it is, very simple:

 Submit form: 

{% csrf_token %}
{{ form.as_p }}





On Monday, August 24, 2015 at 4:31:47 PM UTC-7, Sait Maraşlıoğlu wrote:
>
> Can you provide the template code?
>
>
> On Tuesday, 25 August 2015 00:16:40 UTC+3, Hugo Kitano wrote:
>>
>> Hi, I'm trying to figure out what's wrong with my form:
>>
>> I've noticed that every time I load my submit view, the request.method is 
>> GET not POST, so nothing gets saved to the database.
>>
>>
>> Here's views.py
>>
>>
>> models.py
>>
>>
>> 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/92cc7199-3794-43d6-8692-76d0655119e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-25 Thread Hugo Kitano
Noted.  "/stat/s" is an index page.  Here is what my urls.py looks like.  
Also, by using print statements, I've realized that the request.method is 
always GET, not POST, which makes it so no model instance is ever saved.  
What does this GET request refer to specifically?

Thanks






On Monday, August 24, 2015 at 3:29:40 PM UTC-7, Hugo Osvaldo Barrera wrote:
>
>  
> On Mon, Aug 24, 2015, at 16:41, Hugo Kitano wrote:
>
> I'm actually now pretty certain that my html file is what's causing it to 
> not work
>  
>
>  
> Including your message as an inline image rather than simple text will 
> reduce the amount of people that can actually read your message (and 
> complicate following the thread).
>  
> Does "/stats/" point to the above mentioned view ("submit")? What does 
> your urls.py look like? Did you try putting a "print" (or anything alike) 
> into the view function to really make sure it's the one being called?
>  
> --
> Hugo Osvaldo Barrera
>  
>

-- 
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/fa0965d5-6286-41e3-b408-3ddf2f42664c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working with FileFields/FieldFiles

2015-08-25 Thread Hugo Kitano
I guess my question is more "dumb" than that.  I need a concatenated string 
"*a**b*" where *a *is given and *b *is the name of a file uploaded to a 
field in a model.

Thanks!


On Saturday, August 22, 2015 at 2:55:03 PM UTC-7, Hugo Osvaldo Barrera 
wrote:
>
>  
>  
>  
> On Fri, Aug 21, 2015, at 14:28, Hugo Kitano wrote:
>
> Hi, I'm a beginner with Django, and I'm trying to figure out how to work 
> with FieldFiles.
>  
> One of my models has a FileField in which the user must submit a .bed 
> file.  I use another library in python to analyze the .bed file.
> The .bed file is saved to a specific directory on disk, and I want
>  
> file_on_disk = Bed('/Users/.../media/statistics.bed')
>  
> where statistics.bed is the name of the file, and media is the directory 
> all files are saved to.  How would I construct this line of code?
>  
> Thanks!
>
>  
> You're probably after the upload_to argument of FileField, which let you 
> define where files are saved:
>  
> 
> https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.FileField.upload_to
>  
> (I assume you're already looked into MEDIA_ROOT):
>  
> https://docs.djangoproject.com/en/1.8/ref/settings/#media-root
>  
> --
> Hugo Osvaldo Barrera
>  
>

-- 
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/0341ccce-e637-40fc-b971-0b2fb5d0c624%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using ModelForms

2015-08-25 Thread Hugo Kitano
So the form should have action = '/stats/submit/' ? If I do this, whenever 
I click submit, it brings me back to the submission page, telling me that I 
didn't submit a file even if I did.

On Tuesday, August 25, 2015 at 11:05:59 AM UTC-7, Hugo Osvaldo Barrera 
wrote:
>
>  
> On Tue, Aug 25, 2015, at 14:16, Hugo Kitano wrote:
>
> Noted.  "/stat/s" is an index page.  Here is what my urls.py looks like.  
> Also, by using print statements, I've realized that the request.method is 
> always GET, not POST, which makes it so no model instance is ever saved.  
> What does this GET request refer to specifically?
>  
> Thanks
>  
>  
>  
>  
>
>  
> Your form posts to /stats/, but /stats/ does not map to your view method 
> `submit`. You need to post data to the view that's processing it, so fix t 
> form or the urls.py.
>  
>
> On Monday, August 24, 2015 at 3:29:40 PM UTC-7, Hugo Osvaldo Barrera wrote:
>
>  
> On Mon, Aug 24, 2015, at 16:41, Hugo Kitano wrote:
>
> I'm actually now pretty certain that my html file is what's causing it to 
> not work
>  
>
>  
> Including your message as an inline image rather than simple text will 
> reduce the amount of people that can actually read your message (and 
> complicate following the thread).
>  
> Does "/stats/" point to the above mentioned view ("submit")? What does 
> your urls.py look like? Did you try putting a "print" (or anything alike) 
> into the view function to really make sure it's the one being called?
>  
> --
> Hugo Osvaldo Barrera
>  
>
> Email had 1 attachment:
>
>- Auto Generated Inline Image 1
>  12k (image/png)
>
>  
> --
> Hugo Osvaldo Barrera
>  
>

-- 
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/5cd4b875-2f32-4dca-8a4b-231695fec586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Forms questions

2015-08-25 Thread Hugo Kitano
I've realized that the action field in the form should be "/stats/submit/", 
the same view as the one that sent me to the template.  However, whenever I 
submit with the form then, it tells me that the file I submit is missing, 
even when it is definitely there.

On Tuesday, August 25, 2015 at 10:10:30 AM UTC-7, Hugo Kitano wrote:
>
> Here it is, very simple:
>
>  Submit form: 
> 
> {% csrf_token %}
> {{ form.as_p }}
> 
> 
>
>
>
> On Monday, August 24, 2015 at 4:31:47 PM UTC-7, Sait Maraşlıoğlu wrote:
>>
>> Can you provide the template code?
>>
>>
>> On Tuesday, 25 August 2015 00:16:40 UTC+3, Hugo Kitano wrote:
>>>
>>> Hi, I'm trying to figure out what's wrong with my form:
>>>
>>> I've noticed that every time I load my submit view, the request.method 
>>> is GET not POST, so nothing gets saved to the database.
>>>
>>>
>>> Here's views.py
>>>
>>>
>>> models.py
>>>
>>>
>>> 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/5b3c906a-8902-41f4-82b6-e2140ac0efae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form with MultipleChoiceField

2015-08-31 Thread Hugo Kitano
Hi, Django beginner here.  I'm trying to use a form with a 
MultipleChoiceField, but any choice that is selected doesn't seem to be 
processed.

Here is my form (very simple):


Here is my view:



And here is my template, which I'm sure is correct.



I notice there is a problem since when I print "picked" in the view, the 
console returns "None," even if one or more choices are selected.
Also, how do I work with "picked" if the form is working? Is it a Queryset? 
A list?
 
Thank you!



-- 
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/b8ac4f10-50be-417a-8797-6bbf618f2d72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sending a FileField attachment by email

2015-09-09 Thread Hugo Kitano
 

I'm having problems sending a FileField attachment via email. This should 
send an email, but doesn't. Is there something I have to configure in my 
gmail account for this to work?


settings.py:


EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'em...@gmail.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER

views.py:


#i.output is the FieldFile
message = 'Thanks for using our website!'
email = EmailMessage('Analysis', message, settings.EMAIL_HOST_USER, [toEmail])
email.attach(filename, i.output.read())
email.send()

I've even received an email from Gmail telling me a sign-in attempt was 
prevented. Any help? 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/3db3dfea-fe08-4454-8bb7-eb4837252187%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


HTTPS instead of HTTP in view

2015-09-14 Thread Hugo Kitano
Only one view in my project uses HTTPS instead of HTTP, now, after me 
fooling around with SSL's and cookies and such.
My view for that project is simple enough that it isn't the problem

It's the home page of the project.  Any ideas for why only one view uses 
HTTPS? I can't use the view in runserver anymore now.


-- 
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/054e5b17-6cc5-49e1-b97e-557510616a71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HTTPS instead of HTTP in view

2015-09-14 Thread Hugo Kitano
This is my settings.py, but I've commented out all the code I added 

-- 
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/3c1535df-ff18-4587-97d6-9f95a53a5f76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django deployment

2015-09-15 Thread Hugo Kitano
Hi, I'm a Django newbie, and I'm trying to decide how to deploy my small 
Django project.

I've read into a few options, but I keep hearing that Django deployment is 
unnecessarily difficult.  For a website with very little traffic, and for 
somebody who's new to it all, what is the best way to deploy? And how 
should I go about deploying!

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/d4d2d660-36dc-441c-afab-7b4acaedb53b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django deployment

2015-09-17 Thread Hugo Kitano
I'm having trouble deciphering what a APPMODULE is: 
$(MODULE_NAME):$(VARIABLE_NAME)

What does Module_Name and Variable_NAME refer to in the context of a Django 
project named "stats"?

Thanks


On Tuesday, September 15, 2015 at 1:02:59 PM UTC-7, Michiel Overtoom wrote:
>
> Hi Hugo, 
>
> > I keep hearing that Django deployment is unnecessarily difficult. 
>
> Who says this? And what are the reasons they give for it? 
>
>
> > For a website with very little traffic, and for somebody who's new to it 
> all, what is the best way to deploy? And how should I go about deploying! 
>
> I can tell you how I do it, which is not necessarily the simplest way nor 
> especially suited to low traffic. But it's not that hard. On the server 
> machine, I install nginx, gunicorn, django and supervisor. Nginx will be 
> the frontend, gunicorn will be the webserver, django is the application 
> server, and supervisor will be used to start/stop/restart the web 
> application. 
>
> I basically did the same as Shawn. In my supervisord.conf I have these 
> lines: 
>
>   [program:myapp] 
>   command=/usr/local/bin/gunicorn myapp.wsgi -b 127.0.0.1: 
>   directory=/wwwapp/myapp/my 
>   environment=PATH="%(ENV_PATH)s:/usr/local/bin" 
>   user=root 
>   autostart=true 
>   autorestart=true 
>   stdout_logfile=NONE 
>   stderr_logfile=NONE 
>
> I also wrote a blog article about this subject: 
> http://www.michielovertoom.com/freebsd/flask-gunicorn-nginx-supervisord/ 
> which uses Flask as an example, but as Shawn said, it's easy to plug in 
> your Django app instead. 
>
>

-- 
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/bb609edc-df8c-4ec1-b8c2-5b8d5a07386b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django deployment

2015-09-17 Thread Hugo Kitano
What is the nginx config? And where do I find it?

On Tuesday, September 15, 2015 at 12:46:40 PM UTC-7, Shawn Milochik wrote:
>
> It's very simple. Just follow these instructions:
>
> http://milocast.com/flasknginx.html
>
> Instead of the final line (gunicorn filename:appname -b 127.0.0.1:), 
> use this:
>
> ./manage.py run_gunicorn -b 127.0.0.1:
>
>

-- 
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/6060640a-2e4f-4806-b9ed-872008c58053%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.