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

2020-01-04 Thread Eduardo Cervantes
1. No. The data for 2000,2010 could be in one table
2.. you can create a view that accepts get and post. Get when the user
loads the page initially to fill it out  and Post when they submit it. This
should take them to a new page with the results or a refreshed view if you
are using a JavaScript library.
3. Yes. You need to pass the input of the form as a search parameter to the
post view code.
4.dont worry, this is a small hump and you get over it.

Btw - you should clean up your repo, it has a ton of stuff, ie your whole
virtual env with binaries and executables in it that should never really be
checked in. It could use a requirement.txt and a .gitignore file as well.

Cheers,
Eduardo
https://eddyizm.github.io/resume/


On Fri, Jan 3, 2020, 15:11 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:
>
>1. Should I combine the DB's to "respond" to the users input or keep
>DB's (2000, 2010) separate?
>2. 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".
>3. Is POST what the user inputs? If so, how do I "search through the
>existing DB"?
>4. 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/CALZhWrcM--2KKOfTJQkSXXWRz%2BHvtnD2Rcu4vis4KM-xuBdjiA%40mail.gmail.com.


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

2020-01-04 Thread Integr@te System
Hi friend,

# dont separate bc of the same type of field on one object. ( or find more
zipcode service provider for more options)

# with get/post method you shoud refer more docs, it just view/create
action.

# consider review source, a lot comment in your code base and few err
commands.
Think of zen.



On Sat, Jan 4, 2020, 06:11 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:
>
>1. Should I combine the DB's to "respond" to the users input or keep
>DB's (2000, 2010) separate?
>2. 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".
>3. Is POST what the user inputs? If so, how do I "search through the
>existing DB"?
>4. 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/CAP5HUWpdzGaBg4UEcOUfirLq%2BBYUYiDfe-W5rZ1_3JVZHauPgw%40mail.gmail.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.


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

2020-01-03 Thread nmaxbe...@gmail.com
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: 

   1. Should I combine the DB's to "respond" to the users input or keep 
   DB's (2000, 2010) separate?
   2. 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".
   3. Is POST what the user inputs? If so, how do I "search through the 
   existing DB"?
   4. 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.


How to create "form" from "model" with 2 foreign keys?

2020-01-03 Thread strang
Context: I'm new to Django. I've just completed the tutorial on the Docs 
page. I'm trying to make a coffee ordering application. Basically a person 
has to enter his details and select coffee along with number of cups.
Now a person may select 2 or 3 of the same type of coffee, or he may select 
multiple coffee types.

I've attached my models.py file. How do i make a form for this mode?

-- 
You received this message because you are subscribed to the Google Groups 
"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/444aa5a1-5020-4970-8b7e-c5f2225a760c%40googlegroups.com.
'''
REFERENCE: https://stackoverflow.com/questions/53091688/modeling-product-orders-in-django
'''


from django.db import models
from django.utils import timezone
from django.core.validators import RegexValidator


import datetime


# Create your models here.
class Customer(models.Model):
name = models.CharField(max_length=50)

phone_regex = RegexValidator(regex='^\+?1?\d{9,15}$',  message="Phone number must be entered in the format: '+9'. Up to 15 digits allowed.")
phone_number = models.CharField(validators=[phone_regex], max_length=17, blank=False)

email = models.EmailField(max_length=254)
dob = models.DateField(blank=True)

def __str__(self):
return self.name


class Product(models.Model):
item_name = models.CharField(max_length=255)
price = models.PositiveIntegerField()

def __str__(self):
return self.item_name


class OrderDetail(models.Model):
order = models.ForeignKey(Customer, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)
order_date_time = models.DateTimeField()

def __str__(self):
return self.order.name


Re: How to create form??

2018-09-23 Thread Mateusz
This may not seem simple, but it is.
1) You need a model with all the fields (docs 
<https://docs.djangoproject.com/en/2.1/topics/db/models/>),
2) Register that model to be visible on admin page (docs 
<https://docs.djangoproject.com/en/2.1/ref/contrib/admin/#modeladmin-objects>
),
3) Create a forms.py file inside your app folder and form class inside that 
file (docs 
<https://docs.djangoproject.com/en/2.1/topics/forms/#the-form-class>),
4) Create a simple template, it needs to have specific name or that name 
must be specified in a view from point 4 (same docs page as in 3),
5) Handle the form in views.py by adding a class-based FormView (docs 
<https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#formview>
),
6) Add the specific url to urls.py.

For more info about template creation visit: 
https://simpleisbetterthancomplex.com/article/2017/08/19/how-to-render-django-form-manually.html

W dniu niedziela, 23 września 2018 17:52:00 UTC+2 użytkownik Ansari Sabir 
napisał:
>
> How to create a form that collect information (like first name, last name, 
> email address, contact number, gender) and admin can see that information 
> in the /admin/ in django. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"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/94746cc2-2e64-4182-a659-be73848c4e66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to create form??

2018-09-23 Thread Jani Tiainen
Hi.

If you have done the official tutorial, part 4 is all about this exact
problem.


su 23. syysk. 2018 klo 18.51 Ansari Sabir  kirjoitti:

> How to create a form that collect information (like first name, last name,
> email address, contact number, gender) and admin can see that information
> in the /admin/ in django.
>
> --
> You received this message because you are subscribed to the Google Groups
> "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/71966989-c435-4d68-968b-6f36bdf4b34f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/71966989-c435-4d68-968b-6f36bdf4b34f%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/CAHn91ofxcSfFE8aJsX678eD6tQUEyNH3WYXENRQL1TiGAGyYFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to create form??

2018-09-23 Thread Ansari Sabir
How to create a form that collect information (like first name, last name, 
email address, contact number, gender) and admin can see that information 
in the /admin/ in django. 

-- 
You received this message because you are subscribed to the Google Groups 
"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/71966989-c435-4d68-968b-6f36bdf4b34f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to create form from odd model

2012-04-30 Thread Adam S
Hi,
I am working with an existing database where I am unable to change the
schema and having some trouble trying to deal with presenting forms.
The structure in question is as follows and all models are unmanaged.

class Persons(models.Model):
personid = models.BigIntegerField(primary_key=True,
db_column='PersonID')


class Phones(models.Model):
phoneid = models.BigIntegerField(primary_key=True,
db_column='PhoneID')
number = models.CharField(max_length=60, db_column='Number',
blank=True)
type = models.CharField(max_length=15, db_column='Type',
blank=True)
...

class Personsphones(models.Model):
personphoneid = models.BigIntegerField(primary_key=True,
db_column='PersonPhoneID')
personid = models.ForeignKey(Persons, db_column='PersonID')
phoneid = models.ForeignKey(Phones, db_column='PhoneID')
...

I want to create a form to display all of the 'Phones' associated with
a particular 'Persons' and in addition be able to modify/add/remove
'Phones' belonging to a 'Persons'. Right now the only thing I can
think of is to display the 'Phones' in a modelformset and then if one
is added or removed manually set the 'Personsphones' relation. Any
ideas on how to best deal with this model setup? If I manually need to
update the relationships should I just create a custom save() for my
'Phones' form?

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