Debugging DJango app on production for High CPU Usage

2016-02-23 Thread Web Architect
Hi,

We have an ecommerce platform based on Django. We are using uwsgi to run 
the app. The issue the CPU usage is hitting the roof (sometimes going 
beyond 100%) for some scenarios. I would like to debug the platform on 
Production to see where the CPU consumption is happening. We have used 
Cache all over the place (including templates) as well - hence, the DB 
queries would be quite limited. 

I would refrain from using Django-debug toolbar as it slows down the 
platform further, increases the CPU usage and also need to turn the DEBUG 
on. Is there any other tool or way to debug the platform? Would appreciate 
any recommendations/suggestions. 

Also, does the Django ORM increase the CPU usage? Does it block the CPU? 
Would appreciate if anyone could throw some light on this.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c2699791-6de9-4b94-975b-fd1d4f8bbd3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django css: general query on CDNs and crispy forms

2016-02-23 Thread Mario Gudelj
You're missing a comma after my app inside installed_apps.

You can load bootstrap from cdn inside head, before your custom style
sheet. Not a problem there.

Pip install crispy forms. They'll end up in your site-packages folder. No
need to download it and put it inside your project.

Run collectstatic command to collect any css or js files that package has
and put them inside your static folder




On Wednesday, 24 February 2016,  wrote:

> I have set up a page and have implemented bootstrap using the CDN code
> that is recommended to access the online bootstrap server:
>
> for the CSS:
>
>  href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css; 
> integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
>  crossorigin="anonymous"> href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css;
>  
> integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r"
>  crossorigin="anonymous">
>
> Javascript:
>
>  src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"; 
> integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
>  crossorigin="anonymous">
>
> However eventually my site will have to go live and I'm not certain that
> this code will suffice when that happens and I feel I should download the
> actual bootstrap code.
>
> Furthermore if I download the bootstrap code properly and put it in a
> hypothetical media folder called "css2" such that it won't interfere with
> my own custom css files, where do I then put crispy_forms.
>
> As of now I am holding them in the downloaded crispy forms files within
> "media"- on the same level as "myproject" but the "{ load crispy_forms}"
> tag doesn't look in the media folder because the "CRISPY_TEMPLATE_PACK =
> 'bootstrap3'" does not specify a path to look for the crispy forms
> content... the crispy forms website tells to look up the django
> documentation for how to organise my media folder but searching the website
> under "cripy forms" returns nothing.
>
> Finally, I have added crispy forms to my installed apps:
>
> INSTALLED_APPS = 
> ('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','myproject.myapp''crispy_forms',
>###Registered
>  )
>
> However when i migrate and run the server I get an error:
>
>  ImportError: No module named myappcrispy_forms
>
> so I rearranged the order of the modules and then got this error:
>
>  ImportError: No module named crispy_forms
>
>
>1. Should i download bootstrap properly or do the CDNs suffice?
>2. Where do I store the bootstrap code and how will it affect my own
>CSS code?
>3. How do register the module crispy_forms? and where do I store the
>crispy forms folder there is little documentation on this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com
> 
> .
> To post to this group, send email to django-users@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7605da4a-e6e9-446a-9016-cce4e6e9071e%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/CAHqTbjm3r%3DjSYqdD2vqBEooZTd86ZvkzejCrTkF%3Dm_fdF-XftQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django css: general query on CDNs and crispy forms

2016-02-23 Thread Lee Hinde
On Feb 23, 2016, at 5:27 PM, clarksonchri...@gmail.com wrote:
> 
> Should i download bootstrap properly or do the CDNs suffice?
Your call; but if you want to have a plan B, here’s an example:  
http://www.hanselman.com/blog/CDNsFailButYourScriptsDontHaveToFallbackFromCDNToLocalJQuery.aspx
 


It’s about jQuery, but the same principal would apply for bootstrap.

> Where do I store the bootstrap code and how will it affect my own CSS code?
You put it the same place you’d have your other js/css files. Loading order 
matters. I usually load libraries first and then my files.

> How do register the module crispy_forms? and where do I store the crispy 
> forms folder there is little documentation on this?
Crispy Forms has documentation. 
http://django-crispy-forms.readthedocs.org/en/latest/ 


-- 
You received this message because you are subscribed 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/0AE63F7B-91B3-4A10-8C03-74DF56DB08D9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


django css: general query on CDNs and crispy forms

2016-02-23 Thread clarksonchris81


I have set up a page and have implemented bootstrap using the CDN code that 
is recommended to access the online bootstrap server:

for the CSS:

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css; 
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
 crossorigin="anonymous">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css;
 
integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r"
 crossorigin="anonymous">

Javascript:

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"; 
integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
 crossorigin="anonymous">

However eventually my site will have to go live and I'm not certain that 
this code will suffice when that happens and I feel I should download the 
actual bootstrap code.

Furthermore if I download the bootstrap code properly and put it in a 
hypothetical media folder called "css2" such that it won't interfere with 
my own custom css files, where do I then put crispy_forms.

As of now I am holding them in the downloaded crispy forms files within 
"media"- on the same level as "myproject" but the "{ load crispy_forms}" 
tag doesn't look in the media folder because the "CRISPY_TEMPLATE_PACK = 
'bootstrap3'" does not specify a path to look for the crispy forms 
content... the crispy forms website tells to look up the django 
documentation for how to organise my media folder but searching the website 
under "cripy forms" returns nothing.

Finally, I have added crispy forms to my installed apps:

INSTALLED_APPS = 
('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','myproject.myapp''crispy_forms',
   ###Registered
 )

However when i migrate and run the server I get an error: 

 ImportError: No module named myappcrispy_forms

so I rearranged the order of the modules and then got this error:

 ImportError: No module named crispy_forms


   1. Should i download bootstrap properly or do the CDNs suffice?
   2. Where do I store the bootstrap code and how will it affect my own CSS 
   code?
   3. How do register the module crispy_forms? and where do I store the 
   crispy forms folder there is little documentation on this?

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


Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Bernardo Garcia
Hi James. 
Thanks for your attention and the stackoverflow reference

I try setup the headers in my nginx configuration file but I don't get 
success

My /etc/nginx/sites-enabled/myproject file I had so:

server {
server_name yourdomainorip.com;
access_log off;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-Host $server_name
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM 
NAV"';
}
}


According to the 
reference 
http://stackoverflow.com/questions/19669376/django-rest-framework-absolute-urls-with-nginx-always-return-127-0-0-1
 
my /etc/nginx/sites-enabled/myproject file I stayed so:

server {
server_name yourdomainorip.com;
access_log off;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM 
NAV"';
}
}

But, the result was a bad request (400) how to you can see here 
http://ec2-52-90-253-22.compute-1.amazonaws.com/ 

What is the order in which I should setup the headers?
Thanks
On Tuesday, February 23, 2016 at 4:51:16 PM UTC-5, James Schneider wrote:
>
>
>
> On Tue, Feb 23, 2016 at 6:03 AM, Bernardo Garcia  > wrote:
>
>> Hi everyone Djangonauts
>> :)
>>
>> Currently I am exposing a Django application (for the momento is just 
>> thier users schema) with Django Rest Framework and happen that each 
>> serialized model, in the url attribute, I have is the localhost machine 
>> address development and don't take the hostname of my production server 
>> machine which is located in amazon like as EC2 instance
>>
>>
>> In this picture can detailed it.
>>
>
> Nginx is proxying the end-users' request to http://127.0.0.1:8000, which 
> is where Gunicorn is running. Gunicorn has no idea that there is a proxy in 
> front of it, so it assumes that the request is being sent by the server 
> itself, to the server itself. Gunicorn then passes along the Host header to 
> Django/DRF, which in turn uses it to generate the URL's that you are 
> getting.
>
> You need to tell Nginx to send the correct headers to indicate to Gunicorn 
> that the connection is being proxied, and the correct address to use. See 
> this SO: 
>
>
> http://stackoverflow.com/questions/19669376/django-rest-framework-absolute-urls-with-nginx-always-return-127-0-0-1
>
> -James
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/740b268b-df39-4b2d-bd81-33217a154de0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mathematical function and django connect

2016-02-23 Thread James Schneider
On Mon, Feb 22, 2016 at 12:08 PM, Xristos Xristoou 
wrote:

> the problem in the html form we need to change second input to
> take multiple values,for example first input take a number
> and the second input take many numbers..if the first number = 2 then take
> second input two numbers,two fields for input i try this but not work
>
> orm action="" method="POST">{% csrf_token %}
>   Number of number:  value="Number"/>
>   calc
>   {% for i in total_inputs %}
>  Enter a value: 
> calc
>   {% endfor %}
> 
> show me error in the {% for i in total_inputs %}
>


Why would you ask how many values that a user is going to provide? Why not
just count them after the user provides them? Are they providing them in a
single input, or are you trying to add multiple input fields, one for each
number?

For a workflow like that, you should probably look at django-formtools,
which includes form wizards for multi-page forms (page 1 asks how many
values, page 2 provides X number of fields inputs given on page 1, etc.).
Or you need to amend the form dynamically using JavaScript. That gets
really tricky though.

Is this math formula something you can convert to JavaScript and perform
entirely in the client browser? I would go that route and not even bother
with trying to have Django process the forms and compute a result.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciU93ug1peo92X%3Dwu3DHFuci%2BSSyQa7JVthtXBKA21r9mg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Relations one-to-many on django

2016-02-23 Thread Vijay Khemlani
Each product is only associated with one category, so you can only do

produto.categoria

If you want to iterate over all categories, and then through the products
of each category, you could do

{% for categoria in categorias %}
{% for produto in categoria.produto_set.all %}
do comething with produto
{% endfor %}
{% endfor %}

On Tue, Feb 23, 2016 at 6:58 PM, James Schneider 
wrote:

> >
> > I try to use
> >>
> >> {% if categorias %}
> >> 
> >> {% for categoria in produto.categoria_set() %}
>
> At no time can parentheses be used when referencing variables. The correct
> way to write this tag would be {% for categoria in produto.categoria_set %}.
>
>
> Make sure to review the template syntax for accessing context variables
> and methods:
> https://docs.djangoproject.com/en/1.9/ref/templates/language/#variables
>
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXoFit4aj1sLmNwwiZ2%3DYg2%2Bz2cp0DuNk-cPxxyn8sikA%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/CALn3ei216v2rJedxCuZF3hwx9OFhqVB3hUcww%3D9eXL1%2BvcB42Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Relations one-to-many on django

2016-02-23 Thread James Schneider
>
> I try to use
>>
>> {% if categorias %}
>> 
>> {% for categoria in produto.categoria_set() %}

At no time can parentheses be used when referencing variables. The correct
way to write this tag would be {% for categoria in produto.categoria_set %}.


Make sure to review the template syntax for accessing context variables and
methods:
https://docs.djangoproject.com/en/1.9/ref/templates/language/#variables


-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXoFit4aj1sLmNwwiZ2%3DYg2%2Bz2cp0DuNk-cPxxyn8sikA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread James Schneider
On Tue, Feb 23, 2016 at 6:03 AM, Bernardo Garcia  wrote:

> Hi everyone Djangonauts
> :)
>
> Currently I am exposing a Django application (for the momento is just
> thier users schema) with Django Rest Framework and happen that each
> serialized model, in the url attribute, I have is the localhost machine
> address development and don't take the hostname of my production server
> machine which is located in amazon like as EC2 instance
>
>
> In this picture can detailed it.
>

Nginx is proxying the end-users' request to http://127.0.0.1:8000, which is
where Gunicorn is running. Gunicorn has no idea that there is a proxy in
front of it, so it assumes that the request is being sent by the server
itself, to the server itself. Gunicorn then passes along the Host header to
Django/DRF, which in turn uses it to generate the URL's that you are
getting.

You need to tell Nginx to send the correct headers to indicate to Gunicorn
that the connection is being proxied, and the correct address to use. See
this SO:

http://stackoverflow.com/questions/19669376/django-rest-framework-absolute-urls-with-nginx-always-return-127-0-0-1

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUuy1nKmLqgT%2BJFPsRDDkcxkaxA%3DU46jZfHcD5Xnawg2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Relations one-to-many on django

2016-02-23 Thread Douglas Bonafe
Hello everybody!
I'm new on this forum and in django.
I'm using Python 2.7 environment.

I have the following models.py:

class Categoria(models.Model):
>
> DEFAULT_CATHEGORY = 0
> nome = models.CharField(max_length=255, null=False, default='0')
>
> def __unicode__(self):
> return self.nome
>
> class Produto(models.Model):
>
> nome = models.CharField(max_length=255, null=False)
> pontos_na_compra = models.DecimalField(decimal_places=4, 
> max_digits=10, default=0)
> pontos_na_troca = models.DecimalField(decimal_places=4, max_digits=10, 
> default=0)
> foto = models.ImageField(upload_to=get_image_path, blank=True, 
> null=True)
>
> categoria = models.ForeignKey(
> Categoria,
> default=Categoria.DEFAULT_CATHEGORY
> )
>
> def __unicode__(self):
> return "%s, %s" % (self.nome, self.codigo_depara)
>

I want the relation: each Categoria (cathegory) has many Produto 
(products). Is it correct in the model?
I don't have anything on views.py relationed to it.

I want to do some code like this into HTML file:

show CATEGORIA.nome 
>
for each PRODUTO in LIST OF PRODUCTS IN CATEGORIA do:
>
   show PRODUTO.nome
>
   show PRODUTO.pontos_na_compra
>
   show PRODUTO.foto
>
end-for 
>
 
I try to use

> {% if categorias %}
> 
> {% for categoria in produto.categoria_set() %}
> 
> # SHOW ALL HERE. HOW?
> 
> {% endfor %}
> 
>   {% else %}
>   
>  Nenhum produto encontrado!
>   
>   {% endif %}


But it didn't find the categoria_set() method and returns this:

Could not parse the remainder: '()' from 'produto.categoria_set()'

Request Method: GET 
Request URL: http://127.0.0.1:8000/ 
Django Version: 1.9.2 
Exception Type: TemplateSyntaxError 
Exception Value: 

Could not parse the remainder: '()' from 'produto.categoria_set()'

Exception Location: 
/home/dsbonafe/.virtualenvs/bruno/local/lib/python2.7/site-packages/django/template/base.py
 
in parse, line 516 
Python Executable: /home/dsbonafe/.virtualenvs/bruno/bin/python 
Python Version: 2.7.6 
Python Path: 

['/home/dsbonafe/Documentos/Projetos/Bruno Mercado/bruno/redewebsite',
 '/home/dsbonafe/.virtualenvs/bruno/lib/python2.7',
 '/home/dsbonafe/.virtualenvs/bruno/lib/python2.7/plat-x86_64-linux-gnu',
 '/home/dsbonafe/.virtualenvs/bruno/lib/python2.7/lib-tk',
 '/home/dsbonafe/.virtualenvs/bruno/lib/python2.7/lib-old',
 '/home/dsbonafe/.virtualenvs/bruno/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/dsbonafe/.virtualenvs/bruno/local/lib/python2.7/site-packages',
 '/home/dsbonafe/.virtualenvs/bruno/lib/python2.7/site-packages']

Server time: Ter, 23 Fev 2016 20:55:39 +

Someone could help me?

Thanks a lot.
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a048337-0c19-4266-8b17-87235cd35daa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Bernardo Garcia
Felipe, give me a couple of minutes and I tell to you, but If you see my 
first post in this thread, the api links is related with the serializers.py 
file, in the urls.py files the router.register sentence and the views.py 
the ViewSet class

In this post   is detailed 
... 
http://stackoverflow.com/questions/35565749/api-rest-urls-serialized-models-dont-work-with-the-hostname-of-my-production
 
and in the djangorestframework tutorial explain how to 
doing http://www.django-rest-framework.org/tutorial/quickstart/

On Tuesday, February 23, 2016 at 12:39:49 PM UTC-5, Fellipe Henrique wrote:
>
> Sorry to reply your post, but.. how do you show all api link? there's any 
> settings for these? I asking because, when I try on my api, show me 404 
> page...
>
>
>
>
> T.·.F.·.A.·. S+F
> *Fellipe Henrique P. Soares*
>
> e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 
> 's/(.)/chr(ord($1)-2*3)/ge'
> *Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh 
> *
> *Blog: *http:www.fellipeh.eti.br
> *GitHub: https://github.com/fellipeh *
> *Twitter: @fh_bash*
>
> On Tue, Feb 23, 2016 at 12:42 PM, Bernardo Garcia  > wrote:
>
> Avraham, so yes, efectively ...
>
> This is my gunicorn_config.py
>
> command = '/opt/uleague/bin/gunicorn'
> pythonpath = '/opt/uleague/pickapp'
> bind = '127.0.0.1:8000'
> workers = 3
>
>
> I will should in the directive bind put the  internal ip address of my 
> machine?
> I have some doubts
>
>
>- The internal ip address of my machine is 172.31.60.141
>
>
> root@ip-172-31-60-141:/etc/nginx/sites-enabled# ifconfig 
> eth0  Link encap:Ethernet  HWaddr 12:73:40:a8:59:99  
>   inet addr:172.31.60.141  Bcast:172.31.63.255  Mask:255.255.240.0
>   inet6 addr: fe80::1073:40ff:fea8:5999/64 Scope:Link
>   UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
>   RX packets:220239 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:76169 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:1000 
>   RX bytes:238957069 (238.9 MB)  TX bytes:13656430 (13.6 MB)
>
> loLink encap:Local Loopback  
>   inet addr:127.0.0.1  Mask:255.0.0.0
>   inet6 addr: ::1/128 Scope:Host
>   UP LOOPBACK RUNNING  MTU:65536  Metric:1
>   RX packets:53064 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:53064 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:0 
>   RX bytes:16846573 (16.8 MB)  TX bytes:16846573 (16.8 MB)
>
> root@ip-172-31-60-141:/etc/nginx/sites-enabled# 
>
> But in my dashboard console, the dns public of my ec2 instance is:
> ec2-52-90-253-22.compute-1.amazonaws.com, in fact, you can copy this url 
> in a browser...
>
> I don't know that value of address put in my gunicorn_config.py in the 
> directive bind.
> I put the internal ip address but does not work my server deployment
>
> And my nginx configuration is the following:
>
> /etc/nginx/sites-enabled/myproject , in which I unknown if in the 
> server_name and proxy_pass directives I should fix some values too..
> server {
> *server_name yourdomainorip.com ;*
> access_log off;
> location / {
> *proxy_pass http://127.0.0.1:8000 ;*
> proxy_set_header X-Forwarded-Host $server_name;
> proxy_set_header X-Real-IP $remote_addr;
> add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM 
> NAV"';
> }
> }
>
>  
>
>
>
>
>
> On Tuesday, February 23, 2016 at 9:37:50 AM UTC-5, Avraham Serour wrote:
>
> are you using a config file for gunicorn? in the example it tells to use:
>
> bind = '127.0.0.1:8001'
>
> are you binding to 127.0.0.1 ?
>
> On Tue, Feb 23, 2016 at 4:33 PM, Bernardo Garcia  
> wrote:
>
> Hi Mr. Avraham Serour thanks for the attention
>
> In my amazon ec2 production server I am running my Django Application 
> using nginx, and gunicorn accord to this tutorial 
> https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
>
> python manage.py runserver is used just in my local development machine
>
> On Tuesday, February 23, 2016 at 9:25:36 AM UTC-5, Avraham Serour wrote:
>
> are you running django using manage.py runserver?
>
>
> On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia  
> wrote:
>
> Hi everyone Djangonauts
> :)
>
> Currently I am exposing a Django application (for the momento is just 
> thier users schema) with Django Rest Framework and happen that each 
> serialized model, in the url attribute, I have is the localhost machine 
> address development and don't take the hostname of my production server 
> machine which is located in amazon like as EC2 instance
>
>
> In this picture can detailed it.
>
>
> 
>
>
>
> How to make for 

Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Avraham Serour
this seems to be the problem, honestly I don't have much experience with
gunicorn, I've used uwsgi and never had such problems.

I hope someone on this list with more experience with gunicorn can tell.

I suggest you either look for some other django+gunicorn tutorials and see
what they suggest or go to uwsgi like me and be happy :)



On Tue, Feb 23, 2016 at 5:42 PM, Bernardo Garcia  wrote:

> Avraham, so yes, efectively ...
>
> This is my gunicorn_config.py
>
> command = '/opt/uleague/bin/gunicorn'
> pythonpath = '/opt/uleague/pickapp'
> bind = '127.0.0.1:8000'
> workers = 3
>
>
> I will should in the directive bind put the  internal ip address of my
> machine?
> I have some doubts
>
>
>- The internal ip address of my machine is 172.31.60.141
>
>
> root@ip-172-31-60-141:/etc/nginx/sites-enabled# ifconfig
> eth0  Link encap:Ethernet  HWaddr 12:73:40:a8:59:99
>   inet addr:172.31.60.141  Bcast:172.31.63.255  Mask:255.255.240.0
>   inet6 addr: fe80::1073:40ff:fea8:5999/64 Scope:Link
>   UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
>   RX packets:220239 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:76169 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:1000
>   RX bytes:238957069 (238.9 MB)  TX bytes:13656430 (13.6 MB)
>
> loLink encap:Local Loopback
>   inet addr:127.0.0.1  Mask:255.0.0.0
>   inet6 addr: ::1/128 Scope:Host
>   UP LOOPBACK RUNNING  MTU:65536  Metric:1
>   RX packets:53064 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:53064 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:0
>   RX bytes:16846573 (16.8 MB)  TX bytes:16846573 (16.8 MB)
>
> root@ip-172-31-60-141:/etc/nginx/sites-enabled#
>
> But in my dashboard console, the dns public of my ec2 instance is:
> ec2-52-90-253-22.compute-1.amazonaws.com, in fact, you can copy this url
> in a browser...
>
> I don't know that value of address put in my gunicorn_config.py in the
> directive bind.
> I put the internal ip address but does not work my server deployment
>
> And my nginx configuration is the following:
>
> /etc/nginx/sites-enabled/myproject , in which I unknown if in the
> server_name and proxy_pass directives I should fix some values too..
> server {
> *server_name yourdomainorip.com ;*
> access_log off;
> location / {
> *proxy_pass http://127.0.0.1:8000 ;*
> proxy_set_header X-Forwarded-Host $server_name;
> proxy_set_header X-Real-IP $remote_addr;
> add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM
> NAV"';
> }
> }
>
>
>
>
>
>
>
> On Tuesday, February 23, 2016 at 9:37:50 AM UTC-5, Avraham Serour wrote:
>>
>> are you using a config file for gunicorn? in the example it tells to use:
>>
>> bind = '127.0.0.1:8001'
>>
>> are you binding to 127.0.0.1 ?
>>
>> On Tue, Feb 23, 2016 at 4:33 PM, Bernardo Garcia 
>> wrote:
>>
>>> Hi Mr. Avraham Serour thanks for the attention
>>>
>>> In my amazon ec2 production server I am running my Django Application
>>> using nginx, and gunicorn accord to this tutorial
>>> https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
>>>
>>> python manage.py runserver is used just in my local development machine
>>>
>>> On Tuesday, February 23, 2016 at 9:25:36 AM UTC-5, Avraham Serour wrote:

 are you running django using manage.py runserver?


 On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia 
 wrote:

> Hi everyone Djangonauts
> :)
>
> Currently I am exposing a Django application (for the momento is just
> thier users schema) with Django Rest Framework and happen that each
> serialized model, in the url attribute, I have is the localhost machine
> address development and don't take the hostname of my production server
> machine which is located in amazon like as EC2 instance
>
>
> In this picture can detailed it.
>
>
> 
>
>
>
> How to make for the url of each model that I've serialized take the
> hostname of the production machine in which the application is deployed? 
> In
> this case, an amazon ec2 instance ...
>
>
> These are my serialized models userprofiles/serializers.py
>
>
> from django.contrib.auth.models import Groupfrom .models import User, 
> PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
> serializers
> # Serializers define the API representation# Exponse the model and their 
> fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = User
> fields = ('url','id', 'username', 
> 

Re: Accessing Request Object in Form Definition

2016-02-23 Thread Chris Kavanagh
Thank you so much, James. . .I greatly appreciate you taking the time to 
answer!

On Tuesday, February 23, 2016 at 1:50:57 AM UTC-5, James Schneider wrote:
>
> On Mon, Feb 22, 2016 at 10:23 PM, Chris Kavanagh  > wrote:
>
>> To possibly answer my own question, thinking out loud, we have to 
>> override the Form Constructor so we can pass in the Request from the view 
>> when instantiating the Form?
>>
>
> You beat me to it. Yes, you would need to override __init__() to include 
> the request in to your form class. Be sure to keep it out of your 
> args/kwargs that are passed on to your super() call, though, as it will 
> confuse the parent form class (if I remember correctly when I did the same 
> thing). If you are using CBV's, that you'll need to override get_form() as 
> well in order to return the form with the self.request as one of the 
> arguments being passed in.
>
> -James
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ccd7441-900f-474d-ab26-4e2e737c343c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Fellipe Henrique
Sorry to reply your post, but.. how do you show all api link? there's any
settings for these? I asking because, when I try on my api, show me 404
page...




T.·.F.·.A.·. S+F
*Fellipe Henrique P. Soares*

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
*Fedora Ambassador: https://fedoraproject.org/wiki/User:Fellipeh
*
*Blog: *http:www.fellipeh.eti.br
*GitHub: https://github.com/fellipeh *
*Twitter: @fh_bash*

On Tue, Feb 23, 2016 at 12:42 PM, Bernardo Garcia 
wrote:

> Avraham, so yes, efectively ...
>
> This is my gunicorn_config.py
>
> command = '/opt/uleague/bin/gunicorn'
> pythonpath = '/opt/uleague/pickapp'
> bind = '127.0.0.1:8000'
> workers = 3
>
>
> I will should in the directive bind put the  internal ip address of my
> machine?
> I have some doubts
>
>
>- The internal ip address of my machine is 172.31.60.141
>
>
> root@ip-172-31-60-141:/etc/nginx/sites-enabled# ifconfig
> eth0  Link encap:Ethernet  HWaddr 12:73:40:a8:59:99
>   inet addr:172.31.60.141  Bcast:172.31.63.255  Mask:255.255.240.0
>   inet6 addr: fe80::1073:40ff:fea8:5999/64 Scope:Link
>   UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
>   RX packets:220239 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:76169 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:1000
>   RX bytes:238957069 (238.9 MB)  TX bytes:13656430 (13.6 MB)
>
> loLink encap:Local Loopback
>   inet addr:127.0.0.1  Mask:255.0.0.0
>   inet6 addr: ::1/128 Scope:Host
>   UP LOOPBACK RUNNING  MTU:65536  Metric:1
>   RX packets:53064 errors:0 dropped:0 overruns:0 frame:0
>   TX packets:53064 errors:0 dropped:0 overruns:0 carrier:0
>   collisions:0 txqueuelen:0
>   RX bytes:16846573 (16.8 MB)  TX bytes:16846573 (16.8 MB)
>
> root@ip-172-31-60-141:/etc/nginx/sites-enabled#
>
> But in my dashboard console, the dns public of my ec2 instance is:
> ec2-52-90-253-22.compute-1.amazonaws.com, in fact, you can copy this url
> in a browser...
>
> I don't know that value of address put in my gunicorn_config.py in the
> directive bind.
> I put the internal ip address but does not work my server deployment
>
> And my nginx configuration is the following:
>
> /etc/nginx/sites-enabled/myproject , in which I unknown if in the
> server_name and proxy_pass directives I should fix some values too..
> server {
> *server_name yourdomainorip.com ;*
> access_log off;
> location / {
> *proxy_pass http://127.0.0.1:8000 ;*
> proxy_set_header X-Forwarded-Host $server_name;
> proxy_set_header X-Real-IP $remote_addr;
> add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM
> NAV"';
> }
> }
>
>
>
>
>
>
>
> On Tuesday, February 23, 2016 at 9:37:50 AM UTC-5, Avraham Serour wrote:
>>
>> are you using a config file for gunicorn? in the example it tells to use:
>>
>> bind = '127.0.0.1:8001'
>>
>> are you binding to 127.0.0.1 ?
>>
>> On Tue, Feb 23, 2016 at 4:33 PM, Bernardo Garcia 
>> wrote:
>>
>>> Hi Mr. Avraham Serour thanks for the attention
>>>
>>> In my amazon ec2 production server I am running my Django Application
>>> using nginx, and gunicorn accord to this tutorial
>>> https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
>>>
>>> python manage.py runserver is used just in my local development machine
>>>
>>> On Tuesday, February 23, 2016 at 9:25:36 AM UTC-5, Avraham Serour wrote:

 are you running django using manage.py runserver?


 On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia 
 wrote:

> Hi everyone Djangonauts
> :)
>
> Currently I am exposing a Django application (for the momento is just
> thier users schema) with Django Rest Framework and happen that each
> serialized model, in the url attribute, I have is the localhost machine
> address development and don't take the hostname of my production server
> machine which is located in amazon like as EC2 instance
>
>
> In this picture can detailed it.
>
>
> 
>
>
>
> How to make for the url of each model that I've serialized take the
> hostname of the production machine in which the application is deployed? 
> In
> this case, an amazon ec2 instance ...
>
>
> These are my serialized models userprofiles/serializers.py
>
>
> from django.contrib.auth.models import Groupfrom .models import User, 
> PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
> serializers
> # Serializers define the API representation# Exponse the model and their 
> fieldsclass 

Re: Home Page

2016-02-23 Thread Bob Gailer
On Feb 23, 2016 7:59 AM, "Malik Rumi"  wrote:
>
> Why is there so little information in the docs

Documentation evolves. User input helps that process. Perhaps you can make
a contribution as you learn.

about how to build a home page

I'm not sure what you're looking for here. Designing a home page is not a
django topic. Using django to deliver a homepage is the same as delivering
any other page

where to put the url

I don't understand  what you mean by that. please explain

whether or not to build a separate app around it, or why not to put it in
the folder with settings in it,

If your home page is a portal to several apps then it seems to me you would
have an app for the home page

And how to handle a complex home page with a lot of changing content - like
on a newspaper, where Django was created?

Seems to me that's not a django issue.
>
> And second, where (other than trial and error) do I find that kind of
documentation / support?

Google CMS?

-- 
You received this message because you are subscribed 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/CAP1rxO4_xrKa%2BtdZ4VoHVbwxuvj628D%3DgURg%3DqFP-8R8c9umTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: context dictionary

2016-02-23 Thread Andreas Kuhne
True, didn't know that it was active in that way nowadays. To Malik: Don't
use user as a key in the dictionary.

Regards,

Andréas

2016-02-23 16:01 GMT+01:00 :

> Wouldn't including the name 'user' in your context dictionary override the
> authenticated user object in your template? Might make for some unexpected
> behavior.
>
> --
> You received this message because you are subscribed 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/5e3a7134-d7a6-4385-863f-c25437922127%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/CALXYUbnOJ%2B9HXFePmnrRCbLo4wokVsh5cz%2BaMaHvMQnEWhx9OQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Bernardo Garcia
Avraham, so yes, efectively ...

This is my gunicorn_config.py

command = '/opt/uleague/bin/gunicorn'
pythonpath = '/opt/uleague/pickapp'
bind = '127.0.0.1:8000'
workers = 3


I will should in the directive bind put the  internal ip address of my 
machine?
I have some doubts


   - The internal ip address of my machine is 172.31.60.141
   

root@ip-172-31-60-141:/etc/nginx/sites-enabled# ifconfig 
eth0  Link encap:Ethernet  HWaddr 12:73:40:a8:59:99  
  inet addr:172.31.60.141  Bcast:172.31.63.255  Mask:255.255.240.0
  inet6 addr: fe80::1073:40ff:fea8:5999/64 Scope:Link
  UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
  RX packets:220239 errors:0 dropped:0 overruns:0 frame:0
  TX packets:76169 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000 
  RX bytes:238957069 (238.9 MB)  TX bytes:13656430 (13.6 MB)

loLink encap:Local Loopback  
  inet addr:127.0.0.1  Mask:255.0.0.0
  inet6 addr: ::1/128 Scope:Host
  UP LOOPBACK RUNNING  MTU:65536  Metric:1
  RX packets:53064 errors:0 dropped:0 overruns:0 frame:0
  TX packets:53064 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:0 
  RX bytes:16846573 (16.8 MB)  TX bytes:16846573 (16.8 MB)

root@ip-172-31-60-141:/etc/nginx/sites-enabled# 

But in my dashboard console, the dns public of my ec2 instance is:
ec2-52-90-253-22.compute-1.amazonaws.com, in fact, you can copy this url in 
a browser...

I don't know that value of address put in my gunicorn_config.py in the 
directive bind.
I put the internal ip address but does not work my server deployment

And my nginx configuration is the following:

/etc/nginx/sites-enabled/myproject , in which I unknown if in the 
server_name and proxy_pass directives I should fix some values too..
server {
*server_name yourdomainorip.com;*
access_log off;
location / {
*proxy_pass http://127.0.0.1:8000;*
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM 
NAV"';
}
}

 





On Tuesday, February 23, 2016 at 9:37:50 AM UTC-5, Avraham Serour wrote:
>
> are you using a config file for gunicorn? in the example it tells to use:
>
> bind = '127.0.0.1:8001'
>
> are you binding to 127.0.0.1 ?
>
> On Tue, Feb 23, 2016 at 4:33 PM, Bernardo Garcia  > wrote:
>
>> Hi Mr. Avraham Serour thanks for the attention
>>
>> In my amazon ec2 production server I am running my Django Application 
>> using nginx, and gunicorn accord to this tutorial 
>> https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
>>
>> python manage.py runserver is used just in my local development machine
>>
>> On Tuesday, February 23, 2016 at 9:25:36 AM UTC-5, Avraham Serour wrote:
>>>
>>> are you running django using manage.py runserver?
>>>
>>>
>>> On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia  
>>> wrote:
>>>
 Hi everyone Djangonauts
 :)

 Currently I am exposing a Django application (for the momento is just 
 thier users schema) with Django Rest Framework and happen that each 
 serialized model, in the url attribute, I have is the localhost machine 
 address development and don't take the hostname of my production server 
 machine which is located in amazon like as EC2 instance


 In this picture can detailed it.


 



 How to make for the url of each model that I've serialized take the 
 hostname of the production machine in which the application is deployed? 
 In 
 this case, an amazon ec2 instance ...


 These are my serialized models userprofiles/serializers.py 


 from django.contrib.auth.models import Groupfrom .models import User, 
 PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
 serializers
 # Serializers define the API representation# Exponse the model and their 
 fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
 class Meta:
 model = User
 fields = ('url','id', 'username', 
 'password','first_name','last_name','email','is_active',
   
 'is_staff','is_superuser','last_login','date_joined','is_player','is_coach',
   'is_viewer','photo',)
 class GroupSerializer(serializers.HyperlinkedModelSerializer):
 class Meta:
 model = Group
 fields = ('url', 'name')

 class PlayerProfileSerializer(serializers.HyperlinkedModelSerializer):
 class Meta:
 model = PlayerProfile
 fields = ('url', 'user','full_name','position',)
 class CoachProfileSerializer(serializers.HyperlinkedModelSerializer):
 

Re: Home Page

2016-02-23 Thread jorrit787
I struggled with this as well. I usually end up creating a 'common' app for my 
homepage and project-wide templates and static files, but I don't know if 
that's considered a best practice. Alternatively you could put your homepage in 
your most used/most important app.

-- 
You received this message because you are subscribed 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/94c2253b-3343-436a-a7c2-606d2358579c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: context dictionary

2016-02-23 Thread jorrit787
Wouldn't including the name 'user' in your context dictionary override the 
authenticated user object in your template? Might make for some unexpected 
behavior.

-- 
You received this message because you are subscribed 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/5e3a7134-d7a6-4385-863f-c25437922127%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Avraham Serour
are you using a config file for gunicorn? in the example it tells to use:

bind = '127.0.0.1:8001'

are you binding to 127.0.0.1 ?

On Tue, Feb 23, 2016 at 4:33 PM, Bernardo Garcia  wrote:

> Hi Mr. Avraham Serour thanks for the attention
>
> In my amazon ec2 production server I am running my Django Application
> using nginx, and gunicorn accord to this tutorial
> https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
>
> python manage.py runserver is used just in my local development machine
>
> On Tuesday, February 23, 2016 at 9:25:36 AM UTC-5, Avraham Serour wrote:
>>
>> are you running django using manage.py runserver?
>>
>>
>> On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia 
>> wrote:
>>
>>> Hi everyone Djangonauts
>>> :)
>>>
>>> Currently I am exposing a Django application (for the momento is just
>>> thier users schema) with Django Rest Framework and happen that each
>>> serialized model, in the url attribute, I have is the localhost machine
>>> address development and don't take the hostname of my production server
>>> machine which is located in amazon like as EC2 instance
>>>
>>>
>>> In this picture can detailed it.
>>>
>>>
>>> 
>>>
>>>
>>>
>>> How to make for the url of each model that I've serialized take the
>>> hostname of the production machine in which the application is deployed? In
>>> this case, an amazon ec2 instance ...
>>>
>>>
>>> These are my serialized models userprofiles/serializers.py
>>>
>>>
>>> from django.contrib.auth.models import Groupfrom .models import User, 
>>> PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
>>> serializers
>>> # Serializers define the API representation# Exponse the model and their 
>>> fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
>>> class Meta:
>>> model = User
>>> fields = ('url','id', 'username', 
>>> 'password','first_name','last_name','email','is_active',
>>>   
>>> 'is_staff','is_superuser','last_login','date_joined','is_player','is_coach',
>>>   'is_viewer','photo',)
>>> class GroupSerializer(serializers.HyperlinkedModelSerializer):
>>> class Meta:
>>> model = Group
>>> fields = ('url', 'name')
>>>
>>> class PlayerProfileSerializer(serializers.HyperlinkedModelSerializer):
>>> class Meta:
>>> model = PlayerProfile
>>> fields = ('url', 'user','full_name','position',)
>>> class CoachProfileSerializer(serializers.HyperlinkedModelSerializer):
>>> class Meta:
>>> model = CoachProfile
>>> fields = ('url', 'user','full_name',)
>>> class ViewerProfileSerializer(serializers.HyperlinkedModelSerializer):
>>> class Meta:
>>> model = ViewerProfile
>>> fields = ('url', 'user','full_name','specialty')
>>>
>>>
>>>
>>> This is my urls.py global file (not belont to userprofiles application
>>> that contain all the serialized models.)
>>>
>>>
>>> from django.conf.urls import url, includefrom django.contrib import admin
>>> from .views import home, home_files
>>> from rest_framework import routersfrom userprofiles import views
>>> # Router provide an easy way of automatically determining the URL conf
>>> router = routers.DefaultRouter()
>>> router.register(r'users', views.UserViewSet)
>>> router.register(r'groups', views.GroupViewSet)
>>> router.register(r'players', views.PlayerProfileViewSet)
>>> router.register(r'coachs', views.CoachProfileViewSet)
>>> router.register(r'views', views.ViewerProfileViewSet)
>>>
>>>
>>> urlpatterns = [
>>> url(r'^admin/', admin.site.urls),
>>> url(r'^$', home, name='home'),
>>>
>>> url(r'^(?P(robots.txt)|(humans.txt))$',
>>> home_files, name='home-files'),
>>>
>>> # Wire up our API using automatic URL routing.
>>> url(r'^api/v1/', include(router.urls)),
>>>
>>> # If you're intending to use the browsable API you'll probably also 
>>> want to add REST framework's
>>> # login and logout views.
>>> url(r'^api-auth/', include('rest_framework.urls', 
>>> namespace='rest_framework'))]
>>>
>>>
>>>
>>> And this is my userprofiles/views.py file in where I have expose the
>>> models serializeds
>>>
>>>
>>> from django.shortcuts import renderfrom django.contrib.auth.models import 
>>> Groupfrom .models import User, PlayerProfile, CoachProfile, ViewerProfile
>>> from rest_framework import viewsetsfrom .serializers import UserSerializer, 
>>> GroupSerializer, PlayerProfileSerializer, CoachProfileSerializer, 
>>> ViewerProfileSerializer
>>> # Create your views here.
>>> # Viewsets define the behavior of the viewclass 
>>> UserViewSet(viewsets.ModelViewSet):
>>> """
>>> API endpoint that allows users to be viewed or edited.
>>> """
>>> queryset = User.objects.all().order_by('-date_joined')
>>> serializer_class = UserSerializer
>>> class GroupViewSet(viewsets.ModelViewSet):
>>> 

Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Bernardo Garcia
Hi Mr. Avraham Serour thanks for the attention

In my amazon ec2 production server I am running my Django Application using 
nginx, and gunicorn accord to this 
tutorial 
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn

python manage.py runserver is used just in my local development machine

On Tuesday, February 23, 2016 at 9:25:36 AM UTC-5, Avraham Serour wrote:
>
> are you running django using manage.py runserver?
>
>
> On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia  > wrote:
>
>> Hi everyone Djangonauts
>> :)
>>
>> Currently I am exposing a Django application (for the momento is just 
>> thier users schema) with Django Rest Framework and happen that each 
>> serialized model, in the url attribute, I have is the localhost machine 
>> address development and don't take the hostname of my production server 
>> machine which is located in amazon like as EC2 instance
>>
>>
>> In this picture can detailed it.
>>
>>
>> 
>>
>>
>>
>> How to make for the url of each model that I've serialized take the 
>> hostname of the production machine in which the application is deployed? In 
>> this case, an amazon ec2 instance ...
>>
>>
>> These are my serialized models userprofiles/serializers.py 
>>
>>
>> from django.contrib.auth.models import Groupfrom .models import User, 
>> PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
>> serializers
>> # Serializers define the API representation# Exponse the model and their 
>> fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
>> class Meta:
>> model = User
>> fields = ('url','id', 'username', 
>> 'password','first_name','last_name','email','is_active',
>>   
>> 'is_staff','is_superuser','last_login','date_joined','is_player','is_coach',
>>   'is_viewer','photo',)
>> class GroupSerializer(serializers.HyperlinkedModelSerializer):
>> class Meta:
>> model = Group
>> fields = ('url', 'name')
>>
>> class PlayerProfileSerializer(serializers.HyperlinkedModelSerializer):
>> class Meta:
>> model = PlayerProfile
>> fields = ('url', 'user','full_name','position',)
>> class CoachProfileSerializer(serializers.HyperlinkedModelSerializer):
>> class Meta:
>> model = CoachProfile
>> fields = ('url', 'user','full_name',)
>> class ViewerProfileSerializer(serializers.HyperlinkedModelSerializer):
>> class Meta:
>> model = ViewerProfile
>> fields = ('url', 'user','full_name','specialty')
>>
>>
>>
>> This is my urls.py global file (not belont to userprofiles application 
>> that contain all the serialized models.)
>>
>>
>> from django.conf.urls import url, includefrom django.contrib import admin
>> from .views import home, home_files
>> from rest_framework import routersfrom userprofiles import views
>> # Router provide an easy way of automatically determining the URL conf
>> router = routers.DefaultRouter()
>> router.register(r'users', views.UserViewSet)
>> router.register(r'groups', views.GroupViewSet)
>> router.register(r'players', views.PlayerProfileViewSet)
>> router.register(r'coachs', views.CoachProfileViewSet)
>> router.register(r'views', views.ViewerProfileViewSet)
>>
>>
>> urlpatterns = [
>> url(r'^admin/', admin.site.urls),
>> url(r'^$', home, name='home'),
>>
>> url(r'^(?P(robots.txt)|(humans.txt))$',
>> home_files, name='home-files'),
>>
>> # Wire up our API using automatic URL routing.
>> url(r'^api/v1/', include(router.urls)),
>>
>> # If you're intending to use the browsable API you'll probably also want 
>> to add REST framework's
>> # login and logout views.
>> url(r'^api-auth/', include('rest_framework.urls', 
>> namespace='rest_framework'))] 
>>
>>
>>
>> And this is my userprofiles/views.py file in where I have expose the 
>> models serializeds
>>
>>
>> from django.shortcuts import renderfrom django.contrib.auth.models import 
>> Groupfrom .models import User, PlayerProfile, CoachProfile, ViewerProfile
>> from rest_framework import viewsetsfrom .serializers import UserSerializer, 
>> GroupSerializer, PlayerProfileSerializer, CoachProfileSerializer, 
>> ViewerProfileSerializer
>> # Create your views here.
>> # Viewsets define the behavior of the viewclass 
>> UserViewSet(viewsets.ModelViewSet):
>> """
>> API endpoint that allows users to be viewed or edited.
>> """
>> queryset = User.objects.all().order_by('-date_joined')
>> serializer_class = UserSerializer
>> class GroupViewSet(viewsets.ModelViewSet):
>> """
>> API endpoint that allows groups to be viewed or edited.
>> """
>> queryset = Group.objects.all()
>> serializer_class = GroupSerializer
>> class PlayerProfileViewSet(viewsets.ModelViewSet):
>> """
>> API endpoint that allows players to be viewed or edited.
>> """
>> queryset = 

Re: API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Avraham Serour
are you running django using manage.py runserver?


On Tue, Feb 23, 2016 at 4:03 PM, Bernardo Garcia  wrote:

> Hi everyone Djangonauts
> :)
>
> Currently I am exposing a Django application (for the momento is just
> thier users schema) with Django Rest Framework and happen that each
> serialized model, in the url attribute, I have is the localhost machine
> address development and don't take the hostname of my production server
> machine which is located in amazon like as EC2 instance
>
>
> In this picture can detailed it.
>
>
> 
>
>
>
> How to make for the url of each model that I've serialized take the
> hostname of the production machine in which the application is deployed? In
> this case, an amazon ec2 instance ...
>
>
> These are my serialized models userprofiles/serializers.py
>
>
> from django.contrib.auth.models import Groupfrom .models import User, 
> PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import 
> serializers
> # Serializers define the API representation# Exponse the model and their 
> fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = User
> fields = ('url','id', 'username', 
> 'password','first_name','last_name','email','is_active',
>   
> 'is_staff','is_superuser','last_login','date_joined','is_player','is_coach',
>   'is_viewer','photo',)
> class GroupSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = Group
> fields = ('url', 'name')
>
> class PlayerProfileSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = PlayerProfile
> fields = ('url', 'user','full_name','position',)
> class CoachProfileSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = CoachProfile
> fields = ('url', 'user','full_name',)
> class ViewerProfileSerializer(serializers.HyperlinkedModelSerializer):
> class Meta:
> model = ViewerProfile
> fields = ('url', 'user','full_name','specialty')
>
>
>
> This is my urls.py global file (not belont to userprofiles application
> that contain all the serialized models.)
>
>
> from django.conf.urls import url, includefrom django.contrib import admin
> from .views import home, home_files
> from rest_framework import routersfrom userprofiles import views
> # Router provide an easy way of automatically determining the URL conf
> router = routers.DefaultRouter()
> router.register(r'users', views.UserViewSet)
> router.register(r'groups', views.GroupViewSet)
> router.register(r'players', views.PlayerProfileViewSet)
> router.register(r'coachs', views.CoachProfileViewSet)
> router.register(r'views', views.ViewerProfileViewSet)
>
>
> urlpatterns = [
> url(r'^admin/', admin.site.urls),
> url(r'^$', home, name='home'),
>
> url(r'^(?P(robots.txt)|(humans.txt))$',
> home_files, name='home-files'),
>
> # Wire up our API using automatic URL routing.
> url(r'^api/v1/', include(router.urls)),
>
> # If you're intending to use the browsable API you'll probably also want 
> to add REST framework's
> # login and logout views.
> url(r'^api-auth/', include('rest_framework.urls', 
> namespace='rest_framework'))]
>
>
>
> And this is my userprofiles/views.py file in where I have expose the
> models serializeds
>
>
> from django.shortcuts import renderfrom django.contrib.auth.models import 
> Groupfrom .models import User, PlayerProfile, CoachProfile, ViewerProfile
> from rest_framework import viewsetsfrom .serializers import UserSerializer, 
> GroupSerializer, PlayerProfileSerializer, CoachProfileSerializer, 
> ViewerProfileSerializer
> # Create your views here.
> # Viewsets define the behavior of the viewclass 
> UserViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows users to be viewed or edited.
> """
> queryset = User.objects.all().order_by('-date_joined')
> serializer_class = UserSerializer
> class GroupViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows groups to be viewed or edited.
> """
> queryset = Group.objects.all()
> serializer_class = GroupSerializer
> class PlayerProfileViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows players to be viewed or edited.
> """
> queryset = PlayerProfile.objects.all()
> serializer_class = PlayerProfileSerializer
> class CoachProfileViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows coachs to be viewed or edited.
> """
> queryset = CoachProfile.objects.all()
> serializer_class = CoachProfileSerializer
> class ViewerProfileViewSet(viewsets.ModelViewSet):
> """
> API endpoint that allows viewers to be viewed or edited.
> """
> queryset = ViewerProfile.objects.all()
> serializer_class = ViewerProfileSerializer
>
>
> Any orientation or support about it, I will be 

API REST - Url's Serialized models don't work with the hostname of my production server - Django Rest Framework

2016-02-23 Thread Bernardo Garcia
Hi everyone Djangonauts
:)

Currently I am exposing a Django application (for the momento is just thier 
users schema) with Django Rest Framework and happen that each serialized 
model, in the url attribute, I have is the localhost machine address 
development and don't take the hostname of my production server machine 
which is located in amazon like as EC2 instance


In this picture can detailed it.






How to make for the url of each model that I've serialized take the 
hostname of the production machine in which the application is deployed? In 
this case, an amazon ec2 instance ...


These are my serialized models userprofiles/serializers.py 


from django.contrib.auth.models import Groupfrom .models import User, 
PlayerProfile, CoachProfile, ViewerProfilefrom rest_framework import serializers
# Serializers define the API representation# Exponse the model and their 
fieldsclass UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url','id', 'username', 
'password','first_name','last_name','email','is_active',
  
'is_staff','is_superuser','last_login','date_joined','is_player','is_coach',
  'is_viewer','photo',)
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ('url', 'name')

class PlayerProfileSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = PlayerProfile
fields = ('url', 'user','full_name','position',)
class CoachProfileSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = CoachProfile
fields = ('url', 'user','full_name',)
class ViewerProfileSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = ViewerProfile
fields = ('url', 'user','full_name','specialty')



This is my urls.py global file (not belont to userprofiles application that 
contain all the serialized models.)


from django.conf.urls import url, includefrom django.contrib import admin
from .views import home, home_files
from rest_framework import routersfrom userprofiles import views
# Router provide an easy way of automatically determining the URL conf
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
router.register(r'players', views.PlayerProfileViewSet)
router.register(r'coachs', views.CoachProfileViewSet)
router.register(r'views', views.ViewerProfileViewSet)


urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', home, name='home'),

url(r'^(?P(robots.txt)|(humans.txt))$',
home_files, name='home-files'),

# Wire up our API using automatic URL routing.
url(r'^api/v1/', include(router.urls)),

# If you're intending to use the browsable API you'll probably also want to 
add REST framework's
# login and logout views.
url(r'^api-auth/', include('rest_framework.urls', 
namespace='rest_framework'))] 



And this is my userprofiles/views.py file in where I have expose the models 
serializeds


from django.shortcuts import renderfrom django.contrib.auth.models import 
Groupfrom .models import User, PlayerProfile, CoachProfile, ViewerProfile
from rest_framework import viewsetsfrom .serializers import UserSerializer, 
GroupSerializer, PlayerProfileSerializer, CoachProfileSerializer, 
ViewerProfileSerializer
# Create your views here.
# Viewsets define the behavior of the viewclass 
UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by('-date_joined')
serializer_class = UserSerializer
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all()
serializer_class = GroupSerializer
class PlayerProfileViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows players to be viewed or edited.
"""
queryset = PlayerProfile.objects.all()
serializer_class = PlayerProfileSerializer
class CoachProfileViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows coachs to be viewed or edited.
"""
queryset = CoachProfile.objects.all()
serializer_class = CoachProfileSerializer
class ViewerProfileViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows viewers to be viewed or edited.
"""
queryset = ViewerProfile.objects.all()
serializer_class = ViewerProfileSerializer


Any orientation or support about it, I will be grateful :)

-- 
You received this message because you are subscribed 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 

Re: Home Page

2016-02-23 Thread Sithembewena Lloyd Dube
Have you done the tutorial? Django is suitable for everything you listed,
it's just that you need to learn how to implement those things in Django.
This means you need to know how to use Django.

I suggest you do the tutorial first.

On Tue, Feb 23, 2016 at 2:59 PM, Malik Rumi  wrote:

> Why is there so little information in the docs about how to build a home
> page, where to put the url, whether or not to build a separate app around
> it, why or why not to put it in the folder with settings in it, and how to
> handle a complex home page with a lot of changing content - like on a
> newspaper, where Django was created?
>
> And second, where (other than trial and error) do I find that kind of
> documentation / support?
>
> --
> You received this message because you are subscribed 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/82af7d52-2db2-449e-9f29-cb2f2b29e51d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,
Sithembewena

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


Re: context dictionary

2016-02-23 Thread Andreas Kuhne
Hi,

All you have to do is add what you want to the dictionary that you need for
your template. There isn't anything "magic" about the context. So for
example, if you want to have a model called "user" in the template, you can
add it by writing:

context = {}
context['user'] = User.objects.get(pk=user_id)

Fill the context with the information you want to present in the template
for presentation. It's not much harder than that

In the template you can then access the objects in the context object via
{{user.fullName}} where you would get the fullname property from the user
object.

Regards,

Andréas

2016-02-23 14:05 GMT+01:00 Malik Rumi :

> from the docs:
> Changed in Django 1.8:
>
> The context argument used to be called dictionary. That name is
> deprecated in Django 1.8 and will be removed in Django 1.10.
>
>
> https://docs.djangoproject.com/en/1.9/topics/http/shortcuts/#optional-arguments
>
>
> I've been fooling with Django since 1.6 and I don't recall it ever being
> called "just" dictionary. But presumably it will still, in fact, be a
> dictionary?
>
>
> I get the fact that the dictionary maps from Python objects to where on
> the template it goes, but that's really about all I've ever grasped about
> context. I've read the docs, but I don't feel like I really 'get it'.
>
>
> Can someone here suggest another source - book, blog, online, off, that
> really goes into depth, and step by step explains context and all the
> various ways it can be created in a view? It would be especially helpful if
> this resource went into more advanced and complex contexts, like in a page
> pulling from many different models.
>
>
> 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/1e604039-1eda-4632-bc45-d0762e179eac%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/CALXYUbm-T3_c%2BEUX%2Bx6Su-E4Z6XaqNz1_bFmWt%3DVg0geFPa%2BSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


context dictionary

2016-02-23 Thread Malik Rumi
from the docs:
Changed in Django 1.8:

The context argument used to be called dictionary. That name is deprecated 
in Django 1.8 and will be removed in Django 1.10.

https://docs.djangoproject.com/en/1.9/topics/http/shortcuts/#optional-arguments


I've been fooling with Django since 1.6 and I don't recall it ever being 
called "just" dictionary. But presumably it will still, in fact, be a 
dictionary?


I get the fact that the dictionary maps from Python objects to where on the 
template it goes, but that's really about all I've ever grasped about 
context. I've read the docs, but I don't feel like I really 'get it'.


Can someone here suggest another source - book, blog, online, off, that 
really goes into depth, and step by step explains context and all the 
various ways it can be created in a view? It would be especially helpful if 
this resource went into more advanced and complex contexts, like in a page 
pulling from many different models.


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/1e604039-1eda-4632-bc45-d0762e179eac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Home Page

2016-02-23 Thread Malik Rumi
Why is there so little information in the docs about how to build a home 
page, where to put the url, whether or not to build a separate app around 
it, why or why not to put it in the folder with settings in it, and how to 
handle a complex home page with a lot of changing content - like on a 
newspaper, where Django was created? 

And second, where (other than trial and error) do I find that kind of 
documentation / support?

-- 
You received this message because you are subscribed 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/82af7d52-2db2-449e-9f29-cb2f2b29e51d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installing MySQLdb for python2.7 in RHEL 6

2016-02-23 Thread Larry Martell
I did this:

# yum shell --enablerepo=remi
> remove php-mysql
> install php-mysqlnd
> run

Followed by this:

yum install mysql-devel
/usr/local/bin/pip2.7 install MySQL-python

Now the MySQL server is down and will not come up. It fails with this:

Fatal error: mysql.user table is damaged. Please run mysql_upgrade

Looks like 5.7 is now installed whereas before it was running 5.5
(Server version: 5.5.44 MySQL Community Server (GPL) by Remi') It
fails on start up with Fatal error: mysql.user table is damaged.
Please run mysql_upgrade But how can I run mysql_upgrade if I can't
start the server?

On Tue, Feb 23, 2016 at 6:43 AM, Larry Martell  wrote:
> This is a machine I have inherited and I really know nothing about it.
> I need to set up django on it, but I don't want to break anything.
> They use the Semantic Media Wiki, which uses PHP - If I do this could
> that break that?
>
> On Tue, Feb 23, 2016 at 2:12 AM, Kelvin Wong  wrote:
>> You are mixing the repos (remi and the regular redhat one). You should
>> decide which one you want to use for mysql and stick to it.
>>
>> The remi repo has the devel package available
>>
>> http://rpms.famillecollet.com/enterprise/6/remi/x86_64/repoview/applications.databases.group.html
>>
>> You can isolate a repo to see what it offers
>>
>> $ yum --disablerepo "*" --enablerepo "remi" list available
>>
>> K
>>
>>
>> On Monday, February 22, 2016 at 7:37:43 PM UTC-8, larry@gmail.com wrote:
>>>
>>> Not really sure what I am looking for or what to do.
>>>
>>> # yum list installed | grep mysql
>>> compat-mysql51.x86_64   5.1.54-1.el6.remi   @remi
>>> mysql.x86_645.5.44-1.el6.remi   @remi
>>> mysql-libs.x86_64   5.5.44-1.el6.remi   @remi
>>> mysql-server.x86_64 5.5.44-1.el6.remi   @remi
>>> mysql57-community-release.noarchel6-7
>>> @/mysql57-community-release-el6-7.noarch
>>> php-mysql.x86_645.4.43-1.el6.remi   @remi
>>>
>>> I don't see the devel package, but when I try to install it it fails
>>> as shown below.
>>>
>>> On Mon, Feb 22, 2016 at 10:20 PM, Kelvin Wong  wrote:
>>> > You need to locate the header files in order for that to compile.
>>> >
>>> > You might want to see if they are located somewhere on your system by
>>> > using
>>> > 'find' or else check 'yum list installed' to see if you have already
>>> > installed the mysql devel package for your version of the database
>>> > server
>>> > (i'm guessing that you haven't got the headers).
>>> >
>>> > If you haven't got them on your machine then you have to install them.
>>> >
>>> > K
>>> >
>>> > On Monday, February 22, 2016 at 7:10:34 PM UTC-8, larry@gmail.com
>>> > wrote:
>>> >>
>>> >> That failed:
>>> >>
>>> >> # yum install mysql-devel
>>> >> Loaded plugins: dellsysid, product-id, refresh-packagekit, security,
>>> >> subscription-manager
>>> >> Setting up Install Process
>>> >> Package mysql-devel is obsoleted by mysql-community-devel, trying to
>>> >> install mysql-community-devel-5.7.11-1.el6.x86_64 instead
>>> >> Resolving Dependencies
>>> >> --> Running transaction check
>>> >> ---> Package mysql-community-devel.x86_64 0:5.7.11-1.el6 will be
>>> >> installed
>>> >> --> Processing Dependency: mysql-community-libs(x86-64) = 5.7.11-1.el6
>>> >> for package: mysql-community-devel-5.7.11-1.el6.x86_64
>>> >> --> Processing Dependency: libmysqlclient.so.20()(64bit) for package:
>>> >> mysql-community-devel-5.7.11-1.el6.x86_64
>>> >> --> Running transaction check
>>> >> ---> Package mysql-community-libs.x86_64 0:5.7.11-1.el6 will be
>>> >> obsoleting
>>> >> --> Processing Dependency: mysql-community-common(x86-64) =
>>> >> 5.7.11-1.el6 for package: mysql-community-libs-5.7.11-1.el6.x86_64
>>> >> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted
>>> >> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package:
>>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>>> >> --> Processing Dependency:
>>> >> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package:
>>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>>> >> --> Processing Dependency:
>>> >> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package:
>>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>>> >> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi
>>> >> for package: mysql-server-5.5.44-1.el6.remi.x86_64
>>> >> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi
>>> >> for package: mysql-5.5.44-1.el6.remi.x86_64
>>> >> --> Running transaction check
>>> >> ---> Package mysql.x86_64 0:5.5.44-1.el6.remi will be obsoleted
>>> >> ---> Package mysql-community-client.x86_64 0:5.7.11-1.el6 will be
>>> >> obsoleting
>>> >> ---> Package mysql-community-common.x86_64 0:5.7.11-1.el6 will be
>>> >> installed
>>> >> ---> Package mysql-community-server.x86_64 0:5.7.11-1.el6 will be
>>> >> obsoleting
>>> >> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be 

Re: Installing MySQLdb for python2.7 in RHEL 6

2016-02-23 Thread Larry Martell
This is a machine I have inherited and I really know nothing about it.
I need to set up django on it, but I don't want to break anything.
They use the Semantic Media Wiki, which uses PHP - If I do this could
that break that?

On Tue, Feb 23, 2016 at 2:12 AM, Kelvin Wong  wrote:
> You are mixing the repos (remi and the regular redhat one). You should
> decide which one you want to use for mysql and stick to it.
>
> The remi repo has the devel package available
>
> http://rpms.famillecollet.com/enterprise/6/remi/x86_64/repoview/applications.databases.group.html
>
> You can isolate a repo to see what it offers
>
> $ yum --disablerepo "*" --enablerepo "remi" list available
>
> K
>
>
> On Monday, February 22, 2016 at 7:37:43 PM UTC-8, larry@gmail.com wrote:
>>
>> Not really sure what I am looking for or what to do.
>>
>> # yum list installed | grep mysql
>> compat-mysql51.x86_64   5.1.54-1.el6.remi   @remi
>> mysql.x86_645.5.44-1.el6.remi   @remi
>> mysql-libs.x86_64   5.5.44-1.el6.remi   @remi
>> mysql-server.x86_64 5.5.44-1.el6.remi   @remi
>> mysql57-community-release.noarchel6-7
>> @/mysql57-community-release-el6-7.noarch
>> php-mysql.x86_645.4.43-1.el6.remi   @remi
>>
>> I don't see the devel package, but when I try to install it it fails
>> as shown below.
>>
>> On Mon, Feb 22, 2016 at 10:20 PM, Kelvin Wong  wrote:
>> > You need to locate the header files in order for that to compile.
>> >
>> > You might want to see if they are located somewhere on your system by
>> > using
>> > 'find' or else check 'yum list installed' to see if you have already
>> > installed the mysql devel package for your version of the database
>> > server
>> > (i'm guessing that you haven't got the headers).
>> >
>> > If you haven't got them on your machine then you have to install them.
>> >
>> > K
>> >
>> > On Monday, February 22, 2016 at 7:10:34 PM UTC-8, larry@gmail.com
>> > wrote:
>> >>
>> >> That failed:
>> >>
>> >> # yum install mysql-devel
>> >> Loaded plugins: dellsysid, product-id, refresh-packagekit, security,
>> >> subscription-manager
>> >> Setting up Install Process
>> >> Package mysql-devel is obsoleted by mysql-community-devel, trying to
>> >> install mysql-community-devel-5.7.11-1.el6.x86_64 instead
>> >> Resolving Dependencies
>> >> --> Running transaction check
>> >> ---> Package mysql-community-devel.x86_64 0:5.7.11-1.el6 will be
>> >> installed
>> >> --> Processing Dependency: mysql-community-libs(x86-64) = 5.7.11-1.el6
>> >> for package: mysql-community-devel-5.7.11-1.el6.x86_64
>> >> --> Processing Dependency: libmysqlclient.so.20()(64bit) for package:
>> >> mysql-community-devel-5.7.11-1.el6.x86_64
>> >> --> Running transaction check
>> >> ---> Package mysql-community-libs.x86_64 0:5.7.11-1.el6 will be
>> >> obsoleting
>> >> --> Processing Dependency: mysql-community-common(x86-64) =
>> >> 5.7.11-1.el6 for package: mysql-community-libs-5.7.11-1.el6.x86_64
>> >> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted
>> >> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package:
>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>> >> --> Processing Dependency:
>> >> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package:
>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>> >> --> Processing Dependency:
>> >> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package:
>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>> >> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi
>> >> for package: mysql-server-5.5.44-1.el6.remi.x86_64
>> >> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi
>> >> for package: mysql-5.5.44-1.el6.remi.x86_64
>> >> --> Running transaction check
>> >> ---> Package mysql.x86_64 0:5.5.44-1.el6.remi will be obsoleted
>> >> ---> Package mysql-community-client.x86_64 0:5.7.11-1.el6 will be
>> >> obsoleting
>> >> ---> Package mysql-community-common.x86_64 0:5.7.11-1.el6 will be
>> >> installed
>> >> ---> Package mysql-community-server.x86_64 0:5.7.11-1.el6 will be
>> >> obsoleting
>> >> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted
>> >> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package:
>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>> >> --> Processing Dependency:
>> >> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package:
>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>> >> --> Processing Dependency:
>> >> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package:
>> >> php-mysql-5.4.43-1.el6.remi.x86_64
>> >> ---> Package mysql-server.x86_64 0:5.5.44-1.el6.remi will be obsoleted
>> >> --> Finished Dependency Resolution
>> >> Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi)
>> >>Requires: libmysqlclient.so.18(libmysqlclient_16)(64bit)
>> >>Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi)
>> >>