Re: Newbie question

2021-06-07 Thread Lalit Suthar
try form.save(commit=False)


On Mon, 7 Jun 2021 at 22:10, Moose Smith <47kanga...@gmail.com> wrote:

> I have a table which holds simple data like addresses. Created a form
> which displays the records in the form and allows the user to select a
> record "address" to edit.
>
> I want this edit function to be generic so it will work on any table
> without me having to define fields etc... and using  ModelForm I
> accomplished by goal.
>
> Django creates a form and using instance='myrecord' it even populated the
> fields in the form with the record I want to edit. I can edit my fields
> and now it is time to save the changes back to the database.
>
> I found a .save() method for
> # Create a form to edit an existing Article, but use
> # POST data to populate the form.
> >>> a = Article.objects.get(pk=1)
> >>> f = ArticleForm(request.POST, instance=a) >>> f.save()
>
> My question is this:
> The .save method discuss in the Django Documentation above is a method of
> ModelForm but I have rendered my form and when I hit the SUBMIT button the
> edited fields are returned in a WSGI type object which does not have a save
> method.
>
> I can use the POST data and pass the PK and so on, and update the record
> manually with some code. BUT WHAT is the use of a .SAVE method on a
> ModelForm. In order to edit the form I need to RENDER it right?
>
> Is there a way to return the ModelForm object with the edited fields and
> then save back to the database?
>
> Thanks
>
> Moose
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6ccb9692-5f95-4f8a-86b1-18259b00c0dan%40googlegroups.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVH-Da2AeUFzoXWsdPUQrg5%3Dg2ch8pToeA%2BSsdNNYSC4hQ%40mail.gmail.com.


Newbie question

2021-06-07 Thread Moose Smith
I have a table which holds simple data like addresses. Created a form which 
displays the records in the form and allows the user to select a record 
"address" to edit. 

I want this edit function to be generic so it will work on any table 
without me having to define fields etc... and using  ModelForm I 
accomplished by goal. 

Django creates a form and using instance='myrecord' it even populated the 
fields in the form with the record I want to edit. I can edit my fields  
and now it is time to save the changes back to the database.

I found a .save() method for 
# Create a form to edit an existing Article, but use
# POST data to populate the form.
>>> a = Article.objects.get(pk=1)
>>> f = ArticleForm(request.POST, instance=a) >>> f.save()

My question is this:
The .save method discuss in the Django Documentation above is a method of 
ModelForm but I have rendered my form and when I hit the SUBMIT button the 
edited fields are returned in a WSGI type object which does not have a save 
method.

I can use the POST data and pass the PK and so on, and update the record 
manually with some code. BUT WHAT is the use of a .SAVE method on a 
ModelForm. In order to edit the form I need to RENDER it right?

Is there a way to return the ModelForm object with the edited fields and 
then save back to the database?

Thanks 

Moose

 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6ccb9692-5f95-4f8a-86b1-18259b00c0dan%40googlegroups.com.


Re: Newbie question : running the makemigrations command in the terminal

2019-03-30 Thread kamibarut609
@jgi...@caktusgroup.com  Thank you for your help, I received some help on 
Stackoverflow.
@ Krishna Tulsyan Thank you for your help, I received some help on 
Stackoverflow.

On Friday, 29 March 2019 12:37:05 UTC+1, Krishna Tulsyan wrote:
>
> Hi,
> can you provide the folder structure of your app, and apps.py file
> ensure that the name of the app is 'munichlivin_app' and name of the class 
> in apps.py is 'MunichLivingConfig'
>
> On Thursday, March 28, 2019 at 9:05:46 PM UTC+5:30, kamiba...@gmail.com 
> wrote:
>>
>> Hello,
>>
>> (Newbie here): I am trying to run the makemigrations icommand in my 
>> terminal. You will find here below the three relevant files, the third one 
>> showing the errors displayed in 
>> the terminal. 
>>
>> My settings.py file:
>>
>>
>> https://pastebin.com/raw/xLpX0Zfg
>>
>>
>> My models.py file: 
>>
>> https://pastebin.com/raw/wYfSy8ET
>>
>>
>> The terminal entry (with the errors)
>>
>>
>> https://pastebin.com/raw/Pmpnepf1
>>
>>
>> Thank you for your time and your help.
>>
>>
>> K.
>>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cf03abe8-23b6-4709-a2ff-07c06f3da8e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question : running the makemigrations command in the terminal

2019-03-29 Thread Krishna Tulsyan
Hi,
can you provide the folder structure of your app, and apps.py file
ensure that the name of the app is 'munichlivin_app' and name of the class 
in apps.py is 'MunichLivingConfig'

On Thursday, March 28, 2019 at 9:05:46 PM UTC+5:30, kamiba...@gmail.com 
wrote:
>
> Hello,
>
> (Newbie here): I am trying to run the makemigrations icommand in my 
> terminal. You will find here below the three relevant files, the third one 
> showing the errors displayed in 
> the terminal. 
>
> My settings.py file:
>
>
> https://pastebin.com/raw/xLpX0Zfg
>
>
> My models.py file: 
>
> https://pastebin.com/raw/wYfSy8ET
>
>
> The terminal entry (with the errors)
>
>
> https://pastebin.com/raw/Pmpnepf1
>
>
> Thank you for your time and your help.
>
>
> K.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/67c7a2fd-0697-45bf-b591-d7d0b0bdcfbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question : running the makemigrations command in the terminal

2019-03-28 Thread jgibson
>From your settings file:
 

> munichliving_app.apps.MunichLivingConfig
>
>
That makes me think that the structure of your project looks something like 
this:

\munichliving_app\manage.py
\munichliving_app\apps\MunichLivingConfig\
\munichliving_app\apps\MunichLivingConfig\models.py
\munichliving_app\apps\MunichLivingConfig\views.py
\munichliving_app\apps\MunichLivingConfig\admin.py





And `OffererProfile` is defined inside models. Is that correct?

On Thursday, March 28, 2019 at 11:35:46 AM UTC-4, kamiba...@gmail.com wrote:
>
> Hello,
>
> (Newbie here): I am trying to run the makemigrations icommand in my 
> terminal. You will find here below the three relevant files, the third one 
> showing the errors displayed in 
> the terminal. 
>
> My settings.py file:
>
>
> https://pastebin.com/raw/xLpX0Zfg
>
>
> My models.py file: 
>
> https://pastebin.com/raw/wYfSy8ET
>
>
> The terminal entry (with the errors)
>
>
> https://pastebin.com/raw/Pmpnepf1
>
>
> Thank you for your time and your help.
>
>
> K.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9d5f73c3-0335-4003-8162-5c72aa07f723%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question : running the makemigrations command in the terminal

2019-03-28 Thread kamibarut609


On Thursday, 28 March 2019 16:35:46 UTC+1, kamiba...@gmail.com wrote:
>
> Hello,
>
> (Newbie here): I am trying to run the makemigrations icommand in my 
> terminal. You will find here below the three relevant files, the third one 
> showing the errors displayed in 
> the terminal. 
>
> My settings.py file:
>
>
> https://pastebin.com/raw/xLpX0Zfg
>
>
> My models.py file: 
>
> https://pastebin.com/raw/wYfSy8ET
>
>
> The terminal entry (with the errors)
>
>
> https://pastebin.com/raw/Pmpnepf1
>
>
>
No matter the changes I make in the apps.py, settings.py and models.py 
files, I always read in the terminal :

 "  No changes detected in app 'munichliving_app'

 ( I am using Python 3.6 and Django 2.7.1)
 

>  Thank you for your time and your help.
>
>
> K.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a62b4366-e47b-468a-a562-3ceb8fe69e27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Newbie question : running the makemigrations command in the terminal

2019-03-28 Thread kamibarut609
Hello,

(Newbie here): I am trying to run the makemigrations icommand in my 
terminal. You will find here below the three relevant files, the third one 
showing the errors displayed in 
the terminal. 

My settings.py file:


https://pastebin.com/raw/xLpX0Zfg


My models.py file: 

https://pastebin.com/raw/wYfSy8ET


The terminal entry (with the errors)


https://pastebin.com/raw/Pmpnepf1


Thank you for your time and your help.


K.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5c8fbee-2eff-4bcc-8474-5779f8e0fc11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question, start server with hostname

2017-02-08 Thread Dylan Reinhold
You don't include the http://
python manage.py runserver hostname:8000 or put the IP address in the
hostname area/

Dylan

On Wed, Feb 8, 2017 at 12:29 PM, hippohippo 
wrote:

> Dear all,
>
> I am a new comer on Django. I was able to to run start server by command
> as below yesterday.
>
> python manage.py runserver http:/hostname:8000
>
> However today, it submit the error as CommandError: "
> http://te172.24.221.137:8000/; is not a valid port number or address:port
> pair.
>
> Can anyone give me some hint how to fix this? 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/c029b611-898b-4015-b643-e1eaabaa43cc%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHtg44DExi7rq-NkBgjaC6ZMXMc0VFBvNiXuj6GB7R0ynHztqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Newbie question, start server with hostname

2017-02-08 Thread hippohippo
Dear all,

I am a new comer on Django. I was able to to run start server by command as 
below yesterday.

python manage.py runserver http:/hostname:8000 

However today, it submit the error as CommandError: 
"http://te172.24.221.137:8000/; is not a valid port number or address:port 
pair.

Can anyone give me some hint how to fix this? 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c029b611-898b-4015-b643-e1eaabaa43cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-30 Thread Derek
You'll probably need jQuery. Bear in mind "size" is not absolute as it will 
depend on font family and font height.

On Sunday, 30 October 2016 01:27:59 UTC+2, Ken Albright wrote:
>
> Sounds good. Thanks for the advice. Now if I could only figure out how to 
> get forms to expand and contract to match the size of the quote...
>
> Thanks.
>
> On Friday, October 28, 2016 at 5:00:14 PM UTC-7, Ken Albright wrote:
>>
>> I'm just learning Python and Django so please be gentle...
>>
>> I've written a quote decryption game (like you see in the newspaper) in 
>> Python. I'd like to put it on a web page with Django. However, I'm not sure 
>> of the best way to structure the data. The original quote and the encrypted 
>> quote need to have a one-to-one relationship at the letter level. So it 
>> could be two strings on the same row (same id) or a set of tuples, a 
>> dictionary, or ???
>>
>> How to set up the database and 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/600aea7e-54fc-4856-9c71-fc56469d3712%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Stephanie Statsmann
K

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fd2efe41-c1dc-455d-9597-a931186c6382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Ken Albright
Sounds good. Thanks for the advice. Now if I could only figure out how to 
get forms to expand and contract to match the size of the quote...

Thanks.

On Friday, October 28, 2016 at 5:00:14 PM UTC-7, Ken Albright wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in 
> Python. I'd like to put it on a web page with Django. However, I'm not sure 
> of the best way to structure the data. The original quote and the encrypted 
> quote need to have a one-to-one relationship at the letter level. So it 
> could be two strings on the same row (same id) or a set of tuples, a 
> dictionary, or ???
>
> How to set up the database and 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d97d972b-ec64-483a-8aaf-e69482a4050e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Yaşar Arabacı
I am also quite new to django, but I will go with something like this;

class Quote(models.Model):
quote= models.CharField(max_length=100)

class EncryptedQuote(models.Model)
quote = models.ForeignKey(Quote, on_delete=models.CASCADE)
encrypted_quote = models.CharField(max_length=100)


So, you can have multiple encryptions of any quote.

On Saturday, October 29, 2016 at 3:00:14 AM UTC+3, Ken Albright wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in 
> Python. I'd like to put it on a web page with Django. However, I'm not sure 
> of the best way to structure the data. The original quote and the encrypted 
> quote need to have a one-to-one relationship at the letter level. So it 
> could be two strings on the same row (same id) or a set of tuples, a 
> dictionary, or ???
>
> How to set up the database and 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc31d02e-8345-4467-99df-0e4688a76a48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question - data structure for game

2016-10-29 Thread Bob Gailer
On Oct 28, 2016 7:59 PM, "Ken Albright"  wrote:
>
> I'm just learning Python and Django so please be gentle...
>
> I've written a quote decryption game (like you see in the newspaper) in
Python. I'd like to put it on a web page with Django. However, I'm not sure
of the best way to structure the data. The original quote and the encrypted
quote need to have a one-to-one relationship at the letter level. So it
could be two strings on the same row (same id)

That is the simplest, and I see no need for anything more complex.

or a set of tuples, a dictionary, or ???
>
> How to set up the database

What do you mean?

and models.py?

class Quote:
plain= Models.CharField()
crypt = Models.CharField()

> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/b37833bf-e474-4b15-844d-4ef8d8e854b6%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP1rxO7uhPGRD8MdDaZxPM9ZWpViMMoFdy0_dBfb5ahuZiEB4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Newbie question - data structure for game

2016-10-28 Thread Ken Albright
I'm just learning Python and Django so please be gentle...

I've written a quote decryption game (like you see in the newspaper) in 
Python. I'd like to put it on a web page with Django. However, I'm not sure 
of the best way to structure the data. The original quote and the encrypted 
quote need to have a one-to-one relationship at the letter level. So it 
could be two strings on the same row (same id) or a set of tuples, a 
dictionary, or ???

How to set up the database and 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b37833bf-e474-4b15-844d-4ef8d8e854b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question regarding uninstalling Django system-wide.

2016-07-13 Thread Leo
Thanks Mike

On Tuesday, July 12, 2016 at 8:03:18 PM UTC-4, Mike Dewhirst wrote:
>
> On 13/07/2016 1:55 AM, Leo wrote: 
> > I am learning how to use Django. With my first attempt I did not use a 
> > virtual environment instead installed Django system-wide. Now I have 
> > learned to utilize virtual environments. Can you help me learn how to 
> > uninstall the system-wide Django instance? Also, I can't recall if I 
> > used pip or apt-get. Or do I need to be concerned with this at all, 
> > meaning will the base install conflict with instances installed in the 
> > virtual environments? 
>
> sudo pip uninstall django 
>
> sudo apt-get remove django 
>
> The base install is unnecessary if Django is installed in the venv and 
> it should not conflict. 
>
> It is best to avoid any base installs unless you *know* they will be 
> used by all venvs 
>
>
> > 
> > 
> > Your help is appreciated. 
> > 
> > Leo 
> > 
> > -- 
> > 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 https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/638a94f9-8bb8-40c4-80f2-204b0479dc74%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/638a94f9-8bb8-40c4-80f2-204b0479dc74%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/99ad53fd-8951-46f1-90d8-b88f760ee586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question regarding uninstalling Django system-wide.

2016-07-12 Thread Mike Dewhirst

On 13/07/2016 1:55 AM, Leo wrote:

I am learning how to use Django. With my first attempt I did not use a
virtual environment instead installed Django system-wide. Now I have
learned to utilize virtual environments. Can you help me learn how to
uninstall the system-wide Django instance? Also, I can't recall if I
used pip or apt-get. Or do I need to be concerned with this at all,
meaning will the base install conflict with instances installed in the
virtual environments?


sudo pip uninstall django

sudo apt-get remove django

The base install is unnecessary if Django is installed in the venv and 
it should not conflict.


It is best to avoid any base installs unless you *know* they will be 
used by all venvs






Your help is appreciated.

Leo

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/638a94f9-8bb8-40c4-80f2-204b0479dc74%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71ea4c0f-886d-7fa7-8c8e-267f9cb93715%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Newbie question regarding uninstalling Django system-wide.

2016-07-12 Thread Leo


I am learning how to use Django. With my first attempt I did not use a 
virtual environment instead installed Django system-wide. Now I have 
learned to utilize virtual environments. Can you help me learn how to 
uninstall the system-wide Django instance? Also, I can't recall if I used 
pip or apt-get. Or do I need to be concerned with this at all, meaning will 
the base install conflict with instances installed in the virtual 
environments?


Your help is appreciated.

Leo

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/638a94f9-8bb8-40c4-80f2-204b0479dc74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread Tom Lockhart
> The Python functions I wish to execute use numpy and other Python packages I 
> would like like to convert to JavaScript.

As has been suggested, the tutorial is where you want to start. By the time you 
finish part 4 you will have a good idea how to bypass references to a data 
model and use forms and views to call something in numpy and return results.

Trying to skip the tutorial just means that you will be missing information 
required to be comfortable starting with Django. We pretty much all started 
there and do not regret it.

hth

- 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/15165428-D0C6-47B2-9F23-AC92B2D54BBB%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread Vincent Davis
On Friday, March 20, 2015, john  wrote:

>  Maybe another way to reply to your question is to break down how it would
> work normally.
> There are two sides of this question - the server side and the client side.
>
> In general client side stuff is done in javascript.
> Server side requests are done in python.
>
> So you have to decide where you want this to happen.  If you chose the
> server side realize that a round trip has to occur.  This can be done and
> was done often but not normally used when dealing with direct user input
> (javascript is used) on the client side (in the browser).  You can in fact
> create a button that retrieves the data (executes a view function) and then
> returns a new view.  But that is very old school and normally not used.
> You might want to look at how the django forms works under the hood and use
> similar code.
>

The Python functions I wish to execute use numpy and other Python packages
I would like like to convert to JavaScript.


>
> That said, the above is not the norm of today.  Within your template you
> add div id's that relate to javascript code.  When the action occurs the
> javascript is run (all on the client side) saving a round trip.  Today's
> javascript is able to retrieve data (execute a python function via a view),
> display data, insert new objects, etc..  So of course most use the best
> tool for the job.
>
> Johnf
>


>
>
> On 03/20/2015 10:32 AM, VMD wrote:
>
>
> On Friday, March 20, 2015 at 11:09:57 AM UTC-6, David Gleba wrote:
>>
>>
>>  You don't actually need python or django to get form input and do
>> something with the input.
>>
>
>  My function is not as simple as adding two numbers and for various
> reasons I am not interested in using Javascript. I just used myadder(x,y)
>  as an example.
>
>
>>
>>
>> On Friday, March 20, 2015 at 12:03:51 PM UTC-4, VMD wrote:
>>>
>>> On Friday, March 20, 2015 at 9:58:23 AM UTC-6, David Gleba wrote:

 Does part 3 of the tutorial cover how to make a form, get the values
 without storing them in a database, perform the arithmetic and then display
 the result? I didn't see that in there.

>>>
>>> I don't what to store them in a database. Just do the calculation. Is
>>> this explained in the tutorial?
>>>
>>>  I have been sick = brain not working well. maybe I'll get this figured
>>> out today or actually do the whole tutorial.
>>>
>>>  VMD
>>>
>>>

>>>
 On Thursday, March 19, 2015 at 11:58:14 AM UTC-4, Andrew Farrell wrote:
>
> The other commenters are right that reading the tutorial is a good use
> of your time.
> https://docs.djangoproject.com/en/1.7/intro/tutorial03/
>  is the section relevant to your question.
>
> On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra Giraldez <
> jav...@guerrag.com> wrote:
>
>> On Wed, Mar 18, 2015 at 9:41 PM, VMD  wrote:
>> > I have skimmed the tutorial and didn't find (notice) the answer.
>> Why not
>> > point me to an answer to my question?
>>
>>
>> that's exactly the point.  your question assumes Django works in some
>> specific way, and there should be a simple answer for a simple need.
>>
>> but i don't think you assumptions are correct, if you knew how Django
>> (and frameworks in general) work, your question might be very
>> different, and the answer much simpler and better in general.
>>
>> really, doing the tutorial is a very good investment of your time.
>>
>>
>> --
>> Javier
>>
>> --
>> 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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP
>> 2POm%3DF90Vn%3DF88dYDDQdg%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/0fb52afc-17ec-4301-add2-85fc962f73b4%40googlegroups.com
> 

Re: newbie question

2015-03-20 Thread john
Maybe another way to reply to your question is to break down how it 
would work normally.

There are two sides of this question - the server side and the client side.

In general client side stuff is done in javascript.
Server side requests are done in python.

So you have to decide where you want this to happen.  If you chose the 
server side realize that a round trip has to occur.  This can be done 
and was done often but not normally used when dealing with direct user 
input (javascript is used) on the client side (in the browser).  You can 
in fact create a button that retrieves the data (executes a view 
function) and then returns a new view.  But that is very old school and 
normally not used.  You might want to look at how the django forms works 
under the hood and use similar code.


That said, the above is not the norm of today.  Within your template you 
add div id's that relate to javascript code.  When the action occurs the 
javascript is run (all on the client side) saving a round trip.  Today's 
javascript is able to retrieve data (execute a python function via a 
view), display data, insert new objects, etc..  So of course most use 
the best tool for the job.


Johnf

On 03/20/2015 10:32 AM, VMD wrote:


On Friday, March 20, 2015 at 11:09:57 AM UTC-6, David Gleba wrote:


You don't actually need python or django to get form input and do
something with the input.


My function is not as simple as adding two numbers and for various 
reasons I am not interested in using Javascript. I just used 
myadder(x,y)  as an example.





On Friday, March 20, 2015 at 12:03:51 PM UTC-4, VMD wrote:

On Friday, March 20, 2015 at 9:58:23 AM UTC-6, David Gleba wrote:

Does part 3 of the tutorial cover how to make a form, get
the values without storing them in a database, perform the
arithmetic and then display the result? I didn't see that
in there.

I don't what to store them in a database. Just do the
calculation. Is this explained in the tutorial?

I have been sick = brain not working well. maybe I'll get this
figured out today or actually do the whole tutorial.

VMD


On Thursday, March 19, 2015 at 11:58:14 AM UTC-4, Andrew
Farrell wrote:

The other commenters are right that reading the
tutorial is a good use of your time.
https://docs.djangoproject.com/en/1.7/intro/tutorial03/ 

is the section relevant to your question.

On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra
Giraldez  wrote:

On Wed, Mar 18, 2015 at 9:41 PM, VMD
 wrote:
> I have skimmed the tutorial and didn't find
(notice) the answer. Why not
> point me to an answer to my question?


that's exactly the point.  your question assumes
Django works in some
specific way, and there should be a simple answer
for a simple need.

but i don't think you assumptions are correct, if
you knew how Django
(and frameworks in general) work, your question
might be very
different, and the answer much simpler and better
in general.

really, doing the tutorial is a very good
investment of your time.


--
Javier

--
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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%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 

Re: newbie question

2015-03-20 Thread VMD

On Friday, March 20, 2015 at 11:09:57 AM UTC-6, David Gleba wrote:
>
>
> You don't actually need python or django to get form input and do 
> something with the input.
>

My function is not as simple as adding two numbers and for various reasons 
I am not interested in using Javascript. I just used myadder(x,y)  as an 
example.


>
>
> On Friday, March 20, 2015 at 12:03:51 PM UTC-4, VMD wrote:
>>
>> On Friday, March 20, 2015 at 9:58:23 AM UTC-6, David Gleba wrote:
>>>
>>> Does part 3 of the tutorial cover how to make a form, get the values 
>>> without storing them in a database, perform the arithmetic and then display 
>>> the result? I didn't see that in there.
>>>
>>  
>> I don't what to store them in a database. Just do the calculation. Is 
>> this explained in the tutorial?
>>
>> I have been sick = brain not working well. maybe I'll get this figured 
>> out today or actually do the whole tutorial.
>>
>> VMD
>>
>>  
>>>
>>
>>> On Thursday, March 19, 2015 at 11:58:14 AM UTC-4, Andrew Farrell wrote:

 The other commenters are right that reading the tutorial is a good use 
 of your time.
 https://docs.djangoproject.com/en/1.7/intro/tutorial03/
 is the section relevant to your question.

 On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra Giraldez <
 jav...@guerrag.com> wrote:

> On Wed, Mar 18, 2015 at 9:41 PM, VMD  wrote:
> > I have skimmed the tutorial and didn't find (notice) the answer. Why 
> not
> > point me to an answer to my question?
>
>
> that's exactly the point.  your question assumes Django works in some
> specific way, and there should be a simple answer for a simple need.
>
> but i don't think you assumptions are correct, if you knew how Django
> (and frameworks in general) work, your question might be very
> different, and the answer much simpler and better in general.
>
> really, doing the tutorial is a very good investment of your time.
>
>
> --
> Javier
>
> --
> 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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%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/0fb52afc-17ec-4301-add2-85fc962f73b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread john
I'm not aware that you can use javascript in views.py.  In the Template 
- I believe you mean.


Johnf
On 03/20/2015 09:35 AM, David Gleba wrote:
Also, I am not an expert in Django yet, but I think you can use html 
and javascript in views.


--
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/550C5523.1030103%40jfcomputer.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread David Gleba
I will try to answer your question here another way.

I searched google for: form to add two numbers

I see: 
 http://stackoverflow.com/questions/14496531/adding-two-numbers-using-javascript

This example uses an HTML form and javascript to perform the task on the 
input.

You don't actually need python or django to get form input and do something 
with the input.

Also, I am not an expert in Django yet, but I think you can use html and 
javascript in views.



On Friday, March 20, 2015 at 12:03:51 PM UTC-4, VMD wrote:
>
> On Friday, March 20, 2015 at 9:58:23 AM UTC-6, David Gleba wrote:
>>
>> Does part 3 of the tutorial cover how to make a form, get the values 
>> without storing them in a database, perform the arithmetic and then display 
>> the result? I didn't see that in there.
>>
>  
> I don't what to store them in a database. Just do the calculation. Is this 
> explained in the tutorial?
>
> I have been sick = brain not working well. maybe I'll get this figured out 
> today or actually do the whole tutorial.
>
> VMD
>
>  
>>
>
>> On Thursday, March 19, 2015 at 11:58:14 AM UTC-4, Andrew Farrell wrote:
>>>
>>> The other commenters are right that reading the tutorial is a good use 
>>> of your time.
>>> https://docs.djangoproject.com/en/1.7/intro/tutorial03/
>>> is the section relevant to your question.
>>>
>>> On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra Giraldez <
>>> jav...@guerrag.com> wrote:
>>>
 On Wed, Mar 18, 2015 at 9:41 PM, VMD  wrote:
 > I have skimmed the tutorial and didn't find (notice) the answer. Why 
 not
 > point me to an answer to my question?


 that's exactly the point.  your question assumes Django works in some
 specific way, and there should be a simple answer for a simple need.

 but i don't think you assumptions are correct, if you knew how Django
 (and frameworks in general) work, your question might be very
 different, and the answer much simpler and better in general.

 really, doing the tutorial is a very good investment of your time.


 --
 Javier

 --
 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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%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/1dea13f1-aeb4-4dca-8179-afa7bc7efda1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread VMD
On Friday, March 20, 2015 at 9:58:23 AM UTC-6, David Gleba wrote:
>
> Does part 3 of the tutorial cover how to make a form, get the values 
> without storing them in a database, perform the arithmetic and then display 
> the result? I didn't see that in there.
>
 
I don't what to store them in a database. Just do the calculation. Is this 
explained in the tutorial?

I have been sick = brain not working well. maybe I'll get this figured out 
today or actually do the whole tutorial.

VMD

 
>

> On Thursday, March 19, 2015 at 11:58:14 AM UTC-4, Andrew Farrell wrote:
>>
>> The other commenters are right that reading the tutorial is a good use of 
>> your time.
>> https://docs.djangoproject.com/en/1.7/intro/tutorial03/
>> is the section relevant to your question.
>>
>> On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra Giraldez <
>> jav...@guerrag.com> wrote:
>>
>>> On Wed, Mar 18, 2015 at 9:41 PM, VMD  wrote:
>>> > I have skimmed the tutorial and didn't find (notice) the answer. Why 
>>> not
>>> > point me to an answer to my question?
>>>
>>>
>>> that's exactly the point.  your question assumes Django works in some
>>> specific way, and there should be a simple answer for a simple need.
>>>
>>> but i don't think you assumptions are correct, if you knew how Django
>>> (and frameworks in general) work, your question might be very
>>> different, and the answer much simpler and better in general.
>>>
>>> really, doing the tutorial is a very good investment of your time.
>>>
>>>
>>> --
>>> Javier
>>>
>>> --
>>> 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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%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/fb4e5744-9b31-4408-9e08-47507cc3e29f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-20 Thread David Gleba
Does part 3 of the tutorial cover how to make a form, get the values 
without storing them in a database, perform the arithmetic and then display 
the result? I didn't see that in there.


On Thursday, March 19, 2015 at 11:58:14 AM UTC-4, Andrew Farrell wrote:
>
> The other commenters are right that reading the tutorial is a good use of 
> your time.
> https://docs.djangoproject.com/en/1.7/intro/tutorial03/
> is the section relevant to your question.
>
> On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra Giraldez <
> jav...@guerrag.com > wrote:
>
>> On Wed, Mar 18, 2015 at 9:41 PM, VMD > > wrote:
>> > I have skimmed the tutorial and didn't find (notice) the answer. Why not
>> > point me to an answer to my question?
>>
>>
>> that's exactly the point.  your question assumes Django works in some
>> specific way, and there should be a simple answer for a simple need.
>>
>> but i don't think you assumptions are correct, if you knew how Django
>> (and frameworks in general) work, your question might be very
>> different, and the answer much simpler and better in general.
>>
>> really, doing the tutorial is a very good investment of your time.
>>
>>
>> --
>> Javier
>>
>> --
>> 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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%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/d7071e54-27f5-45f5-b183-1bdcce76820d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-19 Thread Andrew Farrell
The other commenters are right that reading the tutorial is a good use of
your time.
https://docs.djangoproject.com/en/1.7/intro/tutorial03/
is the section relevant to your question.

On Thu, Mar 19, 2015 at 10:39 AM, Javier Guerra Giraldez  wrote:

> On Wed, Mar 18, 2015 at 9:41 PM, VMD  wrote:
> > I have skimmed the tutorial and didn't find (notice) the answer. Why not
> > point me to an answer to my question?
>
>
> that's exactly the point.  your question assumes Django works in some
> specific way, and there should be a simple answer for a simple need.
>
> but i don't think you assumptions are correct, if you knew how Django
> (and frameworks in general) work, your question might be very
> different, and the answer much simpler and better in general.
>
> really, doing the tutorial is a very good investment of your time.
>
>
> --
> Javier
>
> --
> 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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%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/CA%2By5TLZVUzRqL_Tcwwq%2BD2p70XdXbW2E%3DYQ1adavbJOmxggLow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-19 Thread Javier Guerra Giraldez
On Wed, Mar 18, 2015 at 9:41 PM, VMD  wrote:
> I have skimmed the tutorial and didn't find (notice) the answer. Why not
> point me to an answer to my question?


that's exactly the point.  your question assumes Django works in some
specific way, and there should be a simple answer for a simple need.

but i don't think you assumptions are correct, if you knew how Django
(and frameworks in general) work, your question might be very
different, and the answer much simpler and better in general.

really, doing the tutorial is a very good investment of your time.


-- 
Javier

-- 
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/CAFkDaoQ0MOT57JCKfTjxWn6CkypeP2POm%3DF90Vn%3DF88dYDDQdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-19 Thread VMD
On Wednesday, March 18, 2015 at 12:51:22 PM UTC-6, Avraham Serour wrote:
>
> short - use a view
>
> follow the tutorial, yes you will learn how to store and retrieve values 
> from a database, and I understand that you don't need that yet but the 
> tutorial is very brief, you won't waste your time with advanced topics you 
> don't need
>

I understand you have good intentions with your answer. I am trying not to 
be frustrated with it. I don't think I would call the tutorial "very brief" 
I have skimmed the tutorial and didn't find (notice) the answer. Why not 
point me to an answer to my question?

Trying not to be frustrated ;)
Thanks
VMD
 

>  
>
On Wed, Mar 18, 2015 at 8:08 PM, VMD  
> wrote:
>
>> New to django and web frameworks in general. The tutorial is great for 
>> database type apps but I want to solve a different problem to start with 
>> and am kinda stuck. All I want to do is allow a user to input a value(s) 
>> and return the output of a python function using that value(s). Could 
>> someone point me to an example or guide for doing this.
>> For example:
>>
>> Accept input X, Y
>> Return the output of myadder(x,y)
>>
>> def myadder(x,y):
>> return x+y
>>
>>  -- 
>> 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/4f1c37bd-0f91-4708-aa40-e1dd0db44e09%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/91dfe6d9-dc90-42ae-a1e2-c680f718d125%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: newbie question

2015-03-18 Thread Avraham Serour
short - use a view

follow the tutorial, yes you will learn how to store and retrieve values
from a database, and I understand that you don't need that yet but the
tutorial is very brief, you won't waste your time with advanced topics you
don't need

On Wed, Mar 18, 2015 at 8:08 PM, VMD  wrote:

> New to django and web frameworks in general. The tutorial is great for
> database type apps but I want to solve a different problem to start with
> and am kinda stuck. All I want to do is allow a user to input a value(s)
> and return the output of a python function using that value(s). Could
> someone point me to an example or guide for doing this.
> For example:
>
> Accept input X, Y
> Return the output of myadder(x,y)
>
> def myadder(x,y):
> return x+y
>
>  --
> 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/4f1c37bd-0f91-4708-aa40-e1dd0db44e09%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/CAFWa6t%2BhpFfxYPKp1n54KJnjdJ-ASqpiuY12HfFC9kUR1JTp%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


newbie question

2015-03-18 Thread VMD
New to django and web frameworks in general. The tutorial is great for 
database type apps but I want to solve a different problem to start with 
and am kinda stuck. All I want to do is allow a user to input a value(s) 
and return the output of a python function using that value(s). Could 
someone point me to an example or guide for doing this.
For example:

Accept input X, Y
Return the output of myadder(x,y)

def myadder(x,y):
return x+y

-- 
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/4f1c37bd-0f91-4708-aa40-e1dd0db44e09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Cheng Guo
Thank you Daniel, I didn't know this! I am going to lookup how to use 
session. Thanks!

On Monday, 19 January 2015 17:13:10 UTC+8, Daniel Roseman wrote:
>
> On Monday, 19 January 2015 07:28:14 UTC, Cheng Guo wrote:
>>
>> Hello,
>>
>> I am new to Django and I have run into an issue with views.py.  I 
>> understand that there is a function behind each view. For a view that I am 
>> currently writing, it accepts a file upload from user and stores the file 
>> on the server. To do that, I need to:
>>
>> 1. check the file extension is correct
>> 2. generate a SHA-1 id for the file based on its content
>> 3. write the file to disk
>> 4. save information about the file to database
>>
>> (oh, I also created two global variables as well)
>>
>>
> Others have pointed out ways to split this up, but I wanted to pick up on 
> the last sentence. You really really should not be setting global variables 
> in your view, especially in response to user input. Global variables are 
> shared by all requests in a process, and you can't guarantee either that 
> all requests will be from the same user, or even that the same user will 
> hit the same process in subsequent requests. Don't do this: if you need to 
> store state between requests, use the db or the session.
> --
> 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/45f7fdbf-45e6-4616-9204-effb4ef4c528%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Cheng Guo
Hello James:

Thank you very much for spending the time reading and answering this 
question, really appreciated!

I complete understand your suggestion of overriding the "save" method in 
the "UploadFile" to generate the id before saving. Thank you for pointing 
this out.

On the other hand, I read that it is not recommended to store files in 
database. So I decide to only store upload files on disk and save their 
file path and generated id in the database. So here is my model:

class UploadFile(models.Model):
upload_date = models.DateTimeField('timestamp', auto_now_add=True)
original_file_name = models.CharField(max_length=200)
file_id = models.CharField(max_length=40, primary_key=True)
file_path = models.CharField(max_length=500)
owner = models.ForeignKey(User)


I could use your method to override the save method, but the problem I face 
is that to generate the id, I need to pass the "UploadedFile" object to the 
 model, like this:

class UploadFile(models.Model):

def generate_id(self, uploaded_file):
 import hashlib
 hasher = hashlib.sha1()

 for chunk in uploaded_file.chunks():
 hasher.update(chunk)
 
 self.file_id = hasher.hexdigest()

def save(self, upload_file):<--- this is not gonna work since 
'save' only takes (self) as a parameter
self.generate_id(upload_file)
super(UploadFile, self).save(*args, **kwargs)

So I have two ways to solve this:

1. generate the id in the view, and simply pass it to the UploadFile's 
constructor, then call save
2. create a variable in UploadFile:

class UploadFile(models.Model):
...
self.file = None

 def generate_id(self, uploaded_file):
 import hashlib
 hasher = hashlib.sha1()

 for chunk in uploaded_file.chunks():
 hasher.update(chunk)
 
 self.file_id = hasher.hexdigest()

def save(self):
self.generate_id(self.file)
super(UploadFile, self).save(*args, **kwargs)

in my view:
  
 def upload_view(request):
 file = request.FILES['file']
 upload_file = UploadFile(...)
 upload_file.file = file
 upload_file.save()

Do you think this is a good solution?

On Monday, 19 January 2015 17:07:12 UTC+8, James Schneider wrote:
>
> I wouldn't decorate them as class methods. You would want to call them 
> from the objects themselves. For the save_to_disk() method, I was actually 
> referring to the Django save() method (
> https://docs.djangoproject.com/en/1.7/topics/db/models/#overriding-predefined-model-methods
> ).
>
> As you have it now, it wouldn't work since you would need to call 
> UploadFile.generate_id(), but you don't have an available argument to pass 
> in the UploadFile object to get the ID for. 
>
> If you remove the decorator, you would call it on the object itself:
> class UploadFile(models.Model):
>
> def generate_id(self):
> # pseudocode to do stuff to generate ID using self
> # import hashlib
> # self.file_hash = hashlib.sha1(self.file, 'rb') 
> # return the ID or None if it fails
> # return self.file_hash or None
>
> # override the model save method to generate the hash ID, then save 
> for real
> def save(self):
> self.generate_id()
> super(UploadFile, self).save(*args, **kwargs)
>
> You probably don't need to change your view logic at all in this case 
> (unless you have code that generates the hash and attaches it to the 
> object, then remove it and let the object handle that itself). Basically, 
> when your UploadFile object is saved, it will call the save() method on the 
> object, which in turn will generate the ID based on the file, attach it to 
> the object, and then save the object to the database.
>
> Note that this will run the hashing mechanism every time the object is 
> saved, whether the file it points at changes or not. If this isn't what you 
> want, I would add an extra checks in generate_id() to account for all of 
> the scenarios where you wan the hash to update (every time the object is 
> saved vs. only when the file changes vs. only generated once even with a 
> file change, etc.). 
>
> In a typical scenario where the hash is run every time the object is 
> saved, the object itself would create the hash. This way you can save the 
> object from any view (or from the shell), and it would always generate a 
> new hash automagically (new meaning recalculated, may end up the same as 
> the previous value). 
>
> TL;DR; The hash shouldn't be calculated external to the file that is 
> attached to the object, it should be calculated by the object itself.
>
> Hope that helps and makes sense...
>
> -James
>
>
> On Jan 19, 2015 12:37 AM, "Cheng Guo"  
> wrote:
>
>> So in my case, I need to generate a unique id for the file and save it to 
>> disk.
>>
>> I have a model called UploadFile, 

Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Cheng Guo
Hello James:

Thank you very much for spending the time reading and answering this 
question, really appreciated!

I complete understand your suggestion of overriding the "save" method in 
the "UploadFile" to generate the id before saving. Thank you for pointing 
this out.

On the other hand, I read that it is not recommended to store files in 
database. So I decide to only store upload files on disk and save their 
file path and generated id in the database. So here is my model:

class UploadFile(models.Model):
upload_date = models.DateTimeField('timestamp', auto_now_add=True)
original_file_name = models.CharField(max_length=200)
file_id = models.CharField(max_length=40, primary_key=True)
file_path = models.CharField(max_length=500)
owner = models.ForeignKey(User)


I could use your method to override the save method, but the problem I face 
is that to generate the id, I need to pass the "UploadedFile" object to the 
 modal, like this:

class UploadFile(models.Model):

def generate_id(self, uploaded_file):
 import hashlib
 hasher = hashlib.sha1()

 for chunk in uploaded_file.chunks():
 hasher.update(chunk)
 
 self.file_id = hasher.hexdigest()

def save(self, upload_file):<--- this is not gonna work since 
'save' only takes (self) as a parameter
self.generate_id(upload_file)
super(UploadFile, self).save(*args, **kwargs)

So I have two ways to solve this:

1. generate the id in the view, and simply pass it to the UploadFile's 
constructor, then call save
2. create a class variable in UploadFile:

class UploadFile(models.Model):
...
self.file = None

in my view:
  
 def upload_view(request):
 file = request.FILES['file']
 upload_file = UploadFile(...)
 upload_file.file = file
 upload_file.save()

Do you think this is a good solution?


On Monday, 19 January 2015 17:07:12 UTC+8, James Schneider wrote:
>
> I wouldn't decorate them as class methods. You would want to call them 
> from the objects themselves. For the save_to_disk() method, I was actually 
> referring to the Django save() method (
> https://docs.djangoproject.com/en/1.7/topics/db/models/#overriding-predefined-model-methods
> ).
>
> As you have it now, it wouldn't work since you would need to call 
> UploadFile.generate_id(), but you don't have an available argument to pass 
> in the UploadFile object to get the ID for. 
>
> If you remove the decorator, you would call it on the object itself:
> class UploadFile(models.Model):
>
> def generate_id(self):
> # pseudocode to do stuff to generate ID using self
> # import hashlib
> # self.file_hash = hashlib.sha1(self.file, 'rb') 
> # return the ID or None if it fails
> # return self.file_hash or None
>
> # override the model save method to generate the hash ID, then save 
> for real
> def save(self):
> self.generate_id()
> super(UploadFile, self).save(*args, **kwargs)
>
> You probably don't need to change your view logic at all in this case 
> (unless you have code that generates the hash and attaches it to the 
> object, then remove it and let the object handle that itself). Basically, 
> when your UploadFile object is saved, it will call the save() method on the 
> object, which in turn will generate the ID based on the file, attach it to 
> the object, and then save the object to the database.
>
> Note that this will run the hashing mechanism every time the object is 
> saved, whether the file it points at changes or not. If this isn't what you 
> want, I would add an extra checks in generate_id() to account for all of 
> the scenarios where you wan the hash to update (every time the object is 
> saved vs. only when the file changes vs. only generated once even with a 
> file change, etc.). 
>
> In a typical scenario where the hash is run every time the object is 
> saved, the object itself would create the hash. This way you can save the 
> object from any view (or from the shell), and it would always generate a 
> new hash automagically (new meaning recalculated, may end up the same as 
> the previous value). 
>
> TL;DR; The hash shouldn't be calculated external to the file that is 
> attached to the object, it should be calculated by the object itself.
>
> Hope that helps and makes sense...
>
> -James
>
>
> On Jan 19, 2015 12:37 AM, "Cheng Guo"  
> wrote:
>
>> So in my case, I need to generate a unique id for the file and save it to 
>> disk.
>>
>> I have a model called UploadFile, so you recommend to add two class 
>> methods to the UploadFile model, like the following?
>>
>> class UploadFile(models.Model):
>> @classmethod
>> def generate_id():
>> pass
>>
>> @classmethod
>> def save_to_disk():
>> pass
>>
>>
>> On Monday, 19 January 2015 16:12:28 UTC+8, daniel.franca wrote:
>>>
>>> If the operations are model 

Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Daniel Roseman
On Monday, 19 January 2015 07:28:14 UTC, Cheng Guo wrote:
>
> Hello,
>
> I am new to Django and I have run into an issue with views.py.  I 
> understand that there is a function behind each view. For a view that I am 
> currently writing, it accepts a file upload from user and stores the file 
> on the server. To do that, I need to:
>
> 1. check the file extension is correct
> 2. generate a SHA-1 id for the file based on its content
> 3. write the file to disk
> 4. save information about the file to database
>
> (oh, I also created two global variables as well)
>
>
Others have pointed out ways to split this up, but I wanted to pick up on 
the last sentence. You really really should not be setting global variables 
in your view, especially in response to user input. Global variables are 
shared by all requests in a process, and you can't guarantee either that 
all requests will be from the same user, or even that the same user will 
hit the same process in subsequent requests. Don't do this: if you need to 
store state between requests, use the db or the session.
--
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/cbdbf7f5-c742-4047-bec8-8060f6245823%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread James Schneider
I wouldn't decorate them as class methods. You would want to call them from
the objects themselves. For the save_to_disk() method, I was actually
referring to the Django save() method (
https://docs.djangoproject.com/en/1.7/topics/db/models/#overriding-predefined-model-methods
).

As you have it now, it wouldn't work since you would need to call
UploadFile.generate_id(), but you don't have an available argument to pass
in the UploadFile object to get the ID for.

If you remove the decorator, you would call it on the object itself:
class UploadFile(models.Model):

def generate_id(self):
# pseudocode to do stuff to generate ID using self
# import hashlib
# self.file_hash = hashlib.sha1(self.file, 'rb')
# return the ID or None if it fails
# return self.file_hash or None

# override the model save method to generate the hash ID, then save for
real
def save(self):
self.generate_id()
super(UploadFile, self).save(*args, **kwargs)

You probably don't need to change your view logic at all in this case
(unless you have code that generates the hash and attaches it to the
object, then remove it and let the object handle that itself). Basically,
when your UploadFile object is saved, it will call the save() method on the
object, which in turn will generate the ID based on the file, attach it to
the object, and then save the object to the database.

Note that this will run the hashing mechanism every time the object is
saved, whether the file it points at changes or not. If this isn't what you
want, I would add an extra checks in generate_id() to account for all of
the scenarios where you wan the hash to update (every time the object is
saved vs. only when the file changes vs. only generated once even with a
file change, etc.).

In a typical scenario where the hash is run every time the object is saved,
the object itself would create the hash. This way you can save the object
from any view (or from the shell), and it would always generate a new hash
automagically (new meaning recalculated, may end up the same as the
previous value).

TL;DR; The hash shouldn't be calculated external to the file that is
attached to the object, it should be calculated by the object itself.

Hope that helps and makes sense...

-James


On Jan 19, 2015 12:37 AM, "Cheng Guo"  wrote:

> So in my case, I need to generate a unique id for the file and save it to
> disk.
>
> I have a model called UploadFile, so you recommend to add two class
> methods to the UploadFile model, like the following?
>
> class UploadFile(models.Model):
> @classmethod
> def generate_id():
> pass
>
> @classmethod
> def save_to_disk():
> pass
>
>
> On Monday, 19 January 2015 16:12:28 UTC+8, daniel.franca wrote:
>>
>> If the operations are model related, why don't move some of those
>> functions to models.py.
>> On Mon 19 Jan 2015 at 08:46 Mike Dewhirst  wrote:
>>
>>> On 19/01/2015 6:28 PM, Cheng Guo wrote:
>>> > Hello,
>>> >
>>> > I am new to Django and I have run into an issue with views.py.  I
>>> > understand that there is a function behind each view. For a view that I
>>> > am currently writing, it accepts a file upload from user and stores the
>>> > file on the server. To do that, I need to:
>>> >
>>> > 1. check the file extension is correct
>>> > 2. generate a SHA-1 id for the file based on its content
>>> > 3. write the file to disk
>>> > 4. save information about the file to database
>>> >
>>> > (oh, I also created two global variables as well)
>>> >
>>> > As you can see, if more features are added, the list goes on. It makes
>>> > this function very long. As the number of views grow, the views.py file
>>> > will become bloated. I wonder what would be the ideal way to deal with
>>> this?
>>> >
>>> > Something that I can think of but not sure if it is correct:
>>> >
>>> > - divide the long function up into smaller functions
>>> > - store these smaller functions in a different .py file
>>>
>>> Absolutely correct. But first create a views directory (complete with
>>> __init__.py file therein) to completely replace your views.py file.
>>>
>>> Then any number of files can contain your views ...
>>>
>>> from app.views.this import That
>>>
>>> ... where this.py has a class That
>>>
>>>
>>> >
>>> > Let me know your approach, 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...@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/bf9f6ff3-a35a

Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Cheng Guo
So in my case, I need to generate a unique id for the file and save it to 
disk.

I have a model called UploadFile, so you recommend to add two class methods 
to the UploadFile model, like the following?

class UploadFile(models.Model):
@classmethod
def generate_id():
pass

@classmethod
def save_to_disk():
pass


On Monday, 19 January 2015 16:12:28 UTC+8, daniel.franca wrote:
>
> If the operations are model related, why don't move some of those 
> functions to models.py.
> On Mon 19 Jan 2015 at 08:46 Mike Dewhirst  > wrote:
>
>> On 19/01/2015 6:28 PM, Cheng Guo wrote:
>> > Hello,
>> >
>> > I am new to Django and I have run into an issue with views.py.  I
>> > understand that there is a function behind each view. For a view that I
>> > am currently writing, it accepts a file upload from user and stores the
>> > file on the server. To do that, I need to:
>> >
>> > 1. check the file extension is correct
>> > 2. generate a SHA-1 id for the file based on its content
>> > 3. write the file to disk
>> > 4. save information about the file to database
>> >
>> > (oh, I also created two global variables as well)
>> >
>> > As you can see, if more features are added, the list goes on. It makes
>> > this function very long. As the number of views grow, the views.py file
>> > will become bloated. I wonder what would be the ideal way to deal with 
>> this?
>> >
>> > Something that I can think of but not sure if it is correct:
>> >
>> > - divide the long function up into smaller functions
>> > - store these smaller functions in a different .py file
>>
>> Absolutely correct. But first create a views directory (complete with
>> __init__.py file therein) to completely replace your views.py file.
>>
>> Then any number of files can contain your views ...
>>
>> from app.views.this import That
>>
>> ... where this.py has a class That
>>
>>
>> >
>> > Let me know your approach, 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...@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/bf9f6ff3-
>> a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com
>> > > a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com?utm_medium=
>> email_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/54BCB642.8040201%40dewhirst.com.au.
>> 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/80aef78c-9cec-4e50-be11-bc506d019b8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread James Schneider
I second moving some (or most) of the functionality to models.py. For
instance, calculating the SHA value should be done as part of the model's
save() function, not done in the view.

Convention dictates that the only code that is placed in the view itself
should be logic related to prepping the templates for rendering/displaying
things, such as setting variables in the template context.

Any operations related to 'business logic' such as data manipulation (ie
save behavior) as it relates to specific objects should be handled by the
object/model itself. Ideally, the model instance should be smart enough to
save itself (or perform some other action) on its own without any input
from the view, assuming the necessary values for the operation are provided
from some other source.

Obviously this is only a convention and not a rule, but it will likely
serve you better in the long run. In general, views tend to be quite short.
My class-based views just have a couple of class-level attributes set, if
anything at all (although they rely heavily on inherited behavior from
parent class views, which are much more complicated).

-James
On Jan 19, 2015 12:11 AM, "Daniel França"  wrote:

> If the operations are model related, why don't move some of those
> functions to models.py.
> On Mon 19 Jan 2015 at 08:46 Mike Dewhirst  wrote:
>
>> On 19/01/2015 6:28 PM, Cheng Guo wrote:
>> > Hello,
>> >
>> > I am new to Django and I have run into an issue with views.py.  I
>> > understand that there is a function behind each view. For a view that I
>> > am currently writing, it accepts a file upload from user and stores the
>> > file on the server. To do that, I need to:
>> >
>> > 1. check the file extension is correct
>> > 2. generate a SHA-1 id for the file based on its content
>> > 3. write the file to disk
>> > 4. save information about the file to database
>> >
>> > (oh, I also created two global variables as well)
>> >
>> > As you can see, if more features are added, the list goes on. It makes
>> > this function very long. As the number of views grow, the views.py file
>> > will become bloated. I wonder what would be the ideal way to deal with
>> this?
>> >
>> > Something that I can think of but not sure if it is correct:
>> >
>> > - divide the long function up into smaller functions
>> > - store these smaller functions in a different .py file
>>
>> Absolutely correct. But first create a views directory (complete with
>> __init__.py file therein) to completely replace your views.py file.
>>
>> Then any number of files can contain your views ...
>>
>> from app.views.this import That
>>
>> ... where this.py has a class That
>>
>>
>> >
>> > Let me know your approach, 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/bf9f6ff3-
>> a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com
>> > > a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com?utm_medium=
>> email_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/54BCB642.8040201%40dewhirst.com.au.
>> 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/CACPst9JZnMGK8vS00G1oqwEVt9qbf3TnTsdoJCwdy-mN02qEPw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are 

Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Cheng Guo
Great, thanks!

On Monday, 19 January 2015 15:46:40 UTC+8, Mike Dewhirst wrote:
>
> On 19/01/2015 6:28 PM, Cheng Guo wrote: 
> > Hello, 
> > 
> > I am new to Django and I have run into an issue with views.py.  I 
> > understand that there is a function behind each view. For a view that I 
> > am currently writing, it accepts a file upload from user and stores the 
> > file on the server. To do that, I need to: 
> > 
> > 1. check the file extension is correct 
> > 2. generate a SHA-1 id for the file based on its content 
> > 3. write the file to disk 
> > 4. save information about the file to database 
> > 
> > (oh, I also created two global variables as well) 
> > 
> > As you can see, if more features are added, the list goes on. It makes 
> > this function very long. As the number of views grow, the views.py file 
> > will become bloated. I wonder what would be the ideal way to deal with 
> this? 
> > 
> > Something that I can think of but not sure if it is correct: 
> > 
> > - divide the long function up into smaller functions 
> > - store these smaller functions in a different .py file 
>
> Absolutely correct. But first create a views directory (complete with 
> __init__.py file therein) to completely replace your views.py file. 
>
> Then any number of files can contain your views ... 
>
> from app.views.this import That 
>
> ... where this.py has a class That 
>
>
> > 
> > Let me know your approach, 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...@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/bf9f6ff3-a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/bf9f6ff3-a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com?utm_medium=email_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/6e8cf6a4-1967-495b-bfa4-95f9880b0457%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Cheng Guo
Great, 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/3065c69f-2930-43bc-9d12-e8b36a9a63c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-19 Thread Daniel França
If the operations are model related, why don't move some of those functions
to models.py.
On Mon 19 Jan 2015 at 08:46 Mike Dewhirst  wrote:

> On 19/01/2015 6:28 PM, Cheng Guo wrote:
> > Hello,
> >
> > I am new to Django and I have run into an issue with views.py.  I
> > understand that there is a function behind each view. For a view that I
> > am currently writing, it accepts a file upload from user and stores the
> > file on the server. To do that, I need to:
> >
> > 1. check the file extension is correct
> > 2. generate a SHA-1 id for the file based on its content
> > 3. write the file to disk
> > 4. save information about the file to database
> >
> > (oh, I also created two global variables as well)
> >
> > As you can see, if more features are added, the list goes on. It makes
> > this function very long. As the number of views grow, the views.py file
> > will become bloated. I wonder what would be the ideal way to deal with
> this?
> >
> > Something that I can think of but not sure if it is correct:
> >
> > - divide the long function up into smaller functions
> > - store these smaller functions in a different .py file
>
> Absolutely correct. But first create a views directory (complete with
> __init__.py file therein) to completely replace your views.py file.
>
> Then any number of files can contain your views ...
>
> from app.views.this import That
>
> ... where this.py has a class That
>
>
> >
> > Let me know your approach, 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/bf9f6ff3-
> a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com
> >  a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com?utm_medium=
> email_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/54BCB642.8040201%40dewhirst.com.au.
> 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/CACPst9JZnMGK8vS00G1oqwEVt9qbf3TnTsdoJCwdy-mN02qEPw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question: How to avoid a very long view function?

2015-01-18 Thread Mike Dewhirst

On 19/01/2015 6:28 PM, Cheng Guo wrote:

Hello,

I am new to Django and I have run into an issue with views.py.  I
understand that there is a function behind each view. For a view that I
am currently writing, it accepts a file upload from user and stores the
file on the server. To do that, I need to:

1. check the file extension is correct
2. generate a SHA-1 id for the file based on its content
3. write the file to disk
4. save information about the file to database

(oh, I also created two global variables as well)

As you can see, if more features are added, the list goes on. It makes
this function very long. As the number of views grow, the views.py file
will become bloated. I wonder what would be the ideal way to deal with this?

Something that I can think of but not sure if it is correct:

- divide the long function up into smaller functions
- store these smaller functions in a different .py file


Absolutely correct. But first create a views directory (complete with 
__init__.py file therein) to completely replace your views.py file.


Then any number of files can contain your views ...

from app.views.this import That

... where this.py has a class That




Let me know your approach, 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/bf9f6ff3-a35a-4f00-8537-c6fd66d07f8d%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/54BCB642.8040201%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Newbie question: How to avoid a very long view function?

2015-01-18 Thread Cheng Guo
Hello,

I am new to Django and I have run into an issue with views.py.  I 
understand that there is a function behind each view. For a view that I am 
currently writing, it accepts a file upload from user and stores the file 
on the server. To do that, I need to:

1. check the file extension is correct
2. generate a SHA-1 id for the file based on its content
3. write the file to disk
4. save information about the file to database

(oh, I also created two global variables as well)

As you can see, if more features are added, the list goes on. It makes this 
function very long. As the number of views grow, the views.py file will 
become bloated. I wonder what would be the ideal way to deal with this?

Something that I can think of but not sure if it is correct:

- divide the long function up into smaller functions
- store these smaller functions in a different .py file

Let me know your approach, 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/bf9f6ff3-a35a-4f00-8537-c6fd66d07f8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-29 Thread Ken Wayne
That was it...

On Friday, December 26, 2014 4:45:13 PM UTC-6, Collin Anderson wrote:
>
> Hi,
>
> This one comes up a lot. It's confusing because {% block title %} is the 
> _html_ , the title of the browser tab.
>
> You want to change {% block branding %}.
>
> Collin
>
> On Tuesday, December 23, 2014 5:18:49 PM UTC-6, Ken Wayne wrote:
>>
>>  Hmmm, that is one of the directories I tried, 
>> C:\Python34\Scripts\mysite\templates\admin with the file base_site.html 
>>
>> On 12/23/2014 5:07 PM, Néstor wrote:
>>  
>>  You might need to make for admin
>>  mysite/templates/admin/base_site.html
>>  
>> for regular html files for the polls only
>>  mysite/polls/templates/polls/index.html
>>
>>  That is how I got it to work.  Good luck!!!
>>
>> :-)
>>  
>> On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne  wrote:
>>
>>>  Windows 8
>>>  Django 1.7.1
>>> Python 3.4.2
>>>  Google Chrome Version 39.0.2171.95 m
>>>
>>>  Bottom of part 2 of the the tutorial 
>>> https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it indicates 
>>> how to customize the admin template but when I follow the directions it 
>>> doesn't show any change in my browser.  I've restarted the development 
>>> server and refreshed my browser. 
>>>
>>>  *File Snip base_site.html:*
>>>  {% block title %}{{ title }} | Polls Administration {% endblock %}
>>>  
>>>  *File Snip settings.py:*
>>>  import os
>>> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
>>> # TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
>>> TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']
>>>  
>>>  I tried the environment path, and hard coding the path.  Since the 
>>> tutorial didn't indicate the BASE_DIR path I made a copy of the file in 
>>> each of the following directories:
>>> C:\Python34\Scripts\mysite\templates\admin
>>>  C:\Python34\Scripts\mysite\mysite\templates\admin
>>>  C:\Python34\Scripts\mysite\polls\templates\admin
>>>  
>>>  Any thoughts on what I might be doing wrong?
>>>  -- 
>>> 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/0a7c4e30-ba26-418b-b217-72936c72975f%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...@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/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%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/7c710aea-10a9-4f45-9c1e-29fc78db0476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-26 Thread Collin Anderson
Hi,

This one comes up a lot. It's confusing because {% block title %} is the 
_html_ , the title of the browser tab.

You want to change {% block branding %}.

Collin

On Tuesday, December 23, 2014 5:18:49 PM UTC-6, Ken Wayne wrote:
>
>  Hmmm, that is one of the directories I tried, 
> C:\Python34\Scripts\mysite\templates\admin with the file base_site.html 
>
> On 12/23/2014 5:07 PM, Néstor wrote:
>  
>  You might need to make for admin
>  mysite/templates/admin/base_site.html
>  
> for regular html files for the polls only
>  mysite/polls/templates/polls/index.html
>
>  That is how I got it to work.  Good luck!!!
>
> :-)
>  
> On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne  > wrote:
>
>>  Windows 8
>>  Django 1.7.1
>> Python 3.4.2
>>  Google Chrome Version 39.0.2171.95 m
>>
>>  Bottom of part 2 of the the tutorial 
>> https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it indicates how 
>> to customize the admin template but when I follow the directions it doesn't 
>> show any change in my browser.  I've restarted the development server and 
>> refreshed my browser. 
>>
>>  *File Snip base_site.html:*
>>  {% block title %}{{ title }} | Polls Administration {% endblock %}
>>  
>>  *File Snip settings.py:*
>>  import os
>> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
>> # TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
>> TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']
>>  
>>  I tried the environment path, and hard coding the path.  Since the 
>> tutorial didn't indicate the BASE_DIR path I made a copy of the file in 
>> each of the following directories:
>> C:\Python34\Scripts\mysite\templates\admin
>>  C:\Python34\Scripts\mysite\mysite\templates\admin
>>  C:\Python34\Scripts\mysite\polls\templates\admin
>>  
>>  Any thoughts on what I might be doing wrong?
>>  -- 
>> 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/0a7c4e30-ba26-418b-b217-72936c72975f%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...@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/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%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/a1b37c58-aa89-4731-8c07-acf214e8721e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Ken Wayne
Hmmm, that is one of the directories I tried, 
C:\Python34\Scripts\mysite\templates\admin with the file base_site.html


On 12/23/2014 5:07 PM, Néstor wrote:

You might need to make for admin
mysite/templates/admin/base_site.html

for regular html files for the polls only
mysite/polls/templates/polls/index.html

That is how I got it to work.  Good luck!!!

:-)

On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne > wrote:


Windows 8
Django 1.7.1
Python 3.4.2
Google Chrome Version 39.0.2171.95 m

Bottom of part 2 of the the tutorial
https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it
indicates how to customize the admin template but when I follow
the directions it doesn't show any change in my browser.  I've
restarted the development server and refreshed my browser.

*File Snip base_site.html:*
{% block title %}{{ title }} | Polls Administration {% endblock %}

*File Snip settings.py:*
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']

I tried the environment path, and hard coding the path.  Since the
tutorial didn't indicate the BASE_DIR path I made a copy of the
file in each of the following directories:
C:\Python34\Scripts\mysite\templates\admin
C:\Python34\Scripts\mysite\mysite\templates\admin
C:\Python34\Scripts\mysite\polls\templates\admin

Any thoughts on what I might be doing wrong?
-- 
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/0a7c4e30-ba26-418b-b217-72936c72975f%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/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%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/5499F84E.1060109%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Néstor
You might need to make for admin
mysite/templates/admin/base_site.html

for regular html files for the polls only
mysite/polls/templates/polls/index.html

That is how I got it to work.  Good luck!!!

:-)

On Tue, Dec 23, 2014 at 2:13 PM, Ken Wayne  wrote:

> Windows 8
> Django 1.7.1
> Python 3.4.2
> Google Chrome Version 39.0.2171.95 m
>
> Bottom of part 2 of the the tutorial
> https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it indicates how
> to customize the admin template but when I follow the directions it doesn't
> show any change in my browser.  I've restarted the development server and
> refreshed my browser.
>
> *File Snip base_site.html:*
> {% block title %}{{ title }} | Polls Administration {% endblock %}
>
> *File Snip settings.py:*
> import os
> BASE_DIR = os.path.dirname(os.path.dirname(__file__))
> # TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
> TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']
>
> I tried the environment path, and hard coding the path.  Since the
> tutorial didn't indicate the BASE_DIR path I made a copy of the file in
> each of the following directories:
> C:\Python34\Scripts\mysite\templates\admin
> C:\Python34\Scripts\mysite\mysite\templates\admin
> C:\Python34\Scripts\mysite\polls\templates\admin
>
> Any thoughts on what I might be doing wrong?
>
> --
> 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/0a7c4e30-ba26-418b-b217-72936c72975f%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/CAON-vCPcGEhk3%2B0wO4RXSnuQWqW5H6H4ZbiHoo1h5yRx36GbBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Template Not Applying - Django Polls Tutorial (Newbie Question)

2014-12-23 Thread Ken Wayne
Windows 8
Django 1.7.1
Python 3.4.2
Google Chrome Version 39.0.2171.95 m

Bottom of part 2 of the the 
tutorial https://docs.djangoproject.com/en/1.7/intro/tutorial02/ it 
indicates how to customize the admin template but when I follow the 
directions it doesn't show any change in my browser.  I've restarted the 
development server and refreshed my browser.

*File Snip base_site.html:*
{% block title %}{{ title }} | Polls Administration {% endblock %}

*File Snip settings.py:*
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
TEMPLATE_DIRS = ['C:\Python34\Scripts\mysite\templates']

I tried the environment path, and hard coding the path.  Since the tutorial 
didn't indicate the BASE_DIR path I made a copy of the file in each of the 
following directories:
C:\Python34\Scripts\mysite\templates\admin
C:\Python34\Scripts\mysite\mysite\templates\admin
C:\Python34\Scripts\mysite\polls\templates\admin

Any thoughts on what I might be doing wrong?

-- 
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/0a7c4e30-ba26-418b-b217-72936c72975f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question on serving static files from apache

2014-11-15 Thread Daniel Roseman
On Saturday, 15 November 2014 03:13:37 UTC, pythonista wrote:
>
> I am using django 1.7 and apache.
>
> I do not understand the instructions on the django tutorial.
>
> The files were delivered as expected in debug mode and locally from the 
> django web server.
>
>
> Can someone provide me with a simple example or link to a site.
>
> Thanks
>
>
The documentation is pretty extensive:

https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/modwsgi/#serving-files
 
https://docs.djangoproject.com/en/1.7/howto/static-files/deployment/
-- 
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/e5c36b35-577e-4493-81cd-67d6d79fd87e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Newbie question on serving static files from apache

2014-11-14 Thread pythonista
I am using django 1.7 and apache.

I do not understand the instructions on the django tutorial.

The files were delivered as expected in debug mode and locally from the 
django web server.


Can someone provide me with a simple example or link to a site.

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/d9f345b5-5473-4134-a588-6ceb155490a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie Question: Django Tutorial Part 4 - Exception Issue

2014-10-01 Thread Daniel Rus Morales
My pleasure ;)
Enjoy coding!


On 01 Oct 2014, at 22:04, zaiks0105  wrote:

> Daniel,
> 
> I appreciate your help. I got drifted away yesterday and got back to it 
> today. I found my mistake: a fricking typo. My polls/detail.html look for 
> 'error_message' while I spelt 'error_messge' in my views.py. So the error msg 
> was never shown though the page was redirected properly.
> 
> Thanks again!
> 
> On Monday, September 29, 2014 9:36:31 AM UTC-4, Daniel Rus Morales wrote:
> No, that’s not the cause, the lack of it would be. That line shows the 
> content of ‘error_message' when it does exist and has a value other than 
> None. But if you have it in your template the error must be somewhere else in 
> your code. Must be a simple syntax mistake you didn’t notice, either in the 
> template file or in the vote view.
> 
> To be sure that your code is raising an exception you can place a print 
> statement right after the except, before the call to render. Replace the call 
> to render with these lines, they do the same but also print a message in the 
> console:
> 
> except (KeyError, Choice.DoesNotExist):
> # redisplay the question voting form
> context = {
> 'question': p,
> 'error_message': "You didn't select a choice.",
> }
> print("context: ", context)
> return render(request, 'polls/detail.html', context)
> 
> 
> Click vote again and see what’s the output when you click on “Vote” without 
> selecting any choice. The text of the print statement will show up in the 
> console where you launched `python manage.py runserver`.
> 
> If you see the output “context: “ and the ‘error_message’ string with the 
> actual message, then you have a syntax mistake in your template. Otherwise 
> it’s in your view.
> 
> Cheers
> 
> 
> On 29 Sep 2014, at 14:55, zaiks0105  wrote:
> 
>> I do. Is that line causing the behavior?
>> 
>> 
>> 
>> On Monday, September 29, 2014 7:15:47 AM UTC-4, Daniel Rus Morales wrote:
>> Hi Zaiks0105,
>> 
>> Do you have the following line in "your polls/templates/polls/detail.html”?
>> 
>> {% if error_message %}{{ error_message }}{% endif %}
>> 
>> On 29 Sep 2014, at 12:48, zaiks0105  wrote:
>> 
>>> Hi,
>>> 
>>> I am following Django official tutorial and have unanswered issue at part 
>>> 4, https://docs.djangoproject.com/en/1.7/intro/tutorial04/. Here is the 
>>> exception handling code,
>>> 
>>> except (KeyError, Choice.DoesNotExist):
>>> # Redisplay the question voting form.
>>> return render(request, 'polls/detail.html', {
>>> 'question': p,
>>> 'error_message': "You didn't select a choice.",
>>> })
>>> 
>>> When I run the server and click on [Vote] without selecting a choice, the 
>>> page does NOT show me the error message. The same voting page comes back as 
>>> if [Vote] was not clicked.
>>> I checked my lines and everything seems identical per tutorial.
>>> 
>>> Any help appreciated!
>>> 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...@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/69aaa1bb-5371-4aec-ae1f-fb44880e46b3%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...@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/2adefa94-7801-48ad-af1f-1d5ec10ada86%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/64a09fab-f34d-4847-9643-07290910f7c6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Newbie Question: Django Tutorial Part 4 - Exception Issue

2014-10-01 Thread zaiks0105
Daniel,

I appreciate your help. I got drifted away yesterday and got back to it 
today. I found my mistake: a fricking typo. My polls/detail.html look for 
'error_message' while I spelt 'error_messge' in my views.py. So the error 
msg was never shown though the page was redirected properly.

Thanks again!

On Monday, September 29, 2014 9:36:31 AM UTC-4, Daniel Rus Morales wrote:
>
> No, that’s not the cause, the lack of it would be. That line shows the 
> content of ‘error_message' when it does exist and has a value other than 
> None. But if you have it in your template the error must be somewhere else 
> in your code. Must be a simple syntax mistake you didn’t notice, either in 
> the template file or in the vote view.
>
> To be sure that your code is raising an exception you can place a print 
> statement right after the except, before the call to render. Replace the 
> call to render with these lines, they do the same but also print a message 
> in the console:
>
> except (KeyError, Choice.DoesNotExist):
> # redisplay the question voting form
> context = {
> 'question': p,
> 'error_message': "You didn't select a choice.",
> }
> print("context: ", context)
> return render(request, 'polls/detail.html', context)
>
>
> Click vote again and see what’s the output when you click on “Vote” 
> without selecting any choice. The text of the print statement will show up 
> in the console where you launched `python manage.py runserver`.
>
> If you see the output “context: “ and the ‘error_message’ string with the 
> actual message, then you have a syntax mistake in your template. Otherwise 
> it’s in your view.
>
> Cheers
>
>
> On 29 Sep 2014, at 14:55, zaiks0105  
> wrote:
>
> I do. Is that line causing the behavior?
>
>
>
> On Monday, September 29, 2014 7:15:47 AM UTC-4, Daniel Rus Morales wrote:
>>
>> Hi Zaiks0105,
>>
>> Do you have the following line in "your 
>> polls/templates/polls/detail.html”?
>>
>> {% if error_message %}{{ error_message }}{% endif %}
>>
>>
>> On 29 Sep 2014, at 12:48, zaiks0105  wrote:
>>
>> Hi,
>>
>> I am following Django official tutorial and have unanswered issue at part 
>> 4, https://docs.djangoproject.com/en/1.7/intro/tutorial04/. Here is the 
>> exception handling code,
>>
>> except (KeyError, Choice.DoesNotExist):
>> # Redisplay the question voting form.
>> return render(request, 'polls/detail.html', {
>> 'question': p,
>> 'error_message': "You didn't select a choice.",
>> })
>>
>> When I run the server and click on [Vote] without selecting a choice, the 
>> page does NOT show me the error message. The same voting page comes back as 
>> if [Vote] was not clicked.
>> I checked my lines and everything seems identical per tutorial.
>>
>> Any help appreciated!
>> 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...@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/69aaa1bb-5371-4aec-ae1f-fb44880e46b3%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...@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/2adefa94-7801-48ad-af1f-1d5ec10ada86%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/64a09fab-f34d-4847-9643-07290910f7c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie Question: Django Tutorial Part 4 - Exception Issue

2014-09-29 Thread Daniel Rus Morales
No, that’s not the cause, the lack of it would be. That line shows the content 
of ‘error_message' when it does exist and has a value other than None. But if 
you have it in your template the error must be somewhere else in your code. 
Must be a simple syntax mistake you didn’t notice, either in the template file 
or in the vote view.

To be sure that your code is raising an exception you can place a print 
statement right after the except, before the call to render. Replace the call 
to render with these lines, they do the same but also print a message in the 
console:

except (KeyError, Choice.DoesNotExist):
# redisplay the question voting form
context = {
'question': p,
'error_message': "You didn't select a choice.",
}
print("context: ", context)
return render(request, 'polls/detail.html', context)


Click vote again and see what’s the output when you click on “Vote” without 
selecting any choice. The text of the print statement will show up in the 
console where you launched `python manage.py runserver`.

If you see the output “context: “ and the ‘error_message’ string with the 
actual message, then you have a syntax mistake in your template. Otherwise it’s 
in your view.

Cheers


On 29 Sep 2014, at 14:55, zaiks0105  wrote:

> I do. Is that line causing the behavior?
> 
> 
> 
> On Monday, September 29, 2014 7:15:47 AM UTC-4, Daniel Rus Morales wrote:
> Hi Zaiks0105,
> 
> Do you have the following line in "your polls/templates/polls/detail.html”?
> 
> {% if error_message %}{{ error_message }}{% endif %}
> 
> On 29 Sep 2014, at 12:48, zaiks0105  wrote:
> 
>> Hi,
>> 
>> I am following Django official tutorial and have unanswered issue at part 4, 
>> https://docs.djangoproject.com/en/1.7/intro/tutorial04/. Here is the 
>> exception handling code,
>> 
>> except (KeyError, Choice.DoesNotExist):
>> # Redisplay the question voting form.
>> return render(request, 'polls/detail.html', {
>> 'question': p,
>> 'error_message': "You didn't select a choice.",
>> })
>> 
>> When I run the server and click on [Vote] without selecting a choice, the 
>> page does NOT show me the error message. The same voting page comes back as 
>> if [Vote] was not clicked.
>> I checked my lines and everything seems identical per tutorial.
>> 
>> Any help appreciated!
>> 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...@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/69aaa1bb-5371-4aec-ae1f-fb44880e46b3%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/2adefa94-7801-48ad-af1f-1d5ec10ada86%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Newbie Question: Django Tutorial Part 4 - Exception Issue

2014-09-29 Thread zaiks0105
I do. Is that line causing the behavior?



On Monday, September 29, 2014 7:15:47 AM UTC-4, Daniel Rus Morales wrote:
>
> Hi Zaiks0105,
>
> Do you have the following line in "your polls/templates/polls/detail.html”?
>
> {% if error_message %}{{ error_message }}{% endif %}
>
>
> On 29 Sep 2014, at 12:48, zaiks0105  
> wrote:
>
> Hi,
>
> I am following Django official tutorial and have unanswered issue at part 
> 4, https://docs.djangoproject.com/en/1.7/intro/tutorial04/. Here is the 
> exception handling code,
>
> except (KeyError, Choice.DoesNotExist):
> # Redisplay the question voting form.
> return render(request, 'polls/detail.html', {
> 'question': p,
> 'error_message': "You didn't select a choice.",
> })
>
> When I run the server and click on [Vote] without selecting a choice, the 
> page does NOT show me the error message. The same voting page comes back as 
> if [Vote] was not clicked.
> I checked my lines and everything seems identical per tutorial.
>
> Any help appreciated!
> 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...@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/69aaa1bb-5371-4aec-ae1f-fb44880e46b3%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/2adefa94-7801-48ad-af1f-1d5ec10ada86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie Question: Django Tutorial Part 4 - Exception Issue

2014-09-29 Thread Daniel Rus Morales
Hi Zaiks0105,

Do you have the following line in "your polls/templates/polls/detail.html”?

{% if error_message %}{{ error_message }}{% endif %}

On 29 Sep 2014, at 12:48, zaiks0105  wrote:

> Hi,
> 
> I am following Django official tutorial and have unanswered issue at part 4, 
> https://docs.djangoproject.com/en/1.7/intro/tutorial04/. Here is the 
> exception handling code,
> 
> except (KeyError, Choice.DoesNotExist):
> # Redisplay the question voting form.
> return render(request, 'polls/detail.html', {
> 'question': p,
> 'error_message': "You didn't select a choice.",
> })
> 
> When I run the server and click on [Vote] without selecting a choice, the 
> page does NOT show me the error message. The same voting page comes back as 
> if [Vote] was not clicked.
> I checked my lines and everything seems identical per tutorial.
> 
> Any help appreciated!
> 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/69aaa1bb-5371-4aec-ae1f-fb44880e46b3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



signature.asc
Description: Message signed with OpenPGP using GPGMail


Newbie Question: Django Tutorial Part 4 - Exception Issue

2014-09-29 Thread zaiks0105
Hi,

I am following Django official tutorial and have unanswered issue at part 
4, https://docs.djangoproject.com/en/1.7/intro/tutorial04/. Here is the 
exception handling code,

except (KeyError, Choice.DoesNotExist):
# Redisplay the question voting form.
return render(request, 'polls/detail.html', {
'question': p,
'error_message': "You didn't select a choice.",
})

When I run the server and click on [Vote] without selecting a choice, the page 
does NOT show me the error message. The same voting page comes back as if 
[Vote] was not clicked.
I checked my lines and everything seems identical per tutorial.

Any help appreciated!
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/69aaa1bb-5371-4aec-ae1f-fb44880e46b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question about Django and Python versions.

2014-09-08 Thread Andrey Consalter
Thanks Russ, that clarifies a lot! Nice to see guys like you helping newcomers!

-- 
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/0dcca997-adbd-4dab-b759-ae14e796d13c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question about Django and Python versions.

2014-09-08 Thread Russell Keith-Magee
Hi Andrey,

On Tue, Sep 9, 2014 at 4:30 AM, Andrey Consalter 
wrote:

> Hi there,
>
> I've been studying programming with Python 2.7 and Django 1.6, and a few
> days ago Django 1.7 was release and with it, the new tutorial that I had
> just started.
> What you guys would recommend? Keep working with my current environment or
> update it?
>

If you're just starting out - still at the stage of running the tutorial,
then you won't lose much by starting again - but you also won't lose much
by finishing the tutorial on the version you started with. 1.7 introduced a
couple of small changes to the tutorial, so if you ran the tutorial a
second time (this time with 1.7), you'd probably spot a couple of minor
changes in the commands you need to issue; but the code itself will be
almost exactly the same.


> How this updates work? How "deep" are they?
>

1.7 is a fairly big release, but if you're at the tutorial stage, you
should be able to just update Django without too much difficulty.


> Would a project/app wrote with previous versions still work with the new
> ones?
>

Broadly speaking, yes - Django has a very strong backwards compatibility
policy, so code written for one version will generally work with the next
version. If something is introduced that isn't backwards compatible, we
introduce it softly over a couple of releases, and your code will spit out
lots of warnings telling you what needs to be updated.

Yours,
Russ Magee %-)

-- 
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/CAJxq848cK_3BscLLjWRKnQjLQRAVdTQ1ALqYSrKFCSs-kndCnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question about Django and Python versions.

2014-09-08 Thread Michael A. Martin
Is anyone else trying out 1.7? I do a jython manage.py runserver 8080 and then 
it seems to want to render but isn't. 

> On Sep 8, 2014, at 1:30 PM, Andrey Consalter  wrote:
> 
> Hi there,
> 
> I've been studying programming with Python 2.7 and Django 1.6, and a few days 
> ago Django 1.7 was release and with it, the new tutorial that I had just 
> started.
> What you guys would recommend? Keep working with my current environment or 
> update it?
> How this updates work? How "deep" are they?
> Would a project/app wrote with previous versions still work with the new ones?
> 
> Thanks in advance!
> -- 
> 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/19246110-90bf-449a-934e-d55b4f41df6d%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/13628B3C-F3CD-40DC-9E6B-D117473EA1BE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Newbie question about Django and Python versions.

2014-09-08 Thread Andrey Consalter
Hi there,

I've been studying programming with Python 2.7 and Django 1.6, and a few 
days ago Django 1.7 was release and with it, the new tutorial that I had 
just started.
What you guys would recommend? Keep working with my current environment or 
update it?
How this updates work? How "deep" are they?
Would a project/app wrote with previous versions still work with the new 
ones?

Thanks in advance!

-- 
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/19246110-90bf-449a-934e-d55b4f41df6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to simplify this code - newbie question

2014-06-30 Thread Michael Lind Hjulskov
Hi :o)

I would like to simplify *get_rating* to fewer lines of code:

class Product(AbstractProduct):

... just a little info about the model fields ...
title = charfield
parent = foreignkey(Product, related_name='variants')
rating = a float
def is_group - return True if it is a parent product and have variants 
...

@property
def get_rating(self):
u"""Return a product's rating - group product's ratings is gathered 
and presented as one"""
if self.is_group:
ratings_count = 0
if self.rating:
ratings_sum = self.rating
ratings_count+=1
for variant in self.variants.all():
if variant.rating:
ratings_sum += variant.rating
ratings_count+=1

if ratings_count > 0:
rating = float(ratings_sum) / ratings_count
return rating
return self.rating


My best guess is below, but it isnt working.
Will somebody please teach me what I should do and maybe explain to me why 
it isnt working.
I really want to learn this :o)

class Product(AbstractProduct):

@property
def get_rating(self):
u"""Return a product's rating - group product's ratings is gathered 
and presented as one"""
if self.is_group:
return float(Product.objects.filter(Q(parent__in=self) | 
Q(pk=self.pk)).aggregate(Avg('rating')))
return self.rating


Thanks alot :)

-- 
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/007ec8b7-4ab9-460e-bf3e-06c14f91b5db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie question about django-cas

2014-02-19 Thread wasingej
The problem is fixed.  Thanks esauro :)

Jared

-- 
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/d3d1b273-53ed-45db-b5c5-c3d8c6b72f75%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie question about django-cas

2014-02-19 Thread Esau Rodriguez
Hi there,
you have to put the absolute url for CAS_SERVER_URL

try CAS_SERVER_URL=http://login.oregonstate.edu-dev/login (or https)

Regards,
Esau Rodriguez.


On Wed, Feb 19, 2014 at 6:04 PM, wasingej  wrote:
> Hello.
>
> I am trying to put together a little test application which allows a user to
> log in to a CAS server and then redirects them back to the site after they
> have logged in.  I have followed the instructions on this page:
> https://bitbucket.org/cpcc/django-cas/overview.
>
> The URL for my server is: login.oregonstate.edu-dev/login
>
> However, when I try to access http://127.0.0.1:8000/accounts/login, I get
> redirected to:
> http://127.0.0.1:8000/accounts/login/login.oregonstate.edu-dev/login?service=http%3A%2F%2F127.0.0.1%3A8000%2Faccounts%2Flogin%2F%3Fnext%3D%252F
>
> Can anybody point me in the right direction as to what's going on 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/44bfea1a-0a45-44bd-acaf-63a8f717d53a%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
Esaú Rodríguez
esa...@gmail.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/CAB4Jw77Ke0z5DVCMGR8pzJ91Xzsrjb-xu4KdXGVvwz_gaVAHWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie question about django-cas

2014-02-19 Thread Tobias Ramos
try to set your login url to:  http://127.0.0.1:8000/accounts/login while
you testing.

Tobias


On 19 February 2014 15:04, wasingej  wrote:

> Hello.
>
> I am trying to put together a little test application which allows a user
> to log in to a CAS server and then redirects them back to the site after
> they have logged in.  I have followed the instructions on this page:
> https://bitbucket.org/cpcc/django-cas/overview.
>
> The URL for my server is: login.oregonstate.edu-dev/login
>
> However, when I try to access http://127.0.0.1:8000/accounts/login, I get
> redirected to:
>
> http://127.0.0.1:8000/accounts/login/login.oregonstate.edu-dev/login?service=http%3A%2F%2F127.0.0.1%3A8000%2Faccounts%2Flogin%2F%3Fnext%3D%252F
>
> Can anybody point me in the right direction as to what's going on 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/44bfea1a-0a45-44bd-acaf-63a8f717d53a%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAHwEBHMuuGvhgf6LBqaRnbHpLe%3DgmGxHeXM3cMa-Fo_vKNqtyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Newbie question about django-cas

2014-02-19 Thread wasingej
Hello.  

I am trying to put together a little test application which allows a user 
to log in to a CAS server and then redirects them back to the site after 
they have logged in.  I have followed the instructions on this page:  
https://bitbucket.org/cpcc/django-cas/overview. 

The URL for my server is: login.oregonstate.edu-dev/login

However, when I try to access http://127.0.0.1:8000/accounts/login, I get 
redirected to:  
http://127.0.0.1:8000/accounts/login/login.oregonstate.edu-dev/login?service=http%3A%2F%2F127.0.0.1%3A8000%2Faccounts%2Flogin%2F%3Fnext%3D%252F

Can anybody point me in the right direction as to what's going on 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/44bfea1a-0a45-44bd-acaf-63a8f717d53a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie Question - Where to store application constants?

2014-02-19 Thread Mark Phillips
Kirby,

You have a good point. However, in this use case I am dealing with
a jewelry store buying gold at their "market" rate. It is not the same as
owning gold and the value changes based on a published (ie available
through an API) rate. The jewelry store market rate for gold changes
slowly, and from store to store So, I found creating a table called
constants in the database allows me to change the value as needed and not
have to touch the app code.

Mark


On Mon, Feb 17, 2014 at 10:20 AM, C. Kirby  wrote:

> I would suggest that your example, the price of gold, isn't a constant. If
> you want to treat it as such then I agree with the above answers. However,
> you could also look around for APIs that publish commodities values and
> actually pull the real values in real (or semi real) time.
>
>  --
> 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/236a1a12-151d-4730-af8c-c5cdc30a0287%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAEqej2MR1Q0Dqe%2BFEkzSjgZaxDKnN1RFesHh64G3iyyp8gaSxA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie Question - Where to store application constants?

2014-02-17 Thread C. Kirby
I would suggest that your example, the price of gold, isn't a constant. If 
you want to treat it as such then I agree with the above answers. However, 
you could also look around for APIs that publish commodities values and 
actually pull the real values in real (or semi real) time.

-- 
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/236a1a12-151d-4730-af8c-c5cdc30a0287%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie Question - Where to store application constants?

2014-02-15 Thread Camilo Torres
To round this, for the price of gold, and if you are using the 
django.contrib.admin interface, you can use Django Solo or similar 
singleton model. That way you can edit your "business properties" within 
the admin interface:
https://pypi.python.org/pypi/django-solo


On Friday, February 14, 2014 12:24:09 PM UTC-4:30, ke1g wrote:
>
> It depends on the complexity of the issue.
>
> The price of gold does fluctuate.  On the grounds that I might want to 
> change it more often than I would want to ssh in, edit a file, and restart, 
> I would tend to put price of gold in the database, that is, in a model of 
> which there may only be one instance.  Implementing limits on who has 
> permission to change it is a separate fun topic, which may not be needed if 
> very few people have admin logins.
>
> Then there are application specific configuration options, which tent to 
> never change once an installation is up and running.  You can require that 
> they be set in settings.py if the constants are highly likely to differ 
> site to site (or if there is only one site in the world using this app), 
> but it is probably worthwhile providing defaults which can be overridden in 
> settings.py .  A common way to do the latter is to have another settings 
> file in the app directory (usually also called settings.py, since it can be 
> qualified with the app name) which defines constants as the result of 
> calling gettattr on the main settings object, and providing the default 
> value as teh third argument to getattr.  The other parts of the app get the 
> constants from the app specific settings file.
>
> Another kind of constant is truly never expected to change, such as 
> physical or algorithmic constants, defined so that they can be used 
> symbolically.  Sometimes they are only used quite locally, and can be 
> defined in that module, but if they are used by two or more modules, they 
> should probably be defined once, and imported in modules that use them.  
> While it is possible to define them in any module (such as the one that 
> uses them the most) and to import from that module in others that need the 
> constant(s), you must beware of circular import problems, so it is often 
> easier to create a constants.py or the like (if you already have an app 
> specific settings module, it is a fine place for you constants).  But your 
> models.py module, if you have only one, is a pretty safe place to put 
> constants, since it doesn't tend to import your other modules (unless you 
> have an app specific settings module), so you won't (typically)  have 
> circularity if you import from it.
>
> Bill
>
>
> On Fri, Feb 14, 2014 at 11:13 AM, Mark Phillips <
> ma...@phillipsmarketing.biz > wrote:
>
>> Where should one put application specific constants - those that change 
>> sometimes(1) and those that never change? For example, I am creating a 
>> simple inventory application for my mother's estate. Several quotes for 
>> her jewelry are based on the weight of the jewelry and the current price of 
>> gold.
>>
>> In the Estimate model, I have a field for weight, and then a property 
>> that looks something like:
>>
>> @property
>> def estimate_by_weight():
>> return self.weight * PRICE_OF GOLD
>>
>> Where would I put the PRICE_OF_GOLD constant? Some ideas that came to 
>> mind:
>>
>> 1. Settings.py - but then I have to edit that file every time I want to 
>> update the price of gold
>>
>> 2. Maybe a model so I can update it in the admin screens?
>>
>> 3. A form somewhere? But I think this would mean a model, so this is 
>> probably the same as #2.
>>
>> Where would one put a non-changing constant like the speed of light in a 
>> django application? 
>>
>> Thanks!
>>
>> Mark
>>
>> (1) Yes, I realize that terms 'constant' and 'changes sometimes' are 
>> mutually exclusive, but I hope you get the gist of what I am asking 
>> regardless of my imprecise description..
>>  
>> -- 
>> 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/CAEqej2OuRC%3D5c2AwKkLRV0%2BGQJMBd6g2wM41mRZB1RCpMtOshw%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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 

Re: Newbie Question - Where to store application constants?

2014-02-14 Thread Mark Phillips
Thanks! Very clear and helpful.

Mark
On Feb 14, 2014 9:54 AM, "Bill Freeman"  wrote:

> It depends on the complexity of the issue.
>
> The price of gold does fluctuate.  On the grounds that I might want to
> change it more often than I would want to ssh in, edit a file, and restart,
> I would tend to put price of gold in the database, that is, in a model of
> which there may only be one instance.  Implementing limits on who has
> permission to change it is a separate fun topic, which may not be needed if
> very few people have admin logins.
>
> Then there are application specific configuration options, which tent to
> never change once an installation is up and running.  You can require that
> they be set in settings.py if the constants are highly likely to differ
> site to site (or if there is only one site in the world using this app),
> but it is probably worthwhile providing defaults which can be overridden in
> settings.py .  A common way to do the latter is to have another settings
> file in the app directory (usually also called settings.py, since it can be
> qualified with the app name) which defines constants as the result of
> calling gettattr on the main settings object, and providing the default
> value as teh third argument to getattr.  The other parts of the app get the
> constants from the app specific settings file.
>
> Another kind of constant is truly never expected to change, such as
> physical or algorithmic constants, defined so that they can be used
> symbolically.  Sometimes they are only used quite locally, and can be
> defined in that module, but if they are used by two or more modules, they
> should probably be defined once, and imported in modules that use them.
> While it is possible to define them in any module (such as the one that
> uses them the most) and to import from that module in others that need the
> constant(s), you must beware of circular import problems, so it is often
> easier to create a constants.py or the like (if you already have an app
> specific settings module, it is a fine place for you constants).  But your
> models.py module, if you have only one, is a pretty safe place to put
> constants, since it doesn't tend to import your other modules (unless you
> have an app specific settings module), so you won't (typically)  have
> circularity if you import from it.
>
> Bill
>
>
> On Fri, Feb 14, 2014 at 11:13 AM, Mark Phillips <
> m...@phillipsmarketing.biz> wrote:
>
>> Where should one put application specific constants - those that change
>> sometimes(1) and those that never change? For example, I am creating a
>> simple inventory application for my mother's estate. Several quotes for
>> her jewelry are based on the weight of the jewelry and the current price of
>> gold.
>>
>> In the Estimate model, I have a field for weight, and then a property
>> that looks something like:
>>
>> @property
>> def estimate_by_weight():
>> return self.weight * PRICE_OF GOLD
>>
>> Where would I put the PRICE_OF_GOLD constant? Some ideas that came to
>> mind:
>>
>> 1. Settings.py - but then I have to edit that file every time I want to
>> update the price of gold
>>
>> 2. Maybe a model so I can update it in the admin screens?
>>
>> 3. A form somewhere? But I think this would mean a model, so this is
>> probably the same as #2.
>>
>> Where would one put a non-changing constant like the speed of light in a
>> django application?
>>
>> Thanks!
>>
>> Mark
>>
>> (1) Yes, I realize that terms 'constant' and 'changes sometimes' are
>> mutually exclusive, but I hope you get the gist of what I am asking
>> regardless of my imprecise description..
>>
>> --
>> 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/CAEqej2OuRC%3D5c2AwKkLRV0%2BGQJMBd6g2wM41mRZB1RCpMtOshw%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> 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/CAB%2BAj0tCsz6XSb4T4gziZFzUxG%3DnHxmMe_Zj7n%3D3P%3DgEZ7s7rQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 

Re: Newbie Question - Where to store application constants?

2014-02-14 Thread Bill Freeman
It depends on the complexity of the issue.

The price of gold does fluctuate.  On the grounds that I might want to
change it more often than I would want to ssh in, edit a file, and restart,
I would tend to put price of gold in the database, that is, in a model of
which there may only be one instance.  Implementing limits on who has
permission to change it is a separate fun topic, which may not be needed if
very few people have admin logins.

Then there are application specific configuration options, which tent to
never change once an installation is up and running.  You can require that
they be set in settings.py if the constants are highly likely to differ
site to site (or if there is only one site in the world using this app),
but it is probably worthwhile providing defaults which can be overridden in
settings.py .  A common way to do the latter is to have another settings
file in the app directory (usually also called settings.py, since it can be
qualified with the app name) which defines constants as the result of
calling gettattr on the main settings object, and providing the default
value as teh third argument to getattr.  The other parts of the app get the
constants from the app specific settings file.

Another kind of constant is truly never expected to change, such as
physical or algorithmic constants, defined so that they can be used
symbolically.  Sometimes they are only used quite locally, and can be
defined in that module, but if they are used by two or more modules, they
should probably be defined once, and imported in modules that use them.
While it is possible to define them in any module (such as the one that
uses them the most) and to import from that module in others that need the
constant(s), you must beware of circular import problems, so it is often
easier to create a constants.py or the like (if you already have an app
specific settings module, it is a fine place for you constants).  But your
models.py module, if you have only one, is a pretty safe place to put
constants, since it doesn't tend to import your other modules (unless you
have an app specific settings module), so you won't (typically)  have
circularity if you import from it.

Bill


On Fri, Feb 14, 2014 at 11:13 AM, Mark Phillips
wrote:

> Where should one put application specific constants - those that change
> sometimes(1) and those that never change? For example, I am creating a
> simple inventory application for my mother's estate. Several quotes for
> her jewelry are based on the weight of the jewelry and the current price of
> gold.
>
> In the Estimate model, I have a field for weight, and then a property that
> looks something like:
>
> @property
> def estimate_by_weight():
> return self.weight * PRICE_OF GOLD
>
> Where would I put the PRICE_OF_GOLD constant? Some ideas that came to mind:
>
> 1. Settings.py - but then I have to edit that file every time I want to
> update the price of gold
>
> 2. Maybe a model so I can update it in the admin screens?
>
> 3. A form somewhere? But I think this would mean a model, so this is
> probably the same as #2.
>
> Where would one put a non-changing constant like the speed of light in a
> django application?
>
> Thanks!
>
> Mark
>
> (1) Yes, I realize that terms 'constant' and 'changes sometimes' are
> mutually exclusive, but I hope you get the gist of what I am asking
> regardless of my imprecise description..
>
> --
> 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/CAEqej2OuRC%3D5c2AwKkLRV0%2BGQJMBd6g2wM41mRZB1RCpMtOshw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAB%2BAj0tCsz6XSb4T4gziZFzUxG%3DnHxmMe_Zj7n%3D3P%3DgEZ7s7rQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Newbie Question - Where to store application constants?

2014-02-14 Thread Mark Phillips
Where should one put application specific constants - those that change
sometimes(1) and those that never change? For example, I am creating a
simple inventory application for my mother's estate. Several quotes for
her jewelry are based on the weight of the jewelry and the current price of
gold.

In the Estimate model, I have a field for weight, and then a property that
looks something like:

@property
def estimate_by_weight():
return self.weight * PRICE_OF GOLD

Where would I put the PRICE_OF_GOLD constant? Some ideas that came to mind:

1. Settings.py - but then I have to edit that file every time I want to
update the price of gold

2. Maybe a model so I can update it in the admin screens?

3. A form somewhere? But I think this would mean a model, so this is
probably the same as #2.

Where would one put a non-changing constant like the speed of light in a
django application?

Thanks!

Mark

(1) Yes, I realize that terms 'constant' and 'changes sometimes' are
mutually exclusive, but I hope you get the gist of what I am asking
regardless of my imprecise description..

-- 
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/CAEqej2OuRC%3D5c2AwKkLRV0%2BGQJMBd6g2wM41mRZB1RCpMtOshw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Newbie question: first project can't connect to MySQL

2013-08-09 Thread Robert
I got the same problem. I solved it just now.
http://stackoverflow.com/questions/18150858/operationalerror-2002-cant-connect-to-local-mysql-server-through-socket-v

On Thursday, February 5, 2009 1:41:21 AM UTC+8, Kevin Audleman wrote:
>
> Hello everyone, 
>
> I am running through the tutorial and setting up my first django 
> project. Quite exciting! However I have run into trouble connecting to 
> MySQL. My settings.py file looks like this: 
>
> DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2', 
> 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
> DATABASE_NAME = 'test' # Or path to database file if using 
> sqlite3. 
> DATABASE_USER = 'root' # Not used with sqlite3. 
> DATABASE_PASSWORD = '' # Not used with sqlite3. 
> DATABASE_HOST = '' # Set to empty string for localhost. 
> Not used with sqlite3. 
> DATABASE_PORT = '' # Set to empty string for default. Not 
> used with sqlite3. 
>
> Yes, the username is 'root' and there is no password. This is on my 
> local machine (OS X 10.5) so it doesn't matter. 
>
> When I run... 
>
> $ python manage.py syncdb 
>
> I get the following... 
>
> Traceback (most recent call last): 
>   File "manage.py", line 11, in  
> execute_manager(settings) 
>   File "/Library/Python/2.5/site-packages/django/core/management/ 
> __init__.py", line 340, in execute_manager 
> utility.execute() 
>   File "/Library/Python/2.5/site-packages/django/core/management/ 
> __init__.py", line 295, in execute 
> self.fetch_command(subcommand).run_from_argv(self.argv) 
>   File "/Library/Python/2.5/site-packages/django/core/management/ 
> base.py", line 192, in run_from_argv 
> self.execute(*args, **options.__dict__) 
>   File "/Library/Python/2.5/site-packages/django/core/management/ 
> base.py", line 218, in execute 
> self.validate() 
>   File "/Library/Python/2.5/site-packages/django/core/management/ 
> base.py", line 246, in validate 
> num_errors = get_validation_errors(s, app) 
>   File "/Library/Python/2.5/site-packages/django/core/management/ 
> validation.py", line 65, in get_validation_errors 
> connection.validation.validate_field(e, opts, f) 
>   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ 
> validation.py", line 8, in validate_field 
> db_version = connection.get_server_version() 
>   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ 
> base.py", line 277, in get_server_version 
> self.cursor() 
>   File "/Library/Python/2.5/site-packages/django/db/backends/ 
> __init__.py", line 56, in cursor 
> cursor = self._cursor(settings) 
>   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ 
> base.py", line 262, in _cursor 
> self.connection = Database.connect(**kwargs) 
>   File "/Users/audleman/django_projects/pollster/__init__.py", line 
> 74, in Connect 
>
>   File "/Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5- 
> macosx-10.5-i386.egg/MySQLdb/connections.py", line 170, in __init__ 
> _mysql_exceptions.OperationalError: (2002, "Can't connect to local 
> MySQL server through socket '/tmp/mysql.sock' (2)") 
>
>
> I'm not exactly sure what this socket is or why django can't find it. 
> One thought is that I installed LAMP on my machine using XAMPP, which 
> puts everything in the /Applications/xampp directory. Poking around, I 
> managed to find a mysql.sock file here: 
>
> /Applications/xampp/xamppfiles/var/mysql/mysql.sock 
>
> Assuming this is the correct socket, how do I tell django where to 
> find it? 
>
> Thanks, 
> Kevin 
>

-- 
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: [newbie question] python manage syncdb doesn't create all the tables. Models has been splitted up.

2013-05-09 Thread crosa
I found the error. The application wasn't in the INSTALLED_APP in the 
settings file! 


On Thursday, May 9, 2013 2:13:19 PM UTC+2, Mike Dewhirst wrote:
>
> On 9/05/2013 10:04pm, crosa wrote: 
> > Hi guys, 
> > 
> > I'm testing django in order to build a little application. This 
> > application will have several models, so I've decided to split up them, 
> > in order to do this more readable (Any other form to do this?) 
> > When I run python manage.py syncdb, the models tables have not been 
> > created, and I don't know why! 
>
> Check this ... 
>
> https://docs.djangoproject.com/en/dev/ref/models/options/#app-label 
>
> > 
> > I have tried to use south for the migration too, and when I run this: 
> > python manage.py schemamigration testapp --initial 
> > This error appears. 
> > ImproperlyConfigured: App with label testapp could not be found 
> > 
> > I think it's something related with the models split up, but I don't 
> > know what 
> > 
> > Here we are the testproject tree (attached). 
> > 
> > ├── [-rwxr-xr-x  250 May  9 13:14]  manage.py 
> > ├── [drwxr-xr-x 4.0K May  9 13:51]  templates 
> > │   ├── [-rw-r--r--  111 May  9 13:50]  view1.html 
> > │   ├── [-rw-r--r--  111 May  9 13:50]  view2.html 
> > │   └── [-rw-r--r--  111 May  9 13:51]  view3.html 
> > └── [drwxr-xr-x 4.0K May  9 13:54]  testapp 
> >  ├── [-rw-r--r--  406 May  9 13:23]  admin.py 
> >  ├── [-rw-r--r--   27 May  9 13:23]  forms.py 
> >  ├── [-rw-r--r--0 May  9 13:10]  __init__.py 
> >  ├── [drwxr-xr-x 4.0K May  9 13:32]  models 
> >  │   ├── [-rw-r--r--  133 May  9 13:32]  __init__.py 
> >  │   ├── [-rw-r--r--  588 May  9 13:30]  model1.py 
> >  │   ├── [-rw-r--r--  921 May  9 13:31]  model2.py 
> >  │   └── [-rw-r--r--  588 May  9 13:32]  model3.py 
> >  ├── [-rw-r--r-- 5.4K May  9 13:24]  settings.py 
> >  ├── [-rw-r--r--  39K May  9 13:48]  sqlite.db 
> >  ├── [-rw-r--r--  774 May  9 13:52]  urls.py 
> >  ├── [-rw-r--r--  746 May  9 13:48]  views.py 
> >  └── [-rw-r--r-- 1.4K May  9 13:17]  wsgi.py 
> > 
> > Thanks in advance! 
> > 
> > -- 
> > 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?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
>

-- 
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: [newbie question] python manage syncdb doesn't create all the tables. Models has been splitted up.

2013-05-09 Thread Mike Dewhirst

On 9/05/2013 10:04pm, crosa wrote:

Hi guys,

I'm testing django in order to build a little application. This
application will have several models, so I've decided to split up them,
in order to do this more readable (Any other form to do this?)
When I run python manage.py syncdb, the models tables have not been
created, and I don't know why!


Check this ...

https://docs.djangoproject.com/en/dev/ref/models/options/#app-label



I have tried to use south for the migration too, and when I run this:
python manage.py schemamigration testapp --initial
This error appears.
ImproperlyConfigured: App with label testapp could not be found

I think it's something related with the models split up, but I don't
know what

Here we are the testproject tree (attached).

├── [-rwxr-xr-x  250 May  9 13:14]  manage.py
├── [drwxr-xr-x 4.0K May  9 13:51]  templates
│   ├── [-rw-r--r--  111 May  9 13:50]  view1.html
│   ├── [-rw-r--r--  111 May  9 13:50]  view2.html
│   └── [-rw-r--r--  111 May  9 13:51]  view3.html
└── [drwxr-xr-x 4.0K May  9 13:54]  testapp
 ├── [-rw-r--r--  406 May  9 13:23]  admin.py
 ├── [-rw-r--r--   27 May  9 13:23]  forms.py
 ├── [-rw-r--r--0 May  9 13:10]  __init__.py
 ├── [drwxr-xr-x 4.0K May  9 13:32]  models
 │   ├── [-rw-r--r--  133 May  9 13:32]  __init__.py
 │   ├── [-rw-r--r--  588 May  9 13:30]  model1.py
 │   ├── [-rw-r--r--  921 May  9 13:31]  model2.py
 │   └── [-rw-r--r--  588 May  9 13:32]  model3.py
 ├── [-rw-r--r-- 5.4K May  9 13:24]  settings.py
 ├── [-rw-r--r--  39K May  9 13:48]  sqlite.db
 ├── [-rw-r--r--  774 May  9 13:52]  urls.py
 ├── [-rw-r--r--  746 May  9 13:48]  views.py
 └── [-rw-r--r-- 1.4K May  9 13:17]  wsgi.py

Thanks in advance!

--
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.




--
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.




[newbie question] python manage syncdb doesn't create all the tables. Models has been splitted up.

2013-05-09 Thread crosa
Hi guys,

I'm testing django in order to build a little application. This application 
will have several models, so I've decided to split up them, in order to do 
this more readable (Any other form to do this?)
When I run python manage.py syncdb, the models tables have not been 
created, and I don't know why!

I have tried to use south for the migration too, and when I run this:
python manage.py schemamigration testapp --initial
This error appears.
ImproperlyConfigured: App with label testapp could not be found

I think it's something related with the models split up, but I don't know 
what

Here we are the testproject tree (attached).

├── [-rwxr-xr-x  250 May  9 13:14]  manage.py
├── [drwxr-xr-x 4.0K May  9 13:51]  templates
│   ├── [-rw-r--r--  111 May  9 13:50]  view1.html
│   ├── [-rw-r--r--  111 May  9 13:50]  view2.html
│   └── [-rw-r--r--  111 May  9 13:51]  view3.html
└── [drwxr-xr-x 4.0K May  9 13:54]  testapp
├── [-rw-r--r--  406 May  9 13:23]  admin.py
├── [-rw-r--r--   27 May  9 13:23]  forms.py
├── [-rw-r--r--0 May  9 13:10]  __init__.py
├── [drwxr-xr-x 4.0K May  9 13:32]  models
│   ├── [-rw-r--r--  133 May  9 13:32]  __init__.py
│   ├── [-rw-r--r--  588 May  9 13:30]  model1.py
│   ├── [-rw-r--r--  921 May  9 13:31]  model2.py
│   └── [-rw-r--r--  588 May  9 13:32]  model3.py
├── [-rw-r--r-- 5.4K May  9 13:24]  settings.py
├── [-rw-r--r--  39K May  9 13:48]  sqlite.db
├── [-rw-r--r--  774 May  9 13:52]  urls.py
├── [-rw-r--r--  746 May  9 13:48]  views.py
└── [-rw-r--r-- 1.4K May  9 13:17]  wsgi.py

Thanks in advance!

-- 
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.




testapprj.tar.gz
Description: Binary data


Re: Newbie question: session-length data storage best practices?

2013-01-21 Thread Nikolas Stevenson-Molnar
Upon a second glance, it looks like the clearsession command will only
have an effect as of Django 1.5. For <=1.4 if you're using the DB
backend, you could always clear them out yourself with a query:

now = datetime.datetime.now()
Session.objects.filter(expire_date__lt=now).delete()

_Nik

On 1/21/2013 12:46 PM, Nikolas Stevenson-Molnar wrote:
> Hi Spork,
>
> See this section of the sessions docs:
> https://docs.djangoproject.com/en/1.4/topics/http/sessions/#clearing-the-session-table
>
> While it mentions file and db backends specifically, I assume the cache
> backend would work similarly. I.e., you need to periodically run a
> cleanup of session data. According to the docs, Django will
> automatically delete session data when the user logs out, but not
> otherwise (again, the server has no reliable way of knowing the user has
> closed the browser window) so if you want the data gone, you have to
> clean it up periodically.
>
> Taking a step back, I don't think this is a good approach to security.
> This data is still residing on your server for however short a time
> period. The issue should be less one of how long the data exist there,
> and more about how to keep it safe. How to do that depends somewhat on
> the nature of the data (e.g., SSNs or credit card numbers should reside
> only on a system not connected directly to the internet).
>
> _Nik
>
> On 1/21/2013 9:45 AM, testbackupa...@gmail.com wrote:
>> Nik,
>>
>> My concerns are about security. I have some sensitive data associated
>> with each user's session, and I'd like to make sure it is deleted when
>> the user logs out or their session times out or closes their browser
>> window. There's also some other clean up actions I'd like to do under
>> the same circumstances.
>>
>> I took a look at the session caching documents (thanks for the
>> pointer), and I think I would have to go for the cached_db option; if
>> I just used the plain vanilla cache option and the data got expired
>> out of the cache, it would create a terrible user experience. But I
>> would to understand the mechanism by which session data gets purged
>> from the database backend. Can I rely on it getting purged with each
>> log out/session time out/browser window closure?
>>
>> Again, thanks for the good feedback.
>>
>> Spork
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/SOs0zvR48PMJ.
>> 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.

-- 
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: Newbie question: session-length data storage best practices?

2013-01-21 Thread Nikolas Stevenson-Molnar
Hi Spork,

See this section of the sessions docs:
https://docs.djangoproject.com/en/1.4/topics/http/sessions/#clearing-the-session-table

While it mentions file and db backends specifically, I assume the cache
backend would work similarly. I.e., you need to periodically run a
cleanup of session data. According to the docs, Django will
automatically delete session data when the user logs out, but not
otherwise (again, the server has no reliable way of knowing the user has
closed the browser window) so if you want the data gone, you have to
clean it up periodically.

Taking a step back, I don't think this is a good approach to security.
This data is still residing on your server for however short a time
period. The issue should be less one of how long the data exist there,
and more about how to keep it safe. How to do that depends somewhat on
the nature of the data (e.g., SSNs or credit card numbers should reside
only on a system not connected directly to the internet).

_Nik

On 1/21/2013 9:45 AM, testbackupa...@gmail.com wrote:
> Nik,
>
> My concerns are about security. I have some sensitive data associated
> with each user's session, and I'd like to make sure it is deleted when
> the user logs out or their session times out or closes their browser
> window. There's also some other clean up actions I'd like to do under
> the same circumstances.
>
> I took a look at the session caching documents (thanks for the
> pointer), and I think I would have to go for the cached_db option; if
> I just used the plain vanilla cache option and the data got expired
> out of the cache, it would create a terrible user experience. But I
> would to understand the mechanism by which session data gets purged
> from the database backend. Can I rely on it getting purged with each
> log out/session time out/browser window closure?
>
> Again, thanks for the good feedback.
>
> Spork
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/SOs0zvR48PMJ.
> 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.

-- 
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: Newbie question: session-length data storage best practices?

2013-01-21 Thread testbackupacct
Nik,

My concerns are about security. I have some sensitive data associated with 
each user's session, and I'd like to make sure it is deleted when the user 
logs out or their session times out or closes their browser window. There's 
also some other clean up actions I'd like to do under the same 
circumstances.

I took a look at the session caching documents (thanks for the pointer), 
and I think I would have to go for the cached_db option; if I just used the 
plain vanilla cache option and the data got expired out of the cache, it 
would create a terrible user experience. But I would to understand the 
mechanism by which session data gets purged from the database backend. Can 
I rely on it getting purged with each log out/session time out/browser 
window closure? 

Again, thanks for the good feedback.

Spork

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/SOs0zvR48PMJ.
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: Newbie question: session-length data storage best practices?

2013-01-19 Thread Nikolas Stevenson-Molnar
If I understand correctly, you just need to set
SESSION_EXPIRE_AT_BROWSER_CLOSE = True in your settings:
https://docs.djangoproject.com/en/1.4/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions

When the user closes their browser, the session ends. True, the
associated data isn't deleted right when this happens (the server has no
way of knowing when the user has done this), but that data will no
longer be associated with anyone. If you're particularly concerned about
the data not going to disk, you can use a cached session engine (with
memcached) , as Javier suggests:
https://docs.djangoproject.com/en/1.4/topics/http/sessions/#using-cached-sessions

It may help to know a little bit more about what you're trying to
accomplish. Is your concern security or user experience related?

_Nik

On 1/19/2013 12:03 PM, testbackupa...@gmail.com wrote:
> Hi,
>
> I've got some data that I'll need read/write access to for the length
> of an authenticated session's lifetime. But once that browser tab is
> closed or the user logs out or the user session times out, I want that
> data to disappear.
>
> If I'm reading the session docs correctly, if I add the data to the
> session object, it'll get persisted, which I don't want. I believe
> I'll have the same problem if I extend the user profile. And I
> *really* don't want to store the data in the session cookie.
>
> For the time being, I'm just storing it in a global data structure in
> my views.py, and deleting the data via a 'user logged out' signal. But
> I can't seem to find a 'session timed out' signal to catch. And,
> anyway, I can't shake the feeling that there's a better way to do
> this. Is there?
>
> Thanks in advance!
>
> Spork
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/dokMLZNlkbIJ.
> 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.

-- 
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: Newbie question: session-length data storage best practices?

2013-01-19 Thread testbackupacct
Ok, you've made a very convincing argument. I really haven't spent much time 
thinking about scalability -- obviously it's time for me to do so!

Thanks for taking the time to respond.

Spork

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fSWRIFv4ioEJ.
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: Newbie question: session-length data storage best practices?

2013-01-19 Thread Javier Guerra Giraldez
On Sat, Jan 19, 2013 at 3:03 PM,   wrote:
> If I'm reading the session docs correctly, if I add the data to the session
> object, it'll get persisted, which I don't want.

i think you _do_ want it to be persisted.

remember that HTTP is a stateless protocol.  to have it even slightly
scalable (anything beyond a handful of users), you have to realize
that your sessions are longer than the request/response cycle, and can
be handled by any one of several processes.  that's why the session
object saves its data to some backend.

now, not every backend have to necessarily write to disk.  i think you
could simply use the memcached backend.

> I believe I'll have the
> same problem if I extend the user profile. And I *really* don't want to
> store the data in the session cookie.

not the same problem, but if you want session-long data, the best
place to save it is on the session object.


> For the time being, I'm just storing it in a global data structure in my
> views.py, and deleting the data via a 'user logged out' signal. But I can't
> seem to find a 'session timed out' signal to catch. And, anyway, I can't
> shake the feeling that there's a better way to do this. Is there?


that's definitely a bad idea.  it will break down as soon as you use a
non-single-process deployment.

the session object is specifically thought to share data between not
only from one request to the next, but also between the different
processes that might handle it.  tying the user to a single process
creates a very low performance ceiling.


--
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.



Newbie question: session-length data storage best practices?

2013-01-19 Thread testbackupacct
Hi,

I've got some data that I'll need read/write access to for the length of an 
authenticated session's lifetime. But once that browser tab is closed or 
the user logs out or the user session times out, I want that data to 
disappear.

If I'm reading the session docs correctly, if I add the data to the session 
object, it'll get persisted, which I don't want. I believe I'll have the 
same problem if I extend the user profile. And I *really* don't want to 
store the data in the session cookie. 

For the time being, I'm just storing it in a global data structure in my 
views.py, and deleting the data via a 'user logged out' signal. But I can't 
seem to find a 'session timed out' signal to catch. And, anyway, I can't 
shake the feeling that there's a better way to do this. Is there?

Thanks in advance!

Spork


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/dokMLZNlkbIJ.
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: Newbie question: first project can't connect to MySQL

2012-10-05 Thread Javier Guerra Giraldez
On Fri, Oct 5, 2012 at 3:02 PM, Kurtis Mullins  wrote:
> Also, if memory serves me correctly, MySQL may be setup to allow connections
> from 127.0.0.1 but not Localhost

AFAIK, there are at least three different ways to connect to a local
server, each can be allowed/denied individually:

A: unix socket (something like /var/run/mysqld/mysqld.sock)

B: 127.0.0.1

C: a valid IP number that happens to be (one of) your own

-- 
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: Newbie question: first project can't connect to MySQL

2012-10-05 Thread Kurtis Mullins
Also, if memory serves me correctly, MySQL may be setup to allow
connections from 127.0.0.1 but not Localhost

On Fri, Oct 5, 2012 at 2:45 PM, Mohamad Efazati wrote:

> Hi afshin
> localhost is kind of pointer to 127.0.0.1, maybe in /etc/hosts or other
> thing you overwrite it.
> so 127.0.0.1 is source and always work.
>
>
> 2012/10/4 Afshin Mehrabani 
>
>> Hey Kevin,
>>
>> Thanks for your correct reply, I had this problem also but after changing
>> host from "localhost" to "127.0.0.1" problem solved, But why? what's the
>> different between 'localhost' and '127.0.0.1'?
>>
>> On Wednesday, February 4, 2009 9:15:32 PM UTC+3:30, Kevin Audleman wrote:
>>>
>>> I found the solution in the archives: I changed DATABASE_HOST to
>>> 127.0.0.1 from ''
>>>
>>> Kevin
>>>
>>> On Feb 4, 9:41 am, Kevin Audleman  wrote:
>>> > Hello everyone,
>>> >
>>> > I am running through the tutorial and setting up my first django
>>> > project. Quite exciting! However I have run into trouble connecting to
>>> > MySQL. My settings.py file looks like this:
>>> >
>>> > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
>>> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>>> > DATABASE_NAME = 'test' # Or path to database file if using
>>> > sqlite3.
>>> > DATABASE_USER = 'root' # Not used with sqlite3.
>>> > DATABASE_PASSWORD = '' # Not used with sqlite3.
>>> > DATABASE_HOST = '' # Set to empty string for localhost.
>>> > Not used with sqlite3.
>>> > DATABASE_PORT = '' # Set to empty string for default. Not
>>> > used with sqlite3.
>>> >
>>> > Yes, the username is 'root' and there is no password. This is on my
>>> > local machine (OS X 10.5) so it doesn't matter.
>>> >
>>> > When I run...
>>> >
>>> > $ python manage.py syncdb
>>> >
>>> > I get the following...
>>> >
>>> > Traceback (most recent call last):
>>> >   File "manage.py", line 11, in 
>>> > execute_manager(settings)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > __init__.py", line 340, in execute_manager
>>> > utility.execute()
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > __init__.py", line 295, in execute
>>> > self.fetch_command(subcommand)**.run_from_argv(self.argv)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > base.py", line 192, in run_from_argv
>>> > self.execute(*args, **options.__dict__)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > base.py", line 218, in execute
>>> > self.validate()
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > base.py", line 246, in validate
>>> > num_errors = get_validation_errors(s, app)
>>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>>> > validation.py", line 65, in get_validation_errors
>>> > connection.validation.**validate_field(e, opts, f)
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>>
>>> > validation.py", line 8, in validate_field
>>> > db_version = connection.get_server_version(**)
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>>
>>> > base.py", line 277, in get_server_version
>>> > self.cursor()
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/
>>> > __init__.py", line 56, in cursor
>>> > cursor = self._cursor(settings)
>>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>>
>>> > base.py", line 262, in _cursor
>>> > self.connection = Database.connect(**kwargs)
>>> >   File "/Users/audleman/django_**projects/pollster/__init__.py"**,
>>> line
>>> > 74, in Connect
>>> >
>>> >   File "/Library/Python/2.5/site-**packages/MySQL_python-1.2.2-**py2.5-
>>>
>>> > macosx-10.5-i386.egg/MySQLdb/**connections.py", line 170, in __init__
>>> > _mysql_exceptions.**OperationalError: (2002, "Can't connect to local
>>> > MySQL server through socket '/tmp/mysql.sock' (2)")
>>> >
>>> > I'm not exactly sure what this socket is or why django can't find it.
>>> > One thought is that I installed LAMP on my machine using XAMPP, which
>>> > puts everything in the /Applications/xampp directory. Poking around, I
>>> > managed to find a mysql.sock file here:
>>> >
>>> > /Applications/xampp/**xamppfiles/var/mysql/mysql.**sock
>>> >
>>> > Assuming this is the correct socket, how do I tell django where to
>>> > find it?
>>> >
>>> > Thanks,
>>> > Kevin
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/0dD75LGNe6UJ.
>> 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
>> 

Re: Newbie question: first project can't connect to MySQL

2012-10-05 Thread Mohamad Efazati
Hi afshin
localhost is kind of pointer to 127.0.0.1, maybe in /etc/hosts or other
thing you overwrite it.
so 127.0.0.1 is source and always work.


2012/10/4 Afshin Mehrabani 

> Hey Kevin,
>
> Thanks for your correct reply, I had this problem also but after changing
> host from "localhost" to "127.0.0.1" problem solved, But why? what's the
> different between 'localhost' and '127.0.0.1'?
>
> On Wednesday, February 4, 2009 9:15:32 PM UTC+3:30, Kevin Audleman wrote:
>>
>> I found the solution in the archives: I changed DATABASE_HOST to
>> 127.0.0.1 from ''
>>
>> Kevin
>>
>> On Feb 4, 9:41 am, Kevin Audleman  wrote:
>> > Hello everyone,
>> >
>> > I am running through the tutorial and setting up my first django
>> > project. Quite exciting! However I have run into trouble connecting to
>> > MySQL. My settings.py file looks like this:
>> >
>> > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2',
>> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>> > DATABASE_NAME = 'test' # Or path to database file if using
>> > sqlite3.
>> > DATABASE_USER = 'root' # Not used with sqlite3.
>> > DATABASE_PASSWORD = '' # Not used with sqlite3.
>> > DATABASE_HOST = '' # Set to empty string for localhost.
>> > Not used with sqlite3.
>> > DATABASE_PORT = '' # Set to empty string for default. Not
>> > used with sqlite3.
>> >
>> > Yes, the username is 'root' and there is no password. This is on my
>> > local machine (OS X 10.5) so it doesn't matter.
>> >
>> > When I run...
>> >
>> > $ python manage.py syncdb
>> >
>> > I get the following...
>> >
>> > Traceback (most recent call last):
>> >   File "manage.py", line 11, in 
>> > execute_manager(settings)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > __init__.py", line 340, in execute_manager
>> > utility.execute()
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > __init__.py", line 295, in execute
>> > self.fetch_command(subcommand)**.run_from_argv(self.argv)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > base.py", line 192, in run_from_argv
>> > self.execute(*args, **options.__dict__)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > base.py", line 218, in execute
>> > self.validate()
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > base.py", line 246, in validate
>> > num_errors = get_validation_errors(s, app)
>> >   File "/Library/Python/2.5/site-**packages/django/core/**management/
>> > validation.py", line 65, in get_validation_errors
>> > connection.validation.**validate_field(e, opts, f)
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>
>> > validation.py", line 8, in validate_field
>> > db_version = connection.get_server_version(**)
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>
>> > base.py", line 277, in get_server_version
>> > self.cursor()
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/
>> > __init__.py", line 56, in cursor
>> > cursor = self._cursor(settings)
>> >   File "/Library/Python/2.5/site-**packages/django/db/backends/**mysql/
>>
>> > base.py", line 262, in _cursor
>> > self.connection = Database.connect(**kwargs)
>> >   File "/Users/audleman/django_**projects/pollster/__init__.py"**,
>> line
>> > 74, in Connect
>> >
>> >   File "/Library/Python/2.5/site-**packages/MySQL_python-1.2.2-**py2.5-
>>
>> > macosx-10.5-i386.egg/MySQLdb/**connections.py", line 170, in __init__
>> > _mysql_exceptions.**OperationalError: (2002, "Can't connect to local
>> > MySQL server through socket '/tmp/mysql.sock' (2)")
>> >
>> > I'm not exactly sure what this socket is or why django can't find it.
>> > One thought is that I installed LAMP on my machine using XAMPP, which
>> > puts everything in the /Applications/xampp directory. Poking around, I
>> > managed to find a mysql.sock file here:
>> >
>> > /Applications/xampp/**xamppfiles/var/mysql/mysql.**sock
>> >
>> > Assuming this is the correct socket, how do I tell django where to
>> > find it?
>> >
>> > Thanks,
>> > Kevin
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/0dD75LGNe6UJ.
> 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.
>
> --
> با تشکر
> افاضاتی
> http://www.efazati.org
>
>
>

-- 
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 

Re: Newbie question: first project can't connect to MySQL

2012-10-04 Thread Afshin Mehrabani
Hey Kevin,

Thanks for your correct reply, I had this problem also but after changing 
host from "localhost" to "127.0.0.1" problem solved, But why? what's the 
different between 'localhost' and '127.0.0.1'? 

On Wednesday, February 4, 2009 9:15:32 PM UTC+3:30, Kevin Audleman wrote:
>
> I found the solution in the archives: I changed DATABASE_HOST to 
> 127.0.0.1 from '' 
>
> Kevin 
>
> On Feb 4, 9:41 am, Kevin Audleman  wrote: 
> > Hello everyone, 
> > 
> > I am running through the tutorial and setting up my first django 
> > project. Quite exciting! However I have run into trouble connecting to 
> > MySQL. My settings.py file looks like this: 
> > 
> > DATABASE_ENGINE = 'mysql'   # 'postgresql_psycopg2', 
> > 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
> > DATABASE_NAME = 'test' # Or path to database file if using 
> > sqlite3. 
> > DATABASE_USER = 'root' # Not used with sqlite3. 
> > DATABASE_PASSWORD = '' # Not used with sqlite3. 
> > DATABASE_HOST = '' # Set to empty string for localhost. 
> > Not used with sqlite3. 
> > DATABASE_PORT = '' # Set to empty string for default. Not 
> > used with sqlite3. 
> > 
> > Yes, the username is 'root' and there is no password. This is on my 
> > local machine (OS X 10.5) so it doesn't matter. 
> > 
> > When I run... 
> > 
> > $ python manage.py syncdb 
> > 
> > I get the following... 
> > 
> > Traceback (most recent call last): 
> >   File "manage.py", line 11, in  
> > execute_manager(settings) 
> >   File "/Library/Python/2.5/site-packages/django/core/management/ 
> > __init__.py", line 340, in execute_manager 
> > utility.execute() 
> >   File "/Library/Python/2.5/site-packages/django/core/management/ 
> > __init__.py", line 295, in execute 
> > self.fetch_command(subcommand).run_from_argv(self.argv) 
> >   File "/Library/Python/2.5/site-packages/django/core/management/ 
> > base.py", line 192, in run_from_argv 
> > self.execute(*args, **options.__dict__) 
> >   File "/Library/Python/2.5/site-packages/django/core/management/ 
> > base.py", line 218, in execute 
> > self.validate() 
> >   File "/Library/Python/2.5/site-packages/django/core/management/ 
> > base.py", line 246, in validate 
> > num_errors = get_validation_errors(s, app) 
> >   File "/Library/Python/2.5/site-packages/django/core/management/ 
> > validation.py", line 65, in get_validation_errors 
> > connection.validation.validate_field(e, opts, f) 
> >   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ 
> > validation.py", line 8, in validate_field 
> > db_version = connection.get_server_version() 
> >   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ 
> > base.py", line 277, in get_server_version 
> > self.cursor() 
> >   File "/Library/Python/2.5/site-packages/django/db/backends/ 
> > __init__.py", line 56, in cursor 
> > cursor = self._cursor(settings) 
> >   File "/Library/Python/2.5/site-packages/django/db/backends/mysql/ 
> > base.py", line 262, in _cursor 
> > self.connection = Database.connect(**kwargs) 
> >   File "/Users/audleman/django_projects/pollster/__init__.py", line 
> > 74, in Connect 
> > 
> >   File "/Library/Python/2.5/site-packages/MySQL_python-1.2.2-py2.5- 
> > macosx-10.5-i386.egg/MySQLdb/connections.py", line 170, in __init__ 
> > _mysql_exceptions.OperationalError: (2002, "Can't connect to local 
> > MySQL server through socket '/tmp/mysql.sock' (2)") 
> > 
> > I'm not exactly sure what this socket is or why django can't find it. 
> > One thought is that I installed LAMP on my machine using XAMPP, which 
> > puts everything in the /Applications/xampp directory. Poking around, I 
> > managed to find a mysql.sock file here: 
> > 
> > /Applications/xampp/xamppfiles/var/mysql/mysql.sock 
> > 
> > Assuming this is the correct socket, how do I tell django where to 
> > find it? 
> > 
> > Thanks, 
> > Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/0dD75LGNe6UJ.
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: Newbie question - setting a model form foriegn key

2012-10-02 Thread Laxmikant Gurnalkar
Hi,
I think yes, Otherwise database will raise an integrity error, like
Foreign key violates the not null constraint.

*--Laxmikant* *G.*

On Tue, Oct 2, 2012 at 12:51 PM, Keir Lawson  wrote:

> Thanks for your reply :-)
>
> So there's no way to use a model form to proccess the quest and manually
> set just the FK of it?
>
> Keir
>
>
> On Tuesday, October 2, 2012 6:18:21 AM UTC+1, Laxmikant Gurnalkar wrote:
>
>> Sorry, see again!!
>>
>> def payments_view(request, contact_id):
>> payment = Payment()
>> contact =   contact.objects.filter(id=**contact_id)
>> if contact:
>> payment.contact  = contact[0]
>> payment.save()
>>
>>
>> I dont think you are looking for this kind of thing :
>> cheers
>>
>> On Tue, Oct 2, 2012 at 10:42 AM, Laxmikant Gurnalkar <
>> laxmikant...@gmail.com**> wrote:
>>
>>> def payments_view(request, contact_id):
>>> payment = Payment()
>>> payment.contact  = contact[0]
>>>
 'contact': contact, 'payments': payments, 'form' : PaymentForm()
 })
 return render_to_response('CRMSite/**contact_payments.html',rctx)

>>>rctx = RequestContext(request,{
>>> On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson  wrote:
>>>
 Sorry if this is a dumb question, just picking up Django.

 I've set up a payments form, to create payments associated with a
 contact (see payments model) however I'm having trouble figuring out how to
 save the payment with the relevant contact associated, as the contact isnt
 selected as part of the form (its in the URL instead).  I've included both
 the payment view and the view for processing it, my current approach
 results in a validation error. Anyone able to help?

 Thanks

 Keir

 class Payment(models.Model):
 amount = models.DecimalField(max_**digits=10, decimal_places=2)
 date = models.DateField()
 contact = models.ForeignKey(Contact)

 def payments_view(request, contact_id):
 contact = get_object_or_404(Contact, pk=contact_id)
 payments = Payment.objects.filter(**contact=contact_id)
 rctx = RequestContext(request,{
 'contact': contact, 'payments': payments, 'form' : PaymentForm()
 })
 return render_to_response('CRMSite/**contact_payments.html',rctx)

 def save_payment(request,contact_**id):
 PaymentForm(request.POST,**contact=contact_id).save()
 return payments_view(request, contact_id)


  --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To view this discussion on the web visit https://groups.google.com/d/**
 msg/django-users/-/**g4cNoMI7bEoJ
 .
 To post to this group, send email to django...@googlegroups.com.
 To unsubscribe from this group, send email to django-users...@**
 googlegroups.com.

 For more options, visit this group at http://groups.google.com/**
 group/django-users?hl=en
 .

>>>
>>>
>>>
>>>
>>>
>>
>>
>>
You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/UPZcFyHmGtMJ.
>
> 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.
>

-- 
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: Newbie question - setting a model form foriegn key

2012-10-02 Thread Keir Lawson
Thanks for your reply :-)

So there's no way to use a model form to proccess the quest and manually 
set just the FK of it?

Keir

On Tuesday, October 2, 2012 6:18:21 AM UTC+1, Laxmikant Gurnalkar wrote:
>
> Sorry, see again!!
>
> def payments_view(request, contact_id):
> payment = Payment()
> contact =   contact.objects.filter(id=contact_id)
> if contact:
> payment.contact  = contact[0]
> payment.save()
>
>
> I dont think you are looking for this kind of thing :
> cheers 
>
> On Tue, Oct 2, 2012 at 10:42 AM, Laxmikant Gurnalkar <
> laxmikant...@gmail.com > wrote:
>
>> def payments_view(request, contact_id):
>> payment = Payment()
>> payment.contact  = contact[0] 
>>
>>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>>> })
>>> return render_to_response('CRMSite/contact_payments.html',rctx)
>>>
>>rctx = RequestContext(request,{
>> On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson > > wrote:
>>
>>> Sorry if this is a dumb question, just picking up Django.
>>>
>>> I've set up a payments form, to create payments associated with a 
>>> contact (see payments model) however I'm having trouble figuring out how to 
>>> save the payment with the relevant contact associated, as the contact isnt 
>>> selected as part of the form (its in the URL instead).  I've included both 
>>> the payment view and the view for processing it, my current approach 
>>> results in a validation error. Anyone able to help?
>>>
>>> Thanks
>>>
>>> Keir
>>>
>>> class Payment(models.Model):
>>> amount = models.DecimalField(max_digits=10, decimal_places=2)
>>> date = models.DateField()
>>> contact = models.ForeignKey(Contact)
>>>
>>> def payments_view(request, contact_id):
>>> contact = get_object_or_404(Contact, pk=contact_id)
>>> payments = Payment.objects.filter(contact=contact_id)
>>> rctx = RequestContext(request,{
>>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>>> })
>>> return render_to_response('CRMSite/contact_payments.html',rctx)
>>>
>>> def save_payment(request,contact_id):
>>> PaymentForm(request.POST,contact=contact_id).save()
>>> return payments_view(request, contact_id)
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/g4cNoMI7bEoJ.
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>>
>>
>
>
> -- 
> * 
>
>  GlxGuru
>
> *
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UPZcFyHmGtMJ.
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: Newbie question - setting a model form foriegn key

2012-10-01 Thread Laxmikant Gurnalkar
Sorry, see again!!

def payments_view(request, contact_id):
payment = Payment()
contact =   contact.objects.filter(id=contact_id)
if contact:
payment.contact  = contact[0]
payment.save()


I dont think you are looking for this kind of thing :
cheers

On Tue, Oct 2, 2012 at 10:42 AM, Laxmikant Gurnalkar <
laxmikant.gurnal...@gmail.com> wrote:

> def payments_view(request, contact_id):
> payment = Payment()
> payment.contact  = contact[0]
>
>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>> })
>> return render_to_response('CRMSite/contact_payments.html',rctx)
>>
>rctx = RequestContext(request,{
> On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson  wrote:
>
>> Sorry if this is a dumb question, just picking up Django.
>>
>> I've set up a payments form, to create payments associated with a contact
>> (see payments model) however I'm having trouble figuring out how to save
>> the payment with the relevant contact associated, as the contact isnt
>> selected as part of the form (its in the URL instead).  I've included both
>> the payment view and the view for processing it, my current approach
>> results in a validation error. Anyone able to help?
>>
>> Thanks
>>
>> Keir
>>
>> class Payment(models.Model):
>> amount = models.DecimalField(max_digits=10, decimal_places=2)
>> date = models.DateField()
>> contact = models.ForeignKey(Contact)
>>
>> def payments_view(request, contact_id):
>> contact = get_object_or_404(Contact, pk=contact_id)
>> payments = Payment.objects.filter(contact=contact_id)
>> rctx = RequestContext(request,{
>> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
>> })
>> return render_to_response('CRMSite/contact_payments.html',rctx)
>>
>> def save_payment(request,contact_id):
>> PaymentForm(request.POST,contact=contact_id).save()
>> return payments_view(request, contact_id)
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/g4cNoMI7bEoJ.
>> 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.
>>
>
>
>
>
>


-- 
*

 GlxGuru

*

-- 
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: Newbie question - setting a model form foriegn key

2012-10-01 Thread Laxmikant Gurnalkar
def payments_view(request, contact_id):
payment = Payment()

payment.contact  = contact[0]


   rctx = RequestContext(request,{
> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
> })
> return render_to_response('CRMSite/contact_payments.html',rctx)
>
On Tue, Oct 2, 2012 at 4:20 AM, Keir Lawson  wrote:

> Sorry if this is a dumb question, just picking up Django.
>
> I've set up a payments form, to create payments associated with a contact
> (see payments model) however I'm having trouble figuring out how to save
> the payment with the relevant contact associated, as the contact isnt
> selected as part of the form (its in the URL instead).  I've included both
> the payment view and the view for processing it, my current approach
> results in a validation error. Anyone able to help?
>
> Thanks
>
> Keir
>
> class Payment(models.Model):
> amount = models.DecimalField(max_digits=10, decimal_places=2)
> date = models.DateField()
> contact = models.ForeignKey(Contact)
>
> def payments_view(request, contact_id):
> contact = get_object_or_404(Contact, pk=contact_id)
> payments = Payment.objects.filter(contact=contact_id)
> rctx = RequestContext(request,{
> 'contact': contact, 'payments': payments, 'form' : PaymentForm()
> })
> return render_to_response('CRMSite/contact_payments.html',rctx)
>
> def save_payment(request,contact_id):
> PaymentForm(request.POST,contact=contact_id).save()
> return payments_view(request, contact_id)
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/g4cNoMI7bEoJ.
> 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.
>

-- 
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.



Newbie question - setting a model form foriegn key

2012-10-01 Thread Keir Lawson
Sorry if this is a dumb question, just picking up Django.

I've set up a payments form, to create payments associated with a contact 
(see payments model) however I'm having trouble figuring out how to save 
the payment with the relevant contact associated, as the contact isnt 
selected as part of the form (its in the URL instead).  I've included both 
the payment view and the view for processing it, my current approach 
results in a validation error. Anyone able to help?

Thanks

Keir

class Payment(models.Model):
amount = models.DecimalField(max_digits=10, decimal_places=2)
date = models.DateField()
contact = models.ForeignKey(Contact)

def payments_view(request, contact_id):
contact = get_object_or_404(Contact, pk=contact_id)
payments = Payment.objects.filter(contact=contact_id)
rctx = RequestContext(request,{
'contact': contact, 'payments': payments, 'form' : PaymentForm()
})
return render_to_response('CRMSite/contact_payments.html',rctx)

def save_payment(request,contact_id):
PaymentForm(request.POST,contact=contact_id).save()
return payments_view(request, contact_id)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/g4cNoMI7bEoJ.
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: Newbie question about accesing my development Django instance from other computers in my LAN

2012-07-28 Thread Pratik Mandrekar
Yes 0.0.0.0:8000 is correct. 

You would need to disable firewall for that port. In Ubuntu I used the 
Uncomplicated Firewall utility. You can try something like 
http://download.cnet.com/Windows-7-Firewall-Control/3000-10435_4-10618117.html 
for 
Windows 7

On Friday, July 27, 2012 6:42:18 PM UTC+5:30, Miguel Lavalle wrote:
>
> Hi,
>
> I am new to Django. I am developing my first app on a Windows 7 laptop. I 
> want other people to be able to connect to this app. As indicated in the 
> documentation, I start the server with:
>
> python manage.py runserver 0.0.0.0:8000
>
> And then I try to access my app from another laptop pointing the browser 
> to:
>
> 192.168.1.116:8000/myapp/
>
> Where 192.168.1.116 is the ip address of the laptop where my app resides
>
> 1) Am I using the correct URL?
> 2) Is there anything in Windows 7 that I have to change for other laptops 
> to be able to access my app?
>
> Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/hZi4PyL8gXUJ.
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: Newbie question about accesing my development Django instance from other computers in my LAN

2012-07-27 Thread Bill Freeman
The 0.0.0.0:8000 argument to runserver is the right way to do this.
(Apparently 0:8000 us a legal shortcut.)

But you may have a firewall on your machine which is not allowing
access to port 8000.  You will have to find someone (maybe you) with
specific knowledge of firewall configuration on your particular OS to
help check for that.

Bill

On 7/27/12, Miguel Lavalle  wrote:
> Thanks. It didn't work, though. In the development laptop I started the
> server with python manage.py runserver
> 192.168.1.116:8000
>
>
> In the laptop where I am trying to access the app, I typed in the browser:
>
> 192.168.1.116:8000 /page/ where page is
> what I am trying to access
>
> Regards
>
> Miguel
>
> On Friday, July 27, 2012 8:29:07 AM UTC-5, Christopher Downard wrote:
>>
>> Try python manage.py runserver 192.168.1.116 where that address is your
>> computer's address.
>> On Jul 27, 2012 7:15 AM, "Miguel Lavalle"  wrote:
>>
>>> Hi,
>>>
>>> I am new to Django. I am developing my first app on a Windows 7 laptop. I
>>>
>>> want other people to be able to connect to this app. As indicated in the
>>>
>>> documentation, I start the server with:
>>>
>>> python manage.py runserver 0.0.0.0:8000
>>>
>>> And then I try to access my app from another laptop pointing the browser
>>>
>>> to:
>>>
>>> 192.168.1.116:8000/myapp/
>>>
>>> Where 192.168.1.116 is the ip address of the laptop where my app resides
>>>
>>> 1) Am I using the correct URL?
>>> 2) Is there anything in Windows 7 that I have to change for other laptops
>>>
>>> to be able to access my app?
>>>
>>> Thanks
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>>
>>> "Django users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/django-users/-/oGLm8GM7-e8J.
>>> 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.
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/64QQ-6lO7fQJ.
> 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.
>
>

-- 
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: Newbie question about accesing my development Django instance from other computers in my LAN

2012-07-27 Thread Christopher Downard
Assuming both laptops are connected to the same local network (192.168.1.*)
then it should be able to access the server.

Are you getting a page not found or are you getting an error with the URLs?

My server starts up just fine with python manage.py runserver
192.168.1.149:8020 (my lan's info).

If you're getting page not found I'd guess it's something related to your
network (try ipconfig/all on both computers to make sure). If you're
getting a urls error then you can post your URLs file to dpaste or the
like.

On Fri, Jul 27, 2012 at 10:35 AM, Miguel Lavalle wrote:

> Thanks. It didn't work, though. In the development laptop I started the
> server with python manage.py runserver  
> 192.168.1.116:8000
>
>
> In the laptop where I am trying to access the app, I typed in the
> browser:  192.168.1.116:8000 /page/
> where page is what I am trying to access
>
> Regards
>
> Miguel
>
>
> On Friday, July 27, 2012 8:29:07 AM UTC-5, Christopher Downard wrote:
>>
>> Try python manage.py runserver 192.168.1.116 where that address is your
>> computer's address.
>> On Jul 27, 2012 7:15 AM, "Miguel Lavalle"  wrote:
>>
>>> Hi,
>>>
>>> I am new to Django. I am developing my first app on a Windows 7 laptop.
>>> I want other people to be able to connect to this app. As indicated in the
>>> documentation, I start the server with:
>>>
>>> python manage.py runserver 0.0.0.0:8000
>>>
>>> And then I try to access my app from another laptop pointing the browser
>>> to:
>>>
>>> 192.168.1.116:8000/myapp/
>>>
>>> Where 192.168.1.116 is the ip address of the laptop where my app resides
>>>
>>> 1) Am I using the correct URL?
>>> 2) Is there anything in Windows 7 that I have to change for other
>>> laptops to be able to access my app?
>>>
>>> Thanks
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/django-users/-/oGLm8GM7-**e8J
>>> .
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users+unsubscribe@*
>>> *googlegroups.com .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/64QQ-6lO7fQJ.
>
> 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.
>



-- 

Christopher Downard

**

*Software Engineer*

Blue Sun Technologies

E-Mail: ch...@bluesuntechnologies.com

Mobile: 720-434-9792

www.bluesuntechnologies.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: Newbie question about accesing my development Django instance from other computers in my LAN

2012-07-27 Thread Miguel Lavalle
Thanks. It didn't work, though. In the development laptop I started the 
server with python manage.py runserver  
192.168.1.116:8000
 

In the laptop where I am trying to access the app, I typed in the browser:  
192.168.1.116:8000 /page/ where page is 
what I am trying to access

Regards

Miguel

On Friday, July 27, 2012 8:29:07 AM UTC-5, Christopher Downard wrote:
>
> Try python manage.py runserver 192.168.1.116 where that address is your 
> computer's address. 
> On Jul 27, 2012 7:15 AM, "Miguel Lavalle"  wrote:
>
>> Hi,
>>
>> I am new to Django. I am developing my first app on a Windows 7 laptop. I 
>> want other people to be able to connect to this app. As indicated in the 
>> documentation, I start the server with:
>>
>> python manage.py runserver 0.0.0.0:8000
>>
>> And then I try to access my app from another laptop pointing the browser 
>> to:
>>
>> 192.168.1.116:8000/myapp/
>>
>> Where 192.168.1.116 is the ip address of the laptop where my app resides
>>
>> 1) Am I using the correct URL?
>> 2) Is there anything in Windows 7 that I have to change for other laptops 
>> to be able to access my app?
>>
>> Thanks
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/oGLm8GM7-e8J.
>> 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.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/64QQ-6lO7fQJ.
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: Newbie question about accesing my development Django instance from other computers in my LAN

2012-07-27 Thread Christopher Downard
Try python manage.py runserver 192.168.1.116 where that address is your
computer's address.
On Jul 27, 2012 7:15 AM, "Miguel Lavalle"  wrote:

> Hi,
>
> I am new to Django. I am developing my first app on a Windows 7 laptop. I
> want other people to be able to connect to this app. As indicated in the
> documentation, I start the server with:
>
> python manage.py runserver 0.0.0.0:8000
>
> And then I try to access my app from another laptop pointing the browser
> to:
>
> 192.168.1.116:8000/myapp/
>
> Where 192.168.1.116 is the ip address of the laptop where my app resides
>
> 1) Am I using the correct URL?
> 2) Is there anything in Windows 7 that I have to change for other laptops
> to be able to access my app?
>
> Thanks
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/oGLm8GM7-e8J.
> 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.
>

-- 
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.



Newbie question about accesing my development Django instance from other computers in my LAN

2012-07-27 Thread Miguel Lavalle
Hi,

I am new to Django. I am developing my first app on a Windows 7 laptop. I 
want other people to be able to connect to this app. As indicated in the 
documentation, I start the server with:

python manage.py runserver 0.0.0.0:8000

And then I try to access my app from another laptop pointing the browser to:

192.168.1.116:8000/myapp/

Where 192.168.1.116 is the ip address of the laptop where my app resides

1) Am I using the correct URL?
2) Is there anything in Windows 7 that I have to change for other laptops 
to be able to access my app?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/oGLm8GM7-e8J.
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: Dumb newbie question

2012-02-17 Thread Bob Carlson
I kind of like that suggestion. I just finished refactoring that way. It has the
effect of putting the admin and browse stuff with the data model which makes
sense to me.

Cheers, Bob


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On
Behalf Of Tom Evans
Sent: Friday, February 17, 2012 10:12
To: django-users@googlegroups.com
Subject: Re: Dumb newbie question

On Fri, Feb 17, 2012 at 4:15 PM, Babatunde Akinyanmi <tundeba...@gmail.com>
wrote:
> I'm also a noob. If I had code that would use the same models then I 
> would keep everything inside one app but divide them into modules
>

I would say that is slightly sub optimal.

There is nothing wrong with an app that consists solely of models, and another
app which provides views, templates and forms which uses models from the first
app and has no models of its own.

Cheers

Tom

--
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.

-- 
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: Dumb newbie question

2012-02-17 Thread Tom Evans
On Fri, Feb 17, 2012 at 4:15 PM, Babatunde Akinyanmi
 wrote:
> I'm also a noob. If I had code that would use the same models then I
> would keep everything inside one app but divide them into modules
>

I would say that is slightly sub optimal.

There is nothing wrong with an app that consists solely of models, and
another app which provides views, templates and forms which uses
models from the first app and has no models of its own.

Cheers

Tom

-- 
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: Dumb newbie question

2012-02-17 Thread Babatunde Akinyanmi
I'm also a noob. If I had code that would use the same models then I
would keep everything inside one app but divide them into modules

On 2/17/12, Bob Carlson  wrote:
> I'm well into beginning building my actual app after going through the
> tutorial,
> but I have no feel yet for the answer to this question.
>
>
>
> Can apps share a set of models? My application neatly divides into three
> pieces,
> but all the pieces share the same data. Should these be 3 apps or 1? Can
> apps
> freely share access to data models?
>
>
>
> Cheers, Bob
>
>
>
> --
> 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.
>
>

-- 
Sent from my mobile device

-- 
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.



  1   2   3   4   5   >