NoReverseMatch error in django 1.8

2015-09-27 Thread hossein
this is my views and url.py
as long as use  tag in my template show error

url

urlpatterns = [
url(r'^bookee/$', views.index, name='index'),
url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/$', views.uprofile, 
name='userprofile'),
url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/book/(?P\d)/$', 
views.bookprof, name='bookp'),

url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/publisher/(?P\d)/$', 
views.publishprof, name='publishep'),
]

 

view

def uprofile(request, user):
usr = User.objects.get(username=user)
book = Book.objects.filter(user=usr)
return render(request, 'u/uprof.html', {'usr': usr, 'book': book})

def bookprof(request, user, bookid):
usr = User.objects.get(username=user)
bookid = Book.objects.get(id=bookid)
# bookd = Book.objects.filter(id=bookid)
return render(request, 'u/uprof.html', {'usr':usr,'bookid': bookid})

def publishprof(request, user, publishid):
usr = User.objects.get(username=user)
pubid = Publisher.objects.get(id=publishid)
publisher = Publisher.objects.filter(id=pubid)
return render(request, 'u/uprof.html', {'usr':usr,'publisher': publisher})

template



list of books



NoReverseMatch at /bookee/user/admin/
Reverse for 'bookp' with arguments '()' and keyword arguments '{}' not found. 1 
pattern(s) tried: 
['bookee/user/(?P[a-z0-9-._@+]\\w+)/book/(?P\\d)/$']


thanks for your help 

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


Django Tutorial(Database Setup Question)

2015-09-27 Thread Cai Gengyang

Hello all !

So I am going through the (Database setup) chapter of this tutorial 
(https://docs.djangoproject.com/en/1.8/intro/tutorial01/) --- Its the 
section right after the first chapter on "Creating a project"


I opened up mysite/settings.py as per the instructions on the Django 
tutorial.


However, when I try to run the following command : $ python manage.py 
migrate to create the tables in the database,


CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate  
input


I get the following error message :


/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
 
can't open file 'manage.py': [Errno 2] No such file or directory  output


Any idea how to solve this issue?


Thanks a lot !


Gengyang

-- 
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/774360f5-c240-40f9-8d61-80e11899ff8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart
> …
> However, when I try to run the following command : $ python manage.py migrate 
> to create the tables in the database,
> CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate  
> input
> I get the following error message :
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
>  can't open file 'manage.py': [Errno 2] No such file or directory  output

You need to be in the same directory as the file manage.py for the command to 
work. For Django-1.8 that is likely to be one level above your settings.py file.

hth

- Tom

-- 
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/EB6F90BA-E19B-4A79-9DF0-3466F4C2AC6C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Cai Gengyang
Hi Tom,


So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite 
folder ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2)

This puts me in the same directory as the manage.py file.

Then I key in the command  : $ python manage.py migrate, but I still get 
the same error message 

CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate --- 
input


/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
 
can't open file 'manage.py': [Errno 2] No such file or directory --- output 


Not sure where I am doing this wrongly ... zzz



Gengyang



On Sunday, September 27, 2015 at 7:12:54 PM UTC+8, Thomas wrote:
>
> > … 
> > However, when I try to run the following command : $ python manage.py 
> migrate to create the tables in the database, 
> > CaiGengYangs-MacBook-Pro:Weiqi CaiGengYang$ python manage.py migrate 
>  input 
> > I get the following error message : 
> > 
> /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:
>  
> can't open file 'manage.py': [Errno 2] No such file or directory  
> output 
>
> You need to be in the same directory as the file manage.py for the command 
> to work. For Django-1.8 that is likely to be one level above your 
> settings.py file. 
>
> hth 
>
> - Tom

-- 
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/893c0597-de55-4f0a-94d7-829bcc76b3cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart

> On Sep 27, 2015, at 04:39, Cai Gengyang  wrote:
> 
> Hi Tom,
> So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite folder 
> ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2)
> This puts me in the same directory as the manage.py file.
> Then I key in the command  : $ python manage.py migrate

The command must be typed from a terminal window, and afaik Finder has no 
influence on the current working directory in that window.

Use the Terminal app to open a command line window, then use “cd” or “pushd” to 
go to “mysite folder” within that terminal window.

If that is done correctly, then you should be able to type “ls” and see 
manage.py in the resulting listing. Then try typing the python command above.

btw, I would strongly recommend using virtualenv for developing on your Mac 
(and on any other system). There are many references to that in this mailing 
list; do a google search to find a procedure for doing this.

hth

- Tom

-- 
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/C37BDA8F-208C-4656-9C25-68479B07C444%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NoReverseMatch error in django 1.8

2015-09-27 Thread Gergely Polonkai
Hello,

the bookp route requires a user and a book_id parameter. Unless you supply
that, your {% url %} tag won't match.

Best,
Gergely
On 27 Sep 2015 12:49, "hossein"  wrote:

> this is my views and url.py
> as long as use  tag in my template show error
>
> url
>
> urlpatterns = [
> url(r'^bookee/$', views.index, name='index'),
> url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/$', views.uprofile, 
> name='userprofile'),
> url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/book/(?P\d)/$', 
> views.bookprof, name='bookp'),
> 
> url(r'^bookee/user/(?P[a-z0-9-._@+]\w+)/publisher/(?P\d)/$', 
> views.publishprof, name='publishep'),
> ]
>
>
>
> view
>
> def uprofile(request, user):
> usr = User.objects.get(username=user)
> book = Book.objects.filter(user=usr)
> return render(request, 'u/uprof.html', {'usr': usr, 'book': book})
>
> def bookprof(request, user, bookid):
> usr = User.objects.get(username=user)
> bookid = Book.objects.get(id=bookid)
> # bookd = Book.objects.filter(id=bookid)
> return render(request, 'u/uprof.html', {'usr':usr,'bookid': bookid})
>
> def publishprof(request, user, publishid):
> usr = User.objects.get(username=user)
> pubid = Publisher.objects.get(id=publishid)
> publisher = Publisher.objects.filter(id=pubid)
> return render(request, 'u/uprof.html', {'usr':usr,'publisher': publisher})
>
> template
>
> 
> 
> list of books
> 
> 
>
> NoReverseMatch at /bookee/user/admin/
> Reverse for 'bookp' with arguments '()' and keyword arguments '{}' not found. 
> 1 pattern(s) tried: 
> ['bookee/user/(?P[a-z0-9-._@+]\\w+)/book/(?P\\d)/$']
>
>
> thanks for your help
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a9092ae0-ff31-467c-ab25-e8418d82270d%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/CACczBUJeMpAy%2Bqm6c0_Z5c3ihTcdT3eGnEnZD8fUMaFHq93DRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Cai Gengyang
Hi Tom,

Following your latest instructions , I have posted my input and output 
results here. Still getting an error message though it is a different one 
this time ( a traceback error )

CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls

manage.py mysite

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate

Traceback (most recent call last):

  File "manage.py", line 10, in 

execute_from_command_line(sys.argv)

  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 338, in execute_from_command_line

utility.execute()

  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 303, in execute

settings.INSTALLED_APPS

  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 48, in __getattr__

self._setup(name)

  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 44, in _setup

self._wrapped = Settings(settings_module)

  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 92, in __init__

mod = importlib.import_module(self.SETTINGS_MODULE)

  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
 
line 37, in import_module

__import__(name)

  File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45

'django.middleware.csrf.CsrfViewMiddleware',

  ^

SyntaxError: invalid syntax

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ 



On Sunday, September 27, 2015 at 7:51:51 PM UTC+8, Thomas wrote:
>
>
> > On Sep 27, 2015, at 04:39, Cai Gengyang  > wrote: 
> > 
> > Hi Tom, 
> > So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite 
> folder ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2) 
> > This puts me in the same directory as the manage.py file. 
> > Then I key in the command  : $ python manage.py migrate 
>
> The command must be typed from a terminal window, and afaik Finder has no 
> influence on the current working directory in that window. 
>
> Use the Terminal app to open a command line window, then use “cd” or 
> “pushd” to go to “mysite folder” within that terminal window. 
>
> If that is done correctly, then you should be able to type “ls” and see 
> manage.py in the resulting listing. Then try typing the python command 
> above. 
>
> btw, I would strongly recommend using virtualenv for developing on your 
> Mac (and on any other system). There are many references to that in this 
> mailing list; do a google search to find a procedure for doing this. 
>
> hth 
>
> - Tom

-- 
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/278af114-1a2e-4c4b-ab90-f2c4814d7f4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart

> On Sep 27, 2015, at 05:26, Cai Gengyang  wrote:
> 
> Hi Tom,
> 
> Following your latest instructions , I have posted my input and output 
> results here. Still getting an error message though it is a different one 
> this time ( a traceback error )

Oh, much better :)

You are now seeing a typo in your settings.py file. Without seeing more of the 
file I can not guess at the exact place with the error, but perhaps you have an 
extra or a missing single quote character in a preceeding line in the file??

hth

- Tom


> 
> CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder
> 
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls
> 
> manage.py mysite
> 
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate
> 
> Traceback (most recent call last):
> 
>   File "manage.py", line 10, in 
> 
> execute_from_command_line(sys.argv)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 338, in execute_from_command_line
> 
> utility.execute()
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  line 303, in execute
> 
> settings.INSTALLED_APPS
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  line 48, in __getattr__
> 
> self._setup(name)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  line 44, in _setup
> 
> self._wrapped = Settings(settings_module)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  line 92, in __init__
> 
> mod = importlib.import_module(self.SETTINGS_MODULE)
> 
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
>  line 37, in import_module
> 
> __import__(name)
> 
>   File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45
> 
> 'django.middleware.csrf.CsrfViewMiddleware',
> 
>   ^
> 
> SyntaxError: invalid syntax
> 
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ 
> 
> 
> 
> 
> 
> On Sunday, September 27, 2015 at 7:51:51 PM UTC+8, Thomas wrote:
> 
> > On Sep 27, 2015, at 04:39, Cai Gengyang gmail.com 
> > > wrote: 
> > 
> > Hi Tom, 
> > So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite 
> > folder ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2) 
> > This puts me in the same directory as the manage.py file. 
> > Then I key in the command  : $ python manage.py migrate 
> 
> The command must be typed from a terminal window, and afaik Finder has no 
> influence on the current working directory in that window. 
> 
> Use the Terminal app to open a command line window, then use “cd” or “pushd” 
> to go to “mysite folder” within that terminal window. 
> 
> If that is done correctly, then you should be able to type “ls” and see 
> manage.py in the resulting listing. Then try typing the python command above. 
> 
> btw, I would strongly recommend using virtualenv for developing on your Mac 
> (and on any other system). There are many references to that in this mailing 
> list; do a google search to find a procedure for doing this.
> 
> hth 
> 
> - Tom
> 
> -- 
> 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/278af114-1a2e-4c4b-ab90-f2c4814d7f4e%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/BBB8DAA7-9914-4536-8BED-D639F3DD0D57%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Gergely Polonkai
Hello,

that message is clear: line 45 in your settings.py has a syntax error. That
line, however, seem OK, so I guess the previous one is that; maybe a comma
is missing.

Best,
Gergely
On 27 Sep 2015 14:26, "Cai Gengyang"  wrote:

> Hi Tom,
>
> Following your latest instructions , I have posted my input and output
> results here. Still getting an error message though it is a different one
> this time ( a traceback error )
>
> CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder
>
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls
>
> manage.py mysite
>
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate
>
> Traceback (most recent call last):
>
>   File "manage.py", line 10, in 
>
> execute_from_command_line(sys.argv)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 338, in execute_from_command_line
>
> utility.execute()
>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
> line 303, in execute
>
> settings.INSTALLED_APPS
>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
> line 48, in __getattr__
>
> self._setup(name)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
> line 44, in _setup
>
> self._wrapped = Settings(settings_module)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
> line 92, in __init__
>
> mod = importlib.import_module(self.SETTINGS_MODULE)
>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
> line 37, in import_module
>
> __import__(name)
>
>   File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45
>
> 'django.middleware.csrf.CsrfViewMiddleware',
>
>   ^
>
> SyntaxError: invalid syntax
>
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$
>
>
>
> On Sunday, September 27, 2015 at 7:51:51 PM UTC+8, Thomas wrote:
>>
>>
>> > On Sep 27, 2015, at 04:39, Cai Gengyang  wrote:
>> >
>> > Hi Tom,
>> > So I click on Finder ---> Go ---> Home ---> 'Weiqi' folder ---> mysite
>> folder ---> manage.py file. (using a Mac OS X Yosemite Version 10.10.2)
>> > This puts me in the same directory as the manage.py file.
>> > Then I key in the command  : $ python manage.py migrate
>>
>> The command must be typed from a terminal window, and afaik Finder has no
>> influence on the current working directory in that window.
>>
>> Use the Terminal app to open a command line window, then use “cd” or
>> “pushd” to go to “mysite folder” within that terminal window.
>>
>> If that is done correctly, then you should be able to type “ls” and see
>> manage.py in the resulting listing. Then try typing the python command
>> above.
>>
>> btw, I would strongly recommend using virtualenv for developing on your
>> Mac (and on any other system). There are many references to that in this
>> mailing list; do a google search to find a procedure for doing this.
>>
>> hth
>>
>> - Tom
>
> --
> 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/278af114-1a2e-4c4b-ab90-f2c4814d7f4e%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/CACczBULz2y%3D3VRY1SDoE%3DVZE0nQnYUDbmfiu2UJkurY2K79YiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Cai Gengyang


This is my entire settings.py file


"""

Django settings for mysite project.


Generated by 'django-admin startproject' using Django 1.8.4.


For more information on this file, see

https://docs.djangoproject.com/en/1.8/topics/settings/


For the full list of settings and their values, see

https://docs.djangoproject.com/en/1.8/ref/settings/

"""


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

import os


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))



# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/


# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = '6d9q_36l6ka7pkt=e1-r*ze_!tx0bst1i1^!6khpn19yj20^sg'


# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True


ALLOWED_HOSTS = []



# Application definition


INSTALLED_APPS = (

'django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'django.contrib.staticfiles',

)


MIDDLEWARE_CLASSES = (

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.common.CommonMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.auth.middleware.SessionAuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

'django.middleware.clickjacking.XFrameOptionsMiddleware',

'django.middleware.security.SecurityMiddleware',

)


ROOT_URLCONF = 'mysite.urls'


TEMPLATES = [

{

'BACKEND': 'django.template.backends.django.DjangoTemplates',

'DIRS': [],

'APP_DIRS': True,

'OPTIONS': {

'context_processors': [

'django.template.context_processors.debug',

'django.template.context_processors.request',

'django.contrib.auth.context_processors.auth',

'django.contrib.messages.context_processors.messages',

],

},

},

]


WSGI_APPLICATION = 'mysite.wsgi.application'



# Database

# https://docs.djangoproject.com/en/1.8/ref/settings/#databases


DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3',

'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

}

}



# Internationalization

# https://docs.djangoproject.com/en/1.8/topics/i18n/


LANGUAGE_CODE = 'en-us'


TIME_ZONE = 'UTC'


USE_I18N = True


USE_L10N = True


USE_TZ = True



# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/1.8/howto/static-files/


STATIC_URL = '/static/'

On Sunday, September 27, 2015 at 8:34:35 PM UTC+8, Thomas wrote:
>
>
> On Sep 27, 2015, at 05:26, Cai Gengyang > 
> wrote:
>
> Hi Tom,
>
> Following your latest instructions , I have posted my input and output 
> results here. Still getting an error message though it is a different one 
> this time ( a traceback error )
>
>
> Oh, much better :)
>
> You are now seeing a typo in your settings.py file. Without seeing more of 
> the file I can not guess at the exact place with the error, but perhaps you 
> have an extra or a missing single quote character in a preceeding line in 
> the file??
>
> hth
>
> - Tom
>
>
>
> CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder
>
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls
>
> manage.py mysite
>
> CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate
>
> Traceback (most recent call last):
>
>   File "manage.py", line 10, in 
>
> execute_from_command_line(sys.argv)
>
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 338, in execute_from_command_line
>
> utility.execute()
>
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 303, in execute
>
> settings.INSTALLED_APPS
>
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 48, in __getattr__
>
> self._setup(name)
>
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 44, in _setup
>
> self._wrapped = Settings(settings_module)
>
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 92, in __init__
>
> mod = importlib.import_module(self.SETTINGS_MODULE)
>
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
>  
> line 37, in import_module
>
> __import__(name)
>
>   File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45
>
> 'django.middleware.csrf.CsrfViewMiddleware',
>
>   ^
>
> Syn

SynTaxError: invalid syntax

2015-09-27 Thread Cai Gengyang


This is the message I keep getting when I tried to run $ python manage.py 
migrate



File "/Users/CaiGengYang/mysite/mysite/settings.py", line 45

'django.middleware.csrf.CsrfViewMiddleware',

  ^

SyntaxError: invalid syntax



Below is my entire settings.py project --- Can't seem to find any errors in 
it, if anyone can spot anything let me know ...


"""

Django settings for mysite project.


Generated by 'django-admin startproject' using Django 1.8.4.


For more information on this file, see

https://docs.djangoproject.com/en/1.8/topics/settings/


For the full list of settings and their values, see

https://docs.djangoproject.com/en/1.8/ref/settings/

"""


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

import os


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))



# Quick-start development settings - unsuitable for production

# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/


# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = '6d9q_36l6ka7pkt=e1-r*ze_!tx0bst1i1^!6khpn19yj20^sg'


# SECURITY WARNING: don't run with debug turned on in production!

DEBUG = True


ALLOWED_HOSTS = []



# Application definition


INSTALLED_APPS = (

'django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'django.contrib.staticfiles',

)


MIDDLEWARE_CLASSES = (

'django.contrib.sessions.middleware.SessionMiddleware',

'django.middleware.common.CommonMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.contrib.auth.middleware.AuthenticationMiddleware',

'django.contrib.auth.middleware.SessionAuthenticationMiddleware',

'django.contrib.messages.middleware.MessageMiddleware',

'django.middleware.clickjacking.XFrameOptionsMiddleware',

'django.middleware.security.SecurityMiddleware',

)


ROOT_URLCONF = 'mysite.urls'


TEMPLATES = [

{

'BACKEND': 'django.template.backends.django.DjangoTemplates',

'DIRS': [],

'APP_DIRS': True,

'OPTIONS': {

'context_processors': [

'django.template.context_processors.debug',

'django.template.context_processors.request',

'django.contrib.auth.context_processors.auth',

'django.contrib.messages.context_processors.messages',

],

},

},

]


WSGI_APPLICATION = 'mysite.wsgi.application'



# Database

# https://docs.djangoproject.com/en/1.8/ref/settings/#databases


DATABASES = {

'default': {

'ENGINE': 'django.db.backends.sqlite3',

'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

}

}



# Internationalization

# https://docs.djangoproject.com/en/1.8/topics/i18n/


LANGUAGE_CODE = 'en-us'


TIME_ZONE = 'UTC'


USE_I18N = True


USE_L10N = True


USE_TZ = True



# Static files (CSS, JavaScript, Images)

# https://docs.djangoproject.com/en/1.8/howto/static-files/


STATIC_URL = '/static/'

-- 
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/471de3bb-6ace-492a-addc-93194da78d7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


http://pastebin.com/RWt1mp7F

2015-09-27 Thread Cai Gengyang
http://pastebin.com/RWt1mp7F --- If anybody can find any error with this 
settings.py file, let me know !

Looked through it and can't find any mistakes. The error message I got was 
that there is an error on or before line 45 (like a missing parentheses) , 
but can't seem to spot anything wrong , really weird ...

Thanks ...

Gengyang

-- 
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/4365c3a4-76d6-4dc2-8cbf-eeb6a7d34d31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: http://pastebin.com/RWt1mp7F

2015-09-27 Thread Shawn Milochik
Try running ./manage.py shell

You often get a better traceback. I don't see anything wrong with the
beginning of the file you posted. However, you do have dirname twice, so
one is just wasted.
On Sep 27, 2015 13:50, "Cai Gengyang"  wrote:

> http://pastebin.com/RWt1mp7F --- If anybody can find any error with this
> settings.py file, let me know !
>
> Looked through it and can't find any mistakes. The error message I got was
> that there is an error on or before line 45 (like a missing parentheses) ,
> but can't seem to spot anything wrong , really weird ...
>
> Thanks ...
>
> Gengyang
>
> --
> 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/4365c3a4-76d6-4dc2-8cbf-eeb6a7d34d31%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/CAOzwKwEaZixZJzrs1Vbk69jn97uO_dd7XrC6pk5ZC%3DUr9JcMdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: http://pastebin.com/RWt1mp7F

2015-09-27 Thread John
Are you sure that this settings file is the one that is being read? Put
something ugly at the beginning of it that will raise a syntax error
earlier just to check. Also check whether you have any *.pyc files left
that for some reason might be being read instead of the .py. You can
safely delete all *.pyc files to make sure.

John


On 27/09/15 18:50, Cai Gengyang wrote:
> http://pastebin.com/RWt1mp7F --- If anybody can find any error with
> this settings.py file, let me know !
>
> Looked through it and can't find any mistakes. The error message I got
> was that there is an error on or before line 45 (like a missing
> parentheses) , but can't seem to spot anything wrong , really weird ...
>
> Thanks ...
>
> Gengyang
> -- 
> 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/4365c3a4-76d6-4dc2-8cbf-eeb6a7d34d31%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/5608338E.6010305%40martinhome.org.uk.
For more options, visit https://groups.google.com/d/optout.


Re: http://pastebin.com/RWt1mp7F

2015-09-27 Thread Cai Gengyang
Feeling tired, going to take a break and go to sleep.

Guess I must be missing something ... if anybody can spot the error let me 
know. Just message here or shoot me an email at gengyang...@gmail.com. 
Thanks a lot ...

On Monday, September 28, 2015 at 2:23:03 AM UTC+8, John wrote:
>
> Are you sure that this settings file is the one that is being read? Put 
> something ugly at the beginning of it that will raise a syntax error 
> earlier just to check. Also check whether you have any *.pyc files left 
> that for some reason might be being read instead of the .py. You can safely 
> delete all *.pyc files to make sure.
>
> John
>
>
> On 27/09/15 18:50, Cai Gengyang wrote:
>
> http://pastebin.com/RWt1mp7F --- If anybody can find any error with this 
> settings.py file, let me know !
>
> Looked through it and can't find any mistakes. The error message I got was 
> that there is an error on or before line 45 (like a missing parentheses) , 
> but can't seem to spot anything wrong , really weird ...
>
> Thanks ...
>
> Gengyang
> -- 
> 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/4365c3a4-76d6-4dc2-8cbf-eeb6a7d34d31%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/11ab53fa-a592-4898-862e-a76692314f93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: E-commerce

2015-09-27 Thread Ezequiel Bertti
http://www.getlfs.com/

On Fri, Sep 25, 2015 at 8:59 PM, Paul Savignano 
wrote:

> Thanks luisza14 !
>
> On Thursday, September 24, 2015 at 1:30:46 PM UTC-7, luisza14 wrote:
>>
>>
>> http://oscarcommerce.com/
>>
>> or https://www.djangopackages.com/grids/g/ecommerce/
>>
>> 2015-09-24 13:42 GMT-06:00 Paul Savignano :
>>
>>> Hi Django-users,
>>> I am somewhat new to Django and have a client interested in an online
>>> store/e-commerce for their foodservice operation.
>>> Are there any tutorials you can recommend on this subject?
>>>
>>> Thanks in advance for any help you may offer!
>>>
>>>
>>> *Paul*
>>>
>>>
>>>
>>> --
>>> 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/CAMbaZQ0fRXCH71vr2YdcUeAHqb%3DKrNgB4cUPwc7Mb0_Ej%2BJ0aQ%40mail.gmail.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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bb8f0be7-a929-4b96-bfae-9908dd6cc0cf%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Ezequiel Bertti
E-Mail: eber...@gmail.com
Cel: (21) 99188-4860

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


Looking for advise/examples on working with multiple models & export to JSON

2015-09-27 Thread David Spector
Hi,

Am getting back into Django after a few years away working with a mess of 
other platforms and looking for some advise on how to accomplish what 
should be a pretty straight-forward task.

I'm working on a django app that will be the curation point for a large 
number of data feeds.  These feeds are connected to other models in the DB 
including categories the feeds are in, packages that define the external 
view of a feed to a possible consuming app, bundles which group together 
collections of these feeds, licenses that describe the terms of use for 
each feed, bundle etc. 

My goal is to be able to export these various data/models as a single JSON 
file that will be up on something like S3 for various apps to ingest -- 
this data will be (pretty obviously) the basis of an in-app online 
store/catalog used by mobile apps for iOS and Android.


There are two areas I could use some pointers in:

   1. Pointers to a good example of working with, and exporting data, from 
   these multiple models using Django
   2. How to add a top-level cross-model admin panel -- Django's admin 
   panel seems very focused on single-model CRUD operations -- for these kids 
   of cross-app operations. I'd like to be able to have a panel to invoke 
   scripts/process like the one described above;  I've looked at a few 
   packages like django-admin-tools but these don't address this issue 
   directly.


Any advise/pointers would be greatly appreciated

cheers,
  David 

-- 
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/e4688a2f-450d-44c5-bdcf-244bc2d02934%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Looking for advise on exporting data from multiple models

2015-09-27 Thread David Spector
Hi, 

I'm just getting back into Django development after about 4 yrs with some 
other technologies and looking for some advise on what should be a pretty 
straight forward task.

 I have developed a django app this will be the curation point for a very 
large number of data feeds; these data feeds of course are connect by FKs 
to various data categories, grouped in bundles with other feeds, have 
various data use licenses that apply to them, etc.  In a nutshell this 
collection of data represents a product catalog that will be presented as 
part of an in-app store for a collection of iOS and Android apps. 

Obviously I could make this a REST API where the app requests data about 
each model but for efficiency sake (and to keep down my bandwidth bill) my 
goal is to export this to a single JSON file as data are added/changed 
(which will be a relatively show turn-over) and keep it someplace like S3 
where apps download it.

What I am looking to do is be able to process and export all of these 
models in one shot - the django admin system seems very focused on 
single-model CRUD operations and also doesn't seem to have a easy way to 
add new panels for cross-model commands/actions to the default admin panels.

So, I guess I am asking for advise on 2 things:

   1) a good starting point/example for working with multiple models 
simultaneously, and
   2) a way to add a new panel to the admin interface for these kinds of 
high-level cross-model actions?


Any advise/pointers would be appreciated!

cheers,
_David 

-- 
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/a6a3d667-fc04-4369-aa49-7db8b183fbe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I want to make todo List

2015-09-27 Thread Mario R. Osorio


Ram, are you doing this for homework??



On Saturday, September 26, 2015 at 6:46:56 AM UTC-4, Ram Lakhan Agarwal 
wrote:
>
> I want step by step procedure to make todolist 
>

-- 
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/a262ee10-379b-4971-9b2d-01a0159a32d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


garantir acesso a usuários somente para seus dados

2015-09-27 Thread Carlos Andre
Hi, im with a question, want permission to user in only your data.
With doc i trying but only access to all dates.
Can help? thanks.
ps.: if can help to add new user, use the functions to this.
I use django 1.3 version and is necessari.
thaks!

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


how to design app structure

2015-09-27 Thread Sadaf Noor

Hello,
My question is regarding design pattern of django app. what is the 
philosophy behind apps in django? when should we decide to split our web 
app into many django apps? If you could share you relevant experiences, 
it would be helpful.



--
 Md. Sadaf Noor (@sadaf2605 )
www.sadafnoor.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/5608B3E9.7040509%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Tom Lockhart

> On Sep 27, 2015, at 06:04, Cai Gengyang  wrote:
> 
> This is my entire settings.py file
> 
> …

I’m not seeing the problem, but it is certainly there somewhere.

Try removing pieces of the settings file until you can isolate the syntax 
problem which is likely on or before line 45. Copy the original one aside so 
you can go back to it and repair the problem once you figure out where it is.

hth

- Tom

-- 
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/7A42C6CC-7DCE-4C0F-B7D2-6CA67C9F09D6%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Tutorial(Database Setup Question)

2015-09-27 Thread Cai Gengyang


Hey guys, I am happy to announce that it finally works. The problem was 
that there was an additional 'qq' in my settings.py file on line 44.(no 
idea how it got there) I have posted my entire input / output here for 
viewing and discussion ...



CaiGengYangs-MacBook-Pro:~ CaiGengYang$ cd mysite folder

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ ls

manage.py mysite

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ python manage.py migrate

*Operations to perform:*

*  Synchronize unmigrated apps: *staticfiles, messages

*  Apply all migrations: *admin, contenttypes, auth, sessions

*Synchronizing apps without migrations:*

  Creating tables...

Running deferred SQL...

  Installing custom SQL...

*Running migrations:*

  Rendering model states...* DONE*

  Applying contenttypes.0001_initial...* OK*

  Applying auth.0001_initial...* OK*

  Applying admin.0001_initial...* OK*

  Applying contenttypes.0002_remove_content_type_name...* OK*

  Applying auth.0002_alter_permission_name_max_length...* OK*

  Applying auth.0003_alter_user_email_max_length...* OK*

  Applying auth.0004_alter_user_username_opts...* OK*

  Applying auth.0005_alter_user_last_login_null...* OK*

  Applying auth.0006_require_contenttypes_0002...* OK*

  Applying sessions.0001_initial...* OK*

CaiGengYangs-MacBook-Pro:mysite CaiGengYang$ 
On Monday, September 28, 2015 at 1:50:18 PM UTC+8, Thomas wrote:
>
>
> On Sep 27, 2015, at 06:04, Cai Gengyang > 
> wrote:
>
> This is my entire settings.py file
> …
>
>
> I’m not seeing the problem, but it is certainly there somewhere.
>
> Try removing pieces of the settings file until you can isolate the syntax 
> problem which is likely on or before line 45. Copy the original one aside 
> so you can go back to it and repair the problem once you figure out where 
> it is.
>
> hth
>
> - Tom
>
>

-- 
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/45e61d73-4bc8-4a95-a12f-3082f770a692%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django query, order results such that th128 > th99

2015-09-27 Thread gintare
Is it possible to order the query result strings in such a way that th128 
string would be first comparing to th99.
The query results contains 128 items in format: "th"+number. For instance, 
th1, th2, ...th80, ..th99, th100, th128.
Than i order results, they go in the following order, th1, th10,th100, 
th101,th102,... th11,th110, ... th2, th20, th21,th22,.. th9,..th99.
Thus i am not able to get the largest result, which is th128. I am getting 
th99 instead.

def temp(request):
query = request.GET.get( 'q','')
#a=Aref5.objects.filter(Rname__contains='book').count()  #finds128

a=Aref5.objects.filter(Rname__contains='book').order_by('-Rname')[0:1].get() 
#gets aref5 object
print(a.Rname) #prints th99 instead of th128, which logically is larger
return render_to_response('Ath.html', {"query": query})

-- 
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/69e26bab-210e-4137-adf3-498855d0eae6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django query, order results such that th128 > th99

2015-09-27 Thread Gergely Polonkai
Hello,

what you want to achieve is called "natural order sorting" which is not
built into any common SQL implementation I know. You have to do it manually
from code, or, if you have to do pagination, add a sorting column that is
numeric (and indexed).

Best,
Gergely
On 28 Sep 2015 08:42, "gintare"  wrote:

> Is it possible to order the query result strings in such a way that th128
> string would be first comparing to th99.
> The query results contains 128 items in format: "th"+number. For instance,
> th1, th2, ...th80, ..th99, th100, th128.
> Than i order results, they go in the following order, th1, th10,th100,
> th101,th102,... th11,th110, ... th2, th20, th21,th22,.. th9,..th99.
> Thus i am not able to get the largest result, which is th128. I am getting
> th99 instead.
>
> def temp(request):
> query = request.GET.get( 'q','')
> #a=Aref5.objects.filter(Rname__contains='book').count()  #finds128
>
> a=Aref5.objects.filter(Rname__contains='book').order_by('-Rname')[0:1].get()
> #gets aref5 object
> print(a.Rname) #prints th99 instead of th128, which logically is larger
> return render_to_response('Ath.html', {"query": query})
>
> --
> 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/69e26bab-210e-4137-adf3-498855d0eae6%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/CACczBU%2Bi0tVFhMypH7VuPKe9c%2B_-tk8ofdwyMgyAA1h3V4vtAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.