Re: Pass these specific model objects to one template

2016-03-21 Thread Pemby



All of the above seems to be working the way I expect it to. I can get the 
data I am after and pass it to a template. Now I would like take all 
objects, of the below model, and pass all these objects it to my 
'/signup.html/'* IN ADDTION* to what is being passed above so I can start* 
form *processing. 

class Elective( models.Model ):
elective_title = models.CharField( max_length=100 )
elective_description = models.CharField( max_length=100 )

def __str__(self):
return "{0}".format( self.elective_title )



I tried following Django Pass Multiple Models to one Template 


and Refer to multiple Models in View/Template in Django 

 

With unsuccessful results, and now that I have been working on this for 
some time now I thought my next best move is to ask for help. 

-- 
You received this message because you are subscribed 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/d9801311-3793-4931-a736-03d28ac50004%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pass these specific model objects to one template

2016-03-21 Thread Pemby
Person Model

class Person( models.Model ):
first_name = models.CharField( max_length=50 )
last_name = models.CharField( max_length=50 )

def __str__(self): 
return "{0} {1}".format( self.first_name, self.last_name )


View Function

def getPersonData(request):
currPersonData = {}

# get current user
currentUser = request.user
# create a person object based on who is logged in. 
person = Person.objects.create(first_name=currentUser.first_name,
   last_name=currentUser.last_name)  
   # getting front loaded personMeta, that user 
CANNOT provide

# get front-loaded person data based on who is currently logged in
personDetails = 
PersonMeta.objects.filter(legal_first_name=currentUser.first_name,
  
legal_last_name=currentUser.last_name).values()
# setting hash key for dict 
currUserKey = "{0} {1}".format(currentUser.first_name, 
currentUser.last_name)

# setting dictionary
# data[currUserKey] = currentUser
# if person details is not false
if (personDetails):
currPersonData[currUserKey] = personDetails

return currPersonData


View Call

def signup(request):
currPersonData = getPersonData( request )
return render( request, '/signup.html/', {'data': sorted( 
currPersonData.items( ) )}, )


URL 

url(r'^signup/$', views.signup),


Template 





SignUp



{% for tuple in data %}
Tuple key: {{ tuple.0 }}
{% for key, value in tuple.1.0.items %}
Dict key, value: {{ key }}: {{ value }}
{% endfor %}
{% endfor %}


{% for values in eb %}
values
{% endfor %}






All of the above seems to be working the way I expect it to. I can get the 
data I am after and pass it to a template. Now I would like take all 
objects, of the below model, and pass all these objects it to my 
'/signup.html/' so I can start from processing. 

class Elective( models.Model ):
elective_title = models.CharField( max_length=100 )
elective_description = models.CharField( max_length=100 )

def __str__(self):
return "{0}".format( self.elective_title )



I tried following Django Pass Multiple Models to one Template 


and Refer to multiple Models in View/Template in Django 

 

With unsuccessful results, and now that I have been working on this for 
some time now I thought my next best move is to ask for help. 

-- 
You received this message because you are subscribed 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/59859122-6816-4935-9bfa-530013ce994f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Architecture of multiple Sites

2016-03-21 Thread jorrit787
I'm wondering if I understand the Sites framework correctly... I'm building 
a forum-like project which will initially be accessible from mydomain.com . 
The project contains several apps like posts, members, ads, etc. Eventually 
I would like to create myseconddomain.com, which would have unique posts, 
but share the members, ads, etc. apps and look the same as the first site 
except for the domain name and title in the header. The code will be 
identical to the first site. Can I achieve this with a single project and 
several SITE_IDs, or am I correct in thinking that the Sites framework is 
only for sharing the same database across projects, and not the code files? 
And if there is a way to share the code files, how do you get around the 
fact that you set SITE_ID once in settings.py?

Thanks in advance for the help!

-- 
You received this message because you are subscribed 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/86d91419-1f66-48ef-a936-b43ac12699ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: server connection reset when click on localhost: Python error: wsgiref-> simple_server.py "noneType" object has no attribute split

2016-03-21 Thread amarshall
Figured it out.. In case anyone else was wondering or comes across this. I 
went into the wsgiref/simple_server.py file and commented out that line of 
code:
/usr/lib/python2.7/wsgiref/simple_server.py", line 33, in close
self.status.split(' ',1)[0], self.bytes_sent

After commenting that out another set of errors arose. More detailed and 
told me I was missing a package. So I installed that package and all was 
well. Guess I forgot to do another pip freeze into my requirements 
file..Really simple thing that I completely missed. So if anyone else has 
this issue you may be missing a package and Django isn't telling you 
because it hasn't reached a certain line of code yet or some other reason.

On Thursday, March 17, 2016 at 9:08:41 PM UTC-4, amarshall wrote:
>
>
> So I'm moving my work environment from one environment to the next. I did 
> a pip install -r requirements for a list of packages I had. setup the DB. 
> Migration went good. I do runserver and that runs. BUT when I click on the 
> link to the homepage it says "The Connection was reset" in my browser. In 
> my stacktrace is the below message. I've searched and found similar errors 
> on the internet but none django related with a fix. any help
>
> Here's the traceback I get:
>
> Exception happened during processing of request from ('127.0.0.1', 56784)
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/SocketServer.py", line 593, in 
> process_request_thread
> self.finish_request(request, client_address)
>   File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
> self.RequestHandlerClass(request, client_address, self)
>   File 
> "/home/adrian/.virtualenvs/sneak8env/local/lib/python2.7/site-packages/django/core/servers/basehttp.py"
> , line 102, in __init__
> super(WSGIRequestHandler, self).__init__(*args, **kwargs)
>   File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
> self.handle()
>   File 
> "/home/adrian/.virtualenvs/sneak8env/local/lib/python2.7/site-packages/django/core/servers/basehttp.py"
> , line 182, in handle
> handler.run(self.server.get_app())
>   File "/usr/lib/python2.7/wsgiref/handlers.py", line 92, in run
> self.close()
>   File "/usr/lib/python2.7/wsgiref/simple_server.py", line 33, in close
> self.status.split(' ',1)[0], self.bytes_sent
> AttributeError: 'NoneType' object has no attribute 'split'
>
>
>
>

-- 
You received this message because you are subscribed 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/8f5cd8ae-690c-44bb-8581-7707b15dd431%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django models choices

2016-03-21 Thread Mike Dewhirst

On 21/03/2016 7:29 PM, Amine Yaiche wrote:

Hi everyone,

Given a field in a model that uses choices:

|
CHOICES =(
   (0,"choice_0"),
   (1,"choice_1")
)

foo =models.IntegerField(choices=CHOICES)
|


If i put a value other than 0 or 1, django will accept it. Is that
possible that we instruct Django to accept only values that are
mentioned in CHOICES without creating a validator function.


Why don't you want to validate in the model?

I find it valuable to put all sorts of validators in the clean() method 
and raise a ValidationError to force the user to enter good data. eg.,


if self.foo not in CHOICES:
raise ValidationError("bad foo")

Unless there are special reasons otherwise, I think it is much better in 
the model than the form.


Mike




--
You received this message because you are subscribed 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/78d84aa0-506f-4d5c-9590-ef6325c255e0%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/56F0891E.9060500%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


DJANGO TUTORIAL

2016-03-21 Thread Anthony W Smith
When I follow django tutorial on the django site for the polls app I keep 
getting the error after runnig the python manage.py runserver command it 
says no modsule named my site.  Please help
Anthony

-- 
You received this message because you are subscribed 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/ac171014-6e1b-4a93-bf07-daa90f2d6475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hey guys can anyone let me know where I can get some of good Django base web apps

2016-03-21 Thread Luis Zárate
https://www.djangopackages.com/


El lunes, 21 de marzo de 2016, Tibin Geo k k 
escribió:
> I am looking for some good Django web applications,  if we have any site
to download some Django projects let me know
>
> --
> You received this message because you are subscribed 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/f6f82ee9-653a-438f-920d-9e0c5572c627%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed 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/CAG%2B5VyPmFURYv%3D4MvJvdZzxqPuZT-EfckJA61srzmj%3Dva%3DmANQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Who known best solution for resolve problem with building chart in Django power by Python3?

2016-03-21 Thread Larry Martell
On Mon, Mar 21, 2016 at 4:57 PM,   wrote:
> I have method model, that will return pie chart on each instance model. But
> I so far not found normal django-apps for solving problem with creating
> chart on my data.

I use plotly

https://plot.ly/

-- 
You received this message because you are subscribed 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/CACwCsY67_C6MXm1uxVprjLhhK%2Byb8dG1F6RuYP0ELiR5es5TOQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Who known best solution for resolve problem with building chart in Django power by Python3?

2016-03-21 Thread setivolkylany
I have method model, that will return pie chart on each instance model. But 
I so far not found normal django-apps for solving problem with creating 
chart on my data.

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/efb580e3-c0ac-4e0c-a818-91d207ad2b9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Script para automatizar herramientas de desarrollo (automate-dev-tools)

2016-03-21 Thread David Pineda
Comparto script de bash qoue les permitirá automatizar las herramientas de
desarrollo de django,

https://gist.github.com/dpineiden/4c4a20a9cf0eabbe1754

Se ejecuta:

source ~/automate_Django_dev.sh -f="PROJECT_FOLDER" -p='project' -s -g -rp
-d

Corre:

-shell
-server
-gulp
-git
-sphinx-autodocument
-django-extensions {shell,runserver}_plus

-- 
David A. Pineda Osorio
F:+56 9 82142267
Ingeniero Civil Electricista
Universidad de Chile

*http://www.cultura-libre.cl/ *

-- 
You received this message because you are subscribed 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/CAAn3imz7ByCm3qY4_nqra%2BzW8QUEHDugU-qL4rAVYKcMP4%3D0pQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Hey guys can anyone let me know where I can get some of good Django base web apps

2016-03-21 Thread Tibin Geo k k
I am looking for some good Django web applications,  if we have any site to 
download some Django projects let me know

-- 
You received this message because you are subscribed 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/f6f82ee9-653a-438f-920d-9e0c5572c627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django models choices

2016-03-21 Thread Amandeep Singh
The choices don't enforce any default validation. But if you are populating
the data from a http call then use ModelForm they show the invalid_choice
error message on entering value other than defined choices

On Mon, Mar 21, 2016 at 1:59 PM, Amine Yaiche  wrote:

> Hi everyone,
>
> Given a field in a model that uses choices:
>
> CHOICES = (
> (0, "choice_0"),
> (1, "choice_1")
> )
>
> foo = models.IntegerField(choices=CHOICES)
>
>
> If i put a value other than 0 or 1, django will accept it. Is that
> possible that we instruct Django to accept only values that are mentioned
> in CHOICES without creating a validator function.
>
> --
> You received this message because you are subscribed 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/78d84aa0-506f-4d5c-9590-ef6325c255e0%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/CAMi_2%3DETuiuo%3D0xcz%3D3haWv5ayXpurpMazZP1rUsdEcLYxJ%3DJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django models choices

2016-03-21 Thread Amine Yaiche
Hi everyone,

Given a field in a model that uses choices:

CHOICES = (
(0, "choice_0"),
(1, "choice_1")
)

foo = models.IntegerField(choices=CHOICES)


If i put a value other than 0 or 1, django will accept it. Is that possible 
that we instruct Django to accept only values that are mentioned in CHOICES 
without creating a validator function.

-- 
You received this message because you are subscribed 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/78d84aa0-506f-4d5c-9590-ef6325c255e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Override default fields in ModelForm

2016-03-21 Thread Ham Kibz
Here is the link to the 
question 
http://stackoverflow.com/questions/36124194/how-do-i-override-a-modelform-fields-attribute?noredirect=1#comment59888797_36124194


-- 
You received this message because you are subscribed 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/e82584d2-eae9-44a5-b926-d69c4b2296a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.