Re: The view blog.views.create didn't return an HttpResponse object. It returned None instead.can any one help me this issue please nooob here

2017-09-11 Thread Luis Zárate
if request.method == "GET":
if request.method == "POST":

Uppercase is needed.

2017-09-11 17:36 GMT-06:00 harsh sharma :

>  here i m learning django and i m stuck on one thing
> the web page returning
>
> The view blog.views.create didn't return an HttpResponse object. It returned 
> None instead.
>
>
>
> and here is my views.py  file
>
>
>
> def home(request):
>
> story = Story.objects.all()
> return render_to_response('show.html',{'story':story})
>
>
>
>
> def create(request):
> if request.method == "get":
> form = storyform()
> return render(request,'form.html',{'form':form})
> elif request.method == "post":
> form= storyform(request.POST)
> form.save()
> return HttpResponseRedirect('/home')
>
> --
> 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/067af0b0-6761-4daf-a1c0-02fcd1585048%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



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

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


The view blog.views.create didn't return an HttpResponse object. It returned None instead.can any one help me this issue please nooob here

2017-09-11 Thread harsh sharma
 here i m learning django and i m stuck on one thing 
the web page returning 

The view blog.views.create didn't return an HttpResponse object. It returned 
None instead.



and here is my views.py  file



def home(request):

story = Story.objects.all()
return render_to_response('show.html',{'story':story})




def create(request):
if request.method == "get":
form = storyform()
return render(request,'form.html',{'form':form})
elif request.method == "post":
form= storyform(request.POST)
form.save()
return HttpResponseRedirect('/home')

-- 
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/067af0b0-6761-4daf-a1c0-02fcd1585048%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Revert database scheme based on django migrations

2017-09-11 Thread Luis Zárate
Hello people,

I really would like you to help me with some thing I need to solve.

I have an app that do automated deployment of django apps, that also can
update existing deployments. So I need to revert my database to last state
if something went wrong.

So, my question is, how can I revert all the migrations that were applied
after run the migrate command?
It can have more than one migration and in different apps, so how can I
know where to go back and how to leave the database in the previous state
without having to do a backup of database and a restore? (some databases
can have a lot of registers).  How can I make a restore point of my
migrations or indicate django to go back in my database scheme?

Thanks in advance for the help you can provide me.

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

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


Re: type object 'Story' has no attribute 'object'

2017-09-11 Thread harsh sharma
Thanks for helping 

-- 
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/c37d10a2-4e7b-4d24-9217-c042b4d16eb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: setup.py for Django project?

2017-09-11 Thread Scot Hacker
Thanks for the feedback everyone. Good to get some real-world input on 
non-standard approaches like this. I'm going to try and steer the project 
away from it.

And I agree that manage.py and setup.py are not interchangeable at all - 
especially since not everything *goes* through manage.py.

./s

>
>

-- 
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/f33e3f13-4353-48b6-9e9a-b45aa8f82bd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: type object 'Story' has no attribute 'object'

2017-09-11 Thread SHAILESH NEGI
objects it is

On Mon, Sep 11, 2017 at 4:26 PM, harsh sharma 
wrote:

> why i m getting this
> error  :-type object 'Story' has no attribute 'object'
>
>
> this is my views.py file:
>
> from django.shortcuts import render,render_to_response
> from django.http import HttpResponseRedirect
> from django.template import RequestContext
> from .models import *
> from django.http import HttpResponse,HttpRequest
> # Create your views here.
>
>
>
> def home(request):
>
> story = Story.object.all()
> return render_to_response('show.html',{'story':story})
>
>
> this is my models.py file:
>
> from django.db import models
> from django.forms import ModelForm;
> # Create your models here.
>
> class Story(models.Model):
> stories = models.CharField(max_length=1024)
>
>
> class storyform(ModelForm):
> class Meta:
> model = Story
> fields = ['stories']
>
>
>
> --
> 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/711b4bc2-c974-46f7-a88b-d90ad561d92f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Thanks & Regards,
SHAILESH NEGI

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


Re: I am getting an error that django core commands are listed as settings are not properly configured

2017-09-11 Thread Jani Tiainen
Hi.

Information you provided isn't much. What you tried to do to get that
error.

And please don't paste images or binary files they're quite hard to handle
on certain devices.

11.9.2017 17.21 "margana harika"  kirjoitti:

> I am getting the error which i have shown in the screen shot attached.can
> you please give a solution to this problem .i am not able to start a
> newproject yet.
>
> --
> 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/6ffb18fd-184f-4d86-9e32-5aed3d75c9ed%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/CAHn91odg56G1h5pkhhXOkHAnqndKkvHd%3D4jwj1ABPpujP8Ubvw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


bad request(400)

2017-09-11 Thread Pankaj -
I am getting below error while launching host ip

-- 
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/5789526c-1129-4af8-80b0-71a82cc2259e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieving objects created in trasaction

2017-09-11 Thread Александр Христюхин (roboslone)
Thanks to everyone and sorry for the delay, I've missed your responses.

I've tried to use transaction.on_commit, it didn't work for me. For some 
strange reason Django thought the code wasn't running in a transaction.

I'm using Django 1.10 and PostgreSQL 9.6. Bar uses standard manager and yes, I 
can fetch objects after transaction has finished.

I ended up with local storage for newly created objects. So I query database 
for existing objects I've added to relation and if original pk_set is bigger I 
also query that local storage. That fixed the problem for me, but it's not 
exactly a good solution.

> On 24 Aug 2017, at 18:47, Daniel Hepper  wrote:
> 
> I cannot reproduce this behavior with Django 1.11 and PostgreSQL 9.6. What 
> database are you using?
> 
> Does your Bar model maybe use non-standard Manager? Can you actually fetch to 
> objects after the transaction has finished?
> 
> 
> On Wednesday, August 16, 2017 at 8:29:09 PM UTC+2, Александр Христюхин wrote:
> Hi, 
> 
> I have some function (fetcher) that runs in transaction (it has to) and it 
> creates a bunch if new objects that are written to database after transaction 
> is commited. Those objects are added to a many-to-many relation. And on that 
> relation change a signal is fired and handled by my signal handler, that 
> collects objects from relation and writes them into some cache. 
> 
> The problem is that during signal handling newly created objects do have PKs, 
> but are not in database yet. So signal_handler in code below always gets 
> empty queryset. 
> 
> 
> def fetcher(): 
> with transaction.atomic(): 
> foo = Foo.objects.create(...) 
> foo.bars.add( 
> Bar.objects.create(...), 
> Bar.objects.create(...), 
> Bar.objects.create(...), 
> ... 
> ) 
> 
> @receiver(m2m_changed, sender=Foo.bars.through) 
> def signal_handler(pk_set=None, **kwargs): 
> # signal_handler is being called inside of a transaction block 
> Bar.objects.filter(pk__in=pk_set)  # <-- returns empty QuerySet! 
> 
> 
> Is there a way to delay signal handling until transaction is committed or to 
> get newly created objects by PKs? 
> 
> 
> -- 
> 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/e9c89d82-e92b-4de0-bf6a-52f4e505d6fc%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/FE630650-F7DA-4183-97E7-774004D30162%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: type object 'Story' has no attribute 'object'

2017-09-11 Thread James Schneider
On Sep 11, 2017 7:20 AM, "harsh sharma"  wrote:

why i m getting this
error  :-type object 'Story' has no attribute 'object'


this is my views.py file:

from django.shortcuts import render,render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from .models import *
from django.http import HttpResponse,HttpRequest
# Create your views here.



def home(request):

story = Story.object.all()
return render_to_response('show.html',{'story':story})



The first line of your home() view should be this:

story = Story.objects.all()

The default model manager creates an 'objects' attribute that is plural.

-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%2BciXL4G7k6x71_hwZ5%3DfVMauu%3Dv3NNuSoxxgOatB-hvOyMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Documentation 1.7 shows "django-admin.py" whereas it should be "django-admin"

2017-09-11 Thread Deep Sukhwani
The answer is in the first post in this thread!

--
Regards
Deep L Sukhwani

On 11 September 2017 at 10:51, margana harika 
wrote:

>
> hello sir,
>even i got the same problem can you just tell me how did
> you solve this please!!
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/LsFZVzhj4v4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d81aa114-77dc-4a61-9e73-42913b8196c6%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/CAEMqiPdbdbW62NM1Q5_UQLtcL_qEc6XGKPY1gKCHb01a9qyHAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Documentation 1.7 shows "django-admin.py" whereas it should be "django-admin"

2017-09-11 Thread margana harika

hello sir,
   even i got the same problem can you just tell me how did you 
solve this please!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d81aa114-77dc-4a61-9e73-42913b8196c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


type object 'Story' has no attribute 'object'

2017-09-11 Thread harsh sharma
why i m getting this
error  :-type object 'Story' has no attribute 'object'


this is my views.py file:

from django.shortcuts import render,render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from .models import *
from django.http import HttpResponse,HttpRequest
# Create your views here.



def home(request):

story = Story.object.all()
return render_to_response('show.html',{'story':story})


this is my models.py file:

from django.db import models
from django.forms import ModelForm;
# Create your models here.

class Story(models.Model):
stories = models.CharField(max_length=1024)


class storyform(ModelForm):
class Meta:
model = Story
fields = ['stories']



-- 
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/711b4bc2-c974-46f7-a88b-d90ad561d92f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django runserver not working after installing redis for django channels

2017-09-11 Thread Artem Malyshev
Hi,

Please check your redis installation. It should be at least minimum required 
version by redis-py.

Regards, Artem.

-- 
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/beab5ba8-b6db-44f6-b211-bce721259e90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django runserver not working after installing redis for django channels

2017-09-11 Thread Robin Lery
I am learning the Django-channels
 concepts and I am
stuck when after install the asgi_redis and the redis server
.
If I have the CHANNEL_LAYERS configured for the *in-memory backend*. The
server runs okay, and the web page is displayed.However, if I run the
server after configuring the CHANNEL_LAYERS for the *redis backed*, the web
page is not displayed, and I get an error in the terminal:

Channel layer default (asgi_redis.core.RedisChannelLayer)
Quit the server with CONTROL-C.
2017-09-11 12:34:07,259 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,260 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,261 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:07,263 - INFO - server - HTTP/2 support not enabled
(install the http2 and tls Twisted extras)
2017-09-11 12:34:07,263 - INFO - server - Using busy-loop synchronous mode
on channel layer
2017-09-11 12:34:07,265 - INFO - server - Listening on endpoint
tcp:port=8000:interface=127.0.0.1
2017-09-11 12:34:07,267 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:07,268 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-09-11 12:34:12,270 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'
2017-09-11 12:34:17,272 - ERROR - server - Error trying to receive
messages: unknown command 'EVALSHA'

I have installed the asgi_redis in my virtualenv, and also installed Redis
server. What am I doing wrong here?

Here are the useful versions that I am using:

   - channels==1.1.6
   - asgi-redis==1.4.2
   - daphne==1.3.0
   - Django==1.11.5


Sincerely

Robin

-- 
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%2B4-nGrqHGfAbZ7R1pjb528DwJz4gBn81dc4dZk%2BJrm6Pii51Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Jquery datepicker in a django form

2017-09-11 Thread giuseppe ricci
Hi guys,

I need to insert 2 datapicker in a django form.
I have not a form.py file.
My views.py related to the datepicker:

class DatePicker(forms.DateInput):
template_name = 'dkey.html'

class Media:
js = (
'js/jquery.min.js',
'js/jquery-ui.min.js',
)
css = {
'all': (
'css/jquery-ui.css',
)
}

class DateForm(forms.Form):
date = forms.DateField(widget=DatePicker)

and the html page dkey.html


http://code.jquery.com/jquery-1.10.2.js";>
http://code.jquery.com/ui/1.11.0/jquery-ui.js";>




$(document).ready(function() {
// Datepicker Popups calender to Choose date.
$(function() {
$("#datepicker").datepicker();
// Pass the user selected date format.
$("#format").change(function() {
$("#datepicker").datepicker("option", "dateFormat", $(this).val());
});
});
});



Date:
 


but in the html page in the browser I see only a textarea and clicking 
dont't appear the datepicker.
I read other similar questions but no solve..
Can someone to help me?
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/8646fe89-2c9b-4804-a2dc-2f6a2890cdf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.