Changes to Model does not migrate to sqlite with Django 1.7?

2014-12-07 Thread Tobias Dacoir
Hi,

I'm having trouble with changes to my Models. I just added a couple of new 
fields to my existing models but when I run manage makemigrations it says: 
No changes detected. When I try to log in to the admin panel it gives an 
operational error and says: No such column (because I added a column to my 
user model). I have tried to get rid of this error using google and various 
calls to makemigrations app_name or syncdb or whatever, but nothing helps. 
I always have to delete my sqlite database file and start with a new DB. 

Is this a limitation of sqlite or some bug in Django?

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


Re: Testing reusable application: compatible way

2014-12-07 Thread Carl Meyer
On 12/07/2014 12:59 PM, Matwey V. Kornilov wrote:
> The following code works perfect for me, why the code in the
> documentations so sophisticated?
> 
> def runtests():
> os.environ.setdefault("DJANGO_SETTINGS_MODULE",
> "tests.test_settings")
> 
> try:
> from django import setup
> setup()
> except ImportError:
> pass
> from django.core.management import call_command
> 
> call_command("test","tests.__init__")
> 
> if __name__ == "__main__":
> runtests()

Sure, that works too. I don't think it's significantly simpler than the
documented version, and it's less flexible if you want to customize test
running further.

Carl

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5484C772.5040505%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Testing reusable application: compatible way

2014-12-07 Thread Carl Meyer
On 12/07/2014 02:28 PM, Carl Meyer wrote:
> On 12/07/2014 08:40 AM, Matwey V. Kornilov wrote:
>> I've followed this documentation:
>> https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
>> and found that it works only for Django 1.7, whereas I would like to
>> have a code snipped working also for 1.5, 1.6.
>>
>> An issue with the runtests.py from the link above thatdjango.setup() has
>> been introduced only in 1.7 and elder version seems to require different
>> way to prepare settings object.
> 
> Older Django versions didn't require any explicit initialization step,
> so all you need to do is check `hasattr(django, 'setup')` and only call
> it if it exists (or you can check the Django version instead, if you
> prefer).
> 
> DiscoverRunner was only introduced in 1.6, so if you want to be
> 1.5-compatible you'll also need a fallback to the old
> DjangoTestSuiteRunner. And note that the format of test labels changed:
> in DjangoTestSuiteRunner it was an app-label, where in DiscoverRunner
> it's a full Python dotted path.

I forgot that the documented example uses django.test.utils.get_runner
instead of directly importing DiscoverRunner. `get_runner` existed
already in 1.5, so that code should work back to 1.5, I would think.

> You can see an example `runtests.py` that accounts for these differences
> here:
> https://github.com/carljm/django-model-utils/blob/master/runtests.py#L34
> 
> Carl
> 

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5484C73B.7020902%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Testing reusable application: compatible way

2014-12-07 Thread Carl Meyer
Hi Matwey,

On 12/07/2014 08:40 AM, Matwey V. Kornilov wrote:
> I've followed this documentation:
> https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
> and found that it works only for Django 1.7, whereas I would like to
> have a code snipped working also for 1.5, 1.6.
> 
> An issue with the runtests.py from the link above thatdjango.setup() has
> been introduced only in 1.7 and elder version seems to require different
> way to prepare settings object.

Older Django versions didn't require any explicit initialization step,
so all you need to do is check `hasattr(django, 'setup')` and only call
it if it exists (or you can check the Django version instead, if you
prefer).

DiscoverRunner was only introduced in 1.6, so if you want to be
1.5-compatible you'll also need a fallback to the old
DjangoTestSuiteRunner. And note that the format of test labels changed:
in DjangoTestSuiteRunner it was an app-label, where in DiscoverRunner
it's a full Python dotted path.

You can see an example `runtests.py` that accounts for these differences
here:
https://github.com/carljm/django-model-utils/blob/master/runtests.py#L34

Carl

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5484C682.1010805%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Testing reusable application: compatible way

2014-12-07 Thread Matwey V. Kornilov

The following code works perfect for me, why the code in the documentations 
so sophisticated?

def runtests():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
"tests.test_settings")

try:
from django import setup
setup()
except ImportError:
pass
from django.core.management import call_command

call_command("test","tests.__init__")

if __name__ == "__main__":
runtests()


воскресенье, 7 декабря 2014 г., 18:40:42 UTC+3 пользователь Matwey V. 
Kornilov написал:
>
> Hi,
>
> I've followed this documentation: 
> https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
> and found that it works only for Django 1.7, whereas I would like to have 
> a code snipped working also for 1.5, 1.6.
>
> An issue with the runtests.py from the link above that django.setup() has 
> been introduced only in 1.7 and elder version seems to require different 
> way to prepare settings object.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e14ba33-4d84-4d16-afc0-aa02b6b9ce09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to hide the 'empty entry' value in forms relating as ForeignKey?

2014-12-07 Thread inoyon artlover KLANGRAUSCH
Hi there, I got a form:

class Answers(models.ModelForm):

psyq11 = forms.ModelChoiceField(
queryset=PsychologicQuestion11.objects.all(),
   widget=forms.RadioSelect)


psyq12 = forms.ModelChoiceField(
queryset=PsychologicQuestion12.objects.all(),
widget=forms.RadioSelect)

etc. etc

The widget shows the '---' entry.. I don't want it. Is there a way to 
solve it?
Also I would like to split the form into four areas in the template... is 
it possible?

Best regards, cheers :)

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20eb23e6-06f3-4f9a-903e-af2ea858c6e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Testing reusable application: compatible way

2014-12-07 Thread Matwey V. Kornilov
Hi,

I've followed this documentation: 
https://docs.djangoproject.com/en/1.7/topics/testing/advanced/#using-the-django-test-runner-to-test-reusable-applications
and found that it works only for Django 1.7, whereas I would like to have a 
code snipped working also for 1.5, 1.6.

An issue with the runtests.py from the link above that django.setup() has 
been introduced only in 1.7 and elder version seems to require different 
way to prepare settings object.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aeeb089e-d441-4e86-8f40-674eb97d4d58%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django development server crash on syntactic or indent error after check

2014-12-07 Thread Mario De Frutos Dieguez
Thank you very much Collin, i will take a look knowing that its probably a 
bug :)

El sábado, 6 de diciembre de 2014 18:33:34 UTC+1, Collin Anderson escribió:
>
> It happens if there's a SyntaxError in a models.py file.
>
> On Saturday, December 6, 2014 12:32:17 PM UTC-5, Collin Anderson wrote:
>>
>> Hi,
>>
>> Yes, this happens to me frequently. It happens when editing models.py or 
>> something imported by a models.py. It's on my mental dream list of things 
>> to fix, but feel free to open a ticket about it if there's not one open 
>> already.
>>
>> Collin
>>
>> On Friday, December 5, 2014 2:00:01 AM UTC-5, Mario De Frutos Dieguez 
>> wrote:
>>>
>>> If i understand you correctly, when an error occur the server should not 
>>> stop, instead of that it will print the error trace to let you correct the 
>>> problem but in my case when an error occur the server show the trace and 
>>> stop working or at least it returns to the shell. :S
>>>
>>> What i understand reading the official docuementation is that the 
>>> expected behavior is not to exit instead of that the server should show the 
>>> error trace to let you fix it
>>>
>>> Am i right?
>>>
>>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/25f7c455-cbfc-42b3-a7d7-a4bf294f87bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: POSTing data to a django view from a stand alone script with CSRF

2014-12-07 Thread Torsten Bronger
Hallöchen!

Larry Martell writes:

> I have a django view that normally receives POSTed data from a web
> page. That all works fine. But now we also want to call that view from
> a python script. That is failing with a 403 because of a CSRF
> mismatch. I can disable CSRF on my view and then it does work from the
> script.
>
> Is there some way I can have it work with CSRF with my script?

We make it like this (roughly, but you probably can fill the gaps
yourself):

class Connection(object):
cookie_jar = cookiejar.CookieJar()
opener = 
urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie_jar))
http_headers = [("X-requested-with", "XMLHttpRequest"),
("Accept", 
"application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,text/*;q=0.8,*/*;q=0.7")]
opener.addheaders = http_headers

def do_http_request(self, url, data=None):
if data is None:
request = urllib.request.Request(url)
else:
# "Referer" is necessary for HTTPS communication.
headers = {"Content-Type": "application/x-www-form-urlencoded", 
"Referer": url}
request = urllib.request.Request(url, urllib.parse.urlencode(data), 
headers)
self.opener.open(request)

def set_csrf_header(self):
"""Copies the cookie to the header of the subsequent requests."""
csrf_cookies = {cookie for cookie in cookie_jar if cookie.name == 
"csrftoken"}
if csrf_cookies:
assert len(csrf_cookies) == 1
self.opener.addheaders = self.http_headers + [("X-CSRFToken", 
csrf_cookies.pop().value)]

def login(self, username, password):
# First, a GET request to get the CSRF cookie used only for the
# following POST request.  (It's some sort of bootstrapping;
# only necessary for the very first request.)
self.do_http_request("http://mysite.com/login;)
self.set_csrf_header()
self.do_http_request("http://mysite.com/login;, {"username": username, 
"password": password})
# Now, set the CSRF token for the rest of the communication.
self.set_csrf_header()


Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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


Re: I cannot connect with my database remote server mysql django

2014-12-07 Thread rush
Just put correct password into settings. That will fix the error. -- wbr,rush.   07.12.2014, 17:11, "tuktuk" :I am running my django Application in local mode, and my database server is in a remote server with cpanel. Configurations in settings.py are:DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', 
'NAME': 'tim_farmaapp',  
'USER': 'tim_farmaapp',
'PASSWORD': 'mypass_123_',
'HOST': 'stevie.heliohost.org', 
'PORT': '3306',  
}
}But when i make syncdb i get this error:OperationalError: (1045, "Access denied for user 'tim_farmaapp'@'31.44.78.126' (using password: YES)")How can i fix this issue/error ? Thanks to all ! --  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 http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f9f74486-e480-4e6c-a362-5a7b68b77202%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/143581417962392%40web13g.yandex.ru.
For more options, visit https://groups.google.com/d/optout.


I cannot connect with my database remote server mysql django

2014-12-07 Thread tuktuk


I am running my django Application in local mode, and my database server is 
in a remote server with cpanel. Configurations in settings.py are:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', 
'NAME': 'tim_farmaapp',  
'USER': 'tim_farmaapp',
'PASSWORD': 'mypass_123_',
'HOST': 'stevie.heliohost.org', 
'PORT': '3306',  
}}

But when i make syncdb i get this error:

OperationalError: (1045, "Access denied for user 'tim_farmaapp'@'31.44.78.126' 
(using password: YES)")

How can i fix this issue/error ? Thanks to all !

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f9f74486-e480-4e6c-a362-5a7b68b77202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Connect django project with sharepoint 2013

2014-12-07 Thread Mario Gudelj
Well your python code is trying access that url so the url must work
On 07/12/2014 4:47 pm, "Hossein Rashnoo"  wrote:

> I can access to http://portal:8080/ in my browser when i set our office
> proxy and port. And my linux server that i run django on it, is local. Do i
> need to set proxy to access sharepoint?
>
> On Sunday, December 7, 2014 8:30:18 AM UTC+3:30, somecallitblues wrote:
>>
>> Urllib2 can't open the url http:// portal:8080. I assume that you can't
>> visit that url from the browser either
>> On 07/12/2014 3:46 pm, "Hossein Rashnoo"  wrote:
>>
>>> I need this connection for adding list items and save my users data on
>>> sharepoint database. I ran it in command line and when i write something
>>> like """ print site.lists[0] """ this error appear :
>>>
>>>
>>>   File "", line 1, in 
>>>   File "/usr/lib/python2.6/site-packages/sharepoint/lists/__init__.py",
>>> line 84, in __getitem__
>>> return self.all_lists[key]
>>>   File "/usr/lib/python2.6/site-packages/sharepoint/lists/__init__.py",
>>> line 36, in all_lists
>>> result = self.opener.post_soap(LIST_WEBSERVICE, xml)
>>>   File "/usr/lib/python2.6/site-packages/sharepoint/site.py", line 31,
>>> in post_soap
>>> response = self.opener.open(request)
>>>   File "/usr/lib64/python2.6/urllib2.py", line 391, in open
>>> response = self._open(req, data)
>>>   File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
>>> '_open', req)
>>>   File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
>>> result = func(*args)
>>>   File "/usr/lib64/python2.6/urllib2.py", line 1190, in http_open
>>> return self.do_open(httplib.HTTPConnection, req)
>>>   File "/usr/lib64/python2.6/urllib2.py", line 1165, in do_open
>>> raise URLError(err)
>>> URLError: 
>>>
>>>
>>> On Saturday, December 6, 2014 4:19:45 PM UTC+3:30, François
>>> Schiettecatte wrote:

 Ok, but I am not sure what this has to do with Django ? Maybe you
 should ask on a SharePoint mailing list ? And did you try running the code
 in a script on the command line ?

 François

 > On Dec 6, 2014, at 7:10 AM, Hossein Rashnoo 
 wrote:
 >
 > I need to connect my project to sharepoint. So i installed
 "sharepoint 0.4.1" package and then use this code in my view :
 >
 > from sharepoint import SharePointSite, basic_auth_opener
 >
 > def userloginres(request):
 > server_url = "http://portal:8080/;
 > site_url = server_url + "rashno/"
 > opener = basic_auth_opener(server_url, "my username", "my
 password")
 > site = SharePointSite(site_url, opener)
 >
 > htt=r"Sharepoint lists"
 > for sp_list in site.lists:
 > htt = htt + r" %s . %s " % (sp_list.id
 ,sp_list.meta['Title'])
 > htt = htt + r""
 >
 > t = get_template('userlogin/userloginres.html')
 > html= t.render(Context({"htt":htt}))
 > return HttpResponse(html)
 >
 > But now when i open that url this error appear:
 >
 > URLError at /test/login/
 >
 > 
 >
 > --
 > 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...@googlegroups.com.
 > To post to this group, send email to django...@googlegroups.com.
 > Visit this group at http://groups.google.com/group/django-users.
 > To view this discussion on the web visit https://groups.google.com/d/
 msgid/django-users/a982dfcf-6824-441a-ab5f-f68907e1f0d7%40goog
 legroups.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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/34b04a5b-0a1e-4405-9a73-a8e3856940a2%
>>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web 

Open a url with user and password

2014-12-07 Thread Hossein Rashnoo
I want to create a web-service for connection to sharepoint that do 
something like create a list and ...
So at first step because we use sharepoint with local ip i want to check if 
i can connect to our sharepoint portal via my server or not.
So i looking for something like : 
urllib2.urlopen("http://portal:8080/;).read()
and i found this code for test:

import urllib.request# Create an OpenerDirector with support for Basic HTTP 
Authentication...auth_handler = 
urllib.request.HTTPBasicAuthHandler()auth_handler.add_password(realm='PDQ 
Application',
  uri='https://portal:8080/',
  user='my username',
  passwd='my password')opener = 
urllib.request.build_opener(auth_handler)# ...and install it globally so it can 
be used with 
urlopen.urllib.request.install_opener(opener)urllib.request.urlopen('http://portal:8080/')

But after last line i got this error:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
  File "/usr/lib64/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
  File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.6/urllib2.py", line 435, in error
return self._call_chain(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized

Please help me.


-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/70d5031a-be70-4c51-b5eb-c75e821a251f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.