Re: Best Django Rest Framework Tutorial??????

2020-06-10 Thread Jack Lin
DOCUMENTATION


在 2020年6月11日 於 上午2:58:42, chaitanya orakala (chaitu.orak...@gmail.com) 寫下:

can anyone please respond ??

On Wed, Jun 10, 2020 at 9:51 AM Sai  wrote:

> Hi djangoians,
> I want to learn django rest framework, may i please know which is best
> resource in online market or any youtube links or udemy courses???
>
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d8b89181-f0d9-4ee8-9f79-dedec63738d2o%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/CAPcTzRYC7UgBAE%3Dm47w74w7kx7JQEtt3ZGZ1naV%2B1tr4jiicYw%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP7OQq11pVJOX6j6fZRHki2YVNiFE8w_yF_BAeFaCGf_mEhZdQ%40mail.gmail.com.


Re: Study and project partner(s) needed

2020-02-16 Thread Jack Lin
Since no one is gathering everyone, I created a Django Learning Group on 
Telegram 
If anyone is interested, just click the link and join us.

Akorede Habeebullah於 2020年2月15日星期六 UTC+8上午12時16分13秒寫道:
>
> Hi guys, 
>
> I've been learning Django on a solo for a while now and I'm really in need 
> of a Programmer friend/partner who we can always learn together, build 
> projects together. This will really benefit both sides greatly. 
> I am a person you'll really love to make friend with. Interested 
> individuals should pls signify. 
>
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/19bdc232-e608-4027-9066-2e7479772e26%40googlegroups.com.


Re: Study and project partner(s) needed

2020-02-14 Thread Jack Lin
Hi there,
I’ve got a new Django project. Do you guys interested to join?
This is my website  <http://afternoon-beach-38581.herokuapp.com> and this
is a simple Django app  <https://pypi.org/project/django-gitlog/0.2/>wait
to be improved.
There is the Github page. <https://github.com/ebbsanchez/django-gitlog>

If anyone have no idea how to cooperate or help. Feel free to ask, I’ll
teach you.


Jack Sanchez

在 2020年2月15日 於 下午1:34:06, paarull shukla (shukla.paarull...@gmail.com) 寫下:

Heloo satvik I also started learn jango few days back.. If we face
anyproblem can we discuss

On Sat, 15 Feb, 2020, 9:06 AM Satvik GS, <1gssat...@gmail.com> wrote:

> Hello,
> I am Satvik
> Even I'm interested. But I have started to learn Django now is it ok if I
> join you guys?
>
> On Fri, Feb 14, 2020, 10:15 PM Greenfield Obasi <
> greenfieldchine...@gmail.com> wrote:
>
>> Yooo let do this!
>>
>> On Fri, 14 Feb 2020, 16:16 Akorede Habeebullah, 
>> wrote:
>>
>>> Hi guys,
>>>
>>> I've been learning Django on a solo for a while now and I'm really in
>>> need of a Programmer friend/partner who we can always learn together, build
>>> projects together. This will really benefit both sides greatly.
>>> I am a person you'll really love to make friend with. Interested
>>> individuals should pls signify.
>>>
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/6d4ed94c-3864-4c5b-9f9e-5df7b6a77cdd%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/6d4ed94c-3864-4c5b-9f9e-5df7b6a77cdd%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
>> 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/CAMt%3DUZos%2BJoDMbNATWvG_xFV8n0y1kcu2%3DcLCYZEMH_O8HVGjw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMt%3DUZos%2BJoDMbNATWvG_xFV8n0y1kcu2%3DcLCYZEMH_O8HVGjw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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/CAG8BS_vx%2B9RjrXBv-9trZB8xe4pVWxKYekao_418sSGrde2E%3DQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG8BS_vx%2B9RjrXBv-9trZB8xe4pVWxKYekao_418sSGrde2E%3DQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
--
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/CACLQzsccmpWs3FkSLpKmfF4M5O2KsUEsvds-ns_kj7C-WnjNyw%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CACLQzsccmpWs3FkSLpKmfF4M5O2KsUEsvds-ns_kj7C-WnjNyw%40mail.gmail.com?utm_medium=email_source=footer>
.

-- 
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/CAP7OQq1%2B60hGw9noo3eHu0-8BmL%2BGKo3ayzHKvJOGEAu68XF9Q%40mail.gmail.com.


Re: Got an interview, need some idea for projects.

2020-01-24 Thread Jack Lin
Hi Motaz, Aditya, and all.

Won’t that be too easy? Thinking of something more complex like something
need to include a scraper.
But I’m not sure if that can be done In a week.

I think I will like to find a complex stocks article. No need to base on
programming, maybe just a simple theory that I can simulate I python and
put that an a website. What do you guys think?


在 2020年1月23日 於 下午8:25:46, Aditya Khatwa (adityakha...@gmail.com) 寫下:

Create a small website that shows your own portfolio such as your project
listing etc can be done in 3-5 days.
Add a form as well if you want.
Focus on the dynamic aspect rather than its aesthetic for a faster result...

On Thu, 23 Jan 2020, 12:41 Jack Lin,  wrote:

>
>
> Hi Django users, I'm Jack who currently learning Django everyday
> <http://afternoon-beach-38581.herokuapp.com/>
> My practice projects is little tiny function for now. however I got an
> interview yesterday which is an Django Web Developer in Stock Company.
> <https://www.cakeresume.com/companies/sinotrade-newweb/jobs/python-django-web-developer>
>
> The contact person told me that I should prepare a project to show my
> skills. It make me wonder should I do something bigger rather than practice
> some teeny- tiny function :(
> I got a few knowledge and a lot of interest in stock. But I got no ideas
> what can I do on a website?
>
> Any ideas?
>
>
> Sincerely Yours
> Jack Sanchez, who learn DjangoEveryDay
> <https://www.cakeresume.com/companies/sinotrade-newweb/jobs/python-django-web-developer>
> .
> --
> 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/cd6cd293-ed76-49ad-8e70-a0511088912c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cd6cd293-ed76-49ad-8e70-a0511088912c%40googlegroups.com?utm_medium=email_source=footer>
> .
>
--
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/CAOnqjLwUOJZsTHU_pQZwhP3V4CnQ1jmB1dtFXevKm6Le6edESw%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAOnqjLwUOJZsTHU_pQZwhP3V4CnQ1jmB1dtFXevKm6Le6edESw%40mail.gmail.com?utm_medium=email_source=footer>
.

-- 
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/CAP7OQq3n%2BMZ9gdOVJYzXpG0u-0zb_MPD2CoKHnXBw_hB1zG10A%40mail.gmail.com.


Got an interview, need some idea for projects.

2020-01-22 Thread Jack Lin


Hi Django users, I'm Jack who currently learning Django everyday 
<http://afternoon-beach-38581.herokuapp.com/>
My practice projects is little tiny function for now. however I got an 
interview yesterday which is an Django Web Developer in Stock Company. 
<https://www.cakeresume.com/companies/sinotrade-newweb/jobs/python-django-web-developer>

The contact person told me that I should prepare a project to show my 
skills. It make me wonder should I do something bigger rather than practice 
some teeny- tiny function :(
I got a few knowledge and a lot of interest in stock. But I got no ideas 
what can I do on a website?

Any ideas?


Sincerely Yours
Jack Sanchez, who learn DjangoEveryDay 
<https://www.cakeresume.com/companies/sinotrade-newweb/jobs/python-django-web-developer>
.

-- 
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/cd6cd293-ed76-49ad-8e70-a0511088912c%40googlegroups.com.


Re: DjangoEveryDay. My practice website!

2020-01-21 Thread Jack Lin
My Major is information and communication. Kind of Mass Communication but
we made our content more specific to internet world.
I’m not really sure what you mean in
“and importantly how you think contributes to a certain type — or even
workflow or stack — of learning in CS. “
"tying in what you know, how you behave," You mean like do some projects
for my own area?


在 2020年1月21日 於 上午12:47:09, Andrew C. (andreke12...@gmail.com) 寫下:

What is your major? Usually tying in what you know, how you behave, and
importantly how you think contributes to a certain type — or even workflow
or stack — of learning in CS.

On Mon, Jan 20, 2020 at 1:52 AM Jack Lin  wrote:

> I’m not sure what this gonna be in the future. I think I’m just exlpore
> the way.
> I may want to make this reusable for the newbie in the future and make the
> community better.
> Open to any ideas and contribution.
>
>
> 在 2020年1月20日 於 下午2:49:48, Jack Lin (tkic...@gmail.com) 寫下:
>
> Oh yes, this is all on Github. I’ll update the page to include GitHub link
> today! Thanks for reminding.
>
>
> 在 2020年1月20日 於 上午1:43:43, Balaji Shetty (balajishe...@gmail.com) 寫下:
>
> Great
>
> We follow you means ...
>
> Are you making code available on github to improve further..
>
> On Sunday, January 19, 2020, Jack Lin  wrote:
>
>> Hi everyone. I'm doing #DjangoEveryday Challenge to myself.
>> I set a goal for everyday and try to accomplish it. So I got practice and
>> progress everyday :)
>>
>> I'm doing this for preparation of my resume. I'm looking for Django Job
>> in Taiwan but CS is not my major.
>> I want to share this with you guys!
>>
>> btw, I do a bit of develop journal on my Linkedin, too. so if you are
>> interested on my progression, you can follow me on Linkedin!
>>
>> There is the website: Jack's Practice Zone
>> <https://afternoon-beach-38581.herokuapp.com>
>> and this is my Linkedin
>> <https://www.linkedin.com/in/jack-sanchez-677bb5168/> :)
>>
>> --
>> 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/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>
>
> --
> Mr Shetty Balaji
> Asst. Prof.
> IT Department
> SGGS I
> Nanded. My. India
>
> --
> 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/CAECSbOtnvBqGo24hmoA5%2BA56P%2BtZ5VU5OBaSQpHm8VsdRE4sbg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAECSbOtnvBqGo24hmoA5%2BA56P%2BtZ5VU5OBaSQpHm8VsdRE4sbg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> --
> 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/CAP7OQq0QTXBWSP7WoKahq1ezh2S2hH9Akk96OQQp-XD0pE1pfA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAP7OQq0QTXBWSP7WoKahq1ezh2S2hH9Akk96OQQp-XD0pE1pfA%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
--
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/CAJVmkN%3DxSRWJ6asFgzkn320Z4Hw30wUCU4D4VdkterLSHVSj%2Bg%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAJVmkN%3DxSRWJ6asFgzkn320Z4Hw30wUCU4D4VdkterLSHVSj%2Bg%40mail.gmail.com?utm_medium=email_source=footer>
.

-- 
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/CAP7OQq0k7V%3DrMktPeTGXPvii%3D3dNXvm3EYaTiGPeTf_4wrqq5w%40mail.gmail.com.


Re: DjangoEveryDay. My practice website!

2020-01-21 Thread Jack Lin
Actually DjangoEveryDay and Jack's Practice Zone is the same thing.
It is something like “Practice Django Every Day in Jack’s Practice Zone”
But the different name seems confuse. I’ll fix it.

在 2020年1月21日 於 上午1:16:03, maninder singh Kumar (maninder.s.ku...@gmail.com)
寫下:

Did you do Jack's Practice Zone is Django too ?


[image: --]

Maninder Kumar
[image: http://]about.me/maninder.s.kumar
<http://about.me/maninder.s.kumar?promo=email_sig>




On Sun, Jan 19, 2020 at 4:46 PM Jack Lin  wrote:

> Hi everyone. I'm doing #DjangoEveryday Challenge to myself.
> I set a goal for everyday and try to accomplish it. So I got practice and
> progress everyday :)
>
> I'm doing this for preparation of my resume. I'm looking for Django Job in
> Taiwan but CS is not my major.
> I want to share this with you guys!
>
> btw, I do a bit of develop journal on my Linkedin, too. so if you are
> interested on my progression, you can follow me on Linkedin!
>
> There is the website: Jack's Practice Zone
> <https://afternoon-beach-38581.herokuapp.com>
> and this is my Linkedin
> <https://www.linkedin.com/in/jack-sanchez-677bb5168/> :)
>
> --
> 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/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com?utm_medium=email_source=footer>
> .
>
--
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/CABOHK3TxoLAJ0CkZ5jig%3DeNio%3Da6gOTvM6_k%2BLX%2B3JGzRNNbAQ%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CABOHK3TxoLAJ0CkZ5jig%3DeNio%3Da6gOTvM6_k%2BLX%2B3JGzRNNbAQ%40mail.gmail.com?utm_medium=email_source=footer>
.

-- 
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/CAP7OQq1kWR9whsbn0uyY99EasgHUFmKRDjfqdrR%2BWsu2JADSaA%40mail.gmail.com.


Re: DjangoEveryDay. My practice website!

2020-01-19 Thread Jack Lin
I’m not sure what this gonna be in the future. I think I’m just exlpore the
way.
I may want to make this reusable for the newbie in the future and make the
community better.
Open to any ideas and contribution.


在 2020年1月20日 於 下午2:49:48, Jack Lin (tkic...@gmail.com) 寫下:

Oh yes, this is all on Github. I’ll update the page to include GitHub link
today! Thanks for reminding.


在 2020年1月20日 於 上午1:43:43, Balaji Shetty (balajishe...@gmail.com) 寫下:

Great

We follow you means ...

Are you making code available on github to improve further..

On Sunday, January 19, 2020, Jack Lin  wrote:

> Hi everyone. I'm doing #DjangoEveryday Challenge to myself.
> I set a goal for everyday and try to accomplish it. So I got practice and
> progress everyday :)
>
> I'm doing this for preparation of my resume. I'm looking for Django Job in
> Taiwan but CS is not my major.
> I want to share this with you guys!
>
> btw, I do a bit of develop journal on my Linkedin, too. so if you are
> interested on my progression, you can follow me on Linkedin!
>
> There is the website: Jack's Practice Zone
> <https://afternoon-beach-38581.herokuapp.com>
> and this is my Linkedin
> <https://www.linkedin.com/in/jack-sanchez-677bb5168/> :)
>
> --
> 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/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com?utm_medium=email_source=footer>
> .
>


--
Mr Shetty Balaji
Asst. Prof.
IT Department
SGGS I
Nanded. My. India

--
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/CAECSbOtnvBqGo24hmoA5%2BA56P%2BtZ5VU5OBaSQpHm8VsdRE4sbg%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAECSbOtnvBqGo24hmoA5%2BA56P%2BtZ5VU5OBaSQpHm8VsdRE4sbg%40mail.gmail.com?utm_medium=email_source=footer>
.

-- 
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/CAP7OQq0QTXBWSP7WoKahq1ezh2S2hH9Akk96OQQp-XD0pE1pfA%40mail.gmail.com.


Re: DjangoEveryDay. My practice website!

2020-01-19 Thread Jack Lin
Oh yes, this is all on Github. I’ll update the page to include GitHub link
today! Thanks for reminding.


在 2020年1月20日 於 上午1:43:43, Balaji Shetty (balajishe...@gmail.com) 寫下:

Great

We follow you means ...

Are you making code available on github to improve further..

On Sunday, January 19, 2020, Jack Lin  wrote:

> Hi everyone. I'm doing #DjangoEveryday Challenge to myself.
> I set a goal for everyday and try to accomplish it. So I got practice and
> progress everyday :)
>
> I'm doing this for preparation of my resume. I'm looking for Django Job in
> Taiwan but CS is not my major.
> I want to share this with you guys!
>
> btw, I do a bit of develop journal on my Linkedin, too. so if you are
> interested on my progression, you can follow me on Linkedin!
>
> There is the website: Jack's Practice Zone
> <https://afternoon-beach-38581.herokuapp.com>
> and this is my Linkedin
> <https://www.linkedin.com/in/jack-sanchez-677bb5168/> :)
>
> --
> 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/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com?utm_medium=email_source=footer>
> .
>


--
Mr Shetty Balaji
Asst. Prof.
IT Department
SGGS I
Nanded. My. India

--
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/CAECSbOtnvBqGo24hmoA5%2BA56P%2BtZ5VU5OBaSQpHm8VsdRE4sbg%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CAECSbOtnvBqGo24hmoA5%2BA56P%2BtZ5VU5OBaSQpHm8VsdRE4sbg%40mail.gmail.com?utm_medium=email_source=footer>
.

-- 
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/CAP7OQq0Zr8yWguarsbYZMDZjc-TUHO%3DuvvbBW23BnO3vs9fa6w%40mail.gmail.com.


DjangoEveryDay. My practice website!

2020-01-19 Thread Jack Lin
Hi everyone. I'm doing #DjangoEveryday Challenge to myself. 
I set a goal for everyday and try to accomplish it. So I got practice and 
progress everyday :)

I'm doing this for preparation of my resume. I'm looking for Django Job in 
Taiwan but CS is not my major.
I want to share this with you guys! 

btw, I do a bit of develop journal on my Linkedin, too. so if you are 
interested on my progression, you can follow me on Linkedin!

There is the website: Jack's Practice Zone 
<https://afternoon-beach-38581.herokuapp.com>
and this is my Linkedin 
<https://www.linkedin.com/in/jack-sanchez-677bb5168/> :)

-- 
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/fc2e047e-d362-4110-b6c5-9853402b0120%40googlegroups.com.


Re: How to create form to show user input and return results from DB

2020-01-04 Thread victor jack

Hi Nina , just read your write up 
For some form of clarification to your Confusion I’ll just answer the ones I 
can 

For the database , don’t make two different ones , one database with two tables 
2000 and 2010 will do just fine , just query then right. 

For the forms it is required to use POST cause it is more secure since you are 
POSTING form data ( which I feel is sensitive information)

I hope this helps , if I am free I might check out your github link 

>> On 4 Jan 2020, at 00:12, "nmaxbe...@gmail.com"  wrote:
> 
> Hi,
> 
> I am creating a website that lists my states congressional districts based on 
> the US census (i.e. 2000, 2010 and ultimately to update when the 2020 survey 
> is completed).  The entire exercise is to track how the representation could 
> possibly change based on the US census.
> 
> So far, I have a mock-up for two user inputs: one for 2000 and one for 2010 
> entering their zip codes on the homepage. The user is prompted to input their 
> zip code (for each census year) in order to see their representative for 2000 
> and 2010 (basically pulling from a db to show the results) and the results 
> show on the results page (new tab).
> 
> My confusion: 
> Should I combine the DB's to "respond" to the users input or keep DB's (2000, 
> 2010) separate?
> I understand how to create models and I understand how to create views, but I 
> am confused on creating the form (specifically "GET" vs "POST".
> Is POST what the user inputs? If so, how do I "search through the existing 
> DB"?
> I have reviewed the form docs within Django but still am lost.  Please help.
> As you suspected, I am new to Django but want to "get over this hump".  I 
> feel I am reaching too far and the answer is in front of my face.  My github 
> is: https://github.com/NinaMaxberry/Cornerstone-Project. Once you visit, you 
> will see, I've tried a lot of options.
> 
> Any help would be greatly appreciated.
> 
> 
> -- 
> 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/5f1995c7-6e6c-4147-b53b-10373c7b4b31%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/751A25AC-EF77-4519-97D0-A55CC94FDCAD%40gmail.com.


Re: FieldError at / Django models how to reslove this issue....

2019-12-19 Thread Jack Lin
FYI, you can check this documentation
<https://docs.djangoproject.com/en/3.0/topics/db/queries/#field-lookups-intro>
for
double underscore in Django.

-- 
Jack Lin

在 2019年12月20日 於 上午1:28:29, Simon Charette (charett...@gmail.com) 寫下:

You are missing an underscore here.

It should be published_date__lte and not published_date_lte.

Cheers,
Simon

Le jeudi 19 décembre 2019 11:40:05 UTC-5, MEGA NATHAN a écrit :
>
> Hi all.
>
> Cannot resolve keyword 'published_date_lte' into field. Choices are: author, 
> author_id, comments, create_date, id, published_date, text, title
>
>
>
> this are models:
> from django.db import models
> from django.utils import timezone
> from django.urls import reverse
>
> # Create your models here.
>
> class Post(models.Model):
> author = models.ForeignKey('auth.User', on_delete=models.CASCADE,)
> title = models.CharField(max_length=200)
> text = models.TextField()
> create_date = models.DateTimeField(default=timezone.now())
> published_date = models.DateTimeField(blank=True, null=True)
>
> def publish(self):
> self.published_date = timezone.now()
> self.save()
>
> #def approve_comments(self):
> #return self.comments.filter(approved_comments=True)
>
> def approved_comments(self):
> return self.comments.filter(approved_comment=True)
>
> #def get_absolute_url(self):
> #return reverse("post_detail", kwargs={"pk": self.pk})
>
> def __str__self():
> return self.title
>
> class Comment(models.Model):
> post = models.ForeignKey('blog.post',related_name='comments'
> , on_delete=models.CASCADE,)
> title = models.CharField(max_length=200)
> text = models.TextField()
> create_date = models.DateTimeField(default=timezone.now())
> published_date = models.DateTimeField(blank=True, null=True)
> approved_comment = models.BooleanField(default=False)
>
> def approve(self):
> self.approved_comment = True
> self.save()
>
> def get_absolute_url(self):
> return reverse('post_list')
>
> def __str__(self):
> return self.text
>
> And views:
>
> from django.shortcuts import render, get_object_or_404, redirect
> from django.utils import timezone
> #from django.utils.timezone.now`
> from blog.models import Post, Comment
> from .forms import PostForm,CommentForm
> from django.urls import reverse_lazy
> from django.contrib.auth.decorators import login_required
> from django.contrib.auth.mixins import LoginRequiredMixin
> from django.views.generic import (TemplateView, ListView,
> DetailView, CreateView,
> UpdateView, DeleteView)
>
> # Create your views here.
>
> class Aboutview(TemplateView):
> template_name = 'about.html'
>
> class PostListView(ListView):
> model = Post
>
> def get_queryset(self):
> return Post.objects.filter(published_date_lte=
> timezone.now()).order_by('-published_date')
>
> class PostDetailView(DetailView):
> model = Post
>
> class CreatePostView(LoginRequiredMixin,CreateView):
> Login_url = '/Login/'
> redirect_field_name = 'blog/post_detail.html'
> from_class = PostForm
> model = Post
>
> class PostUpdateView(LoginRequiredMixin, UpdateView):
> Login_url = '/Login/'
> redirect_field_name = 'blog/post_detail.html'
> from_class = PostForm
> model = Post
>
> #class PostDeleteView(loginrequiredMixin, DeleteView):
> class PostDeleteView(LoginRequiredMixin,DeleteView):
> model = Post
> success_url = reverse_lazy('post_list')
>
> class DraftListView(LoginRequiredMixin, ListView):
> login_url = '/Login/'
> redirect_field_name = 'blog/post_list.html'
> model = Post
>
> def get__queryset(self):
> return Post.objects.filter(published_date_isnull=True).order_by(
> 'created_date')
>
>
> #
> ##
> def add_comment_to_post(request, pk):
> post = get_object_or_404(Post, pk=pk)
> if request.method == "POST":
> form = CommentForm(request.POST)
> if form.is_valid():
> comment = form.save(commit=False)
> comment.post = post
> comment.save()
> return redirect('post_detail', pk=post.pk)
> else:
> form = CommentForm()
> return render(request, 'blog/comment_form.html', {'form': form})
>
> @login_required
> def post_publish(request, pk):
> post = get_object_or_404(Post, pk=pk)
> post.publish
> return redirect('blog/post_detail.html', pk=pk)
>
> #@login_

Greeting, introduce myself & wondering if one read all documentation.

2019-12-17 Thread Jack Lin
Hi all. I'm a new self-taught developer. Just decided to make backend 
development especially Django to be my full time career. 
I'm new to programming.. at least i just create my own ugly website and 
never involve in big projects or open-sources. I read a lot of tutorial and 
got the basic ideas through year but i didn't really acquire the ability of 
programming. I think I just don't spend enough time and always switching 
from field to field. I learn RoR, python, C, Unity, Security yeah, I 
know. too much and too naive. 

I know my passion is to create tools that utilize life and analyzing. 
ok, enough self introducing. 


I'm going through   
from 37 signals recently and starting to read Django's documentation.
The details in the documentation makes me exciting and happy. so i think 
i'm okay to read through it all.
However, I'll like some share of experience which is any one go through the 
whole documentation before?
does it change you or improve your skills in significant way? not limited 
in Django. if anyone used to read all the basic and have some thought, may 
you share that with me :)?

-- 
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/a7d703e7-9d57-40f5-b464-31b1167a4534%40googlegroups.com.


Serving non-referenced static files

2019-10-29 Thread Jack Sundberg
Hello again, 

I could use some help on loading static files in development mode. 
Specifically, I'd like to tell Django to serve additional files that are 
not explicitly loaded in the html with {% load static %}. My issue is 
actually identical to this post 
<https://groups.google.com/forum/#!searchin/django-users/js$20files%7Csort:date/django-users/FEO0gy37dRw/WeU8GdK4DAAJ>,
 
where I could use some extra explanation on their suggested fix. To restate 
the issue, I load a static javascript file within my myapp/index.html:

{% load static %}
 

The javascript file (myscript_1.js) references another javascript file 
(myscript_2.js) as well as some other media (e.g. a number of *.png, *.css, 
*.json files). However, Django doesn't serve these files because they are 
not directly loaded in the html, and a 404 error is thrown when trying to 
find myscript_2.js - along with the other files. How do I get Django to 
serve these files as well? 

It looks like Django is searching for the files 
at http://127.0.0.1:8000/myapp/myscript_2.js. Could I forward this path to 
http://127.0.0.1:8000/static/myapp/myscript_2.js? I'm trying to do this 
with the following in my urls.py (in projects urls.py - not the myapp 
urls.py):

from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(path=settings.STATIC_URL, document_root=settings.
STATIC_ROOT)

and in my settings.py:

STATIC_ROOT =  os.path.join(BASE_DIR, 'static')
STATIC_URL = /static/

This isn't working for me though, and I think I'm using the static() 
function incorrectly. Could someone offer some guidance on how to set this 
up for development testing?

Thanks in advance,
Jack


-- 
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/9de51c2c-4dca-454a-8057-db9c0e8c8b37%40googlegroups.com.


Re: Complete book

2019-10-22 Thread victor jack
Thanks a lot for sharing 

> On 19 Oct 2019, at 15:09, ISAAC NELSON S.B. KARGBO  
> wrote:
> 
> 
> Try this one out
> 
>> On Sat, Oct 19, 2019, 13:47 Md Nayem Tushar  wrote:
>> Have any easy and properly complete book in django? pls ans me
>> -- 
>> 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/b523ac3b-9aad-4c1b-a4f9-d9310b6f69da%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/CAA4EwCsFAkvbZ99z5aT9jX-R849Gkxg%3DTbSaSRvE-qUShgOL6w%40mail.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/E13DDDE6-5FEA-413A-B3AF-97BE709454C9%40gmail.com.


Re: Creating an app that generates static files

2019-10-18 Thread Jack Sundberg
Thank you both! This helps a ton.


On Friday, October 18, 2019 at 5:02:40 AM UTC-4, vineet daniel wrote:
>
> and use ssd for maximum I/O as youd creating and deleting files a lot, 
> move session from db to something like redis and python has concurrency 
> libraries make use of them as well.
>
> On Fri, 18 Oct 2019, 14:29 vineet daniel,  > wrote:
>
>> Dont forget inode and files limit if you are creating too many files real 
>> quickly. 
>>
>> On Fri, 18 Oct 2019, 13:15 James Gutu, > 
>> wrote:
>>
>>> Jack,
>>> That sounds about right.
>>>
>>> On Thu, Oct 17, 2019 at 11:22 PM Jack Sundberg >> > wrote:
>>>
>>>> Thank you, James! This seems like a good fix. From reading through the 
>>>> documentation (here 
>>>> <https://docs.djangoproject.com/en/2.2/topics/http/sessions/>), this 
>>>> is how I understand the workflow -- so correct me if I'm wrong please!
>>>>
>>>>  > First, I can activate Django sessions by 
>>>> adding 'django.contrib.sessions' to my installed apps. 
>>>>  > Django by-default stores session info in the SQLite database -- 
>>>> therefore, each session entry will have an ID assigned to it 
>>>> automatically. 
>>>>  > I can use each session_id to create a temporary folder in some 
>>>> directory (say /tmp) where the generated files can be made. So folder 
>>>> structure will look like:
>>>> tmp/
>>>> [session_id1]/ 
>>>> file1.tlgf
>>>> file2.bin
>>>> [session_id2]/ 
>>>> file1.tlgf
>>>> file2.bin
>>>> 
>>>>  > when sessions data hits a certain threshold, I can call 
>>>> django.contrib.sessions.clearsessions which will delete expired session 
>>>> entries in the database
>>>>  > pull out which entries were deleted and then delete the 
>>>> corresponding tmp/[session_id] directory 
>>>>
>>>> Is that the best way to do it?
>>>>
>>>> -Jack
>>>>
>>>>
>>>> On Thursday, October 17, 2019 at 4:42:04 PM UTC-4, James Gutu wrote:
>>>>>
>>>>> Jack,
>>>>>
>>>>> From what I understand it looks like a conflict of uniquely named 
>>>>> files when they are generated simultaneously.
>>>>> Could you resolve this by creating a folder named from the session_id, 
>>>>> with the file inside of that. So that if two users request the same file, 
>>>>> there will never be a conflict, as the unique file will be created in 
>>>>> both 
>>>>> folders.
>>>>>
>>>>> [user_1_session_id]/entry123.jpeg
>>>>> [user_2_session_id]/entry123.jpeg
>>>>>
>>>>> Though, this might seem like a fix, but the issue may be more 
>>>>> fundamental than file names.
>>>>> Let me know what you think.
>>>>>
>>>>> Regards,
>>>>> James
>>>>>
>>>>> On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg  
>>>>> wrote:
>>>>>
>>>>>> Yes, I tried getting the idea across in layman terms, as I hope this 
>>>>>> helps discussion of the issue -- and then I can later translate the 
>>>>>> solution into django implementation. 
>>>>>>
>>>>>> I avoided the full process in my original post for clarity. I used 
>>>>>> the *.jpeg file as an illustrative example, when I'm actually generating 
>>>>>> *.gltf and *.bin files. These files are typically a couple hundred KB in 
>>>>>> size, but I will have thousands of them (millions as I add to my 
>>>>>> database). 
>>>>>> These files are used in coordination with Verge3D  - an app built on top 
>>>>>> of 
>>>>>> Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which 
>>>>>> is 
>>>>>> a python-based program that my scripts are written in. Running of these 
>>>>>> scripts are certainly cpu intensive; however I am going to get around 
>>>>>> this 
>>>>>> by using an  of this Verge3D request.
>>>>>>
>>>>>> So to be more specific, my app does t

Re: Creating an app that generates static files

2019-10-17 Thread Jack Sundberg
Thank you, James! This seems like a good fix. From reading through the 
documentation (here 
<https://docs.djangoproject.com/en/2.2/topics/http/sessions/>), this is how 
I understand the workflow -- so correct me if I'm wrong please!

 > First, I can activate Django sessions by 
adding 'django.contrib.sessions' to my installed apps. 
 > Django by-default stores session info in the SQLite database -- 
therefore, each session entry will have an ID assigned to it automatically. 
 > I can use each session_id to create a temporary folder in some directory 
(say /tmp) where the generated files can be made. So folder structure will 
look like:
tmp/
[session_id1]/ 
file1.tlgf
file2.bin
[session_id2]/ 
file1.tlgf
file2.bin

 > when sessions data hits a certain threshold, I can call 
django.contrib.sessions.clearsessions which will delete expired session 
entries in the database
 > pull out which entries were deleted and then delete the corresponding 
tmp/[session_id] directory 

Is that the best way to do it?

-Jack


On Thursday, October 17, 2019 at 4:42:04 PM UTC-4, James Gutu wrote:
>
> Jack,
>
> From what I understand it looks like a conflict of uniquely named files 
> when they are generated simultaneously.
> Could you resolve this by creating a folder named from the session_id, 
> with the file inside of that. So that if two users request the same file, 
> there will never be a conflict, as the unique file will be created in both 
> folders.
>
> [user_1_session_id]/entry123.jpeg
> [user_2_session_id]/entry123.jpeg
>
> Though, this might seem like a fix, but the issue may be more fundamental 
> than file names.
> Let me know what you think.
>
> Regards,
> James
>
> On Thu, Oct 17, 2019 at 4:23 PM Jack Sundberg  > wrote:
>
>> Yes, I tried getting the idea across in layman terms, as I hope this 
>> helps discussion of the issue -- and then I can later translate the 
>> solution into django implementation. 
>>
>> I avoided the full process in my original post for clarity. I used the 
>> *.jpeg file as an illustrative example, when I'm actually generating *.gltf 
>> and *.bin files. These files are typically a couple hundred KB in size, but 
>> I will have thousands of them (millions as I add to my database). These 
>> files are used in coordination with Verge3D  - an app built on top of 
>> Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which is 
>> a python-based program that my scripts are written in. Running of these 
>> scripts are certainly cpu intensive; however I am going to get around this 
>> by using an  of this Verge3D request.
>>
>> So to be more specific, my app does the following:
>>  - the url mapping pulls a database entry
>>  - the app serves the proper html template with an  embedded in 
>> it. It displays a loading screen while the 3D model is created backend.
>>  - the  calls a separate app using the identical data entry
>>  - using the data entry, static files are created from the data (Blender 
>> script creates a *.gltf and *.bin)
>>  - the app serves the html template with the generated static files 
>> embedded inside the 
>>
>> Is this helpful? Also thank you for the quick response. I really 
>> appreciate the help.
>>
>> -Jack
>>
>>
>> On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel wrote:
>>>
>>> This problem can happen with any stack and shouldn't be considered as 
>>> django specific. What you are looking for is a solution in a layman 
>>> terms.which then can be translated to django implementation.
>>>
>>> Before that i would like to know image size and kind of image that you 
>>> create. Is it some qr code or what?
>>>
>>> Please note that working with images on the fly is always a cpu 
>>> intensive operation. Ill can come up with something once you share the 
>>> details with me.
>>>
>>> On Thu, 17 Oct 2019, 20:00 Jack Sundberg,  wrote:
>>>
>>>> Hi all,
>>>>
>>>> I am currently writing an app that generates static files before 
>>>> serving them, and I could use some input! Here's a step-by-step example of 
>>>> how the app is setup:
>>>>
>>>>  - the url mapping pulls a database entry
>>>>  - using the data entry, static files are created from the data (for 
>>>> example, a *.jpeg or a *.gltf)
>>>>  - the app serves the html template with the generated static files 
>>>

Re: Creating an app that generates static files

2019-10-17 Thread Jack Sundberg
Yes, I tried getting the idea across in layman terms, as I hope this helps 
discussion of the issue -- and then I can later translate the solution into 
django implementation. 

I avoided the full process in my original post for clarity. I used the 
*.jpeg file as an illustrative example, when I'm actually generating *.gltf 
and *.bin files. These files are typically a couple hundred KB in size, but 
I will have thousands of them (millions as I add to my database). These 
files are used in coordination with Verge3D  - an app built on top of 
Three.js for 3D rendering. Verge3D allows use of Blender for CAD, which is 
a python-based program that my scripts are written in. Running of these 
scripts are certainly cpu intensive; however I am going to get around this 
by using an  of this Verge3D request.

So to be more specific, my app does the following:
 - the url mapping pulls a database entry
 - the app serves the proper html template with an  embedded in it. 
It displays a loading screen while the 3D model is created backend.
 - the  calls a separate app using the identical data entry
 - using the data entry, static files are created from the data (Blender 
script creates a *.gltf and *.bin)
 - the app serves the html template with the generated static files 
embedded inside the 

Is this helpful? Also thank you for the quick response. I really appreciate 
the help.

-Jack


On Thursday, October 17, 2019 at 10:56:56 AM UTC-4, vineet daniel wrote:
>
> This problem can happen with any stack and shouldn't be considered as 
> django specific. What you are looking for is a solution in a layman 
> terms.which then can be translated to django implementation.
>
> Before that i would like to know image size and kind of image that you 
> create. Is it some qr code or what?
>
> Please note that working with images on the fly is always a cpu intensive 
> operation. Ill can come up with something once you share the details with 
> me.
>
> On Thu, 17 Oct 2019, 20:00 Jack Sundberg,  > wrote:
>
>> Hi all,
>>
>> I am currently writing an app that generates static files before serving 
>> them, and I could use some input! Here's a step-by-step example of how the 
>> app is setup:
>>
>>  - the url mapping pulls a database entry
>>  - using the data entry, static files are created from the data (for 
>> example, a *.jpeg or a *.gltf)
>>  - the app serves the html template with the generated static files 
>> embedded (for example, via an  tag)
>>
>> The issue comes with the creation of the unique static files. I can have 
>> the app create a file in the static folder, send it off, then delete the 
>> file to ready for the next request -- but the webpage will run into issues 
>> if multiple requests are made at the same time. If two people request the 
>> same url at the same time, the app will fail because both requests are 
>> trying to create/serve/delete an identical file (i.e. entry123.jpeg) at the 
>> same time. Trying to mess with the filename to avoid this won't work here 
>> either (i.e. naming entry123.01.jpeg, entry123.02.jpeg, entry123.03.jpeg, 
>> ...).
>>
>> I can think of two solutions, but they both are things I'd like to avoid:
>>  1. have the files premade and stored -- I want to avoid this because of 
>> the massive filesize required for all these files
>>  2. have the static files generated in a user-specific directory -- I 
>> want to avoid this because I'd rather not have registered users on my 
>> website
>>
>> Is there another solution to this? I'm still relatively new with Django, 
>> so there might be something simple I'm missing.
>>
>> -Jack
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/190637d2-bd9b-499a-a122-1dc7adf2aca5%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/190637d2-bd9b-499a-a122-1dc7adf2aca5%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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/317c4ce6-5378-4e59-920e-c0fdcacd453a%40googlegroups.com.


Creating an app that generates static files

2019-10-17 Thread Jack Sundberg
Hi all,

I am currently writing an app that generates static files before serving 
them, and I could use some input! Here's a step-by-step example of how the 
app is setup:

 - the url mapping pulls a database entry
 - using the data entry, static files are created from the data (for 
example, a *.jpeg or a *.gltf)
 - the app serves the html template with the generated static files 
embedded (for example, via an  tag)

The issue comes with the creation of the unique static files. I can have 
the app create a file in the static folder, send it off, then delete the 
file to ready for the next request -- but the webpage will run into issues 
if multiple requests are made at the same time. If two people request the 
same url at the same time, the app will fail because both requests are 
trying to create/serve/delete an identical file (i.e. entry123.jpeg) at the 
same time. Trying to mess with the filename to avoid this won't work here 
either (i.e. naming entry123.01.jpeg, entry123.02.jpeg, entry123.03.jpeg, 
...).

I can think of two solutions, but they both are things I'd like to avoid:
 1. have the files premade and stored -- I want to avoid this because of 
the massive filesize required for all these files
 2. have the static files generated in a user-specific directory -- I want 
to avoid this because I'd rather not have registered users on my website

Is there another solution to this? I'm still relatively new with Django, so 
there might be something simple I'm missing.

-Jack

-- 
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/190637d2-bd9b-499a-a122-1dc7adf2aca5%40googlegroups.com.


python manage.py runserver error

2019-07-13 Thread Jack Bergemann
(venv) C:\Users\Chas\rp-portfolio\personal_portfolio>python manage.py 
runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
  File "C:\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 54, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
 
line 109, in inner_run
autoreload.raise_last_exception()
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 77, in raise_last_exception
raise _exception[1]
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\__init__.py",
 
line 337, in execute
autoreload.check_errors(django.setup)()
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 54, in wrapper
fn(*args, **kwargs)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\__init__.py", 
line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\apps\registry.py", 
line 91, in populate
app_config = AppConfig.create(entry)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\apps\config.py", 
line 90, in create
module = import_module(entry)
  File "C:\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'hello_world'

Traceback (most recent call last):
  File "manage.py", line 21, in 
main()
  File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\__init__.py",
 
line 381, in execute_from_command_line
utility.execute()
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\__init__.py",
 
line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\base.py",
 
line 323, in run_from_argv
self.execute(*args, **cmd_options)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
 
line 60, in execute
super().execute(*args, **options)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\base.py",
 
line 364, in execute
output = self.handle(*args, **options)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
 
line 95, in handle
self.run(**options)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\core\management\commands\runserver.py",
 
line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 587, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 572, in start_django
reloader.run(django_main_thread)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 290, in run
self.run_loop()
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 296, in run_loop
next(ticker)
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 336, in tick
for filepath, mtime in self.snapshot_files():
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 352, in snapshot_files
for file in self.watched_files():
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 251, in watched_files
yield from iter_all_python_module_files()
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
  File 
"C:\Users\Chas\rp-portfolio\venv\lib\site-packages\django\utils\autoreload.py", 
line 138, in iter_modules_and_files
if not path.exists():
  File "C:\Python37\lib\pathlib.py", line 1346, in exists
self.stat()
  File "C:\Python37\lib\pathlib.py", line 1168, in stat
return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label 
syntax is incorrect: ''

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop 

I need adding records within another model

2019-03-13 Thread Jack Gonzales
Hi everyone, i have two classes in my model.py, this system is for 
registering the payments of an account, for instance, a client is lent 1000 
dollars and that account has an ID, each loan has an ID and what i want is 
when the client makes the payment of his fees i can register each ammount 
and that every payment is linked with the ID of the account, 1000 dollars 
could be 10 payments of 100 dollars and that 10 records are linked to that 
account and the same for all loans, every loan with its records of payment. 
I hope that you've could understand and help me.
 

## THIS IS THE MODEL OF LOANS DATA WHERE THE DATA OF LOAN IS STORED.

class LoansData(models.Model):
"""
Profile model.

Proxy model that extend the base data
with other informarion.
"""

customer   = models.ForeignKey(CustomerData, 
on_delete=models.CASCADE)
ammount= models.PositiveIntegerField(default=0)
interest   = models.DecimalField(max_digits=3, decimal_places=2)
total  = models.PositiveIntegerField(editable=False)

uid   = models.CharField('UUID', max_length=5, help_text='5 
characters', blank=True)

created= models.DateField(auto_now_add=True)
modified   = models.DateTimeField(auto_now=True)

def save(self, *args, **kwargs):
self.total = self.ammount + (self.ammount*self.interest)
super(LoansData, self).save(*args, **kwargs)



class Meta:
verbose_name = 'Loan Data'
verbose_name_plural = 'Loans Data'

def __str__(self):
""" Return username """

return str(self.pk)   






#THIS IS WHAT I CREATED FOR ADDING THE RECORDS OF EVERY PAYMENT THE CLIENT 
MAKES TO ITS RESPECTIVE ACCOUNT OF LOAN. BUT IF IT'S NECESSARY CHANGE THIS IT 
DOESN'T MATTER.


class LoanInstance(models.Model):

"""
This represents the status up to date of loan
"""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, 
help_text="Uniquie ID for every single payment." )
loan = models.ForeignKey('LoansData', on_delete=models.CASCADE, null=True)
date = models.DateField(auto_now_add=True)
ammount = models.PositiveIntegerField(default=0)

def __str__(self):
""" Return id """
return '%s' % (self.id)




###333


I REALLY HOPE THAT YOU CAN HELP ME PLEASE. I'M STUCK WITH THIS.


-- 
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/4f32f051-3770-493b-b9f5-e42843e88381%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /catalog/author/1

2018-10-09 Thread victor jack
Manjunath thanks i have fixed the bug in my code , the problem was in the
author_detail page. THanks so much for your time , i really appreciate your
help
On Tue, Oct 9, 2018 at 9:40 AM Manjunath  wrote:

> No issues.
> So, is the issue resolved now?
>
> On Tuesday, October 9, 2018 at 10:51:13 AM UTC+5:30, victor jack wrote:
>>
>> Will check it out . Thanks for your input very much appreciated
>>
>> On Tue, 9 Oct 2018 6:17 AM Manjunath,  wrote:
>>
>>> Hi Victor,
>>> Are you sure book.author.pk has value?
>>> can you send the model definition of Book & Author to verify?
>>> Or you can verify yourself by using django Shell.
>>>
>>>
>>> On Tuesday, October 9, 2018 at 12:52:28 AM UTC+5:30, victor jack wrote:
>>>>
>>>>
>>>> Thanks Manjunath, i will post two screen shots of the templates
>>>> On Saturday, October 6, 2018 at 7:25:50 AM UTC+1, Manjunath wrote:
>>>>>
>>>>> Seems like you are not passing the argument along with the url.
>>>>> Please share your template file to verify.
>>>>>
>>>>> On Saturday, October 6, 2018 at 7:06:08 AM UTC+5:30, victor jack wrote:
>>>>>>
>>>>>> Hello guys, i am in dire need of any django user's knowledge, i have
>>>>>> this issue that has been bugging me literally in my codebase. I want to
>>>>>> render a html page but the error keeps on coming, i have tried but to no
>>>>>> avail, ['catalog\\/author/(?P\\d+)$'] - this regex keeps
>>>>>> throwing me off please guys i need your assistance. Attached are the
>>>>>> screenshots . 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/a619bb69-b9be-481b-8731-51f9b920c817%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/a619bb69-b9be-481b-8731-51f9b920c817%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/8b5f8e90-5ecb-4593-915e-e495e998760a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8b5f8e90-5ecb-4593-915e-e495e998760a%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/CABkm6MWJzMANM0xZEgMkLOVA76_yQFD%2BDf4PJDpSZ0%3DKccNQ4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /catalog/author/1

2018-10-08 Thread victor jack
Your application'software URL  is not mapped correctly , from the error
page it is only the admin that can be loaded .

On Tue, 9 Oct 2018 6:40 AM Pradeep Singh,  wrote:

>
>
> On Mon, 8 Oct 2018 at 22:30, victor jack  wrote:
>
>> screenshot of the error message Singh will be helpful
>>
>> On Tue, 9 Oct 2018 6:24 AM Pradeep Singh,  wrote:
>>
>>> i am using python 3.7+django 2.0
>>>
>>> On Tue, 9 Oct 2018 at 10:52, Pradeep Singh 
>>> wrote:
>>>
>>>> what is wrong with my...code...and setting please tell me
>>>>
>>>> On Tue, 9 Oct 2018 at 10:52, Pradeep Singh 
>>>> wrote:
>>>>
>>>>> please help me ...i am always getting django 404 error .how to fix
>>>>> it
>>>>>
>>>>> On Mon, 8 Oct 2018 at 22:17, Manjunath 
>>>>> wrote:
>>>>>
>>>>>> Hi Victor,
>>>>>> Are you sure book.author.pk has value?
>>>>>> can you send the model definition of Book & Author to verify?
>>>>>> Or you can verify yourself by using django Shell.
>>>>>>
>>>>>>
>>>>>> On Tuesday, October 9, 2018 at 12:52:28 AM UTC+5:30, victor jack
>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>> Thanks Manjunath, i will post two screen shots of the templates
>>>>>>> On Saturday, October 6, 2018 at 7:25:50 AM UTC+1, Manjunath wrote:
>>>>>>>>
>>>>>>>> Seems like you are not passing the argument along with the url.
>>>>>>>> Please share your template file to verify.
>>>>>>>>
>>>>>>>> On Saturday, October 6, 2018 at 7:06:08 AM UTC+5:30, victor jack
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Hello guys, i am in dire need of any django user's knowledge, i
>>>>>>>>> have this issue that has been bugging me literally in my codebase. I 
>>>>>>>>> want
>>>>>>>>> to render a html page but the error keeps on coming, i have tried but 
>>>>>>>>> to no
>>>>>>>>> avail, ['catalog\\/author/(?P\\d+)$'] - this regex keeps
>>>>>>>>> throwing me off please guys i need your assistance. Attached are
>>>>>>>>> the screenshots . 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/a619bb69-b9be-481b-8731-51f9b920c817%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/django-users/a619bb69-b9be-481b-8731-51f9b920c817%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/CANwgZcaRK6uCOy0QPRWe%3DgNeo%3DaLcyTRx2U7adixe-mB5Xof1g%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CANwgZcaRK6uCOy0QPRWe%3DgNeo%3DaLcyTRx2U7adixe-mB5Xof1g%40mail.gmail.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+uns

Re: NoReverseMatch at /catalog/author/1

2018-10-08 Thread victor jack
screenshot of the error message Singh will be helpful

On Tue, 9 Oct 2018 6:24 AM Pradeep Singh,  wrote:

> i am using python 3.7+django 2.0
>
> On Tue, 9 Oct 2018 at 10:52, Pradeep Singh  wrote:
>
>> what is wrong with my...code...and setting please tell me
>>
>> On Tue, 9 Oct 2018 at 10:52, Pradeep Singh  wrote:
>>
>>> please help me ...i am always getting django 404 error .how to fix it
>>>
>>> On Mon, 8 Oct 2018 at 22:17, Manjunath  wrote:
>>>
>>>> Hi Victor,
>>>> Are you sure book.author.pk has value?
>>>> can you send the model definition of Book & Author to verify?
>>>> Or you can verify yourself by using django Shell.
>>>>
>>>>
>>>> On Tuesday, October 9, 2018 at 12:52:28 AM UTC+5:30, victor jack wrote:
>>>>>
>>>>>
>>>>> Thanks Manjunath, i will post two screen shots of the templates
>>>>> On Saturday, October 6, 2018 at 7:25:50 AM UTC+1, Manjunath wrote:
>>>>>>
>>>>>> Seems like you are not passing the argument along with the url.
>>>>>> Please share your template file to verify.
>>>>>>
>>>>>> On Saturday, October 6, 2018 at 7:06:08 AM UTC+5:30, victor jack
>>>>>> wrote:
>>>>>>>
>>>>>>> Hello guys, i am in dire need of any django user's knowledge, i have
>>>>>>> this issue that has been bugging me literally in my codebase. I want to
>>>>>>> render a html page but the error keeps on coming, i have tried but to no
>>>>>>> avail, ['catalog\\/author/(?P\\d+)$'] - this regex keeps
>>>>>>> throwing me off please guys i need your assistance. Attached are
>>>>>>> the screenshots . 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/a619bb69-b9be-481b-8731-51f9b920c817%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/a619bb69-b9be-481b-8731-51f9b920c817%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/CANwgZcaRK6uCOy0QPRWe%3DgNeo%3DaLcyTRx2U7adixe-mB5Xof1g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CANwgZcaRK6uCOy0QPRWe%3DgNeo%3DaLcyTRx2U7adixe-mB5Xof1g%40mail.gmail.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/CABkm6MVqrT9tydRX6ndJf2xk_AMMTBqvqvjYn3yqAiRTHaWPjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /catalog/author/1

2018-10-08 Thread victor jack
Will check it out . Thanks for your input very much appreciated

On Tue, 9 Oct 2018 6:17 AM Manjunath,  wrote:

> Hi Victor,
> Are you sure book.author.pk has value?
> can you send the model definition of Book & Author to verify?
> Or you can verify yourself by using django Shell.
>
>
> On Tuesday, October 9, 2018 at 12:52:28 AM UTC+5:30, victor jack wrote:
>>
>>
>> Thanks Manjunath, i will post two screen shots of the templates
>> On Saturday, October 6, 2018 at 7:25:50 AM UTC+1, Manjunath wrote:
>>>
>>> Seems like you are not passing the argument along with the url.
>>> Please share your template file to verify.
>>>
>>> On Saturday, October 6, 2018 at 7:06:08 AM UTC+5:30, victor jack wrote:
>>>>
>>>> Hello guys, i am in dire need of any django user's knowledge, i have
>>>> this issue that has been bugging me literally in my codebase. I want to
>>>> render a html page but the error keeps on coming, i have tried but to no
>>>> avail, ['catalog\\/author/(?P\\d+)$'] - this regex keeps throwing
>>>> me off please guys i need your assistance. Attached are the
>>>> screenshots . 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/a619bb69-b9be-481b-8731-51f9b920c817%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a619bb69-b9be-481b-8731-51f9b920c817%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/CABkm6MVhDKdF9AY010WYV_WhfrD96Cakw_6Q37gdQe_s4sdvMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch at /catalog/author/1

2018-10-08 Thread victor jack

Thanks Manjunath, i will post two screen shots of the templates 
On Saturday, October 6, 2018 at 7:25:50 AM UTC+1, Manjunath wrote:
>
> Seems like you are not passing the argument along with the url.
> Please share your template file to verify.
>
> On Saturday, October 6, 2018 at 7:06:08 AM UTC+5:30, victor jack wrote:
>>
>> Hello guys, i am in dire need of any django user's knowledge, i have this 
>> issue that has been bugging me literally in my codebase. I want to render a 
>> html page but the error keeps on coming, i have tried but to no avail, 
>> ['catalog\\/author/(?P\\d+)$'] 
>> - this regex keeps throwing me off please guys i need your assistance. 
>> Attached are the screenshots . 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/3b890b8c-5bb3-4d5f-9603-4bacc3bba790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can i modify the base_site.html Template?

2018-09-04 Thread victor jack
*Ok i see, you create an admin folder in your template folder then create a
base_site.html and an index. html file , these file will contain your
custom feature ,then when you runserver the new admin site will be rendered
from there(admin ) folder. I hope this helps.*
On Mon, Sep 3, 2018 at 7:58 PM  wrote:

> Yes, that exactly
>
> --
> 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/9eaec872-a629-4b70-994d-2b6d2b3c942c%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/CABkm6MXKVH-AXoSGwSW3RjMc-ywTBrqGink%3Dd%3D6pAYLY9G-2vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can i modify the base_site.html Template?

2018-09-03 Thread victor jack
Do u want to customise  the admin page to be different  from the default
 one django  provides?


On Mon, 3 Sep 2018 8:04 AM ,  wrote:

> Hello, i want to change de title and the default text in the header of the
> Django-Admin site but i don´t know do that.
>
> --
> 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/51312f80-3d0c-417a-b36e-d42b397fa5f1%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/CABkm6MVsBM8KO0-TBLqam%2Br8sjnwTCauXW10pU%2B0i6V2wZOC7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: text editor

2018-09-02 Thread victor jack
More like vim and vs code are the best editors

On Sun, 2 Sep 2018 06:51 RONAK JAIN,  wrote:

> Atom is best editor.
>
> On Sun, 2 Sep 2018, 11:11 a.m. sankar ardhas, 
> wrote:
>
>>
>> Hi to all,
>> Which is the best editor for django framework  in Ubuntu os
>> 18.04
>>
>> Get Outlook for Android 
>>
>>
>>
>>
>> On Sun, Sep 2, 2018 at 1:46 AM +0530, "RONAK JAIN" <
>> jainronak...@gmail.com> wrote:
>>
>> Namaste !!
>>>
>>> Dear ,
>>>
>>> I have two models categories and Project.
>>>
>>>  created like that :
>>>
>>> class Category(models.Model):
>>> categorys = models.ManyToManyField('Category',blank=True)
>>> name = models.CharField(max_length=100)
>>> created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
>>> updated_at = models.DateTimeField(auto_now=True)
>>>
>>>
>>>
>>> class Meta:
>>> verbose_name_plural = "Categories"
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> def __unicode__(self):
>>> return self.categorys
>>>
>>> class Project(models.Model):
>>> categorys = models.ManyToManyField('Category',blank=True)
>>> name = models.CharField(max_length=100)
>>> description = models.CharField(max_length=100)
>>> created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
>>> updated_at = models.DateTimeField(auto_now=True)
>>> photo = models.ImageField(upload_to="pictures")
>>>
>>>
>>> def __str__(self):
>>> return self.name
>>>
>>> def __unicode__(self):
>>> return self.categorys
>>>
>>> *and Views I did here :*
>>>
>>> *from web.models import Category,Project*
>>>
>>> class Portfolio(TemplateView):
>>> template_name = "web/protfolio.html"
>>>
>>> def post(self, request, *args, **kwargs):
>>> context = self.get_context_data()
>>> return super(TemplateView, self).render_to_response(context)
>>>
>>> def portfolio(request):
>>>   context = RequestContext(request)
>>>   # Project_list = Project.objects.order_by('-likes')[:3]
>>>   # context_dict = {'Project': project_list}
>>>   # return render(template_name, context_dict, context
>>>   brand_list = Category.objects.all()
>>>   return render(template_name, {'brand_list' : brand_list},
>>> context)
>>>
>>> *I need correct relationship both I mean project and categories. How can
>>> I do correct here ? *
>>> Note : I attached picture please analyse briefly.
>>>
>>> How to do approch html page and   I want  the html(view) page should
>>> load from our db.
>>> please give me quickly answer.
>>> How can i do ?
>>>
>>>
>>> Thanks
>>> Ronak
>>>
>>> --
>>> 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/63ecd6f1-411a-4581-b245-296efbd49303%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/39ABAA35669F59A4.eb8de1ab-f7fe-4f09-ac86-ab24def151d1%40mail.outlook.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/CA%2BAqMUcMUft6Wfa_YUzhRshp4vDF4fT5UxfUfUh2XeazH%2BxSxQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because 

Re: How can I get back my English pages (multi-lingual site updated from en to en-us)

2018-09-02 Thread victor jack
https://docs.djangoproject.com/en/2.0/topics/i18n/

check this out, but i don't think changing language_code from en to en-us
is the problem.

On Sat, Sep 1, 2018 at 2:31 PM Leo Treasure  wrote:

> Hello,
>
> I've needed to update the settings.py file LANGUAGE_CODE = 'en' to 'en-us'
> which has resulted in the English pages becoming empty.
>
> I've been told by my host that there maybe an SQL command I need to run to
> change the languages for the previously created pages over to en-us.
>
> Can someone help me with this please?
>
> --
> 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/086037f5-08b3-4816-85c1-82d22e03be70%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/CABkm6MVvxLBM-%2BhwnyFDmyn_s74G8Ycs8fnxGF5m%2B5EZ9T7MLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: creating virtualenv for django but i get import zlib module error what could be the problem

2018-09-02 Thread victor jack
from the error message , i think you need to install the  package zlib and
import it.

On Sat, Sep 1, 2018 at 2:31 PM Lutalo Bbosa joseph 
wrote:

> raceback (most recent call last):
>   File "/usr/local/bin/virtualenv", line 9, in 
> load_entry_point('virtualenv==15.0.1', 'console_scripts',
> 'virtualenv')()
>   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line
> 542, in load_entry_point
> return get_distribution(dist).load_entry_point(group, name)
>   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line
> 2569, in load_entry_point
> return ep.load()
>   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line
> 2229, in load
> return self.resolve()
>   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line
> 2235, in resolve
> module = __import__(self.module_name, fromlist=['__name__'], level=0)
>   File "/usr/lib/python3/dist-packages/virtualenv.py", line 1993, in
> 
> """)
>   File "/usr/lib/python3/dist-packages/virtualenv.py", line 1848, in
> convert
> return zlib.decompress(b).decode('utf-8')
> NameError: name 'zlib' is not defined
>
> --
> 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/44266161-c188-45e9-9b91-94901b7d8232%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/CABkm6MV-OVYFk_vxZwRKCPwmOO7V1hhXccdYcUfYj1yo2v0%2BwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: __init__.py Won't Upload To Github Respository

2018-09-02 Thread victor jack
Thanks for the link stephen , really much appreciated.

On Sat, Sep 1, 2018 at 7:59 PM Stephen J. Butler 
wrote:

> GitHub has an excellent set of gitignore files. My first commit to a
> project is always one of these:
>
> https://github.com/github/gitignore
>
> In particular:
> https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
>
>
> On Sat, Sep 1, 2018 at 10:52 AM Kasper Laudrup 
> wrote:
>
>> Hi Sandy,
>>
>> On 01/09/2018 17.18, Sandy Leon wrote:
>> > Hello everyone,
>> > I am trying to upload my Django site files to github to then deploy with
>> > Heroku.
>> > I have had no major problems except in trying to upload the folder that
>> > contains my Django site, github gets stuck on trying to upload '
>> > /mysite/polls/__pycache__/__init__.cpython-36.pyc'
>> > Just to be clear, my project is called 'mysite' and the app that I made
>> > following the Django tutorial is called polls.
>> > Thanks you in advance to anyone who can help.
>> >
>>
>> I have no idea why you are not able to upload these files, but you
>> shouldn't be uploading cache files or compiled python modules to you git
>> repository anyway.
>>
>> If you have any of these files in your local git repository, remove them
>> using "git rm".
>>
>> Something like:
>>
>> # find -name __pycache__ -exec git rm -r {} \;
>>
>> And:
>>
>> # find -name *.pyc -exec git rm {} \;
>>
>> Ought to do it.
>>
>> Then commit these changes with something like:
>>
>> # git commit -m "Remove cache and object files from repository"
>>
>> Finally add cache and compiled object files to you .gitignore. Something
>> like:
>>
>> *.pyc
>> __pycache__
>>
>> And try to push your changes again.
>>
>> Be aware that I have not actually tested any of these commands, so
>> please be careful before blindly executing them.
>>
>> Hope that helps a bit.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> --
>> 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/12e119ed-9ffe-d30a-2f88-71f8c70c37dd%40stacktrace.dk
>> .
>> 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/CAD4ANxVoJg7y9%2B6jga5PSpCR%3Dc0hGy6F2DBTqDY%3Di9nO7RVv7g%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABkm6MU77ZMrspuzQeiCQBFrPTsnbb-Nb9RZ1FxwTDJO9E00KQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django website hosting

2018-08-27 Thread victor jack
Check out the documentation  on digital ocean

On Sat, 25 Aug 2018 15:36 ERICK OMONDI AYARA,  wrote:

> I would like to host a django project onto a web domain but cant seem to
> get around it. i cant also find the python setup on the SOFTWARE section of
> my file manager. Is there a way to do 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/714a85d5-3bc3-4817-a66c-a92c0397f332%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/CABkm6MVwK4ys61H6mWq%3DF0Mnni7%3Dq7dZto_iNapCHfm92EWo0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Intregration Of on form submit user recive a sms in his phone

2018-07-31 Thread Aaron Jack
I use this company:

https://www.reach-interactive.com/

On Tuesday, 31 July 2018 14:32:02 UTC+1, im...@wsegames.com wrote:
>
> How to impement this feature Intregration Of on form submit user recive a 
> sms in his phone.
>

-- 
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/e818b28e-a933-4f5e-8759-4978e77e0605%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jack
See original question on Stack Overflow 

 for 
better formating.

-- 
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/8b8f53c5-2e53-4ec8-b2e6-7c7ec18ed5fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jack
I am trying to add a bunch of school boundary files into the database.  The 
boundary files are inconsistent.  They are processed by `DataSource` as 
either `Polygon`, `MultiPolygon`, or `GeometryCollection`.

Converting `Polygon` into `MultiPolygon` is fairly simple using this 
solution 
(https://gis.stackexchange.com/questions/13498),
 
but the conversion does not work for `GeometryCollection`.

class School(models.Model):
boundaries = models.MultiPolygonField()

---

from django.contrib.gis.geos import Polygon, MultiPolygon
from django.contrib.gis.geos.collections import GeometryCollection

ds = DataSource('school_boundaries.aspx')
feature = ds[0][0]
geom_geos = feature.geom.geos
if isinstance(geom_geos, Polygon):
geom_geos = MultiPolygon(geom_geos)
elif isinstance(geom_geos, GeometryCollection):
geom_geos = MultiPolygon(GeometryCollection)  #This does not work
school = School(boundaries = geom_geos)
school.save()

Is there some way to convert `GeometryField` to `MultiPolygon` in GeoDjango?

-- 
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/9fa3df23-bc41-4ea4-a766-d68525065766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DJANGO NOT FOUND

2017-12-23 Thread Jack
Hi, i've installed on my ubuntu 16.04 LTS python3.6 and django but django i 
have installed with pip3 and usign virtualenv, but it is ok by console, the 
problem is in eclipse, i installed python, it is OK, but at the moment of 
creating a django project, it drops a message, django not found, i've 
removed the interpreter and add it again because i thought it was the 
problem but the problem continues, i've uninstalled pydev from eclipse and 
the problem is the same.

If someone knows about this, please help me.

Thnks a lot.

-- 
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/58251deb-dc26-4f68-8a1b-c838f0f97e43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Single-page app with dynamic filtering - 2 options to proceed

2017-12-18 Thread Jack


I am building a real estate listings map, which dynamically refreshes its 
filter whenever the user moves the map. The page never refreshes when a 
change is made. Think Zillow/Trulia 

.

There are 2 main filters:

   - Filter properties within the user's viewport
   - Filter properties according to user's custom filter (e.g. property 
   type, # of bedrooms, etc.)

I see 2 methods of approaching this problem.

   1. 
   
   On initial visit, pass ALL properties in the database to the user. And 
   then filter these properties whenever the user moves his map or changes his 
   filter selection.
   2. 
   
   Create an ajax call whenever the user moves his map or changes his 
   filter selection. The ajax call will only return the properties that match 
   the user's current requirements.
   
Which method is preferable? I estimate there will be maybe 200k-300k 
records in my database.

-- 
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/7e6179d4-2274-4aec-aa83-27fbfdc1238c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django - Paginate with another GET request; not working with just pagination page number

2017-12-06 Thread Jack
I'm building a page with pagination and a filter form (2 GET requests).  If 
the URL includes both pagination and filter results, something like 
`/questions/?page=2_questions=on`, it works fine.  It also works if it 
just has filter results, something like `/questions/?all_questions=on`.

However if it only has the pagination page result, something like 
`/questions/?page=1`, no results are shown.

So I figured I need to do something in the views so that if there is only 
page number in the URL, a default filter will be given.  I know I probably 
need to add something to the Try and Except section of pagination, but I'm 
stumped as the actual code I need to write.


def questions_index(request):

user = request.user
form = QuestionFilterForm(request.GET or None)
question_list = []
if not form.is_bound:
question_list = Question.objects.all().order_by('-date_created')
if form.is_valid():
if form.cleaned_data['all_questions'] | 
(form.cleaned_data['general_questions'] & 
form.cleaned_data['location_all_gta']) == True:
question_list = 
Question.objects.all().order_by('-date_created')
elif form.cleaned_data['location_all_gta'] == True:
question_list += 
Question.objects.filter(question_type=1).order_by('-date_created')
else:
if form.cleaned_data['general_questions'] == True:
question_list += 
Question.objects.filter(question_type=2).order_by('-date_created')
if form.cleaned_data['location_toronto'] == True:
question_list += 
Question.objects.filter(location='1').order_by('-date_created')

paginator = Paginator(question_list, 15)

# Pagination
page = request.GET.get('page')
try:
questions = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
questions = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of 
results.
questions = paginator.page(paginator.num_pages)

### I need to write something here...
except (url has no filter result)  
give default filter 

return render(request, 'questions_index.html', {'questions': 
questions, 'user': user, 'form': form})

-- 
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/2a2f05ae-d71a-419b-9df0-394e1e129fcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Seeking design guidance on a Team model where a user sends invitation to other users to join the team

2017-11-27 Thread Jack
Hey Adam.  I took a week to properly learn some JavaScript and jQuery and 
how to make ajax calls.  I just got it working!  It was much simpler than I 
thought.  I created a views to catch the appropriate agent's pk and put 
that in a data-href attribute like this:

Send Invite

Then I passed the button into an ajax call... a few lines of processing in 
the `send_invitation` views and it works nicely.  Took maybe 15 lines of 
code in total?

Thanks for your help, but mainly thanks for leading me into using ajax.  I 
was always too lazy to properly learn javascript but now, I can do a lot 
more with jquery and ajax!

Best regards,

On Friday, November 10, 2017 at 12:37:46 PM UTC-5, Adam wrote:
>
>
>
>
>
>
>
> Weird, I dont see our conversation,
>
> Anyway here is a simple setup:
>
> urls.py:
>
> from django.conf.urls import url
>
> from .views import ajax_comment_send
>
> urlpatterns = [
>
>  url("comment_send", ajax_comment_send, name="comment_send"),
>
> ]
>
>
>
> then a view - this is from my project, you will to make changes to do the 
> calculations. :)
>
> ...
>
> def ajax_comment_send(request):
>  if not request.is_ajax():
>  return HttpResponse('SERVER RESPONSE: ajax_comment_send, Not an ajax 
> call.')
>
>  comment_thread = None
>  recipient = None
>
>  if request.method == "POST":
>  content = request.POST.get("content", "0")
>  recip_id_str = request.POST.get("recip_id", "0") # this is where to make 
> changes
>
>  if scope == 'story':
>  comment_thread = CommentThread.objects.get(story__id=int(recip_id_str))
>  recipient = get_object_or_404(User, pk=comment_thread.first_recipient_id)
>
> ...
>
>  send_message = Comment.objects.create(
>  body=content,
>  comment_thread=comment_thread,
>  recipient=recipient,
>  sender=request.user
>  )
>
>  send_message.save()
>
>  return HttpResponse("SERVER RESPONSE ajax_comment_send; send_message.id: 
> " +
>  str(send_message.id)) # this is a check to help with debugging
>
>  return HttpResponse('SERVER RESPONSE: ajax_comment_send, AJAX fell 
> through.')
>
>
>
>
> this is the key part ; javascript in the front end:
>
>
> function replyThread (scope, recip_id, cntnt) {
>  console.log('replyThread : scope:' + scope + ', recip_id: ' + recip_id + ', 
> content: ' + cntnt);
>  $.ajax({
>  type: 'POST',
>  url: '/jos_comments/comment_send',
>  data: { // this is the part that scoops up the agents and sends it to 
> the backend
>  'scope': scope, // This is unique to me
>  'recip_id': recip_id,
>  'content': cntnt
>  },
>  success: function (serverResponse_data) {
>  console.log('replyThread success: ' + serverResponse_data);
>  $('#message_box').html(
>  "Message sent!");
>  setTimeout(function () {
>  getThreadComments(serverResponse_data.split(':')[1]); // this reloads 
> the messages; you probably don't need
>  }, 1500);
>  },
>  error: function (serverResponse_data) {
>  console.log('error:' + JSON.stringify(serverResponse_data).split(',').
> join('\n')); // helps with debug
>  }
>  });
> }
>
> Hope this helps
>
>
>
>
>
>
>
>
>
>
> On Saturday, November 4, 2017 at 8:27:12 PM UTC-7, Jack wrote:
>>
>> I have a model called *Team*, which has a ForeignKey relationship with 
>> *User* (a team can have many users, but a user can only be part of one 
>> team).
>>
>> A user can create a team, and that user will automatically become a *Team 
>> Leader* (a group, not a model).  The team leader can query the database 
>> for other users and send invitations to other users join his team.  Users 
>> who receive an invitation can either accept or decline the invitation; if a 
>> user accepts an invitation, he joins the team as as a *Team Member*
>>
>> My question is, how do I go about designing the invitation system?  After 
>> the team leader clicks the 'Send Invitation' button, the receiving-user 
>> should see a special invitation message on his dashboard, which he can 
>> either accept or decline.
>>
>> My current thinking tells me I should create a model called *Invitation* 
>> which has a OneToOne relationship with User.  When an invitation is sent, 
>> an instance of Invitation is created which is assigned to the 
>> receiving-user.  The invitation instance will be deleted when the 
>> receiving-user accepts or declines the invitation.
>>
>> Another method I can think of is to send an Email to the receiving-user.  
>> The Email will be like an account activation Email, except the activation 
>> 

Re: Django - Pass a model instance specified by template tags to the view

2017-11-09 Thread Jack Zhang
No I am not familiar with Ajax.  I only know a bit of JavaScript.
ᐧ

On Thu, Nov 9, 2017 at 6:19 PM, Adam Simon <add.simm.8...@gmail.com> wrote:

>
> Hi Jack. I will write some more details when I get home. Have you ever
> used Ajax?
>
> On Thu, Nov 9, 2017 at 3:14 PM Jack <valachio...@gmail.com> wrote:
>
>> Ok I'm very stuck.  Thought very hard about it but can't see how I can
>> add a hidden field into the HTML, and relay the specified instance of the
>> hidden field back to the views... or am I completely off about something?
>>
>> Also in regards to the looped form's.  If you look at my original code, I
>> actually do have a  representing a button for each agent.  The
>> resulting page looks like this
>> <https://i.gyazo.com/bf67b8a3808fb14a265459776847c08b.png> (excuse the
>> bad CSS).  I'm not sure if that is what you meant by having a form for each
>> agent.
>>
>> So if I understood you correctly, I do have a separate  input for
>> each displayed agent; looped with {% for agent in agent_list %}.  The
>> question is, how do I relay the correct agent linked to its 'Send Invite'
>> button back to the 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/eab1a4c0-2cc1-41d0-aace-f8ef3fd73112%
>> 40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/eab1a4c0-2cc1-41d0-aace-f8ef3fd73112%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> --
>
> Adam F. Simon, PhD
> Calabasas, CA.
>
> cell:  818-425-3719 <(818)%20425-3719>
> home:   818-880-8405 <(818)%20880-8405>
>
> Feel free to link w/ me: LinkedIn
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/k5mwo58aPfU/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAH-jdcw11Z1w2qRCkuwzdXL0qFNXD1PkL
> Jsw6sRSVHNDBfWAfQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAH-jdcw11Z1w2qRCkuwzdXL0qFNXD1PkLJsw6sRSVHNDBfWAfQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

*Jack Zhang*

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


Re: Django - Pass a model instance specified by template tags to the view

2017-11-09 Thread Jack
Ok I'm very stuck.  Thought very hard about it but can't see how I can add 
a hidden field into the HTML, and relay the specified instance of the 
hidden field back to the views... or am I completely off about something?

Also in regards to the looped form's.  If you look at my original code, I 
actually do have a  representing a button for each agent.  The 
resulting page looks like this 
 (excuse the bad 
CSS).  I'm not sure if that is what you meant by having a form for each 
agent.

So if I understood you correctly, I do have a separate  input for 
each displayed agent; looped with {% for agent in agent_list %}.  The 
question is, how do I relay the correct agent linked to its 'Send Invite' 
button back to the 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eab1a4c0-2cc1-41d0-aace-f8ef3fd73112%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - Pass a model instance specified by template tags to the view

2017-11-09 Thread Jack
There will be a lot of agents in the database, so would it violate the DRY 
principle if I were to write a form for each agent?  Plus it'll be super 
time consuming.

I'm going to try the hidden agent.id thing, I never thought about that.  
I'll report back to see if I managed to get it working. 

On Wednesday, November 8, 2017 at 6:24:29 PM UTC-5, Adam wrote:
>
>
> On Wed, Nov 8, 2017 at 1:38 PM Jack <valac...@gmail.com > 
> wrote:
>
>> On my HTML page, I have a list of Agent's (Agent is my custom User 
>> model).  Beside each agent is a 'Send Invite' button.  To create a 
>> `TeamInvitation`, I need to specify which Agent is attached to its 
>> `receiver_agent` field (a OneToOneField with Agent)
>>
>> There are multiple Agents displayed on the HTML page, and they are listed 
>> in order with template tags.  I need to input something after `pk` at 
>> `receiver_agent = Agent.objects.get(pk = ???)`, but I don't know what to 
>> input.
>>
>> *views.py*
>>
>> class InviteAgentSearchResults(ListView):
>> model = Agent
>> form_class = AgentSearchForm
>> template_name = 'invite_agent_search_results.html'
>> 
>> def get_queryset(self):
>> # ... Code to find correct list of agents
>> 
>> def post(self, request, *args, **kwargs):
>> invite = TeamInvitation.objects.create(receiver_agent = 
>> Agent.objects.get(pk = ???))
>> return HttpResponse('Invite successfully sent.')
>>
>> *HTML:*
>>
>> {% for agent in agent_list %}
>> 
>> # ... Some code here
>>
>>   # The "Send Invite" button
>> {% csrf_token %}
>> Send Invite
>> 
>> 
>> {% endfor %}
>>
>> -- 
>> 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/bd0439e2-7fdd-4f7c-b6ce-4847d4a877c8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/bd0439e2-7fdd-4f7c-b6ce-4847d4a877c8%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> It seems to me that the quickest thing would be to make each agent a 
> separate form. 
>
> Alternatively, you could set up some JavaScript:
>
> Add the agent.id to a hidden input,  separated by commas, and have that 
> hidden field submitted via the form
>
> Then on the backend separate out each ID and have the invites sent one by 
> one. I would be happy to write some code if you wish.
>
>
> -- 
> -- 
>
> Adam F. Simon, PhD
> Calabasas, CA.
>
> cell:  818-425-3719
> home:   818-880-8405
>
> Feel free to link w/ me: LinkedIn
>
>
>

-- 
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/49997913-66f3-416d-847e-d2ba69459f0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django - Pass a model instance specified by template tags to the view

2017-11-08 Thread Jack
On my HTML page, I have a list of Agent's (Agent is my custom User model).  
Beside each agent is a 'Send Invite' button.  To create a `TeamInvitation`, 
I need to specify which Agent is attached to its `receiver_agent` field (a 
OneToOneField with Agent)

There are multiple Agents displayed on the HTML page, and they are listed 
in order with template tags.  I need to input something after `pk` at 
`receiver_agent = Agent.objects.get(pk = ???)`, but I don't know what to 
input.

*views.py*

class InviteAgentSearchResults(ListView):
model = Agent
form_class = AgentSearchForm
template_name = 'invite_agent_search_results.html'

def get_queryset(self):
# ... Code to find correct list of agents

def post(self, request, *args, **kwargs):
invite = TeamInvitation.objects.create(receiver_agent = 
Agent.objects.get(pk = ???))
return HttpResponse('Invite successfully sent.')

*HTML:*

{% for agent in agent_list %}

# ... Some code here

  # The "Send Invite" button
{% csrf_token %}
Send Invite


{% endfor %}

-- 
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/bd0439e2-7fdd-4f7c-b6ce-4847d4a877c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Seeking design guidance on a Team model where a user sends invitation to other users to join the team

2017-11-05 Thread Jack
Thanks, I'm looking into it and you are right, it seems quite fitting for 
my project.

Stupid question as I've never used a 3rd party app before...  Am I supposed 
to download the source code and put that into my project folder?  I already 
did 'pip install django-invitations'. 

On Saturday, November 4, 2017 at 11:49:19 PM UTC-4, Shree Kant Bohra wrote:
>
> Check out django-invitations app, which does exactly what you need - 
> https://github.com/bee-keeper/django-invitations
>
>
> --
> Shree Kant Bohra
> Co-founder 
> Geekybuddha Technologies
>
>
>
>
> On Sun, Nov 5, 2017 at 8:57 AM, Jack <valac...@gmail.com > 
> wrote:
>
>> I have a model called *Team*, which has a ForeignKey relationship with 
>> *User* (a team can have many users, but a user can only be part of one 
>> team).
>>
>> A user can create a team, and that user will automatically become a *Team 
>> Leader* (a group, not a model).  The team leader can query the database 
>> for other users and send invitations to other users join his team.  Users 
>> who receive an invitation can either accept or decline the invitation; if a 
>> user accepts an invitation, he joins the team as as a *Team Member*
>>
>> My question is, how do I go about designing the invitation system?  After 
>> the team leader clicks the 'Send Invitation' button, the receiving-user 
>> should see a special invitation message on his dashboard, which he can 
>> either accept or decline.
>>
>> My current thinking tells me I should create a model called *Invitation* 
>> which has a OneToOne relationship with User.  When an invitation is sent, 
>> an instance of Invitation is created which is assigned to the 
>> receiving-user.  The invitation instance will be deleted when the 
>> receiving-user accepts or declines the invitation.
>>
>> Another method I can think of is to send an Email to the receiving-user.  
>> The Email will be like an account activation Email, except the activation 
>> link adds the receiving-user to the team and marks the receiving-user as a 
>> *team 
>> member.*
>>
>> Pointers and guidance welcome.  I feel like both my methods are clumsy 
>> and maybe there is a built-in feature in Django which I missed which could 
>> solve this problem much easier.
>>
>> -- 
>> 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/029d4382-fdb2-4fc5-8832-337e1f870e24%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/029d4382-fdb2-4fc5-8832-337e1f870e24%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/6c96ca21-20e9-49b4-9f17-407abcc66ea8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Seeking design guidance on a Team model where a user sends invitation to other users to join the team

2017-11-04 Thread Jack
I have a model called *Team*, which has a ForeignKey relationship with 
*User* (a team can have many users, but a user can only be part of one 
team).

A user can create a team, and that user will automatically become a *Team 
Leader* (a group, not a model).  The team leader can query the database for 
other users and send invitations to other users join his team.  Users who 
receive an invitation can either accept or decline the invitation; if a 
user accepts an invitation, he joins the team as as a *Team Member*

My question is, how do I go about designing the invitation system?  After 
the team leader clicks the 'Send Invitation' button, the receiving-user 
should see a special invitation message on his dashboard, which he can 
either accept or decline.

My current thinking tells me I should create a model called *Invitation* 
which has a OneToOne relationship with User.  When an invitation is sent, 
an instance of Invitation is created which is assigned to the 
receiving-user.  The invitation instance will be deleted when the 
receiving-user accepts or declines the invitation.

Another method I can think of is to send an Email to the receiving-user.  
The Email will be like an account activation Email, except the activation 
link adds the receiving-user to the team and marks the receiving-user as a 
*team 
member.*

Pointers and guidance welcome.  I feel like both my methods are clumsy and 
maybe there is a built-in feature in Django which I missed which could 
solve this problem much easier.

-- 
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/029d4382-fdb2-4fc5-8832-337e1f870e24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


MultipleChoiceField is being displayed as a string instead of a list

2017-10-29 Thread Jack
I have a MultipleChoiceField forms field which shows up in the database like 
this . It seems to have been converted 
to a string in the database, because when I try to display it with a 'for 
property in property_type' statement in the HTML, it shows up like this 
. I want it to be displayed like this 
.  I have also tried using an 
ArrayField (shown below), but the result is the same.


models.py:

property_type = models.CharField(max_length=50, help_text="You can select more 
than 1 option")

property_type = ArrayField(models.CharField(max_length=50), help_text="You can 
select more than 1 option"))


forms.py:

property_type = forms.MultipleChoiceField(widget=forms.SelectMultiple, 
choices=BuyerListing.PROPERTY_TYPE)

HTML:

{% for property in listing.property_type %}
Property type: {{ property }}
{% endfor %}



How do I get this MultipleChoiceField to load as a list so I can display it 
properly with a for statement?

-- 
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/cb625aff-b96e-4a07-9737-d89805085962%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Building a search form with 4 required choices, which will be inserted as arguments in an URL [warning: long question]

2017-10-29 Thread Jack
That makes much more sense.  It's my fault for not reading the Django docs 
properly, but I don't seem to soak in the concepts at all by simply 
reading.  

I went with a ListView + get_queryset override.  I haven't managed to get 
the filter to work but the search itself is working properly.

Thanks Daniel!

On Sunday, October 29, 2017 at 7:59:25 AM UTC-4, Daniel Roseman wrote:
>
> On Monday, 23 October 2017 16:59:36 UTC+1, Jack wrote:
>>
>> This is a semi-long question.  Please let me know wherever I make a 
>> mistake.
>>
>> I'm building a search form with 4 required choices, 1 of the choices is a 
>> CharField with a max_length of 3.  The other 3 choices are ChoiceField's.  
>> Here is a picture of what the search form looks like:
>>
>>
>> <https://lh3.googleusercontent.com/-8GREjIuYfMc/We4LXpdGMtI/CeI/lF08A9M1zj4gL3saaVvKY9rWZ4APYU4EACLcBGAs/s1600/Capture.PNG>
>>
>> I've read through the Django docs and other things on the Internet but 
>> I'm still very unclear about how to approach this.
>>
>> 1. First I believe I need to create 4 args or kwargs in the url for each 
>> of the choices.  If I use args, it would look something like...
>>
>> url(r'^search?(\w+{3})&(\w+{2})&(\w+{1-2})&(\w+{1-2})', function/class 
>> view, name='search')
>>
>> 2. Next, I need to pass the user's input in the html page into the url 
>> args.  I have a form set up to get the user's input.  But how would I write 
>> this on the HTML page?  Do I simply make a url tag like {% url 'search' 
>> args1, args2, args3, args4 %}?
>>
>> 3. Then I need to create the views function.  My first question is, 
>> should I use a function-based view or the generic class-based ListView?  
>> The result of the search will be a list of items, so ListView is a good 
>> template to use, but I don't know how having 4 args would affect using 
>> ListView.  My second question is, what is the most effective way of making 
>> this search?  I need to check if any records in the database matches the 
>> user's search, so would I do something like 'For record in database' to 
>> check over every record in the database?
>>
>> If I used a function view, would it look something like:
>>
>> def search(request, args1, args2, args3, args4):
>>  for record in database:
>>   if args matches record:
>>display record
>>
>> Thank you for reading through the question
>>
>
>
> Your difficulties all stem from the same misunderstanding here.
>
> Forms - at least when using the GET action - put their arguments in the 
> querystring - the bit after the ? in the URL. Django doesn't treat that as 
> part of the URL itself, but as a separate attribute, `request.GET`. So both 
> your first and second questions are irrelevant: you don't need to capture 
> the values in a URL pattern, and nor do you need to insert them in there in 
> the HTML somehow. Just use a basic pattern of `r('^search/$)` and all will 
> be fine.
>
> For your third question, it makes no difference whether you use function 
> or class-based views. If you did use a ListView, though, you could override 
> `get_queryset` to filter by the values in the GET dictionary:
>
> def get_queryset(self):
> qs = super(MyListView, self).get_queryset()
> if 'bedrooms' in request.GET:
> qs = qs.filter(bedrooms=request.GET['bedrooms']
> ... etc ...
> return qs
>
> -- 
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c6bb83c1-16fd-4375-88ba-9516a9677c29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Passing 3 user inputs as argument in url, for a search form

2017-10-26 Thread Jack
I managed to get the code functional.  I haven't done extensive testing but 
it's certainly working right now with your code plus some of my own fixes.  
I should read the documentation more carefully in the future.

Thanks again for the super detailed response James.

On Wednesday, October 25, 2017 at 7:50:58 PM UTC-4, James Schneider wrote:
>
>
>
> On Wed, Oct 25, 2017 at 11:29 AM, Jack <valac...@gmail.com > 
> wrote:
>
>> I am building a search form where the user inputs 3 values on a form, and 
>> I search the database for all records that match the 3 inputs.  Right now I 
>> am stuck on the user input part.
>>
>> If you look at my *urls.py*, you will see that I tried to put 3 keywords 
>> arguments in there.  Then I tried to pass the 3 keyword arguments in the 
>> url tag with variables from my *forms.py*.  I think this is where things 
>> went wrong but I'm not sure.  I don't know if the .html file can use 
>> variables from *forms.py*
>>
>> Basically what I'm trying to do is to take the 3 user inputs, and pass 
>> them as arguments in the URL.  Right now I'm getting:
>>
>> NoReverseMatch at /
>>
>> Reverse for 'search-results' with keyword arguments '{'pt': '', 'nb': '', 
>> 'nw': ''}' not found. 1 pattern(s) tried: 
>> ['search?(?P\\w+)&(?P\\w+)&(?P\\w+)']
>>
>>
>>
>> *urls.py*
>> url(r'^search?(?P\w+)&(?P\w+)&(?P\w+)', 
>> views.IndexSearchResults.as_view(), name='search-results')
>>
>>
> This is not the correct usage of the URL dispatcher. It should look 
> something like this:
>
> url(r'^search$', views.IndexSearchResults.as_view(), name='search-results')
>
> The URL dispatcher does not match on GET arguments within the URL, that's 
> left for the request object to parse.
>
>
> https://docs.djangoproject.com/en/1.11/topics/http/urls/#what-the-urlconf-searches-against
>
>  
>
> *views.py*
>> class IndexSearchResults(generic.ListView):
>> template_name = 'search-results.html'
>>
>>
> The view is where your GET arguments will be processed. Note that if you 
> are submitting the form directly to the URL above, then no validation of 
> the form values will be performed. If you want those values to be 
> validated, you should submit to a FormView to validate the results and 
> redirect to this search page with the GET arguments in tow. I'd imagine 
> that both strategies are common, since sending bad values to search against 
> usually just results in bad searches. The ORM takes care of most of the 
> security concerns in this case.
>
> You will want to override get_queryset() to add in your GET arguments for 
> filtering after retrieving them from the request object. The GET arguments 
> are automatically captured in to a QueryDict attached to the request:
>
>
> https://docs.djangoproject.com/en/1.11/ref/request-response/#querydict-objects
>
> So, in your IndexSearchResults view:
>
> def get_queryset(self):
> queryset = super().get_queryset()
>
> # I can do something fancy with lists of tuples to cut down on the 
> code, but this is more readable
> pt = self.request.GET.get('pt')
> nb = self.request.GET.get('nb')
> nw = self.request.GET.get('nw')
> 
> if pt:
> queryset = queryset.filter(property_type=pt)
> if nb:
> queryset = queryset.filter(number_of_bedrooms=nb)
> if nw:
> queryset = queryset.filter(number_of_washrooms=nw)
>
> return queryset
>
>
> This should return a queryset to the view that will filter down the list 
> of objects matching the GET arguments.
>
>  
>
>>
>> *models.py*
>> Class BuyerListing(models.Model):
>>  BEDS_OPTION = (
>> (BEDS_0, '0 [Studio/Bachelor]'),
>> (BEDS_1, '1'),
>> (BEDS_1_1, '1+1'),
>> (BEDS_2, '2'),
>> (BEDS_2_1, '2+1'),
>> (BEDS_3, '3'),
>> (BEDS_3_1, '3+1'),
>> (BEDS_4, '4'),
>> (BEDS_5, '5'),
>> (BEDS_5_1, '5+'),
>> )
>>
>>  WASH_OPTION = (
>> (WASH_1, '1'),  
>> (WASH_2, '2'),  
>> (WASH_3, '3'),  
>> (WASH_4, '4'),  
>> (WASH_5, '5'),  
>> (WASH_5_1, '5+'),  
>> )
>>
>> PROPERTY_TYPE = (
>> (CONDO_APARTMENT, 'Condo Apartment'),
>> (DETACHED_HOUSE, 'Detached House'),
>> (SEMI_DETACHED, 'Semi-detached'),
>> (TOWNHOUSE, 'Townhouse'),
>> )
>>
>> property_type = models.CharField(max_length=50)
>> number_of_bedroo

MultipleChoiceField records down choices as a list, but CharField converts them to a list?

2017-10-26 Thread Jack
I have a model field for choosing multiple options.  Here is the code for 
models and forms:

*models.py:*
CONDO_APARTMENT = 'Condo Apartment'
DETACHED_HOUSE = 'Detached House'
SEMI_DETACHED = 'Semi-detached'
TOWNHOUSE = 'Townhouse'

PROPERTY_TYPE = (
(CONDO_APARTMENT, 'Condo Apartment'),
(DETACHED_HOUSE, 'Detached House'),
(SEMI_DETACHED, 'Semi-detached'),
(TOWNHOUSE, 'Townhouse'),
)

property_type = models.CharField(max_length=50, help_text="You can 
select more than 1 option")


*forms.py:*
property_type = forms.MultipleChoiceField(widget=forms.SelectMultiple, 
choices=BuyerListing.PROPERTY_TYPE)


Let's assume the selected choices were 'Condo Apartment' and 
'Semi-detached'.  The value stored on my database is this - ['Condo 
Apartment', 'Semi-detached']

Now this is in a list format, which makes sense, but it seems to have been 
converted to a string.  When I try to call on property_type in a .html 
document...

{% for property in model.property_type %}
{{ property }}
{% endfor %}

The result is displayed in singular characters, like this:

[
'
C
o
n
d
o
 
a
p
.. and so on.  Instead I want the result to be the values in the list, like 
this:

Condo apartment
Semi-detached

How do I do this?  I tried experimenting with different model field types 
but CharField seems like the only appropriate one for MultipleChoiceField.

-- 
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/06ff88b7-4ec4-4ddc-a4da-af8e25e3c516%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Passing 3 user inputs as argument in url, for a search form

2017-10-25 Thread Jack
I am building a search form where the user inputs 3 values on a form, and I 
search the database for all records that match the 3 inputs.  Right now I 
am stuck on the user input part.

If you look at my *urls.py*, you will see that I tried to put 3 keywords 
arguments in there.  Then I tried to pass the 3 keyword arguments in the 
url tag with variables from my *forms.py*.  I think this is where things 
went wrong but I'm not sure.  I don't know if the .html file can use 
variables from *forms.py*

Basically what I'm trying to do is to take the 3 user inputs, and pass them 
as arguments in the URL.  Right now I'm getting:

NoReverseMatch at /

Reverse for 'search-results' with keyword arguments '{'pt': '', 'nb': '', 'nw': 
''}' not found. 1 pattern(s) tried: 
['search?(?P\\w+)&(?P\\w+)&(?P\\w+)']



*urls.py*
url(r'^search?(?P\w+)&(?P\w+)&(?P\w+)', 
views.IndexSearchResults.as_view(), name='search-results')


*index.html *

{{ form.as_p }}



*views.py*
class IndexSearchResults(generic.ListView):
template_name = 'search-results.html'


*models.py*
Class BuyerListing(models.Model):
 BEDS_OPTION = (
(BEDS_0, '0 [Studio/Bachelor]'),
(BEDS_1, '1'),
(BEDS_1_1, '1+1'),
(BEDS_2, '2'),
(BEDS_2_1, '2+1'),
(BEDS_3, '3'),
(BEDS_3_1, '3+1'),
(BEDS_4, '4'),
(BEDS_5, '5'),
(BEDS_5_1, '5+'),
)

 WASH_OPTION = (
(WASH_1, '1'),  
(WASH_2, '2'),  
(WASH_3, '3'),  
(WASH_4, '4'),  
(WASH_5, '5'),  
(WASH_5_1, '5+'),  
)

PROPERTY_TYPE = (
(CONDO_APARTMENT, 'Condo Apartment'),
(DETACHED_HOUSE, 'Detached House'),
(SEMI_DETACHED, 'Semi-detached'),
(TOWNHOUSE, 'Townhouse'),
)

property_type = models.CharField(max_length=50)
number_of_bedrooms = models.CharField(max_length=50, default=BEDS_0)
number_of_washrooms = models.CharField(max_length=50, default=WASH_1)


*forms.py*
class MainSearch(forms.Form):

property_type = forms.ChoiceField(choices=BuyerListing.PROPERTY_TYPE)

number_of_bedrooms = forms.ChoiceField(choices=BuyerListing.BEDS_OPTION)

number_of_washrooms = 
forms.ChoiceField(choices=BuyerListing.WASH_OPTION)
  

-- 
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/deaaeafb-c8b9-45fc-9553-1c495c65dc28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-25 Thread Jack
I tried using FormView but kept running into errors.  I used your second 
response and it worked!  I don't fully understand the code, but it seems to 
work flawlessly.

Thank you so much! I own you a big one.

On Wednesday, October 25, 2017 at 5:57:04 AM UTC-4, k2527806 wrote:
>
> that your code : 
> class CreatePost(CreateView):
> model = Post
>
> def form_valid(self, form):
> form.instance.user = self.request.user
> return super(CreatePost, self).form_valid(form)
>
> On Wed, Oct 25, 2017 at 1:22 PM, mohammad k <k252...@gmail.com 
> > wrote:
>
>> use FormView
>>
>>
>> https://docs.djangoproject.com/en/1.11/ref/class-based-views/generic-editing/#formview
>>
>> On Wed, Oct 25, 2017 at 1:21 PM, mohammad k <k252...@gmail.com 
>> > wrote:
>>
>>> class Upload(FormView):
>>> http_method_names = ['get', 'post']
>>> template_name = 'public/upload.html'
>>> success_url = reverse_lazy('upload')
>>> form_class = UploadForms
>>>
>>> def get(self, request, *args, **kwargs):
>>> form = self.form_class(user=request.user)
>>> return render(request, self.template_name, {'form': form})
>>>
>>> def post(self, request, *args, **kwargs):
>>> form = self.form_class(request.POST, request.FILES, 
>>> user=request.user)
>>> if form.is_valid():
>>> data = form.save(commit=False)
>>> data.user = request.user
>>> data.save()
>>> messages.add_message(request, messages.SUCCESS, 
>>> self.success_message)
>>> return redirect(self.success_url)
>>> return render(request, self.template_name, {'form': form})
>>>
>>> On Wed, Oct 25, 2017 at 3:22 AM, Jack Zhang <valac...@gmail.com 
>>> > wrote:
>>>
>>>> Thanks for your response.  This is an off-topic question but I can't 
>>>> figure out how to get 'request' working.  I'm using the CreateView generic 
>>>> class, so there's no space to insert 'request'.  This is what my code 
>>>> looks 
>>>> like.  When I try to run it, it tells me that request is not found.  
>>>>
>>>> class ListingCreateView(LoginRequiredMixin, CreateView):
>>>> model = BuyerListing
>>>> 
>>>> form_class = PostListing(self.request.POST)
>>>> if form.is_valid():
>>>> form_save = form.save(commit=False)
>>>> form_save.user = request.user # user is logged in
>>>> form.save()
>>>> 
>>>> def get_queryset(self):  # the user want to edit this post must be 
>>>> owner this post
>>>> post_qs = super(PostListing, self).get_queryset()
>>>> return post_qs.filter(user=self.request.user)
>>>>
>>>> On Tuesday, October 24, 2017 at 12:35:15 PM UTC-4, k2527806 wrote:
>>>>>
>>>>> try that in your views
>>>>>
>>>>> form = Dog_Form(request.POST)
>>>>> if form.is_valid():
>>>>> form_save = form.save(commit=False)
>>>>> form_save.user = request.user # user is logged in
>>>>> form.save()
>>>>>
>>>>>
>>>>> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang <valac...@gmail.com> 
>>>>> wrote:
>>>>>
>>>>>> Let's say I have a model called 'Dogs'.  Users can create instances 
>>>>>> of Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>>>>>
>>>>>> 1. When User1 creates an instance of Dogs, how do I automatically 
>>>>>> assign that instance to User1?  I tried using a model field like this 
>>>>>> but 
>>>>>> it doesn't pick the user automatically:
>>>>>>
>>>>>> user = models.ForeignKey(User, unique=False)
>>>>>>
>>>>>> 2. After the instance has been created, how do I make the instance 
>>>>>> only editable and removable by the user who made it?  Basically, if 
>>>>>> User1 
>>>>>> creates an instance of Dogs, only User1 can edit and delete that 
>>>>>> instance. 
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>

Re: Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread Jack Zhang
Thanks for your response.  This is an off-topic question but I can't figure 
out how to get 'request' working.  I'm using the CreateView generic class, 
so there's no space to insert 'request'.  This is what my code looks like.  
When I try to run it, it tells me that request is not found.  

class ListingCreateView(LoginRequiredMixin, CreateView):
model = BuyerListing

form_class = PostListing(self.request.POST)
if form.is_valid():
form_save = form.save(commit=False)
form_save.user = request.user # user is logged in
form.save()

def get_queryset(self):  # the user want to edit this post must be 
owner this post
post_qs = super(PostListing, self).get_queryset()
return post_qs.filter(user=self.request.user)

On Tuesday, October 24, 2017 at 12:35:15 PM UTC-4, k2527806 wrote:
>
> try that in your views
>
> form = Dog_Form(request.POST)
> if form.is_valid():
> form_save = form.save(commit=False)
> form_save.user = request.user # user is logged in
> form.save()
>
>
> On Tue, Oct 24, 2017 at 7:37 PM, Jack Zhang <valac...@gmail.com 
> > wrote:
>
>> Let's say I have a model called 'Dogs'.  Users can create instances of 
>> Dogs.  Let's say we have a user called User1.  I have 2 questions:
>>
>> 1. When User1 creates an instance of Dogs, how do I automatically assign 
>> that instance to User1?  I tried using a model field like this but it 
>> doesn't pick the user automatically:
>>
>> user = models.ForeignKey(User, unique=False)
>>
>> 2. After the instance has been created, how do I make the instance only 
>> editable and removable by the user who made it?  Basically, if User1 
>> creates an instance of Dogs, only User1 can edit and delete that instance. 
>>
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/dedbfe8b-1013-4844-b142-1e8615a1ef9a%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/950d853a-ade3-4d27-8e23-a47c6b70c80e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Automatically assign model instance to the user who created it. And only that user can edit/delete the instance.

2017-10-24 Thread Jack Zhang
Let's say I have a model called 'Dogs'.  Users can create instances of 
Dogs.  Let's say we have a user called User1.  I have 2 questions:

1. When User1 creates an instance of Dogs, how do I automatically assign 
that instance to User1?  I tried using a model field like this but it 
doesn't pick the user automatically:

user = models.ForeignKey(User, unique=False)

2. After the instance has been created, how do I make the instance only 
editable and removable by the user who made it?  Basically, if User1 
creates an instance of Dogs, only User1 can edit and delete that instance. 

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/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generating a unique 10 digit ID for each model instance

2017-10-23 Thread Jack Zhang
Hi James,

First of all thank you for all your detailed replies.  You have a wealth of 
knowledge.  

I took your advice and chose the separated method.  I decided to use 2 
letters + 8 numbers because 3 letters can render results like 'SEX' and 
'FUK'.

I think I got it right.  Here is my code:

class Dogs(models.Model):

def random_number():
a = random.randint(1000, )
b = Model.objects.values_list('id_numbers')
for num in b:
if a == b:
a = random.randint(1000, )
return a

def random_letter():
import string
a = ''
for i in range(2):
a += random.choice(string.ascii_uppercase)
return a

id_numbers = models.IntegerField(default = random_number)
id_letters = models.CharField(max_length=2, default = random_letter)


On Monday, October 23, 2017 at 4:32:28 AM UTC-4, James Schneider wrote:
>
>
>
> On Oct 22, 2017 8:52 AM, "Jack Zhang" <valac...@gmail.com > 
> wrote:
>
> Let's say I have a model called 'Dogs'.  Users can create instances of 
> Dogs.  For every Dogs instance that is created, I want to assign a globally 
> unique ID to it.  The ID will be 3 capitalized letters followed by 7 
> numbers.  E.g. ABC1234567, POZ2930193
>
> What is the easiest way to go about doing this?  I looked into UUID but it 
> generates a longer string.  Keep in mind that the ID must be globally 
> unique - so after one has been created, it should not be created again.
>
>
> A unique index constraint on the field will ensure that duplicate values 
> are not allowed. There are several ways to go about doing this. Will the 
> ID's be sequential or random? 
>
> If sequential, all of your save operations where an ID is created should 
> be within transaction blocks. ORM operations like .last() come in handy to 
> determine the next available ID. 
>
> One option to consider is splitting the ID into two model fields, one for 
> the 3 character prefix, and the second for the numerical suffix. The "ID" 
> would then be presented to the end user as the concatenation of the two 
> fields. Doing this provides two advantages. Searching against a text string 
> is slow compared to a numerical search. An ID provided by the user is then 
> searched within the DB using the two fields after being easily split in 
> Python, taking advantage of native type indexing in the DB. Secondly, you 
> can choose to take advantage of the DB's auto-increment functionality on 
> the second field. The DB is way more efficient for tracking that. Sure, it 
> will start with 1 and work its way up, but to make a 7 digit number out of 
> that, you just pad it with six zeros before combining it with the prefix 
> just before you display it to the user. It wouldn't matter what the prefix 
> value is at that point. All you would need is the 7 digit code (which would 
> contain mostly zeros at first) to find any record. The prefix would simply 
> be for human interpretation. This strategy does have the side affect of two 
> prefixes never having the same suffix, meaning you'll never have an ID 
> value of ABC001 and POZ001 at the same time. This does limit you to 
> a total of 9,999,999 items between all of your prefixes though. 
>
> If it will be random, then you simply have a math.random(1,1000) 
> function, but you'll need extra logic to determine uniqueness and handle 
> collisions. I'd still recommend breaking it up in to two fields if you know 
> that is always going to be the format of your ID. Keep in mind that if you 
> go the random route, you can never delete a record once it has been created 
> to ensure that the ID is not reused. In this case, the .exists() method is 
> your friend, or you can use the insertion strategy I mentioned in my other 
> thread.
>
> -James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e0ba594d-04c2-46e8-b580-a533655b41d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Building a search form with 4 required choices, which will be inserted as arguments in an URL [warning: long question]

2017-10-23 Thread Jack Zhang
This is a semi-long question.  Please let me know wherever I make a mistake.

I'm building a search form with 4 required choices, 1 of the choices is a 
CharField with a max_length of 3.  The other 3 choices are ChoiceField's.  
Here is a picture of what the search form looks like:



I've read through the Django docs and other things on the Internet but I'm 
still very unclear about how to approach this.

1. First I believe I need to create 4 args or kwargs in the url for each of 
the choices.  If I use args, it would look something like...

url(r'^search?(\w+{3})&(\w+{2})&(\w+{1-2})&(\w+{1-2})', function/class 
view, name='search')

2. Next, I need to pass the user's input in the html page into the url 
args.  I have a form set up to get the user's input.  But how would I write 
this on the HTML page?  Do I simply make a url tag like {% url 'search' 
args1, args2, args3, args4 %}?

3. Then I need to create the views function.  My first question is, should 
I use a function-based view or the generic class-based ListView?  The 
result of the search will be a list of items, so ListView is a good 
template to use, but I don't know how having 4 args would affect using 
ListView.  My second question is, what is the most effective way of making 
this search?  I need to check if any records in the database matches the 
user's search, so would I do something like 'For record in database' to 
check over every record in the database?

If I used a function view, would it look something like:

def search(request, args1, args2, args3, args4):
 for record in database:
  if args matches record:
   display record

Thank you for reading through the question

-- 
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/01912c3f-f10b-4134-8731-908b6585d6c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generating a unique 10 digit ID for each model instance

2017-10-22 Thread Jack Zhang
I need this 10-digit unique ID for every model instance so users can easily 
search up a specific model instance.  It will be publicly displayed on the 
website, unlike a primary key which is usually hidden

On Sunday, October 22, 2017 at 1:31:23 PM UTC-4, Avraham Serour wrote:
>
> The database usually handles this and you don't need to worry, there are 
> many corner cases and DB systems are able to handle them
>
> But they won't look like whatever format you would like, usually it is 
> just a number
>
> Why do you need the IDs to look like that?
>
> On Oct 22, 2017 6:53 PM, "Jack Zhang" <valac...@gmail.com > 
> wrote:
>
>> Let's say I have a model called 'Dogs'.  Users can create instances of 
>> Dogs.  For every Dogs instance that is created, I want to assign a globally 
>> unique ID to it.  The ID will be 3 capitalized letters followed by 7 
>> numbers.  E.g. ABC1234567, POZ2930193
>>
>> What is the easiest way to go about doing this?  I looked into UUID but 
>> it generates a longer string.  Keep in mind that the ID must be globally 
>> unique - so after one has been created, it should not be created again.
>>
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0cd8e33c-8c92-471c-9c36-ac82749750b4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0cd8e33c-8c92-471c-9c36-ac82749750b4%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/e22c52fe-ff85-4d26-806b-4de9bb12e7a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generating a unique 10 digit ID for each model instance

2017-10-22 Thread Jack Zhang
Hi Andréas,

Yes, by globally unique I mean a unique 10-digit ID is assigned to every 
model instance of 'Dogs' within my application.  This ID will be shown 
publicly on the website to allow easy search access to a specific model 
instance.

I think you are right about creating a new field to hold the unique ID, 
instead of using the primary key.  Generating the ID is not too difficult, 
but how can I ensure that I won't generate a duplicate ID?  From briefly 
thinking about it, this is what I got...

When a new instance is created, generate *new ID*
For every *existing ID* in the database:
 If *new ID* == *existing ID* in the database:
  Generate *new ID* and re-run the for loop
If *new ID* does not match any *existing ID * in the database, proceed with 
continuing the model instance.

Also I read up on Signals, but is it necessary?


On Sunday, October 22, 2017 at 12:30:02 PM UTC-4, Andréas Kühne wrote:
>
> Hi,
>
> When you say "globally unique" - I am supposing you mean within your 
> application?
>
> What you need to do is set a field to be the primary key, see : 
> https://docs.djangoproject.com/en/1.11/topics/db/models/#automatic-primary-key-fields
>
> However - it would be simpler to use the standard primary key auto id 
> field, and then add another field to hold your unique ID in it. This could 
> then be created on the pre_save signal and you could write something that 
> randomly generates the unique ID field. See 
> https://docs.djangoproject.com/en/1.11/topics/signals/
>
> Best regards,
>
> Andréas
>
> 2017-10-22 17:52 GMT+02:00 Jack Zhang <valac...@gmail.com >:
>
>> Let's say I have a model called 'Dogs'.  Users can create instances of 
>> Dogs.  For every Dogs instance that is created, I want to assign a globally 
>> unique ID to it.  The ID will be 3 capitalized letters followed by 7 
>> numbers.  E.g. ABC1234567, POZ2930193
>>
>> What is the easiest way to go about doing this?  I looked into UUID but 
>> it generates a longer string.  Keep in mind that the ID must be globally 
>> unique - so after one has been created, it should not be created again.
>>
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0cd8e33c-8c92-471c-9c36-ac82749750b4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0cd8e33c-8c92-471c-9c36-ac82749750b4%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/f7675114-b219-45a3-a7a6-372a223435f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Generating a unique 10 digit ID for each model instance

2017-10-22 Thread Jack Zhang
Let's say I have a model called 'Dogs'.  Users can create instances of 
Dogs.  For every Dogs instance that is created, I want to assign a globally 
unique ID to it.  The ID will be 3 capitalized letters followed by 7 
numbers.  E.g. ABC1234567, POZ2930193

What is the easiest way to go about doing this?  I looked into UUID but it 
generates a longer string.  Keep in mind that the ID must be globally 
unique - so after one has been created, it should not be created again.

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/0cd8e33c-8c92-471c-9c36-ac82749750b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.11 - Best Datepicker to use?

2017-10-21 Thread Jack Zhang
I'm looking for a datepicker widget to use for a DateTime form field.  I 
searched around and most of the answers were old Stack Overflow posts from 
2011 about hacking the calendar datepicker widget from Django's Admin.  The 
information about that was inconclusive and I couldn't get mine to work.

As of right now, what is the best Datepicker I can use for a DateTime form 
field?  It doesn't have to be Django's Admin, or anything fancy.  It just 
has to be perfectly functional.

-- 
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/b8a25047-e89a-4c0a-922a-f2746a07e1df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Getting my head around ForeignKey, One-To-Many and Many-To-Many.

2017-09-13 Thread Jack Razors
I am creating a mindmap visio-like editor website using d3js and a bunch of 
custom javascript.  Rather than the schema/stencils being populated by 
static JSON files, I wanted to create an administration area to edit the 
schema without requiring JSON kung-fu skills and serve the dynamically 
generated JSON to my javascript app on the fly.  

I have 2 models that I am trying to figure out the best way to create a 
relationship between.

class EditorVocab(models.Model):
VOCAB_TYPES = (
('string', 'String'),
('textarea', 'Text Box'),
('list', 'List of values'),
('list-identifier', 'Open Vocabulary/Dictionary'),
('object_ref', 'Object Reference'),
)

vocab_name = models.CharField(max_length=255, unique=False, 
blank=False, null=False)
label = models.CharField(max_length=255, unique=False, blank=False, 
null=False)
help_text = models.CharField(max_length=255, unique=False, blank=True, 
null=True)
default_value = JSONField(default={}, blank=True, db_index=True)
vocab_type = models.CharField(max_length=255, choices=VOCAB_TYPES, 
unique=False, blank=False, null=False)

class Meta:
managed = True
db_table = 'editor_vocabularies'

def __str__(self):
return '%s (%s)' % (self.label, self.vocab_type)


class EditorStencil(models.Model):
stencil_type = models.CharField(max_length=32, unique=True)
stencil_name = models.CharField(max_length=128, unique=False)
stencil_icon = models.FileField(upload_to='stencils')
schema = models.ForeignKey(EditorSchema, on_delete=models.CASCADE)
vocab = models.ManyToManyField(EditorVocab, related_name="vocabs")
vocab_requirement = models.ManyToManyField(EditorVocab, 
related_name="required_vocabs", blank=True)

class Meta:
managed = True
db_table = 'editor_stencil'

def __str__(self):
return '%s (%s)' % (self.stencil_name, self.stencil_name)

I am using Postgres with the jsoneditor integrated into the Django Admin 
area and it works well.  What I would like to have is a One-to-Many 
relationship from EditorStencils -> EditorVocab and be able to 
select/edit/add which "vocabs" are apart of a stencil as well as required. 
 This works with ManyToManyFields but a vocab needs to belong to a stencil. 
 The way it is now, it could potentially belong to multiple stencils (which 
I do not want).

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/55ae3904-85f7-44f0-a288-eaf6a97bdc98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help modifying form on intermediate page of admin action

2017-07-29 Thread Jack Twilley
I looked over those apps and I don't think they'll help with my issue.

Let's say that Crate 1 has a capacity of 12 and currently holds 10 jars. 
 If I look at the jars in Crate 2, select 3 of them, and then trigger the 
admin action to move the selected jars, Crate 1 should *not* be in the drop 
down list on the intermediate form because it only has room for 2 more 
jars.  There isn't really a value entered by the user, it's just the number 
of jars that are selected before the admin action is triggered that matters.

I do not know how to modify the value of dest in an unbound instance of 
MoveMultipleJarsForm based on the length of the queryset.  As a workaround, 
I think I could do some validation in move_multiple_jars() that would check 
the capacity of the destination and generate an error message if the 
destination can't hold all the selected jars, but that seems inelegant.

Jack.

On Saturday, July 29, 2017 at 10:24:02 PM UTC-7, mark wrote:
>
> You might find one of these helpful - 
>
> https://github.com/digi604/django-smart-selects
>
> https://github.com/yourlabs/django-autocomplete-light
>
> Basically, you want a "chained select" that is populated after a value is 
> entered by the user, if I understand the problem. If you want to roll your 
> own, then you need something like ajax or node.js to populate the crate 
> select once you know how many jars you want to ship. 
>
> Another way to think about it, is to use a validation on the crate object 
> to make sure there is room. This solution may not be as elegant, but does 
> not need any additional coding outside of django. 
>
> Good luck!
>
> Mark
>
> On Sat, Jul 29, 2017 at 8:57 PM, Jack Twilley <mat...@gmail.com 
> > wrote:
>
>> I have a Django app which keeps inventory.  There are two relevant 
>> classes here, one named Jar and another named Crate.  The Jar class has an 
>> attribute crate which is a foreign key for the Crate class.  The Crate 
>> class has an attribute capacity of type models.IntegerField which 
>> represents the maximum number of Jar objects that it can hold.  The Crate 
>> class also has a property "jars" which returns "self.jar_set.filter(
>> is_active=True).count()" or in other words, the number of Jar objects 
>> with is_active set to True that are associated with that Crate object.
>>
>> This code is from models.py and shows the two object classes:
>>
>> class Crate(models.Model):
>> number = models.IntegerField()
>> slug = models.SlugField(max_length=10, unique=True, blank=True)
>> capacity = models.IntegerField(default=12)
>> # bin where the crate can currently be found
>> bin = models.ForeignKey(Bin)
>>
>>
>> created_at = models.DateTimeField(auto_now_add=True)
>> updated_at = models.DateTimeField(auto_now=True)
>>
>>
>> class Meta:
>> ordering = ['number']
>>
>>
>> @property
>> def jars(self):
>> return self.jar_set.filter(is_active=True).count()
>>
>>
>> @property
>> def shortname(self):
>> return "C%d" % self.number
>>
>>
>> @property
>> def longname(self):
>> return "Crate %d" % self.number
>>
>>
>> @property
>> def name(self):
>> return self.longname
>>
>>
>> def __str__(self):
>> return self.name
>>
>>
>> def save(self, *args, **kwargs):
>> self.slug = 'c%d' % self.number
>> super(Crate, self).save(*args, **kwargs)
>>
>>
>> def get_absolute_url(self):
>> return reverse('inventory_crate', kwargs={'crate_slug': self.slug
>> })
>>
>>
>> def clean(self):
>> # ensure that the current number of jars is less than or equal 
>> to the capacity
>> if self.jars > self.capacity:
>> raise ValidationError('Capacity of crate exceeded')
>>
>>
>>
>>
>> class Jar(models.Model):
>> product = models.ForeignKey(Product)
>> number = models.IntegerField()
>> slug = models.SlugField(max_length=13, unique=True, blank=True)
>> # volume in liters
>> volume = models.IntegerField(default=1)
>> crate = models.ForeignKey(Crate)
>> # is_active = not yet sold
>> is_active = models.BooleanField(default=True)
>> # is_available = considered 'in stock'
>> is_available = models.BooleanField(default=True)
>> created_at = models.DateTimeField(auto_now_add=True)
>> updated_at = models.DateTimeField(auto_no

Need help modifying form on intermediate page of admin action

2017-07-29 Thread Jack Twilley
t, plural, dest))
return HttpResponseRedirect(request.get_full_path())
if not form:
form = self.MoveMultipleJarsForm()


return render(request, 'admin/move_multiple_jars.djhtml', {
'jars': queryset,
'move_multiple_jars_form': form,
})


move_multiple_jars.short_description = "Move multiple jars to new crate"




admin.site.register(Jar, JarAdmin)


I don't know if it helps, but this is the content of 
admin/move_multiple_jars.djhtml:

{% extends "admin/base_site.html" %}


{% block content %}


Moving multiple jars from crate {{ crate.name }}:



{% csrf_token %}


Move the following jars:



{% for jar in jars %}

{{ jar }}


{% endfor %}



{{ move_multiple_jars_form }}







{% endblock %}



Thank you in advance for any help you may be able to give!

Jack.

-- 
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/c18c7558-55ac-4da2-9fd1-22392090ecf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting 500 error on ASO

2015-12-13 Thread Jack Maxwell
I've got the same problem to configure my Shared Host on QHoster, using 
fastCGI. 

I didn't find a valid tutorial so far.

my config:
/home/username/
| /public_html/.htaccess
|   /index.fcgi
|-/mydjangoVirtualEnv
|-/MyDjangoProject_SRC
  |manage.py
  |MyDjangoProject
  |--settings.py

My .htaccess :

> AddHandler fcgi-script .fcgi
> RewriteEngine On
> RewriteCon %{REQUEST_FILENAME} !-f
> RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]
>

My index.fcgi:

> #!/home/username/djangoenv/bin/python
> import sys
> import os
>
> sys.path.insert(0, "/home/username/djangoenv/lib/python3.4/site-packages")
> sys.path.append("/home/username/MyDjangoProject_SRC/MyDjangoProject")
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'MyDjangoProject.settings'
>
> from django.core.servers.fastcgi import runfastcgi
> runfastcgi(method="threaded", daemonize="false")
>

When I go to my home page, I get a 500 error.
The log from cPanel only displays: 
MY_IP - - [13/Dec/2015:09:34:29 +] "GET / HTTP/1.0" 500 - "-" 
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 
Firefox/42.0"


Any help or even a little suggestions welcome! I can go nowhere from here 
after days of searching... 

-- 
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/0eb8e651-7be8-42a3-bbed-59a7a8187a24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Transform all Django exceptions to JSON?

2015-04-16 Thread jack
Hello, 

I use django rest framework to make API server. DRF catches some Django 
exceptions and transforms them in JSON. However some exceptions, like 404, 
are still returned as Django pages (at least it works that way on my 
machine). How can I wrap all exceptions in JSON from any library? I'm 
working on mobile app and I can't debug html dumps from Django in console 
:( 

Am I missing something important?

-- 
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/d40d4630-e01b-4416-83bd-16a20ac1c161%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django 1.7 migration generates wrong column name for foreign key to a one-to-one model

2015-02-10 Thread Jack Peng
I ran into this problem trying to run manage.py test. The error I get looks 
like this:


ALTER TABLE "quote_agentorderrejection" ADD CONSTRAINT 
"quote_agentor_agent_id_1388a6f8215473de_fk_user_agentprofile_id" FOREIGN 
KEY ("agent_id") REFERENCES "user_agentprofile" ("id") DEFERRABLE INITIALLY 
DEFERRED
Traceback (most recent call last):
File 
"/home/jack/Envs/envp1/lib/python3.4/site-packages/django/db/backends/utils.py",
 
line 66, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "id" referenced in foreign key constraint 
does not exist


I realize this is similar to https://code.djangoproject.com/ticket/23415, 
which has been fixed. However, my case is a little different.


class AgentOrderRejection(models.Model):
agent = models.ForeignKey(AgentProfile)

But AgentProfile itself is a one-to-one model to the user model, so its 
primary key is user_id, not id.

user = models.OneToOneField(USER_MODEL, primary_key=True)

But django 1.7's migration incorrectly identifies id as the primary key and 
looks for it in the agentprofile model and fails. Does anyone have similar 
experiences? Thanks.

Jack



-- 
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/e3d2cdb7-4982-4de7-bd4c-60ca779187a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "Authenticating Users" where should I put the code?

2014-03-06 Thread Jack Yan
Thank you :)

On Friday, March 7, 2014 12:13:26 AM UTC+8, Felipe Coelho wrote:
>
> 2014-03-06 11:45 GMT-03:00 Jack Yan <luce...@gmail.com >:
>
>> in the tutorial and section "Authenticating Users":
>> https://docs.djangoproject.com/en/1.6/topics/auth/default/
>>
>> where can I put code:
>>
>> from django.contrib.auth import authenticateuser = 
>> authenticate(username='john', password='secret')if user is not None:
>> # the password verified for the user
>> if user.is_active:
>> print("User is valid, active and authenticated")
>> else:
>> print("The password is valid, but the account has been 
>> disabled!")else:
>> # the authentication system was unable to verify the username and 
>> password
>> print("The username and password were incorrect.")
>>
>> in what file or what folder?
>>
>
> That is described later in the same page [1].
>
> But if you just want to enable login/logout/password reset for your 
> project, the easiest way is to include Django's default auth views in your 
> urls.py [2].
>
> [1] 
> https://docs.djangoproject.com/en/1.6/topics/auth/default/#how-to-log-a-user-in
> [2] 
> https://docs.djangoproject.com/en/1.6/topics/auth/default/#module-django.contrib.auth.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/ee3a12da-814c-4169-bc59-d160176566a9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


"Authenticating Users" where should I put the code?

2014-03-06 Thread Jack Yan
in the tutorial and section "Authenticating Users":
https://docs.djangoproject.com/en/1.6/topics/auth/default/

where can I put code:

from django.contrib.auth import authenticateuser = 
authenticate(username='john', password='secret')if user is not None:
# the password verified for the user
if user.is_active:
print("User is valid, active and authenticated")
else:
print("The password is valid, but the account has been disabled!")else:
# the authentication system was unable to verify the username and password
print("The username and password were incorrect.")

in what file or what folder?

-- 
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/0654812d-74d5-48a1-a977-26958f417a61%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Hiring Django developers

2013-05-16 Thread Jack Hanna

We are looking to hire Django developers at the following locations:

Los Angeles, CA
San Diego, CA
Seattle, WA
Kuala Lumpur, Malaysia


Skills & Requirements:

Must be at least intermediate or Expert level Python programmer.
Deep experience in building and deployment of Django/Python based web sites.
Basic knowledge of Linux/Unix operating system environments.
Experience with debugging tools and techniques.
Experience of relational databases such as PostgreSQL.
Experience with Search Methodologies django Haystack.
Experience in Data warehouses and Big Data analytics is a plus.
Experience in profiling tools and performance instrumentation is a plus.
Experience with Agile and Continuous development and deployment techniques.
Excellent written and communication skills.

Bonuses:

Hadoop or Caldera.
Solr/Elasticsearch.
Use or understanding of AWS.


How to apply:

Send us an email at j...@fintoo.com , attach your resume and put "Django 
developer & your location" in the subject line.
If you have additional questions feel free to message me at 
jha...@fintoo.com.



Regards,

Jack Hanna

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




Does python(django) have an official database driver to access SQLFire?

2012-01-29 Thread Jack
Hello,

I have a question on Python(django)

Does python(django) have an official database driver to access
SQLFire? Or is there any roadmap to deliver an official database
driver?

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



Doing a relationship lookup from within a model.

2011-10-18 Thread Jack Morgan
I've got 2 tables that are related to each other. Orders and History.
Inside the History table is the 'status' column. Like so..

class Orders(models.Model):
  'order info'

class History(models.Model):
timestamp = models.DateTimeField(auto_add_now = True)
order = models.ForeignKey(Orders)
user = models.ForeignKey(User)
comment = models.TextField()
status = models.CharField(max_length = 20)


I'm storing the status in the History table right now because I need to keep
track of who is moving the orders along.  However, I need to do a lookup on
orders based on their current(most recent) status.  For simplicities purpose
it seems a good idea would be to just put a status field in the Orders table
and update as the Order advances through the stages. However, that creates
duplicate data, which my client has expressed an extreme hatred for.

What It's like to be able to do is something like:
o = Orders.filter(status = 'new')

I'm not entirely sure how or when relationship managers are brought in, so I
was thinking something like this in the Orders model:
status = self.history_set.values('status').order_by('-id')[0]['status']

But that wouldn't let me do a lookup by state.

What's a good Django way to handle this issue?

Thanks!

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



Return a CSV and a template in the same response.

2011-10-03 Thread Jack
Hey gang,
I am trying to use a response object to serve a dynamically created CSV. I have 
that part working perfectly but I'd like to display a page afterwards with a 
summary of the data. Is there a good way to do this? I tired added the rendered 
template to the httpresponse object after I write the CSV into it but it gives 
a header error. 

Thanks in advance

-- 
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: Getting a count of a RawQuerySet object

2011-09-21 Thread Jack Morgan
Hi, thanks!
The issue I'm getting here is that the RawQuerySet object does not have the
.count() method so it just gives an error.
I also just checked that it does not have the 'all()' method either.


On Wed, Sep 21, 2011 at 9:23 AM, <delegb...@timbaobjects.com> wrote:

> Let's say you have a model Utility, you can do
> Utility.objects.all().count()
> Hope that helps.
> Regards.
> Sent from my BlackBerry wireless device from MTN
>
> -Original Message-
> From: Jack <jackofseat...@gmail.com>
> Sender: django-users@googlegroups.com
> Date: Wed, 21 Sep 2011 09:10:49
> To: Django users<django-users@googlegroups.com>
> Reply-To: django-users@googlegroups.com
> Subject: Getting a count of a RawQuerySet object
>
> Hello everyone, I'm quite new to django and python in general so I'm
> sure there's just something I missed in my searching to answer this.
> But...
>
> Is there a way to count the number of results returned in the
> RawQuerySet option?
>
> I've tried the len() function and I've search the django documentation
> with no results. So, any help would be very welcomed.
>
> Thanks!
>
> --
> 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.
>
>

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



Getting a count of a RawQuerySet object

2011-09-21 Thread Jack
Hello everyone, I'm quite new to django and python in general so I'm
sure there's just something I missed in my searching to answer this.
But...

Is there a way to count the number of results returned in the
RawQuerySet option?

I've tried the len() function and I've search the django documentation
with no results. So, any help would be very welcomed.

Thanks!

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



can django be used in destop application?

2011-08-23 Thread smith jack
i mean not use django for web site development, but for desktop application,
it seems its orm can be used in destop application, isn't it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: why i cannot load css from django lib?

2011-08-21 Thread smith jack
Thank you, but i am not using django with apache, but with python
manage.py runserver command, i find it confused, if i set the debug
mode to be true, then things may go well, what happened?

2011/8/21 zhijun wu <pinot...@gmail.com>:
> I've encountered such a problem, so maybe I can help.
> I solved that like this:
> First, make sure you have the right permission to the folder 'media'.
> Then,
> #setting.py
> MEDIA_ROOT='' #Use absolute path
> ADMIN_MEDIA_PAREFIX='' #'/media/', focus on the 2 slashs
> #httpd.conf
>
> Alias /media
> /usr/local/lib/python2.6/site-packages/django/contrib/admin/media  #end
> without slash
>
>   "/usr/local/lib/python2.6/site-packages/django/contrib/admin/media">
> #absolute path
>
> AllowOverride None
>
> Options None
>
> Order allow,deny
>
> Allow from all
>
> 
>
>   #2 slashs
>
> SetHandler None
>
> 
>
>  
>
> SetHandler None
>
> 
>
> 2011/8/21 smith jack <thinke...@gmail.com>
>>
>> face a strange problem, now i am using django.contrib.admin module
>> with its default page, but i cannot load css code now, so the web page
>> is ugly
>> what's wrong?
>>
>> --
>> 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.
>

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



why i cannot load css from django lib?

2011-08-20 Thread smith jack
face a strange problem, now i am using django.contrib.admin module
with its default page, but i cannot load css code now, so the web page
is ugly
what's wrong?

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



How to make pydev suport django specific syntax?

2011-08-19 Thread smith jack
for example, django have some dynamic mechanism, the code can be
processed wel by django, but pydev will just simply show some error
message,
how to make pydev deal with such dynamics?

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



How to change the schma of database using python manage.py syncdb?

2011-08-18 Thread smith jack
for example at first i have a model named url, the code is as follows:

class url(models.Model):
 link=models.URLField(unique=True)

then i change this class as follows:

class url(models.Model):
 link=models.URLField(unique=True)
 hits=models.IntegerField()

at last, i use command  python manage.py syncdb

but was suprised to find that the schema of url table in the database
is not changed

so is there any method to change the shcema of table using django command?

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



Multiple Django/Python developer Positions- Atlanta, GA

2010-10-29 Thread Jack
Good Morning!

I am looking for Django/Python developers to join the team of one our
clients in Atlanta, GA working on one of the largest Django apps EVER
in  - scaled to serve web,mobile, and more for 100+ prominent
newspaper, TV, and radio sites! There are 3-5 job openings and they
are looking for someone who can hit the ground running! Please send me
an e-mail at jmabb...@apexsystemsinc.com or call at (770) 481-0044 and
I would love to tell you more details!

Company:  Leading communications, media and automotive services
company.
Role:  Application Developer
Length:  6 Month to Hire
Location:  Atlanta, GA
Interview Process:  Phone and Face to Face
Compensation:  60k to 100k

Please reply if you or someone you know if looking for a job as a
expert Python or Django Developer.

only US Citizens or Greencard holders need apply

Thanks!

Jack

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: database schemas support for postgresql psycopg2

2009-05-29 Thread Jack Orenstein

On May 29, 2009, at 8:25 PM, david.schruth wrote:

>
> Hello,
>
> I'm trying to get this working for multiple (non public) schemas in
> postgresql databases using the psycopg2 database driver.  I'm using
> the most current svn of django 1.01 (from today).
>
> ...
> Does anybody have a solution for using django with more than one
> schema in postgresql?

I don't use the django ORM, but running the postgres command 'set  
search_path = some_schema,public' works for me. This sets the schema  
search path only for the connection on which the command is run.

Jack

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



Serving static content

2009-03-30 Thread Jack Orenstein

I have my first Django app running, but with very basic html. I'm  
trying to add my first  tag and finding it difficult to serve up  
the image file.

I've read this: http://docs.djangoproject.com/en/dev/howto/static- 
files/?from=olddocs, which points out that having django serve static  
content is "inefficient and insecure", and then points to a reference  
for Apache plus mod_python.

Questions:

1) The method outlined above isn't working for me. urls.py says (for  
my foobar application):

 (r'^media/(?P.*)$', 'django.views.static.serve',   
{'document_root': '/Users/jao/django/foobar/media'}),

/Users/jao/django/foobar/media/images has xyz.gif, and my page says:

 

But when I load the page, the image doesn't show up. I get a little  
box with a question mark in it.


2) I'm not using mod_python, I'm using mod_wsgi. Is the procedure  
pretty close to that of mod_python?


3) Why exactly is the builtin django method insecure?


Thanks for any help.

Jack Orenstein


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Field errors

2009-03-29 Thread Jack Orenstein

On Mar 29, 2009, at 9:35 AM, Matthew Somerville wrote:

>
> Jack Orenstein wrote:
>> On Mar 28, 2009, at 12:26 PM, Daniel Roseman wrote:
>>
>>> On Mar 28, 4:14 pm, Jack Orenstein <j...@geophile.com> wrote:
>>>> My application needs to validate data from a from beyond the
>>>> validation of Fields done by django. So in my form handler, I check
>>>> Form.is_valid, and if that returns true, then I do my own  
>>>> validation.
>
> If you have a field you need to perform more validation on, what you
> should do is give your Form subclass a clean_() method  
> which
> will be called automatically, and should raise a ValidationError if  
> the
> data doesn't validate (which will then put the error in the right  
> place
> for you). Then is_valid() will do Django and your validation together.
> For more information, see
> http://docs.djangoproject.com/en/dev/ref/forms/validation/

Thanks, that's really useful to know about. This works for most of  
the additional validation I need to do, but doesn't fit so well for  
the cross-field validation, (e.g. password and confirm_password  
fields match). Or can I do that by overriding Form.is_valid?

Jack


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with Field errors

2009-03-28 Thread Jack Orenstein

On Mar 28, 2009, at 12:26 PM, Daniel Roseman wrote:

>
> On Mar 28, 4:14 pm, Jack Orenstein <j...@geophile.com> wrote:
>> My application needs to validate data from a from beyond the
>> validation of Fields done by django. So in my form handler, I check
>> Form.is_valid, and if that returns true, then I do my own validation.
>> In case of errors, I attach an error message to the field, e.g.
>>
>>  self.form.fields['foobar'].errors = 'some error message'
>>
>> And then I redisplay the form. But the error message doesn't show up,
>> even though the template includes
>>
>>  {{ form.foobar.errors }}
>>
>> And through logging I have confirmed that the errors attribute of the
>> field has been set, right before the render_to_response call
>> containing the form. I'm guessing that this has something to do with
>> the fact that the form already passed the is_valid check.
>>
>> How can I force the form to become "invalid" again, once my own
>> validation detects errors?
>>
>> Jack Orenstein
>
> Try self.form._errors['foobar'] instead.

That works, thank you.

Why does it work?

Jack

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



Problem with Field errors

2009-03-28 Thread Jack Orenstein

My application needs to validate data from a from beyond the  
validation of Fields done by django. So in my form handler, I check  
Form.is_valid, and if that returns true, then I do my own validation.  
In case of errors, I attach an error message to the field, e.g.

 self.form.fields['foobar'].errors = 'some error message'

And then I redisplay the form. But the error message doesn't show up,  
even though the template includes

 {{ form.foobar.errors }}

And through logging I have confirmed that the errors attribute of the  
field has been set, right before the render_to_response call  
containing the form. I'm guessing that this has something to do with  
the fact that the form already passed the is_valid check.

How can I force the form to become "invalid" again, once my own  
validation detects errors?

Jack Orenstein


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



Problem getting application to run with Apache2 and wsgi

2009-03-20 Thread Jack Orenstein

I'm running Django 1.02 and my application is running with the  
development server. I'm trying to move it over to Apache2 + wsgi.

Here is my httpd.conf setup for wsgi:

 LoadModule wsgi_module modules/mod_wsgi.so
 WSGIScriptAlias /foobar/ "/var/www/html/foobar/wsgi_handler.py"
 WSGIDaemonProcess foobar user=apache group=apache processes=1  
threads=10
 WSGIProcessGroup foobar
 
 Order allow,deny
 Allow from all
 

This isn't in a virtual host. My domain is geophile.com and I want my  
foobar application to be reachable at geophile.com/foobar.

When I go to geophile.com/foobar I get a 404 page:

 Page not found (404)
 Request Method:GET
 Request URL:   http://geophile.com/
 Using the URLconf defined in foobar.urls, Django tried these URL  
patterns, in this order:
 ^foobar/
 The current URL, , didn't match any of these.

What am I doing wrong?

Jack Orenstein

--~--~-~--~~~---~--~~
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: Location of files that are part of my application

2009-03-03 Thread Jack Orenstein

Sorry, I was unclear. I don't mean that these files contain python  
source code. They contain text that I want to read from certain  
requests to my app. So the question is where to put the files (under  
the app directory I assume), and how to refer to them using a  
relative path, or how I can discover the context to specify an  
absolute path.

Jack

On Mar 3, 2009, at 4:58 PM, Briel wrote:

>
> Django makes python aware of your app folder when you install the app
> so you can just do:
>
> from appname.resources.filename import function
>
> That should work whenever your app is propperly installed.
>
> On 3 Mar., 21:41, Jack Orenstein <j...@geophile.com> wrote:
>> I have a small number of files that need to be accessible to my
>> Django application. These are part of the application, and so should
>> be treated as source code. The question is where to put them? Putting
>> them under MEDIA_ROOT doesn't seem right. They go with the
>> application so they should be somewhere under the application
>> directory. Suppose I put them in APPLICATION_NAME/resources -- how
>> would I then refer to these files? I obviously don't want to code an
>> absolute path into my application.
>>
>> Jack
> >


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



Location of files that are part of my application

2009-03-03 Thread Jack Orenstein

I have a small number of files that need to be accessible to my  
Django application. These are part of the application, and so should  
be treated as source code. The question is where to put them? Putting  
them under MEDIA_ROOT doesn't seem right. They go with the  
application so they should be somewhere under the application  
directory. Suppose I put them in APPLICATION_NAME/resources -- how  
would I then refer to these files? I obviously don't want to code an  
absolute path into my application.

Jack

--~--~-~--~~~---~--~~
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: Customizing HTML

2009-02-26 Thread Jack Orenstein

On Feb 26, 2009, at 10:04 PM, Alex Gaynor wrote:

>
>
> On Thu, Feb 26, 2009 at 9:56 PM, Jack Orenstein <j...@geophile.com>  
> wrote:
>
> 
>  value="m" name="gender" /> male
>  value="f" name="gender" /> female
> 
>
> I want to get rid of the ul and li tags, and just put a  between
> the two inputs.
>
> I'm going to try subclassing RadioSelect and overriding render.
>

> Yep that's the right technique for now, there's  aticket to make  
> those widgets that have multiple tags(checkbox and radio input)  
> iterable so you could iterate over it nicely.

That would be nice. Do you know when this is expected to materialize?

Jack

--~--~-~--~~~---~--~~
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: Customizing HTML

2009-02-26 Thread Jack Orenstein

On Feb 26, 2009, at 9:44 PM, Alex Gaynor wrote:

> On Thu, Feb 26, 2009 at 9:42 PM, Jack Orenstein <j...@geophile.com>  
> wrote:
>
> Suggestion: Instead of hardwiring formatting into Django, allow
> attributes to specify formatting. E.g., here is the minimal HTML for
> radio buttons for selecting gender:
>
> Male
> Female
>
> I might want to generate some HTML before the first input, after the
> last, and between adjacent inputs. RadioFieldRenderer does this in a
> hardcoded way. How about providing, through the API, widget
> attributes such as 'before', 'after', and 'in_between'? These could
> default to what RadioFieldRendered does, but I could also substitute
> my own.


But that includes the default formatting I'm trying to get rid of.  
E.g., for the radio example:


 male
 female


I want to get rid of the ul and li tags, and just put a  between  
the two inputs.

I'm going to try subclassing RadioSelect and overriding render.

Jack

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



Customizing HTML

2009-02-26 Thread Jack Orenstein

I'm new to Django, and making good progress rewriting a Struts-based  
website. (It started rotting because I found Struts so painful and  
non-intuitive. Django is so much easier.)

The major problems I'm running into have to do with HTML generation,  
first with error messages, and then with RadioSelect. In general, I  
don't like the, default, as_p or as_ul options. I'm also finding that  
the documentation on how to change the HTML is kind of thin, so I'm  
reading code and guessing. For errors, I ended up doing something  
like this:

 form.errors # Force creation of _errors
 errors = form._errors.items()

I now have a list of unformatted items which I can format anyway I want.

I'm running into a similar problem with RadioSelect. I found  
widgets.RadioFieldRender, but I can't extend it (it isn't exported).

So I have a question and a suggestion.

Question: How do I control HTML generation, ideally at field- or  
widget-level? I feel I must be overlooking something easy.

Suggestion: Instead of hardwiring formatting into Django, allow  
attributes to specify formatting. E.g., here is the minimal HTML for  
radio buttons for selecting gender:

 Male
 Female

I might want to generate some HTML before the first input, after the  
last, and between adjacent inputs. RadioFieldRenderer does this in a  
hardcoded way. How about providing, through the API, widget  
attributes such as 'before', 'after', and 'in_between'? These could  
default to what RadioFieldRendered does, but I could also substitute  
my own.

Jack Orenstein


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django database connections

2009-02-14 Thread Jack Orenstein

I'm trying to understand how Django 1.0 handles connections. This is  
from the django docs, on the subject of raw SQL:

 from django.db import connection
 cursor = connection.cursor()
 cursor.execute("select ...")
 row = cursor.fetchone()

If I have a Django app running lots of requests, then how are  
connections handled? Is connection the same in each request, even  
requests running concurrently? That can't possibly be the case,  
(could it)? So does each request get its own? When are connections  
closed? When closed are they really closed, or just returned to a  
pool? Can the pool be configured, (e.g. to set the postgres  
search_path)?

Sorry to ask such basic questions, but I've been unable to find this  
information documented.

Jack Orenstein


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



Adding fields to model objects that don't correspond to database state

2009-02-08 Thread Jack Orenstein

I have a model object that looks something like this:

   class Foo(models.Model)
   foo_id = models.IntegerField(primary_key = True)
   xyz = models.CharField(max_length = 20)

In my application, I'd like to add a list of Bar objects. It's like a  
foreign key, except that Bar objects don't exist in my databases. So  
I want a Foo.bars field.

- If I just create the field:

   class Foo(models.Model)
   foo_id = models.IntegerField(primary_key = True)
   xyz = models.CharField(max_length = 20)
   bars = []

Then the list belongs to the class, not instances.

- If I try creating the field lazily, e.g.

   class Foo(models.Model)
   foo_id = models.IntegerField(primary_key = True)
   xyz = models.CharField(max_length = 20)

   def attach_bar(self, bar):
   if self.bars is None:
   self.bars = []
   self.bars.append(bar)

Then calling attach_bar from the application results in an  
AttributeError, 'Foo' object has no attribute 'bars'.

- Specifying Foo.__init__ to initialize bars doesn't work, because it  
interferes with creation of Foo objects from database queries.

I played around with subclassing, e.g. class FooBase 
(models.Model) ... class Foo(FooBase) but couldn't get that to work.

How can I add a field to the Foo class that doesn't come from the  
database?

Jack Orenstein

--~--~-~--~~~---~--~~
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: Integrating raw SQL and model objects

2009-02-03 Thread Jack Orenstein

On Feb 3, 2009, at 12:15 AM, Malcolm Tredinnick wrote:

>>
>> 1) How do I turn a row into a model object? There is some discussion
>> of writing raw SQL in the docs (http://docs.djangoproject.com/en/dev/
>> topics/db/sql/#topics-db-sql), but I didn't see anything on turning
>> the row into a model object. Do I need to create a dict from the row
>> values and then call the model object's __init__ method?
>
> Yes.
>
>>  Or is there
>> something simpler that I'm missing?
>
> I realise that's just a turn of phrase, but when I read it  
> literally, I
> have to wonder just how much simpler could it get? :-)
>
> You know the field attribute names, since you constructed the  
> query.You
> have their values, returned from the database. So it's a one-liner:
>
> MyModel(**dict(zip(field_names, row_data)))

This is pretty simple, I agree. I came up with this exact code, but  
then ran into the FK problem, at which point I started wondering if I  
was just going about things the wrong way.

>
>
>> 2) If the model object as a ForeignKey, then the construction of a
>> model object is trickier. From playing around, it appears to be the
>> case that the dict must have an object of the referenced type, not
>> the value of the foreign key. This could make manual construction of
>> model objects difficult. I must be doing something wrong -- forcing
>> creation of the related objects seems wasteful, especially as it
>> could propagate, (if the referenced object has its own FKs).
>
> If you know the id value for the referenced model, you can assign  
> to the
> '*_id' attribute, which is the hidden field containing the related  
> value
> (not the referred-to instance). For example, with a ForeignKey field
> called "foo", you can create a model with foo_id=6 or whatever, to set
> the appropriate element.

Excellent, thanks.

Jack

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



Integrating raw SQL and model objects

2009-02-02 Thread Jack Orenstein

Hello, I am new to Django, and trying to figure out how best to use  
it. My immediate problem is that I'm trying to figure out how to use  
raw SQL in combination with the model layer. Here are the issues I've  
run into:

1) How do I turn a row into a model object? There is some discussion  
of writing raw SQL in the docs (http://docs.djangoproject.com/en/dev/ 
topics/db/sql/#topics-db-sql), but I didn't see anything on turning  
the row into a model object. Do I need to create a dict from the row  
values and then call the model object's __init__ method? Or is there  
something simpler that I'm missing?

2) If the model object as a ForeignKey, then the construction of a  
model object is trickier. From playing around, it appears to be the  
case that the dict must have an object of the referenced type, not  
the value of the foreign key. This could make manual construction of  
model objects difficult. I must be doing something wrong -- forcing  
creation of the related objects seems wasteful, especially as it  
could propagate, (if the referenced object has its own FKs).

Jack Orenstein

--~--~-~--~~~---~--~~
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: Users getting logged out/cookie issues?

2008-05-30 Thread Jack M.

I'm fairly new to django, and I don't know it's intricacies very well,
but common sense says:

1.  Are they changing domains?  Maybe logging in on mydomain.com and
being redirected to www.mydomain.com ?

2.  Are they hopping IP addresses in the middle of their session?
Common for larger corporations with big honking proxies to the outside
world.

3.  Failing that, can you paste the information out of the cookie, as
it may provide more information?

On May 30, 6:47 am, Jarek Zgoda <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] pisze:
>
>
>
> > I've got multiple users all saying roughly the same thing as this
> > one:
> > "I come to the site and log in.  I click on to a page and I'm logged
> > out. I try to log back in and it says my cookies are disabled. Log in
> > - log in - I'm in, and then I click on a page and I'm out again. Over
> > and over Says I'm in, then I'm out again
>
> > Clear all the cookies and delete temporary internet files and I'm
> > good...for a couple hours and then the whole thing starts again."
>
> > It's turned up mostly with IE6, but I've seen reports from people on
> > Mozilla-based browsers, too.
>
> > Caching is turned on using memcached, with
> > CACHE_MIDDLEWARE_ANONYMOUS_ONLY set to True
> > I do have two sites running and thought maybe there was an issue with
> > the cookies or sessions conflicting, so I have at least one of the
> > sites setting a SESSION_COOKIE_DOMAIN.
>
> I'm getting the same on my sites, mostly with IE6, but sometimes happens
> with IE7. I'm using 0.96.
>
> --
> Jarek Zgoda
> Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101
>
> "We read Knuth so you don't have to." (Tim Peters)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i18n issues.

2008-05-30 Thread Jack M.

Holy crap I'm an idiot.
Thanks, Ramiro, you hit the nail on the head.  I've been using sp for
spanish for so long I completely spaced that it is incorrect usage.
Once I switched to es everything worked.

Another one chalked up to PEBKAC.

Thanks,
-Jack


On May 29, 3:54 pm, "Ramiro Morales" <[EMAIL PROTECTED]> wrote:
> Jack,
>
> On Thu, May 29, 2008 at 2:51 PM, Jack M. <[EMAIL PROTECTED]> wrote:
>
> > [...]
>
> >  Used make-message.py -l sp to generate the Spanish language files.
>
> Why are you using "sp" for Spanish?. You should be using "es" as that's the
> two-letter code for the spanish language used both by the gettext
> infrastructure and the browser language preferences.
>
> If you insist on using a new "sp" custom language code you will need to make
> sure:
>
> a) you (and your users') browsers sends "sp" in the list of languages
>preference represented by the Accept-Language HTTP request header.
>
> b) you create a minimal translation of Django to "sp" (in addition to the
>translation of your app), as per the "Locale restrictions" note here:
>
>  http://www.djangoproject.com/documentation/i18n/#how-to-create-langua...
>
>and here:
>
>  http://www.djangobook.com/en/1.0/chapter18/
>
>(starting on the paragraph that begins with: "The LocaleMiddleware can only
> select languages for which there is a Django-provided base translation.")
>
> But even if you do that, I'm not sure you will get because the GNU gettext
> machinery Django uses might simply refuse to handle a language that doesn't
> exist (from what I can see "sp" isn't a two-lteer code known by gettext), so I
> can't imagine why would you want to embark yourself in such a task.
>
> Regards,
>
> --
>  Ramiro Morales
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



i18n issues.

2008-05-29 Thread Jack M.

Hello, all.  Forgive me as I'm still fairly new to django, but I'm
having some issues getting i18n running, and I can't seem to find any
help in the online docs.

I've read chapter 18 (i18n) of djangobook.com, and chapter 10 relating
to RequestContext.  I've also read the docs on djangoproject.com for
the same subjects.

Basic problem description:  No matter what language I select, I get
English output.

My setup:
  OSX.5.3
  manually compiled gettext from source because xgettext was missing
from OSX.
  django from svn revision 7565 (did an update this morning).
  brand new project just for testing this functionality.
  mysql database (ran manage.py syncdb after getting the middle ware
setup).

What I've written:
  url r'^i18n/$' mapped to:  include('django.conf.urls.i18n') per
djangobook.com and djangoproject.com
  url r'^lang/' mapped to dolang from my views, which displays the
example code from djangobook.com on how to switch languages.  Changed
method="get" to POST so that it'll actually work.
  url r'^$' to hello_world from my views, which displays a template
say_hello.html with a simple string as output and a link to /lang/.

Hurtles I've already crossed:
  Made sure to use RequestContext in every (or both, whatever :)
request.
  Used make-message.py -l sp to generate the Spanish language files.
  Translated the two tokens (views.py:10, and templates/say_hello.html:
7) in the locale/sp/LC_MESSAGES_django.po file.
  Used compile-messages.py to compile the language into the django.mo
file.
  Ensured that the cookie is being set in my browser for the session,
and that the language is being saved to the session.
  Ensured that the language is in fact being saved to
request.LANGUAGE_CODE.
  Tried simply printing the string and bypassing the templates all
together.  Always outputs English.
  Pounded head into wall multiple times.

Any help is greatly appreciated.  I'm really excited about pitching
django to upper management and ridding myself of the perl hell I've
been tossed into.  ^_^

Below is the code, I'll leave out obvious things like import
statements.

-- views.py --
def dolang(request):
return render_to_response('dolang.html', {},
context_instance=RequestContext(request))

def hello_world(request):
string = _("Hello %(lang)s world!") % {'lang':
request.LANGUAGE_CODE}
print request.session['django_language']
print string
return render_to_response('say_hello.html', {'string': string},
context_instance=RequestContext(request))
-- / views.py --

-- urls.py --
urlpatterns = patterns('',
(r'^i18n/', include('django.conf.urls.i18n')),
(r'^lang/', dolang),
(r'^$', hello_world),
)
-- / urls.py --

-- templates/say_hello.html --
{% load i18n %}



{{ string }}

{% trans "Choose a language" %}


-- / templates/say_hello.html --
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database Migration Question

2008-05-06 Thread jack

Russ - We had a few back and forths about this several weeks ago, if
you recall.  I now am much better versed in Django and so maybe a bit
more capable of making intelligent comments.

It would seem to me that with the primitives that I am seeking (which
is basically a continuation of hiding the SQL specifics of each DMBS
using Python code) all kinds of migration capabilities can easily be
implemented.  In fact, I can see several options, all valid, that each
developer can choose for their project.  That way Django would not
have to decide in advance how to do migrations.   Some may prefer
whole frameworks and specific methodologies, others will prefer to
roll their own.  For all intents and purposes, many of these
primitives already exist, at least for the initial creation of tables
from model class definitions, why not extend it to the next level and
provide the same toosl for Django developers to create tables and
modify them?  Seems like a natural to me.  I would write it myself,
but I am too rusty with SQL and the different syntaxes across
databases to be able to really dive in at this point.  But I would
enjoy collaborating on design and proposed implementation with anyone
who was willing and capable of tackling this task.

Jack

On May 5, 9:34 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Tue, May 6, 2008 at 11:57 AM, jack <[EMAIL PROTECTED]> wrote:
>
> >  Are there any Python/Django methods that represent generic database
> >  commands such as creating a new table, renaming or dropping a column,
> >  etc.?  My thinking is that if these generic methods existed, so that
> >  all I needed to do was specifiy the correct info abt my DBMS in the
> >  Settings file, I could create my own migrations as custom Views.  I
> >  could invoke these via the web as well after having copied my latest
> >  code to my production server.
>
> There isn't anything built into Python or Django, but there are a few
> projects running externally to Django that implement this sort of
> feature.
>
> Personally, I would recommend Django Evolution [1] - but then, I'm one
> of the developers of that project. If you search the django-users and
> django-developers archives for "schema evolution", you will find
> references to a few other projects.
>
> [1]http://code.google.com/p/django-evolution
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Database Migration Question

2008-05-05 Thread jack

Are there any Python/Django methods that represent generic database
commands such as creating a new table, renaming or dropping a column,
etc.?  My thinking is that if these generic methods existed, so that
all I needed to do was specifiy the correct info abt my DBMS in the
Settings file, I could create my own migrations as custom Views.  I
could invoke these via the web as well after having copied my latest
code to my production server.

If these methods do not exist, how difficult would it be to create
them?

Jack
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >