I am not able to run the following code

2016-05-26 Thread Madhusudhana H V


I am trying to execute the following code. But I am getting error at step 2, 
namely ">>> t = template.Template('My name is {{ name }}.')"
Kindly help me out of this.

>>> from django import template>>> t = template.Template('My name is {{ name 
>>> }}.')>>> c = template.Context({'name': 'Adrian'})>>> print t.render(c)My 
>>> name is Adrian.>>> c = template.Context({'name': 'Fred'})>>> print 
>>> t.render(c)My name is Fred.

Thanks and Regards,
Madhusudhana H V

-- 
You received this message because you are subscribed 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/1da7713e-5019-4a96-b026-30ff4ecc13bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django ~

2016-05-26 Thread 鈴木一朗
Newborn ! very exiting haha

-- 
You received this message because you are subscribed 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/5f6909cd-ef79-4da0-99f6-0530be9a99f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Beginner

2016-05-26 Thread Atchuta Saikumar
Hello ...
I want to learn Django.I have some basic knowledge in python but don't know 
oop concepts in python.what to do now?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/44bad709-1c35-40ec-a154-1792a2cf3b14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Live video streaming from ffserver

2016-05-26 Thread Jahan Balasubramaniam
Hi

I have setup a ffserver which provides live video stream in the local 
network over http.

What I want is django app which enables me to do some authentication stuff 
and stream from local network to outside world.

I have more than decent amount of knowledge in Django and have done dozen 
projects using django framework.

I m very much clueless and even wondering how to begin with this.

If anyone with knowledge on how to accomplish this sort of stuff could 
provide some guidance would be helpful.

Even just a hint or starting tip off would be of great help.

Regards
Jahan

-- 
You received this message because you are subscribed 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/01b0be1b-cc37-41c9-b747-d7e329407a92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Beginner

2016-05-26 Thread Matthias Müller
h, what about making the tutorial ?

https://docs.djangoproject.com/en/1.9/intro/tutorial01/

enjoy it !



2016-05-26 9:16 GMT+02:00 Atchuta Saikumar :

> Hello ...
> I want to learn Django.I have some basic knowledge in python but don't
> know oop concepts in python.what to do now?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/44bad709-1c35-40ec-a154-1792a2cf3b14%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/CAA2xsHSZG91o-MVwvYZ27FO_xAND6QVYpxPYYCCxU4u-7HkmzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Live video streaming from ffserver

2016-05-26 Thread Javier Rivera
You can try to use a proxy. Maybe not the most performance-wise idea in 
the world, but it could work.


You can try this:

http://django-http-proxy.readthedocs.io/en/stable/

Best regards,

Javier.


On 26/05/16 12:38, Jahan Balasubramaniam wrote:

Hi

I have setup a ffserver which provides live video stream in the local
network over http.

What I want is django app which enables me to do some authentication
stuff and stream from local network to outside world.

I have more than decent amount of knowledge in Django and have done
dozen projects using django framework.

I m very much clueless and even wondering how to begin with this.

If anyone with knowledge on how to accomplish this sort of stuff could
provide some guidance would be helpful.

Even just a hint or starting tip off would be of great help.

Regards
Jahan

--
You received this message because you are subscribed 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/01b0be1b-cc37-41c9-b747-d7e329407a92%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/5746E271.8090701%40castroparga.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Beginner

2016-05-26 Thread Jani Tiainen
And after that official tutorial there exists Django Girls and Django 
Taskbuster which are much more verbose tutorials.


On 26.05.2016 14:45, Matthias Müller wrote:

h, what about making the tutorial ?

https://docs.djangoproject.com/en/1.9/intro/tutorial01/

enjoy it !



2016-05-26 9:16 GMT+02:00 Atchuta Saikumar >:


Hello ...
I want to learn Django.I have some basic knowledge in python but
don't know oop concepts in python.what to do now?
-- 
You received this message because you are subscribed to the Google

Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/44bad709-1c35-40ec-a154-1792a2cf3b14%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/CAA2xsHSZG91o-MVwvYZ27FO_xAND6QVYpxPYYCCxU4u-7HkmzQ%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/5746EA71.3090600%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to select undetermined field(s) in django model?

2016-05-26 Thread Jianshu Hu
To all,

I am new to django, and learning to establish a site.

Here is my problem:
I have got a databse and a table in mysql, and am using django to read 
the data from it.
I got a pair of values [FIELD_NAME,VALUE] from the GET method of a html 
page. When the values passed to the searching function, I want to get the 
searching result.
I knew how to do this in MySQLdb, but unable to achieve it in django 
model.
In MySQLdb:
cur.execute("SELECT COLUMN_A,COLUMN_B,COLUMN_C FROM mydatabase 
WHERE %s=%s",(filed_name,value))
However, in django:
results=mydatabase.objects.filter(filed_name=value)
I got an error: Cannot resolve keyword 'filed1' into field. Choices 
are: Bla bla bla

   What should I do?

Bests.
 
 

-- 
You received this message because you are subscribed 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/bddb8755-33d2-4bb4-9769-3fb350a43ff0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Beginner

2016-05-26 Thread Ketan Bhatt
The official tutorial is difficult for a beginner, it was for me.

I would suggest you start with Django girls, or "Tango with Django"

On Thu, May 26, 2016, 5:52 PM Jani Tiainen  wrote:

> And after that official tutorial there exists Django Girls and Django
> Taskbuster which are much more verbose tutorials.
>
>
> On 26.05.2016 14:45, Matthias Müller wrote:
>
> h, what about making the tutorial ?
>
> https://docs.djangoproject.com/en/1.9/intro/tutorial01/
>
> enjoy it !
>
>
>
> 2016-05-26 9:16 GMT+02:00 Atchuta Saikumar :
>
>> Hello ...
>> I want to learn Django.I have some basic knowledge in python but don't
>> know oop concepts in python.what to do now?
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/44bad709-1c35-40ec-a154-1792a2cf3b14%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/CAA2xsHSZG91o-MVwvYZ27FO_xAND6QVYpxPYYCCxU4u-7HkmzQ%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/5746EA71.3090600%40gmail.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/CACyRkBWu4w4%2B3E%2BkmOwFAtwpTDvjhn9-%3DUcUs9%2By18%3DThDPdbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select undetermined field(s) in django model?

2016-05-26 Thread Ketan Bhatt
It just means the "field_name" you are using in the filter query doesn't
exist.

Multiple reasons:
1. The model doesn't really have that field in its definition.
2. You forgot migrating your database.
3. The field name being sent from your form is not right.

To get a clearer picture, try the same filter query directly on Django
shell ("Python manage.py shell") and check what happens.

On Thu, May 26, 2016, 5:54 PM Jianshu Hu  wrote:

> To all,
>
> I am new to django, and learning to establish a site.
>
> Here is my problem:
> I have got a databse and a table in mysql, and am using django to read
> the data from it.
> I got a pair of values [FIELD_NAME,VALUE] from the GET method of a
> html page. When the values passed to the searching function, I want to get
> the searching result.
> I knew how to do this in MySQLdb, but unable to achieve it in django
> model.
> In MySQLdb:
> cur.execute("SELECT COLUMN_A,COLUMN_B,COLUMN_C FROM mydatabase
> WHERE %s=%s",(filed_name,value))
> However, in django:
> results=mydatabase.objects.filter(filed_name=value)
> I got an error: Cannot resolve keyword 'filed1' into field. Choices
> are: Bla bla bla
>
>What should I do?
>
> Bests.
>
>
>
> --
> You received this message because you are subscribed 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/bddb8755-33d2-4bb4-9769-3fb350a43ff0%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/CACyRkBUFVBe2K5Ym4xokFdGdNvhFfN-8%3D54YFSdf_NEm_f_Ssw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select undetermined field(s) in django model?

2016-05-26 Thread Jani Tiainen

You need to construct a dict with fieldname value pairs, like:

search = {'field1': value1, 'field2', value2}

And then you can do standard python kw-expansion: 
MyModel.objects.filter(**search)


Though I suspect you want to do that for arbitrary fields so you should 
filter out all bad stuff before doing such queries. Queries itself are 
safe from SQL injection.


On 26.05.2016 15:30, Ketan Bhatt wrote:


It just means the "field_name" you are using in the filter query 
doesn't exist.


Multiple reasons:
1. The model doesn't really have that field in its definition.
2. You forgot migrating your database.
3. The field name being sent from your form is not right.

To get a clearer picture, try the same filter query directly on Django 
shell ("Python manage.py shell") and check what happens.



On Thu, May 26, 2016, 5:54 PM Jianshu Hu > wrote:


To all,

I am new to django, and learning to establish a site.

Here is my problem:
I have got a databse and a table in mysql, and am using django
to read the data from it.
I got a pair of values [FIELD_NAME,VALUE] from the GET method
of a html page. When the values passed to the searching function,
I want to get the searching result.
I knew how to do this in MySQLdb, but unable to achieve it in
django model.
In MySQLdb:
cur.execute("SELECT COLUMN_A,COLUMN_B,COLUMN_C FROM
mydatabase WHERE %s=%s",(filed_name,value))
However, in django:
results=mydatabase.objects.filter(filed_name=value)
I got an error: Cannot resolve keyword 'filed1' into field.
Choices are: Bla bla bla

   What should I do?

Bests.
-- 
You received this message because you are subscribed 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/bddb8755-33d2-4bb4-9769-3fb350a43ff0%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/CACyRkBUFVBe2K5Ym4xokFdGdNvhFfN-8%3D54YFSdf_NEm_f_Ssw%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/5746ED77.8090002%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Live video streaming from ffserver

2016-05-26 Thread Stefano Probst
Hi,
eventual something like X-Accel-Redirect can help to do this without a 
performance penalty. See 
https://wellfire.co/learn/nginx-django-x-accel-redirects/ Serving protected 
upstream services


Am Donnerstag, 26. Mai 2016 13:44:02 UTC+2 schrieb Jahan Balasubramaniam:
>
> Hi
>
> I have setup a ffserver which provides live video stream in the local 
> network over http.
>
> What I want is django app which enables me to do some authentication stuff 
> and stream from local network to outside world.
>
> I have more than decent amount of knowledge in Django and have done dozen 
> projects using django framework.
>
> I m very much clueless and even wondering how to begin with this.
>
> If anyone with knowledge on how to accomplish this sort of stuff could 
> provide some guidance would be helpful.
>
> Even just a hint or starting tip off would be of great help.
>
> Regards
> Jahan
>

-- 
You received this message because you are subscribed 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/8390ae5f-70d4-4b6e-947a-06867b4c5429%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reportlab no module named pdfgen

2016-05-26 Thread Fred Stluka

  
  
David,

It works fine for me.  Must be something about your environment.

--Fred
  
  Fred Stluka -- mailto:f...@bristle.com --
  http://bristle.com/~fred/
  
  Bristle Software, Inc -- http://bristle.com -- Glad to be of
  service!
  
  Open Source: Without walls and fences, we need no Windows or
  Gates.
  

On 5/23/16 4:33 PM, david rodgers
  wrote:


  Hello All,


I am trying to use reportlab to generate pdfs from html.
  When I pip install reportlab it say its installed correctly.
  However, when I try 'from reportlab.pdfgen import canvas' I
  get an error saying no module named pdfgen. Any ideas to help
  solve this would be much appreciated.


Thanks!
  
  -- 
  You received this message because you are subscribed to the Google
  Groups "Django users" group.
  To unsubscribe from this group and stop receiving emails from it,
  send an email to django-users+unsubscr...@googlegroups.com.
  To post to this group, send email to django-users@googlegroups.com.
  Visit this group at https://groups.google.com/group/django-users.
  To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56450467-71c1-496c-9e48-a82d12660743%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/34045cf8-19eb-c19e-e58a-390bca1e4f09%40bristle.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2016-05-26 Thread ludovic coues
Have you done the django tutorial ? It help a lot when starting with django.

Your problem come from site1/urls.py . `include(admin.site.urls)` work
because you import admin. `include(site1.reg.urls)` cannot work
because site1 is not defined.

Also, the djangogirls tutorial [1] have a great chapter about form.

[1] http://tutorial.djangogirls.org/en/django_forms/

2016-05-26 3:46 GMT+02:00 meInvent bbird :
> https://drive.google.com/file/d/0Bxs_ao6uuBDUQm5jOEdCOFowa0U/view?usp=sharing
>
> On Tuesday, May 24, 2016 at 9:07:25 PM UTC+8, ludovic coues wrote:
>>
>> It should work better this way:
>> > onClick="window.location.href='{% url 'post_detail' pk=post.pk
>> %}'">Save
>>
>> the url template tag take a route name, not an url as it first argument.
>>
>> 2016-05-24 10:19 GMT+02:00 meInvent bbird :
>> > Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword arguments
>> > '{}' not found. 0 pattern(s) tried: []
>> >
>> > i follow django girl web , expect to go to /reg to fill a form and press
>> > save button then go to web /reg/
>> >
>> > it has error
>> >
>> > INSTALLED_APPS = (
>> > 'django.contrib.admin',
>> > 'django.contrib.auth',
>> > 'django.contrib.contenttypes',
>> > 'django.contrib.sessions',
>> > 'django.contrib.messages',
>> > 'django.contrib.staticfiles',
>> > 'django.contrib.sites',
>> > )
>> >
>> > MIDDLEWARE_CLASSES = (
>> > 'django.contrib.sessions.middleware.SessionMiddleware',
>> > 'django.middleware.common.CommonMiddleware',
>> > 'django.middleware.csrf.CsrfViewMiddleware',
>> > 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> > 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>> > 'django.contrib.messages.middleware.MessageMiddleware',
>> > 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> > 'django.middleware.security.SecurityMiddleware',
>> > 'site1.reg.models.Post',
>> > )
>> >
>> > registration.html
>> >
>> > {% block content %}
>> >
>> > New user registration
>> >
>> > {% csrf_token %}
>> >
>> > {{ form.as_p }}
>> >
>> > > > onClick="window.location.href='{% url 'reg/{{post.pk}}/'
>> > %}'">Save
>> >
>> > 
>> >
>> > {% endblock %}
>> >
>> > urls.py
>> >
>> > from django.conf.urls import include, url
>> >
>> > from . import views
>> >
>> >
>> >
>> > urlpatterns = [
>> >
>> > url(r'^reg/$', views.post_new, name='post_new'),
>> >
>> > url(r'^reg/(?P\d+)/$', views.post_detail, name='post_detail'),
>> >
>> > ]
>> >
>> > views.py
>> >
>> > from .forms import PostForm
>> >
>> > from django.shortcuts import render
>> >
>> > from django.template.loader import get_template
>> >
>> >
>> >
>> > def post_new(request):
>> >
>> > form = PostForm()
>> >
>> > return render(request, 'registration.html', {'form': form})
>> >
>> >
>> >
>> > def post_detail(request, pk):
>> >
>> > post = get_object_or_404(Post, pk=pk)
>> >
>> > if request.method == "POST":
>> >
>> > form = PostForm(request.POST, instance=post)
>> >
>> > if form.is_valid():
>> >
>> > post = form.save(commit=False)
>> >
>> > post.author = request.user
>> >
>> > post.ProjectName = request.ProjectName
>> >
>> > post.UserName = request.UserName
>> >
>> > post.Company = request.Company
>> >
>> > post.Contact = request.Contact
>> >
>> > post.InitialPassword = request.InitialPassword
>> >
>> > post.UserType = request.UserType
>> >
>> > post.BusinessType = request.BusinessType
>> >
>> > post.published_date = timezone.now()
>> >
>> > post.save()
>> >
>> > return redirect('registration.html', pk=post.pk)
>> >
>> > else:
>> >
>> > form = PostForm(instance=post)
>> >
>> >
>> > return render(request, 'registration.html', {'form': form})
>> >
>> > models.py
>> >
>> > from django.db import models
>> >
>> > from django.utils import timezone
>> > from django.apps import AppConfig
>> >
>> > import csv
>> > import os.path
>> >
>> > USERTYPE = (
>> > ('Cyberport Tenant', 'Cyberport Tenant'),
>> > ('SmartSpace User', 'SmartSpace User'),
>> > ('Cyberport Incubate', 'Cyberport Incubate'),
>> > ('Collaboration Center Subscriber', 'Collaboration Center
>> > Subscriber'),
>> > ('Cyberport Alumnus', 'Cyberport Alumnus'),
>> > ('Technology Partner', 'Technology Partner'),
>> > ('HKOSUG', 'HKOSUG'),
>> > ('Others', 'Others'),
>> > )
>> >
>> >
>> > BUSINESSTYPE = (
>> > ('Building', 'Building'),
>> > ('Data Analysis', 'Data Analysis'),
>> > ('Digital Entertainment', 'Digital Entertainment'),
>> > ('Education', 'Education'),
>> > ('Games', 'Games'),
>> > ('Gaming', 'Gaming'),
>> > ('ICT', 'ICT'),
>> > ('Marketing', 'Marketing'),
>> > ('Social Media', 'Social Media'),
>> > ('Others', 'Others'),
>> > )
>> >
>> >
>> > class MyAppConfig(AppConfig):
>> > name = '

Re: I am not able to run the following code

2016-05-26 Thread Gergely Polonkai
I don’t see any error here; what is the error message you see?



Gergely Polonkai
[image: https://]about.me/gergely.polonkai


2016-05-26 10:16 GMT+02:00 Madhusudhana H V :

> I am trying to execute the following code. But I am getting error at step 2, 
> namely ">>> t = template.Template('My name is {{ name }}.')"
> Kindly help me out of this.
>
> >>> from django import template>>> t = template.Template('My name is {{ name 
> >>> }}.')>>> c = template.Context({'name': 'Adrian'})>>> print t.render(c)My 
> >>> name is Adrian.>>> c = template.Context({'name': 'Fred'})>>> print 
> >>> t.render(c)My name is Fred.
>
> Thanks and Regards,
> Madhusudhana H V
>
> --
> You received this message because you are subscribed 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/1da7713e-5019-4a96-b026-30ff4ecc13bf%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/CACczBUJ0kXk8x0cp1g8vCbSUge4G8Dbt0v18BH9ivZF9Qm9OEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to implement a ManyToManyField with a View

2016-05-26 Thread Bruce Whealton
Hello all,
 I started a similar thread but couldn't find it.
I was creating a Personal Information Management Project, with Project name 
mypim.  My first app was a contacts app.
This has two Class based Models in the models.py in the contacts directory. 
 My first view works fine, where I display 
a list of contacts.  It seemed that the Django Admin got confused unless I 
put the Relationship model prior to the Resource model.
Ok, so, I call a Relationship model instead of Contact model for reasons 
unimportant to my question.  Here is what my models.py looks like
with some fields snipped to show only what is important.

class Relationship(models.Model):
category = models.CharField(max_length=60)

def __str__(self):
return self.category


class Resource(models.Model):
first_name = models.CharField(max_length=80)
last_name = models.CharField(max_length=80)
organization = models.CharField(max_length=100, null=True, blank=True)
[snip]
relationship = models.ManyToManyField(Relationship)

class Meta:
ordering = ['last_name',]

def __str__(self):
return self.first_name +  " " + self.last_name

And my views.py for the app:

def contact_list(request):
contacts = Resource.objects.all()
return render(request, 'contacts/contact_list.html', {'contacts': 
contacts })


def contact_detail(request, pk):
contact = get_object_or_404(Resource, pk=pk)
return render(request, 'contacts/contact_detail.html', {'contact': 
contact})

End of File.
Ok, so when I display the list of contacts/resources, things look fine and 
I can click on a contact and see
the details, aka full listing of the contact, minus the categories which 
come from the Resource.  I know things cannot be 
correct in that the view doesn't seem to query for the categories assigned 
to the Contact, aka Resource.  My contact_detail.html
template has this section for displaying the category in the Relationship 
model and I do have defined relationships.


  {% for relationship in contact.relationship_set.all %}
{{ relationship.category }}
  {% endfor %}


Can someone guide me here, please?  I'd actually like to display the 
categories separated by commas on the same line.  However, I am not seeing
anything in this area.

Thanks in advance for any help,
Bruce



-- 
You received this message because you are subscribed 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/39ddf178-8274-4323-acc1-8f9834da570d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to implement a ManyToManyField with a View

2016-05-26 Thread Simon Charette
Hi Bruce,

I think you want to call get_object_or_404 with the Contact model in your
contact_detail() view.

Cheers,
Simon

Le jeudi 26 mai 2016 13:43:00 UTC-4, Bruce Whealton a écrit :
>
> Hello all,
>  I started a similar thread but couldn't find it.
> I was creating a Personal Information Management Project, with Project 
> name mypim.  My first app was a contacts app.
> This has two Class based Models in the models.py in the contacts 
> directory.  My first view works fine, where I display 
> a list of contacts.  It seemed that the Django Admin got confused unless I 
> put the Relationship model prior to the Resource model.
> Ok, so, I call a Relationship model instead of Contact model for reasons 
> unimportant to my question.  Here is what my models.py looks like
> with some fields snipped to show only what is important.
>
> class Relationship(models.Model):
> category = models.CharField(max_length=60)
>
> def __str__(self):
> return self.category
>
>
> class Resource(models.Model):
> first_name = models.CharField(max_length=80)
> last_name = models.CharField(max_length=80)
> organization = models.CharField(max_length=100, null=True, blank=True)
> [snip]
> relationship = models.ManyToManyField(Relationship)
>
> class Meta:
> ordering = ['last_name',]
>
> def __str__(self):
> return self.first_name +  " " + self.last_name
>
> And my views.py for the app:
>
> def contact_list(request):
> contacts = Resource.objects.all()
> return render(request, 'contacts/contact_list.html', {'contacts': 
> contacts })
>
>
> def contact_detail(request, pk):
> contact = get_object_or_404(Resource, pk=pk)
> return render(request, 'contacts/contact_detail.html', {'contact': 
> contact})
>
> End of File.
> Ok, so when I display the list of contacts/resources, things look fine and 
> I can click on a contact and see
> the details, aka full listing of the contact, minus the categories which 
> come from the Resource.  I know things cannot be 
> correct in that the view doesn't seem to query for the categories assigned 
> to the Contact, aka Resource.  My contact_detail.html
> template has this section for displaying the category in the Relationship 
> model and I do have defined relationships.
>
> 
>   {% for relationship in contact.relationship_set.all %}
> {{ relationship.category }}
>   {% endfor %}
> 
>
> Can someone guide me here, please?  I'd actually like to display the 
> categories separated by commas on the same line.  However, I am not seeing
> anything in this area.
>
> Thanks in advance for any help,
> Bruce
>
>
>
>

-- 
You received this message because you are subscribed 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/b53a4093-12c5-4394-b5cb-ad4dba6a1081%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.contrib apps migrations

2016-05-26 Thread McKinley
I managed to use fixtures to suit my needs for maintaining concurrency 
across admin app with collaborators.

On Sunday, May 15, 2016 at 2:42:00 AM UTC-7, Michal Petrucha wrote:
>
> On Fri, May 13, 2016 at 01:01:22PM -0700, McKinley wrote: 
> > Hi Michal, 
> > 
> > I know the django.contrib migrations reside within my virtualenv. What 
> if I 
> > wanted a fellow developer to have access to these migrations without 
> > sharing the same django install. If i have a colleague working on their 
> own 
> > machine and they git pull my django project, they aren't getting my 
> admin 
> > and auth migrations so aren't we working on different data afterwards? 
>
> If someone else sets up the same project on a different machine, they 
> will still need to install the same version of Django in their 
> virtualenv for it to work. That means, they will also install the 
> necessary contrib pacages and their migrations on their machines, 
> exactly the same way as if you used any other third-party package that 
> includes models. 
>
> Migrations are a part of thier packages' code base. So the migrations 
> for django.contrib.admin are part of the code base of 
> django.contrib.admin, just like migrations for any of your packages 
> are part of the code base of your packages. There is no reason to 
> treat them in any special way. When you install Django, which includes 
> all its contrib packages, you inevitably also install all the 
> migrations that ship with Django. 
>
> Does this help answer your question? (I'm not sure I understand your 
> concerns correctly, to be honest.) 
>
> Michal 
>

-- 
You received this message because you are subscribed 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/612f9748-61ac-43ba-b396-ab7333d7203e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Questions about Deploying django for production using apache and mod_wsgi.

2016-05-26 Thread Bruce Whealton
Hello all,
I have a few questions of which I am not finding answers.
1) If I export my development db (Postgresql) and then import it into 
production database,
won't I be pulling in a very weak password that I used for development?  I 
guess I can
just change that.
2) Should I export all the content and structure from my development server 
to my
production server?  Or should I just create the database connection and 
then run migrations and
then create the data content on the production server?  Obviously, my 
development server has
minimal content.

3) Should I just upload the other packages that I installed with pip on my 
development server or
should I instead run pip install on the production server to get all the 
packages needed on the
production server?  

4) Is it a best practice ( continuing from #3) to create a requirement file 
and use that to install
with pip all the packages, as opposed to uploading the packages from 
development to production?  
Note: I am developing on Ubuntu but deploying to Centos.  

5) I suppose, even if I had a Centos development environment, I would still 
want to install the required
packages on the production server instead of just uploading everything.

Regarding #5, I am liking Python better than what I have used for some 
time, PHP based application
development.  However, for the longest time, things were much simpler with 
php in that most php code is
just text and so there isn't the notion of "installing" a package.  One 
could expect things to work fine
if one just uploaded the site from development to production (perhaps 
certain new OO features are changing
this situation for php sites, e.g. the use of autoloaders but that's 
another topic).

6) Is there anything else, in addition to the top level assets (with 
js/css) that I would want apache to serve directly
versus going through mod_wsgi?  It seems like I read something to this 
effect relating to parts of the admin, 
that need to be served directly by apache.  I could be wrong.  

Thanks in advance for any help,
Bruce  

P.S. If anyone wants to develop a course on udemy.com on a python 
framework, please don't develop with
sqlite3 since we won't use that in production and please discuss deployment 
on a server besides 
something like pythonanywhere.com.  The issues of setting things up on 
one's own vps server are not 
trivial at all.  (smile).

-- 
You received this message because you are subscribed 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/50b71c19-10a1-4610-8050-191bde7facda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Questions about Deploying django for production using apache and mod_wsgi.

2016-05-26 Thread Gergely Polonkai
On May 26, 2016 20:12, "Bruce Whealton" 
wrote:
>
> Hello all,
> I have a few questions of which I am not finding answers.
> 1) If I export my development db (Postgresql) and then import it into
production database,
> won't I be pulling in a very weak password that I used for development?
I guess I can
> just change that.

Yes you can, and yes, you will. I usually start prod with an empn]ty DB, I
consider that safer.

> 2) Should I export all the content and structure from my development
server to my
> production server?  Or should I just create the database connection and
then run migrations and
> then create the data content on the production server?  Obviously, my
development server has
> minimal content.

See my previous answer. If your dev data is production-ready, I don’t see
the downside though.

>
> 3) Should I just upload the other packages that I installed with pip on
my development server or
> should I instead run pip install on the production server to get all the
packages needed on the
> production server?

If you use virtualenv, you should use pip install. I suggest creating a
requirements.txt file (you can create one with pip freeze) and update it
regularly.

>
> 4) Is it a best practice ( continuing from #3) to create a requirement
file and use that to install
> with pip all the packages, as opposed to uploading the packages from
development to production?
> Note: I am developing on Ubuntu but deploying to Centos.

See previous answer.

>
> 5) I suppose, even if I had a Centos development environment, I would
still want to install the required
> packages on the production server instead of just uploading everything.
>
> Regarding #5, I am liking Python better than what I have used for some
time, PHP based application
> development.  However, for the longest time, things were much simpler
with php in that most php code is
> just text and so there isn't the notion of "installing" a package.  One
could expect things to work fine
> if one just uploaded the site from development to production (perhaps
certain new OO features are changing
> this situation for php sites, e.g. the use of autoloaders but that's
another topic).

PHP has its package system, too, it is called composer. It also has binary
modules (although they require much more effort on the server side)

>
> 6) Is there anything else, in addition to the top level assets (with
js/css) that I would want apache to serve directly
> versus going through mod_wsgi?  It seems like I read something to this
effect relating to parts of the admin,
> that need to be served directly by apache.  I could be wrong.

Take a look at the collectstatic management command. Also, if you use
django-compress, e.g. for less,sass, css/js minimizing), you need to run
that.

>
> Thanks in advance for any help,
> Bruce

Also, you may want to check this page[1] for other possible caveats and
best practises.

[1] https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

>
> P.S. If anyone wants to develop a course on udemy.com on a python
framework, please don't develop with
> sqlite3 since we won't use that in production and please discuss
deployment on a server besides
> something like pythonanywhere.com.  The issues of setting things up on
one's own vps server are not
> trivial at all.  (smile).
>
> --
> You received this message because you are subscribed 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/50b71c19-10a1-4610-8050-191bde7facda%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/CACczBULd2mqRCuY72euyZR0xiUCT2wWNKWBYF78qLsWP7KbFww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Models

2016-05-26 Thread Ken Edem
 

I am new to Django Python and I need bit of help



Can someone please help me with how I should structure my models, since 
this is a very important part of the project I am trying to develop, I had 
been teaching myself and not yet good at this stuff. I want to develop a 
web project for matching teachers or instructors who will teach students 
who subscribes to our service at they residence.For now I think I will need 
these models:


Students = Database to contain all students details.  See below for the 
database fields

Instructors = Database to contain all instructors or teachers details. See 
below

Course = Databases for all the courses or services that will be offering

Feedbacks = Database to contains both feedbacks from students about 
teachers and also teachers about students.


So, I have done something in terms of normalising my database, but I do not 
think it is efficient enough.? I think I also need a database Class, which 
is combination of Students and Instructors, but I cannot figures what the 
fields of this database should be.

I also think I need a combine database Instructors & Course and Course & 
Students. But I cannot figure out what the fields of these databases also 
should be and what the foreign key or whatever should be.


You see, our primary service will be matching students with instructors and 
having these instructors teach student what they want to be thought.


Please can  someone assist me in structuring my models a structure and also 
should I just have one app or separate apps for students, instructors, 
feedbacks etc. Thanks in advance.


Below is my database models.


Thanks agains


 


Models and Tables

-   Students

-   Instructors

-   Course

-   Feedbacks

-   Class


Model Properties and Fields

Students

-   student-id

-   student_firstname

-   student_lastname

-   student_address

-   student_city

-   student_region

-   student_startdate  (immediately, in 2 weeks, in a month over 6 months)

-   student_classLocation (student address, instructor address, arrange 
location)

-   student_phone1

-   student_email

-   student_phone2

-   student_internetContact  (skype, viber etc)

-   student_days_to_take_classes (mon - sun)

-   student_duration_of_course  (1 - 12 months)

-   student_hours_to_spend_on_course  (1 -8 hours)

-   student_class_start_time  ( 06am - 06am)

-   student_course_skill_level (beginner, intermediate, advance)

-   student_personal_wishes_to_help_match_an_intructor ( )

-   student_budget_amount

-   student_preferred_instructor_gender  (male, female)

-   student_date_of_birth


Students Methods and actions

-   match a student to instructors

-   seek payment

-   message update




Instuctors

-   id

-   firstname

-   lastname

-   middlename

-   gender

-   date_of_birth

-   phone1

-   phone2

-   streetaddress

-   city

-   region

-   country

-   qualifications  (multiple entry)

-   certfications  (multiple entry)

-   degrees (multiple entry)

-   present occupation

-   previous occupations (multiple entry)

-   present job position

-   length of teaching skills

-   type of skills to teach

-   class location (student address, tutor address, arranged address)


Instructor Methods and Actions

match instructor to students

seek instructors

pay instructors

-



Courses

-   id

-   course_name

-   course_description

-   course_duration


Methods



Feedbacks

-   id

-   course_name

-   instructor

-   student

-   Feedback_details

-   Grade (Beneficial, Great, Average, Satisfied, Very Satisfied, Excellent)




Class

-   instructor

-   students

-   course

-- 
You received this message because you are subscribed 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/44926a47-6931-494f-a368-a002fc6fa67b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2016-05-26 Thread meInvent bbird
this works, because i set ROOT_URLCONF

since it work, it can go to registration.html by reading urls.py in 
directory reg


INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'site1',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'site1.reg.models.Post',
)

ROOT_URLCONF = 'site1.reg.urls'




On Thursday, May 26, 2016 at 10:24:44 PM UTC+8, ludovic coues wrote:
>
> Have you done the django tutorial ? It help a lot when starting with 
> django. 
>
> Your problem come from site1/urls.py . `include(admin.site.urls)` work 
> because you import admin. `include(site1.reg.urls)` cannot work 
> because site1 is not defined. 
>
> Also, the djangogirls tutorial [1] have a great chapter about form. 
>
> [1] http://tutorial.djangogirls.org/en/django_forms/ 
>
> 2016-05-26 3:46 GMT+02:00 meInvent bbird >: 
>
> > 
> https://drive.google.com/file/d/0Bxs_ao6uuBDUQm5jOEdCOFowa0U/view?usp=sharing 
> > 
> > On Tuesday, May 24, 2016 at 9:07:25 PM UTC+8, ludovic coues wrote: 
> >> 
> >> It should work better this way: 
> >>  >> onClick="window.location.href='{% url 'post_detail' pk=post.pk 
> >> %}'">Save 
> >> 
> >> the url template tag take a route name, not an url as it first 
> argument. 
> >> 
> >> 2016-05-24 10:19 GMT+02:00 meInvent bbird : 
> >> > Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword 
> arguments 
> >> > '{}' not found. 0 pattern(s) tried: [] 
> >> > 
> >> > i follow django girl web , expect to go to /reg to fill a form and 
> press 
> >> > save button then go to web /reg/ 
> >> > 
> >> > it has error 
> >> > 
> >> > INSTALLED_APPS = ( 
> >> > 'django.contrib.admin', 
> >> > 'django.contrib.auth', 
> >> > 'django.contrib.contenttypes', 
> >> > 'django.contrib.sessions', 
> >> > 'django.contrib.messages', 
> >> > 'django.contrib.staticfiles', 
> >> > 'django.contrib.sites', 
> >> > ) 
> >> > 
> >> > MIDDLEWARE_CLASSES = ( 
> >> > 'django.contrib.sessions.middleware.SessionMiddleware', 
> >> > 'django.middleware.common.CommonMiddleware', 
> >> > 'django.middleware.csrf.CsrfViewMiddleware', 
> >> > 'django.contrib.auth.middleware.AuthenticationMiddleware', 
> >> > 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
> >> > 'django.contrib.messages.middleware.MessageMiddleware', 
> >> > 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
> >> > 'django.middleware.security.SecurityMiddleware', 
> >> > 'site1.reg.models.Post', 
> >> > ) 
> >> > 
> >> > registration.html 
> >> > 
> >> > {% block content %} 
> >> > 
> >> > New user registration 
> >> > 
> >> > {% csrf_token %} 
> >> > 
> >> > {{ form.as_p }} 
> >> > 
> >> >  >> > onClick="window.location.href='{% url 'reg/{{post.pk}}/' 
> >> > %}'">Save 
> >> > 
> >> >  
> >> > 
> >> > {% endblock %} 
> >> > 
> >> > urls.py 
> >> > 
> >> > from django.conf.urls import include, url 
> >> > 
> >> > from . import views 
> >> > 
> >> > 
> >> > 
> >> > urlpatterns = [ 
> >> > 
> >> > url(r'^reg/$', views.post_new, name='post_new'), 
> >> > 
> >> > url(r'^reg/(?P\d+)/$', views.post_detail, 
> name='post_detail'), 
> >> > 
> >> > ] 
> >> > 
> >> > views.py 
> >> > 
> >> > from .forms import PostForm 
> >> > 
> >> > from django.shortcuts import render 
> >> > 
> >> > from django.template.loader import get_template 
> >> > 
> >> > 
> >> > 
> >> > def post_new(request): 
> >> > 
> >> > form = PostForm() 
> >> > 
> >> > return render(request, 'registration.html', {'form': form}) 
> >> > 
> >> > 
> >> > 
> >> > def post_detail(request, pk): 
> >> > 
> >> > post = get_object_or_404(Post, pk=pk) 
> >> > 
> >> > if request.method == "POST": 
> >> > 
> >> > form = PostForm(request.POST, instance=post) 
> >> > 
> >> > if form.is_valid(): 
> >> > 
> >> > post = form.save(commit=False) 
> >> > 
> >> > post.author = request.user 
> >> > 
> >> > post.ProjectName = request.ProjectName 
> >> > 
> >> > post.UserName = request.UserName 
> >> > 
> >> > post.Company = request.Company 
> >> > 
> >> > post.Contact = request.Contact 
> >> > 
> >> > post.InitialPassword = request.InitialPassword 
> >> > 
> >> > post.UserType = request.UserType 
> >> > 
> >> > post.BusinessType = request.BusinessType 
> 

Re: Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2016-05-26 Thread meInvent bbird

i succeed to make it trigger something when press button after read 
tutorial again

however got error,

WSGIRequest' object has no attribute 'Email'




def post_new(request):

#post = get_object_or_404(Post)

#form = PostForm()

#return render_to_response(request, 'registration.html', {'pk': 12})

#return render(request, 'registration.html', {'form': form})
if request.method == "POST":
form = PostForm(request.POST)
if form.is_valid():
post = form.save(commit=False)

#post.author = request.user

post.Email = request.Email

post.ProjectName = request.ProjectName

post.UserName = request.UserName

post.Company = request.Company

post.Contact = request.Contact

post.InitialPassword = request.InitialPassword

post.UserType = request.UserType

post.BusinessType = request.BusinessType

post.published_date = timezone.now()

post.publish()
#self.published_date = timezone.now()
return redirect('post_detail', pk=post.pk)
#isexist = os.path.isfile('newusers.csv') 

#with 
open('/home/martin/Downloads/site1/site1/reg/newusers.csv', 'a') as csvfile:

 #fieldnames = ['name','email address','project','initial 
password','userType','contact','businessType','company']

 #writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

 #if isexist == 0:

  #writer.writeheader()

 #writer.writerow({'name': request.user, 'email address': 
request.Email, 'project': request.ProjectName, 'initial password': 
request.InitialPassword,'userType': request.UserType, 'contact': 
request.Contact, 'businessType': request.BusinessType, 'company': 
request.Company,})



return redirect('hello.html', pk=post.pk)
else:
form = PostForm()
return render(request, 'registration.html', {'form': form})



On Thursday, May 26, 2016 at 10:24:44 PM UTC+8, ludovic coues wrote:
>
> Have you done the django tutorial ? It help a lot when starting with 
> django. 
>
> Your problem come from site1/urls.py . `include(admin.site.urls)` work 
> because you import admin. `include(site1.reg.urls)` cannot work 
> because site1 is not defined. 
>
> Also, the djangogirls tutorial [1] have a great chapter about form. 
>
> [1] http://tutorial.djangogirls.org/en/django_forms/ 
>
> 2016-05-26 3:46 GMT+02:00 meInvent bbird >: 
>
> > 
> https://drive.google.com/file/d/0Bxs_ao6uuBDUQm5jOEdCOFowa0U/view?usp=sharing 
> > 
> > On Tuesday, May 24, 2016 at 9:07:25 PM UTC+8, ludovic coues wrote: 
> >> 
> >> It should work better this way: 
> >>  >> onClick="window.location.href='{% url 'post_detail' pk=post.pk 
> >> %}'">Save 
> >> 
> >> the url template tag take a route name, not an url as it first 
> argument. 
> >> 
> >> 2016-05-24 10:19 GMT+02:00 meInvent bbird : 
> >> > Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword 
> arguments 
> >> > '{}' not found. 0 pattern(s) tried: [] 
> >> > 
> >> > i follow django girl web , expect to go to /reg to fill a form and 
> press 
> >> > save button then go to web /reg/ 
> >> > 
> >> > it has error 
> >> > 
> >> > INSTALLED_APPS = ( 
> >> > 'django.contrib.admin', 
> >> > 'django.contrib.auth', 
> >> > 'django.contrib.contenttypes', 
> >> > 'django.contrib.sessions', 
> >> > 'django.contrib.messages', 
> >> > 'django.contrib.staticfiles', 
> >> > 'django.contrib.sites', 
> >> > ) 
> >> > 
> >> > MIDDLEWARE_CLASSES = ( 
> >> > 'django.contrib.sessions.middleware.SessionMiddleware', 
> >> > 'django.middleware.common.CommonMiddleware', 
> >> > 'django.middleware.csrf.CsrfViewMiddleware', 
> >> > 'django.contrib.auth.middleware.AuthenticationMiddleware', 
> >> > 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
> >> > 'django.contrib.messages.middleware.MessageMiddleware', 
> >> > 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
> >> > 'django.middleware.security.SecurityMiddleware', 
> >> > 'site1.reg.models.Post', 
> >> > ) 
> >> > 
> >> > registration.html 
> >> > 
> >> > {% block content %} 
> >> > 
> >> > New user registration 
> >> > 
> >> > {% csrf_token %} 
> >> > 
> >> > {{ form.as_p }} 
> >> > 
> >> >  >> > onClick="window.location.href='{% url 'reg/{{post.pk}}/' 
> >> > %}'">Save 
> >> > 
> >> >  
> >> > 
> >> > {% endblock %} 
> >> > 
> >> > urls.py 
> >> > 
> >> > from django.conf.urls import include, url 
> >> > 
> >> > from . import views 
> >> > 
> >> > 
> >> > 
> >> > urlpatterns = [ 
> >> > 
> >> > url(r'^reg/$', views.post_new, name='post_new'), 
> >> > 
> >> > url(r'^reg/(?P\d+)/$', views.post_detail, 
> name='post_detail'), 
> >> > 
> >> > ] 
> >> > 
> >> > views.py 
> >> > 
> >> > from .forms import PostForm 
> >> > 
> >> > from django.shortcuts import render 
> >> > 
> >> 

Re: Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2016-05-26 Thread meInvent bbird
so far, the link do not have querystring, the error is WSGIRequest' object 
has no attribute 'Email'

On Thursday, May 26, 2016 at 10:24:44 PM UTC+8, ludovic coues wrote:
>
> Have you done the django tutorial ? It help a lot when starting with 
> django. 
>
> Your problem come from site1/urls.py . `include(admin.site.urls)` work 
> because you import admin. `include(site1.reg.urls)` cannot work 
> because site1 is not defined. 
>
> Also, the djangogirls tutorial [1] have a great chapter about form. 
>
> [1] http://tutorial.djangogirls.org/en/django_forms/ 
>
> 2016-05-26 3:46 GMT+02:00 meInvent bbird >: 
>
> > 
> https://drive.google.com/file/d/0Bxs_ao6uuBDUQm5jOEdCOFowa0U/view?usp=sharing 
> > 
> > On Tuesday, May 24, 2016 at 9:07:25 PM UTC+8, ludovic coues wrote: 
> >> 
> >> It should work better this way: 
> >>  >> onClick="window.location.href='{% url 'post_detail' pk=post.pk 
> >> %}'">Save 
> >> 
> >> the url template tag take a route name, not an url as it first 
> argument. 
> >> 
> >> 2016-05-24 10:19 GMT+02:00 meInvent bbird : 
> >> > Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword 
> arguments 
> >> > '{}' not found. 0 pattern(s) tried: [] 
> >> > 
> >> > i follow django girl web , expect to go to /reg to fill a form and 
> press 
> >> > save button then go to web /reg/ 
> >> > 
> >> > it has error 
> >> > 
> >> > INSTALLED_APPS = ( 
> >> > 'django.contrib.admin', 
> >> > 'django.contrib.auth', 
> >> > 'django.contrib.contenttypes', 
> >> > 'django.contrib.sessions', 
> >> > 'django.contrib.messages', 
> >> > 'django.contrib.staticfiles', 
> >> > 'django.contrib.sites', 
> >> > ) 
> >> > 
> >> > MIDDLEWARE_CLASSES = ( 
> >> > 'django.contrib.sessions.middleware.SessionMiddleware', 
> >> > 'django.middleware.common.CommonMiddleware', 
> >> > 'django.middleware.csrf.CsrfViewMiddleware', 
> >> > 'django.contrib.auth.middleware.AuthenticationMiddleware', 
> >> > 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
> >> > 'django.contrib.messages.middleware.MessageMiddleware', 
> >> > 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
> >> > 'django.middleware.security.SecurityMiddleware', 
> >> > 'site1.reg.models.Post', 
> >> > ) 
> >> > 
> >> > registration.html 
> >> > 
> >> > {% block content %} 
> >> > 
> >> > New user registration 
> >> > 
> >> > {% csrf_token %} 
> >> > 
> >> > {{ form.as_p }} 
> >> > 
> >> >  >> > onClick="window.location.href='{% url 'reg/{{post.pk}}/' 
> >> > %}'">Save 
> >> > 
> >> >  
> >> > 
> >> > {% endblock %} 
> >> > 
> >> > urls.py 
> >> > 
> >> > from django.conf.urls import include, url 
> >> > 
> >> > from . import views 
> >> > 
> >> > 
> >> > 
> >> > urlpatterns = [ 
> >> > 
> >> > url(r'^reg/$', views.post_new, name='post_new'), 
> >> > 
> >> > url(r'^reg/(?P\d+)/$', views.post_detail, 
> name='post_detail'), 
> >> > 
> >> > ] 
> >> > 
> >> > views.py 
> >> > 
> >> > from .forms import PostForm 
> >> > 
> >> > from django.shortcuts import render 
> >> > 
> >> > from django.template.loader import get_template 
> >> > 
> >> > 
> >> > 
> >> > def post_new(request): 
> >> > 
> >> > form = PostForm() 
> >> > 
> >> > return render(request, 'registration.html', {'form': form}) 
> >> > 
> >> > 
> >> > 
> >> > def post_detail(request, pk): 
> >> > 
> >> > post = get_object_or_404(Post, pk=pk) 
> >> > 
> >> > if request.method == "POST": 
> >> > 
> >> > form = PostForm(request.POST, instance=post) 
> >> > 
> >> > if form.is_valid(): 
> >> > 
> >> > post = form.save(commit=False) 
> >> > 
> >> > post.author = request.user 
> >> > 
> >> > post.ProjectName = request.ProjectName 
> >> > 
> >> > post.UserName = request.UserName 
> >> > 
> >> > post.Company = request.Company 
> >> > 
> >> > post.Contact = request.Contact 
> >> > 
> >> > post.InitialPassword = request.InitialPassword 
> >> > 
> >> > post.UserType = request.UserType 
> >> > 
> >> > post.BusinessType = request.BusinessType 
> >> > 
> >> > post.published_date = timezone.now() 
> >> > 
> >> > post.save() 
> >> > 
> >> > return redirect('registration.html', pk=post.pk) 
> >> > 
> >> > else: 
> >> > 
> >> > form = PostForm(instance=post) 
> >> > 
> >> > 
> >> > return render(request, 'registration.html', {'form': form}) 
> >> > 
> >> > models.py 
> >> > 
> >> > from django.db import models 
> >> > 
> >> > from django.utils import timezone 
> >> > from django.apps import AppConfig 
> >> > 
> >> > import csv 
> >> > import os.path 
> >> > 
> >> > USERTYPE = ( 
> >> > ('Cyberport Tenant', 'Cyberport Tenant'), 
> >> > ('SmartSpace User', 'SmartSpace User'), 
> >> > ('Cyberport Incubate', 'Cyberport Incubate'), 
> >> > ('Collaboration Center Subscriber', 'Collaboration Center 
> >>

Re: Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2016-05-26 Thread meInvent bbird
i succeed to save to csv, 

i use post instead of request

but it is quite odd, it do not have request in query string in link

writer.writerow({'name': post.UserName, 'email address': post.Email, 
'project': post.ProjectName, 'initial password': 
post.InitialPassword,'userType': post.UserType, 'contact': post.Contact, 
'businessType': post.BusinessType, 'company': post.Company,})




On Thursday, May 26, 2016 at 10:24:44 PM UTC+8, ludovic coues wrote:
>
> Have you done the django tutorial ? It help a lot when starting with 
> django. 
>
> Your problem come from site1/urls.py . `include(admin.site.urls)` work 
> because you import admin. `include(site1.reg.urls)` cannot work 
> because site1 is not defined. 
>
> Also, the djangogirls tutorial [1] have a great chapter about form. 
>
> [1] http://tutorial.djangogirls.org/en/django_forms/ 
>
> 2016-05-26 3:46 GMT+02:00 meInvent bbird >: 
>
> > 
> https://drive.google.com/file/d/0Bxs_ao6uuBDUQm5jOEdCOFowa0U/view?usp=sharing 
> > 
> > On Tuesday, May 24, 2016 at 9:07:25 PM UTC+8, ludovic coues wrote: 
> >> 
> >> It should work better this way: 
> >>  >> onClick="window.location.href='{% url 'post_detail' pk=post.pk 
> >> %}'">Save 
> >> 
> >> the url template tag take a route name, not an url as it first 
> argument. 
> >> 
> >> 2016-05-24 10:19 GMT+02:00 meInvent bbird : 
> >> > Reverse for 'reg/{{post.pk}}/' with arguments '()' and keyword 
> arguments 
> >> > '{}' not found. 0 pattern(s) tried: [] 
> >> > 
> >> > i follow django girl web , expect to go to /reg to fill a form and 
> press 
> >> > save button then go to web /reg/ 
> >> > 
> >> > it has error 
> >> > 
> >> > INSTALLED_APPS = ( 
> >> > 'django.contrib.admin', 
> >> > 'django.contrib.auth', 
> >> > 'django.contrib.contenttypes', 
> >> > 'django.contrib.sessions', 
> >> > 'django.contrib.messages', 
> >> > 'django.contrib.staticfiles', 
> >> > 'django.contrib.sites', 
> >> > ) 
> >> > 
> >> > MIDDLEWARE_CLASSES = ( 
> >> > 'django.contrib.sessions.middleware.SessionMiddleware', 
> >> > 'django.middleware.common.CommonMiddleware', 
> >> > 'django.middleware.csrf.CsrfViewMiddleware', 
> >> > 'django.contrib.auth.middleware.AuthenticationMiddleware', 
> >> > 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
> >> > 'django.contrib.messages.middleware.MessageMiddleware', 
> >> > 'django.middleware.clickjacking.XFrameOptionsMiddleware', 
> >> > 'django.middleware.security.SecurityMiddleware', 
> >> > 'site1.reg.models.Post', 
> >> > ) 
> >> > 
> >> > registration.html 
> >> > 
> >> > {% block content %} 
> >> > 
> >> > New user registration 
> >> > 
> >> > {% csrf_token %} 
> >> > 
> >> > {{ form.as_p }} 
> >> > 
> >> >  >> > onClick="window.location.href='{% url 'reg/{{post.pk}}/' 
> >> > %}'">Save 
> >> > 
> >> >  
> >> > 
> >> > {% endblock %} 
> >> > 
> >> > urls.py 
> >> > 
> >> > from django.conf.urls import include, url 
> >> > 
> >> > from . import views 
> >> > 
> >> > 
> >> > 
> >> > urlpatterns = [ 
> >> > 
> >> > url(r'^reg/$', views.post_new, name='post_new'), 
> >> > 
> >> > url(r'^reg/(?P\d+)/$', views.post_detail, 
> name='post_detail'), 
> >> > 
> >> > ] 
> >> > 
> >> > views.py 
> >> > 
> >> > from .forms import PostForm 
> >> > 
> >> > from django.shortcuts import render 
> >> > 
> >> > from django.template.loader import get_template 
> >> > 
> >> > 
> >> > 
> >> > def post_new(request): 
> >> > 
> >> > form = PostForm() 
> >> > 
> >> > return render(request, 'registration.html', {'form': form}) 
> >> > 
> >> > 
> >> > 
> >> > def post_detail(request, pk): 
> >> > 
> >> > post = get_object_or_404(Post, pk=pk) 
> >> > 
> >> > if request.method == "POST": 
> >> > 
> >> > form = PostForm(request.POST, instance=post) 
> >> > 
> >> > if form.is_valid(): 
> >> > 
> >> > post = form.save(commit=False) 
> >> > 
> >> > post.author = request.user 
> >> > 
> >> > post.ProjectName = request.ProjectName 
> >> > 
> >> > post.UserName = request.UserName 
> >> > 
> >> > post.Company = request.Company 
> >> > 
> >> > post.Contact = request.Contact 
> >> > 
> >> > post.InitialPassword = request.InitialPassword 
> >> > 
> >> > post.UserType = request.UserType 
> >> > 
> >> > post.BusinessType = request.BusinessType 
> >> > 
> >> > post.published_date = timezone.now() 
> >> > 
> >> > post.save() 
> >> > 
> >> > return redirect('registration.html', pk=post.pk) 
> >> > 
> >> > else: 
> >> > 
> >> > form = PostForm(instance=post) 
> >> > 
> >> > 
> >> > return render(request, 'registration.html', {'form': form}) 
> >> > 
> >> > models.py 
> >> > 
> >> > from django.db import models 
> >> > 
> >> > from django.utils import timezone 
> >> > from django.apps import AppConfig 
> >> > 
> >> > import csv 
> >>

with django, how to write a grdview or table to show information and add a button or link in each row for approval?

2016-05-26 Thread meInvent bbird
with django, how to write a grdview or table to show information and add a 
button or link in each row for approval?

-- 
You received this message because you are subscribed 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/528ec61f-3a97-4ab7-8ee2-5fcae05c6e19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.