Re: Noob: How do I get this app to work :(

2013-05-19 Thread Kelvin Wong
If you have old code, you can still use it with an older Django using the 
pip installer

$ pip install Django==1.3.7

K


On Thursday, May 16, 2013 1:58:52 PM UTC-7, Todd Wickizer wrote:
>
> Hello there,
>
> I just install Django yesterday. I am trying to take a calendar app and 
> edit it for my own means. Unfortunately I am a little confused on how to 
> create the Urls.py file to match the application.
>
> Here is the application.
>
> http://code.google.com/p/django-event-calendar/source/browse/#svn%2Ftrunk%2Fevents
>
>
> The admin menu + add event + add event category works great. But when I 
> click on 'view this event' I get a 404 error.
>
> Additionally I see this app uses Template Tags, which I know little about.
>
>
> I'm not sure if I am supposed to offer money for this? If it is required I 
> am willing to pay for help
>
> 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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: new to Django and building web applications. Advice with postgresql

2013-05-19 Thread Kelvin Wong
You don't have to become an expert with postgres to use Django. You can do 
most of the db development using SQLite and hold off on postgres until you 
are ready to deploy.

I'd get a Linux server running in VirtualBox. Install Apache and postgres. 
Configure postgres. Install phpPgAdmin.

If you are going to be looking for a job doing Django, your employer will 
want you to know Django and Python really well, not postgres.

K


On Thursday, May 16, 2013 10:16:59 PM UTC-7, d.gu...@gmail.com wrote:
>
> Hi, 
>
> I'm new to building web applications, django, backend work, etc... I have 
> experience in C++ up to A.P. computer science level if that means anything 
> and I'm beginning to get a grasp on the python language. I've done all of 
> the exercises on code academy and have watched fairly a lot of videos on 
> building with django and python. I have somewhat of a grasp on the overall 
> design of files in the terminal that are involved (url.py, views.py, 
> etc...). I've been following 
> http://www.djangobook.com/en/2.0/chapter02.html. My question is It was 
> suggested by this free online open source book to install postgresql, so I 
> did but I had no idea how to use it and kind of gave up on it and setting 
> up the backend. Can anyone suggest a resource a book perhaps that can guide 
> me in the right direction or just give some friendly advice. My goal by the 
> end of the summer is to be able to build a substantial dynamic web 
> application with python in Django that will have the feel of a Khan Academy 
> or code academy (a dynamic website that is able to hold lots of content and 
> have a user-interface with accounts, logins, rewards systems and much more) 
> and be launced on the web for the world to see and use. The only other true 
> experience I have with web design is with static web pages and basic HTML 
> and CSS. Yes, it is a big goal, but I think I can do it with the right 
> amount of guidance. I have all summer to learn. Hell, you have to start 
> somewhere right? All suggestions are welcome.
>
> 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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: working with images in django

2013-07-29 Thread Kelvin Wong
So you have images already made and you want to place them into HTML? 
That's easy. If you want to make the image dynamically using something like 
PIL or Pillow then flow them into a PDF then that's a little more involved.

Try explaining your use case a bit more.

K


On Sunday, July 28, 2013 7:21:33 AM UTC-7, Robert Brown wrote:
>
> Hello, can anyone suggest where I might find some of example of working 
> with images in django.  I want to store them and pull them into text 
> documents, about one every couple of paragraphs.  I am finding a lot of 
> posts on this site about the img class but most of them seem to address 
> very specific problems.  I am looking more for a beginners how to do it 
> discussion or tutorial.
>
> 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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How the authentication takes place at the backend in django?

2013-07-29 Thread Kelvin Wong
You can always read the source code to find this out

https://github.com/django/django/blob/master/django/contrib/auth/models.py

https://github.com/django/django/blob/master/django/contrib/auth/backends.py

https://github.com/django/django/blob/master/django/contrib/auth/hashers.py

Also the docs are very good

https://docs.djangoproject.com/en/dev/topics/auth/default/#auth-web-requests

https://docs.djangoproject.com/en/dev/ref/contrib/auth/

K


On Saturday, July 27, 2013 10:37:25 PM UTC-7, Viji Venkatesan wrote:
>
> Hi,
>
>
> If we are giving credentials in login form as username and password,how 
> the process takes place to check with database at the backend ,whether the 
> user is authenticated or not.?
> just make clear of itplease give detail explanation for it.
>
> Thank you.!!
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Help getting started: Which server setup for a beginner? Apache? lighttpd? To use or not virtualenv?

2013-08-01 Thread Kelvin Wong
It is def worth taking the trouble to learn how to use virtualenv and 
virtualenvwrapper. Once they are set up and assuming that you haven't 
already put too much already into your global site-packages, they will save 
you time and greatly simplify keeping different project environments 
separate.

You didn't mention if you were on a Mac or what. On a UNIX dev machine 
setting up virtualenv and the wrapper are fairly straightforward.

K



On Tuesday, July 30, 2013 8:48:18 AM UTC-7, Jared Nielsen wrote:
>
> I'm trying to learn Django but finding myself lost in troubleshooting 
> hell. I can't find consistent information on the best approach for a 
> beginner to get set up.
>
> I started setting up Apache with mod_wsgi, but ran into innumerable config 
> errors. After some Googling about, I found a number of suggestions to use 
> lighttpd instead. Installed that and more troubleshooting. And what's this 
> about gunicorn? 
>
> What's the best approach for a beginner? Where is my time best spent 
> troubleshooting? 
>
> Also, should I be using virtualenv? Inconsistent use across the various 
> tutorials I'm reading. 
>
> Many thanks in advance! 
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: problem with deploying django using mod wsgi

2013-08-10 Thread Kelvin Wong
Is your form (on page /mice/search_mice/) submitting to

/mice/search

or

/search

Check your form element in the html document. Is it pointing to the right 
URL?

Maybe check your WSGIScriptAlias setting. Maybe verify your DocumentRoot 
setting.

You might also want to check the request and response using a tool like 
HttpFox

K



On Thursday, August 8, 2013 6:10:34 AM UTC-7, sah wrote:
>
> I have this error in the error_log file :
>
>  [error] [client 10.10.8.41] File does not exist: /var/www/html/search, 
> referer: http://tarinformatics03/mice/search_mice/
>
> search is one of my view function why is it looking for it in the html 
> directory ??
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Error importing middleware django.contrib.sessions.middleware

2013-08-13 Thread Kelvin Wong
Did you do this part (from the docs):

https://docs.djangoproject.com/en/1.5/topics/http/sessions/#using-database-backed-sessions
Using database-backed 
sessions

...

Once you have configured your installation, run manage.py syncdb to install 
the single database table that stores session data.

---

If that doesn't help then, you could try using the Django shell and looking 
for exception that comes up:
$ python manage.py shell

>>> middleware_path = 'django.contrib.sessions.middleware.SessionMiddleware'
>>> mw_module, mw_classname = middleware_path.rsplit('.', 1)
>>> mw_module
'django.contrib.sessions.middleware'
>>> from django.utils.importlib import import_module
>>> mod = import_module(mw_module)

See

https://github.com/django/django/blob/stable/1.5.x/django/core/handlers/base.py




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Error importing middleware django.contrib.sessions.middleware

2013-08-14 Thread Kelvin Wong
What version of Django are you running?

$ python2.7 -c "import django; print django.VERSION;"

Did this ever work before you enabled Memcached? Did you remove the extra 
CACHES dictionary from settings.py?

What was the full traceback from the Django shell?

K

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django Gunicorn with Two Django App

2013-08-14 Thread Kelvin Wong
The error "Could not reliably determine the server's fully qualified domain 
name" is harmless, but the fix is easy. See...

https://help.ubuntu.com/community/ApacheMySQLPHP#Troubleshooting_Apache

If you are running Django under Nginx and Gunicorn, why are you restarting 
Apache anyway?

Your gateway issue is very common with Nginx and can be fixed by proper 
configuration of your reverse proxy and ensuring that your Gunicorns are 
actually running and handling traffic. I've used Supervisor to manage the 
Gunicorns and it works well for that purpose.

http://wiki.nginx.org/HttpProxyModule

http://docs.gunicorn.org/en/latest/deploy.html

If you find the reverse proxy set-up too confusing, I'd recommend mod_wsgi. 
I find it easier to set-up and manage than other methods.

K

On Tuesday, August 13, 2013 1:11:28 PM UTC-7, Muhammed TÜFEKYAPAN wrote:
>
> I edit my port, sites enabled files etc.
>
> Now two sites run different port but i got an error: 502 Bad Gateway
>
> Also when i type "service apache2 restart" there is error "Could not 
> reliably determine the server's fully qualified domain name, using 
> 127.0.0.1 for ServerName" error. 
>
> I think real problem this.
>
>
> On Tuesday, August 13, 2013 5:31:07 PM UTC+3, Muhammed TÜFEKYAPAN wrote:
>>
>> Hello Everyone,
>>
>>
>> I use digitalocean for server and i install nginx and unicorn for django. 
>> I have one service for my project. I also want to add new django project 
>> and i made it with making new services. 
>>
>> When my one project running the other project stop. 
>>
>> How can i run two projects same time?
>>
>> 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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: How do I create a script to fill in django admin login form and submit?

2013-08-14 Thread Kelvin Wong
https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.login

K


On Tuesday, August 13, 2013 10:23:48 PM UTC-7, 7equiv...@gmail.com wrote:
>
> Here is what I'm doing. I have written a script the runs and monitors a 
> serial connection for incoming data. The data comes from an RFID tag 
> reader. I have that working. What I'd like to do is use this rfid tag 
> number to fill in the password feild and  submit the django Admin login form. 
> I'm still a novice and Any advise is appreciated... Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: is it possible to use REST API with HTML within Django?

2013-08-15 Thread Kelvin Wong
To make calls to remote http-enabled servers, use Requests within your 
view. The results can be passed to the template in the standard way.

http://docs.python-requests.org/en/latest/

K



On Thursday, August 15, 2013 9:27:26 AM UTC-7, evh wrote:
>
> Hi,
>
> I am having trouble getting REST to work within Django.  Has anyone 
> succeeded in doing this?  How do I embed REST API calls within the HTML 
> that runs my webpage?  I am trying to send "commands" to a device that is 
> connected to my webpage and can do this outside of Django manually in a 
> PowerShell window, but just within my HTML code.
>
> Thanks for any help or advice,
> Ed
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: tests failing/throwing errors - not sure where to start

2013-08-18 Thread Kelvin Wong
My advice to you is to just ignore it all and focus on the tests in your 
application.

For example, if your app that you wrote yourself is called "amazingapp" 
then you test only that app thus.

---

$ python manage.py test amazingapp

---

And it will say something similar to this...

---

Creating test database for alias 'default'...
.
--
Ran 1 test in 0.002s

OK
Destroying test database for alias 'default'...

---

Don't bother testing your framework code or your modules, which Django does 
if you leave out the app name (assuming you're not making patches for 
Django itself).

PS. Good for you for testing your code.

K



On Saturday, August 17, 2013 11:27:34 PM UTC-7, Kris Fields wrote:
>
> Hi,
>
> The project I'm working on seems to work fine but running "python 
> manage.py test" results in a lot of failed tests. I'm trying to get a 
> handle on them but I'm not sure where to start.  I'm hoping someone can 
> help point me in the right direction.
>
> Most of the failed tests are for django, but some are for mezzanine and 
> allauth.  I've included them all in case it's relevant.
>
> Running django 1.4.3, python 2.7.2
> Mezzanine 1.4.5, allauth 0.12.0
>
> Any help is much appreciated!
>
> Thanks,
>
> Kris
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-18 Thread Kelvin Wong
You were missing a key. The following works on my machine.

K

---


import requests
login_url = "http://192.168.0.21/admin/login/";


client = requests.session()
client.get(login_url)


csrftoken = client.cookies['csrftoken']


login_data = {'username':'jim', 'password':'beam', 
'this_is_the_login_form':'1', 'csrfmiddlewaretoken':csrftoken}


r = client.post(login_url, data=login_data)


target_url = "http://192.168.0.21/admin/auth/user/";
t = client.get(target_url)


'Select user to change' in t.text # True 

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Kelvin Wong
This is how I do it.

In settings.py:

STATIC_ROOT = '/home/user/app/site_media/static/'  # Generated files here 
from 'manage.py collectstatic'

STATIC_URL = 'http://static.example.com/static/'

In templates:

{% load staticfiles %}

...



Produces:

http://static.example.com/static/myapp/stylesheets/app.css"; 
rel="stylesheet" type="text/css">

If static.example.com is behind Nginx this is in your static server conf 
file:

# Nginx staticfiles setting

location /site_media/ {
  alias /home/user/app/site_media/;
}

This is a made up example, but the real thing is close to it.

K

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I create a script to fill in django admin login form and submit?

2013-08-21 Thread Kelvin Wong
I've used Requests in the past.

All I did was load the page in Chrome and then I looked at what was being 
sent and compared it to what your script was sending. When I added the 
missing key it worked.

Trial and error. :)

K



On Wednesday, August 21, 2013 8:48:16 AM UTC-7, 7equiv...@gmail.com wrote:
>
> How did you know that that was the name of the form? When I went to 
> django.contrib.auth.forms, it seemed the form name was AuthenticationForm, 
> and when I used view source in a browser it looked like the form was named 
> login-form. How could one know the form was named 'this_is_the_login_form'?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django IndexError: list index out of range

2013-08-24 Thread Kelvin Wong
Can you change the name of this file from

newweb/polls/__init.py__

to

newweb/polls/__init__.py

That file name is not right.

K



On Saturday, August 24, 2013 8:02:38 AM UTC-7, Oleg Gorjajnov wrote:
>
> I'm new to Django. 
>
>
> newweb/
>   manage.py
>   newweb/
> __init__.py
> settings.py
> urls.py
> wsgi.py
>   polls/
> __init.py__
> admin.py
> models.py
> tests.py
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Saving google maps values to db

2013-08-29 Thread Kelvin Wong
If you have a map on a page, you can add some Javascript that obtains the 
Lat and Lng and Zoom Level from the map and then use that data to fill in a 
form (or do whatever you want with it). This code give some hints

https://developers.google.com/maps/documentation/javascript/examples/map-coordinates

K


On Thursday, August 29, 2013 8:02:31 PM UTC-7, Nkansah Rexford wrote:
>
> I came across this app for displaying Google maps to pages in django. 
> https://bitbucket.org/dbinit/django-gmapi/src
>
> Is there a way I can save Google maps values via a form to db for 
> retrieval later in a page?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Admin: Add new dataset with a pre-selected foreign key?

2013-08-30 Thread Kelvin Wong
Take a look at filters in the admin. You might be able to add log entries 
to recent items using an appropriate ModelAdmin on 'entry_created'

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter

Then use an InlineModelAdmin

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.InlineModelAdmin

You could then select the sample by finding recently added samples, 
clicking on it, then add the log entry

K



On Friday, August 30, 2013 7:45:14 AM UTC-7, Katja wrote:
>
> Hi,
>
> I have a data model like this:
> class Samples(models.Model):  
>   sample_id = models.CharField(max_length=128, help_text='Id of the 
> sample')
>   entry_created = models.DateTimeField(auto_now_add=True)
>   sample_status = models.CharField(choices=SAMPLE_STATUS_CHOICES, 
> max_length=128)
>   comments = models.TextField(null=True, blank=True)
>   def __unicode__(self):
> return ("%s" % (self.sample_id))
>
> class StatusLog(models.Model):
>   sample_id = models.ForeignKey(Samples)
>   lsu_proc_id = models.IntegerField()
>   orig_lab = models.ForeignKey(OriginatingLab)
>   cruise_id = models.ForeignKey(Cruises)
>   tier = models.ForeignKey(Tiers)
>   orig_tier_tote_nr = models.IntegerField()
>   gear_type = models.ForeignKey(GearType)
>   orig_number_jars = models.IntegerField()
>   all_consumed = models.CharField(max_length=3, choices=YES_NO_CHOICE)
>   def __unicode__(self):
> return ("%s %s" %(self.sample_id, self.lsu_proc_id))
>
> 
>
> So first I add a Sample, and later I want to add a status log entry - 
> using the admin interface.
> Problem: My list of samples will be LONG (right now roughly 1000 entries, 
> more are coming). 
>
> Is there any way that I can call the "add" page (
> http://MYSERVER/admin/statuslog/statuslog/add/) with the sample already 
> preselected, so I don't have to go through the whole list?
>
> Any ideas?
>
> Thanks!
> Katja
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: New to Django and developing website based on a Framework. What is the best order to develop website?

2013-08-31 Thread Kelvin Wong
Add features as you need them. If you are going to launch in multiple 
languages I'd add that early on. Adding the stock authorization is pretty 
safe as well.

Learn and use the testing framework as much as possible.

K


On Saturday, August 31, 2013 1:07:46 PM UTC-7, Mark Strickland wrote:
>
> I am starting to develop a website using django and I am wondering if I 
> should add all the extra modules (authorization, mutliLanguages, comments), 
> at the beginning, or should I develop the basic pages (apps) and then go 
> back and add in the requirements for the modules I want to add.
>
>
> I am trying to develop a website using django, like my current website 
> www.serviidb.com created in drupal.,
>
> Any advice would be greatly appreciated.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django driving me nuts

2013-08-31 Thread Kelvin Wong
Try the Django IRC channel for faster answers

https://code.djangoproject.com/wiki/IrcFAQ

If you are learning Python at the same time learning Django then it can be 
a tough climb

K


On Saturday, August 31, 2013 5:50:19 AM UTC-7, Gerd Koetje wrote:
>
> Why is it so hard to get as a former php programmer.
>
> anyone willing to help me over this part?
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django logs for the website

2013-09-01 Thread Kelvin Wong
It depends on how you're running your Django app. If you are running this 
under Apache mod_wsgi, they end up in the Apache error.log file. If you are 
running this under Gunicorn/Supervisor with an Nginx out in front then I've 
seen them show up in the Supervisor log file.

I've also seen them emit messages to a network logging machine. It depends 
how you set up your loggers.

K



On Sunday, September 1, 2013 10:21:09 AM UTC-7, Alek Uritsky wrote:
>
> Hi all,
> does Django/Python has a standard logs system? I am trying to find the 
> logs generated by the website, so far was able to find only the webserver 
> logs (nginx).
> Is there a standard place where a Python website developer would put 
> website specific logs?
>
> thanx
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django-registration reset password templates not getting picked up

2013-09-01 Thread Kelvin Wong
TEMPLATE_DIRS needs to have the location of the templates. As long as those 
templates are being picked up and one is called 'password_reset_form.html' 
it should work.

One of my apps has this form at:

/my_project/templates_global/registration/password_reset_form.html

In /my_project/my_project/settings.py

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

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates_global')
)

The templates were all copied 
from django.contrib.admin.templates.registration

K


On Saturday, August 31, 2013 11:02:14 PM UTC-7, Vibhu Rishi wrote:
>
> I am getting a bit of a problem with django-registration
>
> what else do i need to do ? As per the django-registration documentation, 
> the auth_urls.py is supposed to be automatically included with the default 
> backend. But apparently, there is some disconnect here. 
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django-registration reset password templates not getting picked up

2013-09-02 Thread Kelvin Wong
If you are not using a templates folder in your project root, where are 
your registration templates located?

K


On Monday, September 2, 2013 9:42:50 AM UTC-7, Vibhu Rishi wrote:
>
>
> So far, all the other template html files get picked up - except the ones 
> related to the password management ones. 
>
> Vibhu
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django-registration reset password templates not getting picked up

2013-09-02 Thread Kelvin Wong
Check that your 'homepage' app is above the 'registration' app:

INSTALLED_APPS = (
'homepage',  # Order matters, this is loaded before others
'registration',
'django.contrib.auth',
   ...
)

Order of the apps is significant. Review

https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.app_directories.Loader

As a matter of personal style, I would put them in a project template 
folder and not in an app templates folder.

K



On Monday, September 2, 2013 7:01:30 PM UTC-7, Vibhu Rishi wrote:
>
> Essentially the below should work (and is working for all) as I have the 
> following template loader:
>
> TEMPLATE_LOADERS = (
> 'django.template.loaders.filesystem.Loader',
> 'django.template.loaders.app_directories.Loader',
> )
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django-registration reset password templates not getting picked up

2013-09-03 Thread Kelvin Wong
I put the overridden templates (auth, registration, etc) in a project 
templates folder in the project root. You have to set it up though in your 
settings.py as I noted earlier. The filesystem loader is still right there 
above the app_directories loader. To me the overridden templates don't seem 
to make sense in an app even if it does nothing but serve the homepage.

Templates that belong to certain apps are put into application templates 
folders. That makes more sense to me.

This is just personal dogma though.

K



On Tuesday, September 3, 2013 9:59:24 AM UTC-7, Vibhu Rishi wrote:
>
>
> I was doing all my templates within a single directory pre 1.5 . But then 
> in 1.5 they changed it, so I got a bit confused but then started putting 
> the templates within the app. Not sure if this is good or bad.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-04 Thread Kelvin Wong
The MEDIA_ROOT is the local system location where the FileField in your 
models is going to store incoming files. Users submit files and they are 
placed in the location specified by the 'upload_to' setting of the field 
(usually a directory within MEDIA_ROOT).

https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to

You should remove your MEDIA_ROOT from STATICFILES_DIRS.

Then you should review this documentation.

https://docs.djangoproject.com/en/dev/topics/http/file-uploads/

The 'collectstatic' command collects your static assets, not user submitted 
content. Your system is misconfigured and that is why it is collecting user 
submitted files.

K


On Wednesday, September 4, 2013 12:41:03 PM UTC-7, Robin Lery wrote:
>
> I have a site, where users can upload images. And it works fine in 
> django's own server. But I am using apache to serve both my app and 
> statics. And when I upload any image, I can't see the pics. Only when I run
> collectstatic I can see them. Do I always have to run collectstatic? Is 
> there any better way to do this?
>
> my settings.py snippet:
>
> MEDIA_ROOT = 'C:/Users/Robin/web/leo/static'
>
> STATIC_ROOT = 'C:/Users/Robin/static/'
>
> STATICFILES_DIRS = (
> "C:/Users/Robin/web/leo/static",
>
>  apache http.cont snippet:
>
> AliasMatch ^/([^/]*\.css) C:/Users/Robin/static/styles/$1
> Alias /static/ C:/Users/Robin/static/
> Order deny,allowAllow from all
> WSGIScriptAlias / C:/Users/Robin/web/leo/leo/wsgi.py
> Order allow,denyAllow 
> from all
>
>  Please guide me. Any help will be appreciated greatly. Thank you!
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ValueError at / Empty module name

2013-09-04 Thread Kelvin Wong
Your MEDIA_ROOT setting is also suspect.

As-is you will be writing user submitted files into your shared 
site-packages folder. Hopefully you won't be running Django as root and 
you'll get a permission error.

K

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Do I always have to run collectstatic to serve uploaded images by apache?

2013-09-05 Thread Kelvin Wong
Check your templates. I bet your tag there is giving the wrong root 
relative path to the user uploads.

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#get-media-prefix

If Apache is giving you problems, what does it say in your Apache logs? Try 
debugging this like you would an Apache configuration error.

K


On Thursday, September 5, 2013 8:35:49 AM UTC-7, Robin Lery wrote:
>
> I did as you told, but I can only see it, when I reload the page served by 
> the django's inbuilt server. Kindly check this - 
> https://mail.google.com/mail/u/0/#sent/140ee7fdc09d4f22
>
>
> On Thu, Sep 5, 2013 at 2:29 AM, Kelvin Wong 
> > wrote:
>
>> The MEDIA_ROOT is the local system location where the FileField in your 
>> models is going to store incoming files. Users submit files and they are 
>> placed in the location specified by the 'upload_to' setting of the field 
>> (usually a directory within MEDIA_ROOT).
>>
>>
>> https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to
>>
>> You should remove your MEDIA_ROOT from STATICFILES_DIRS.
>>
>> Then you should review this documentation.
>>
>> https://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>>
>> The 'collectstatic' command collects your static assets, not user 
>> submitted content. Your system is misconfigured and that is why it is 
>> collecting user submitted files.
>>
>> K
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Mezzanine Gunicorn Problem

2013-09-09 Thread Kelvin Wong

>
> This is the command (single line) that I am using for a Django app using 
> Gunicorn (and Supervisor). It is running with a virtualenv which explains 
> the python executable.
>
> /home/myapp/.virtualenvs/productionmyapp/bin/python 
> /home/myapp/webapps/production_fido/fido/manage.py run_gunicorn -c 
> /home/myapp/webapps/production_fido/fido/gunicorn_production.py
>
> The gunicorn_production.py file is a configuration file.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: static files are not working

2013-09-13 Thread Kelvin Wong
Are you saying that your settings are like this?

STATIC_ROOT = 
'/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static'

STATIC_URL='/static/'  # < Trailing slash required! check it

If so that is asking for trouble when you do a collectstatic. You'll prob 
get permission error unless you do a sudo.

Set your STATIC_ROOT somewhere you can write to without sudo when you do a 
manage.py collectstatic:

STATIC_ROOT = '/var/www/myproject/site_media/static'

if your deployment files are at /var/www/myproject

Review...

https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#collectstatic

K


On Friday, September 13, 2013 9:17:17 PM UTC-7, Harjot Mann wrote:
>
> I have placed my static folder called time in 
> /usr/local/lib/python2.7/dist-packages/django/contrib/admin/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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django unittest failure

2013-09-14 Thread Kelvin Wong
Are you reusing an old database or something? There should be only two 
users in the database prior to testing that section.

# Create two users so we can filter by is_staff when handing our
# wizard a queryset keyword argument.
self.normal_user = User.objects.create(username='test1', 
email='nor...@example.com')
self.staff_user = User.objects.create(username='test2', 
email='st...@example.com', is_staff=True)


See line 369

https://github.com/django/django/blob/stable/1.5.x/django/contrib/formtools/tests/wizard/wizardtests/tests.py

K



On Saturday, September 14, 2013 3:35:06 PM UTC-7, Ryan Boggs wrote:

AssertionError: 2 != 3
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django unittest failure

2013-09-16 Thread Kelvin Wong
You should probably open a bug on this issue. The test suite fails for me 
on MacOS/Python 2.7 on the stable/1.5.x branch. This is the command that 
fails reliably on my machine:

$ PYTHONPATH=..:$PYTHONPATH python ./runtests.py --settings=test_sqlite 
utils formtools

It might be related to this addition

https://github.com/django/django/commit/cb9aaac

The user created by this line (l.129):

user = User.objects.create_user('johndoe', 'j...@example.com', 'pass')

... persists into subsequent WizardFormKwargsOverrideTests tests on 
the stable/1.5.x branch

Running the individual test for 'formtools' passes without issue.

K


On Sunday, September 15, 2013 12:30:54 PM UTC-7, Ryan Boggs wrote:
>
> FYI,
>
> Just tried with 1.5.4 and the same test is still failing.
>
> Thanks,
> Ryan
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with STATIC_URL in v1.5.2

2013-09-17 Thread Kelvin Wong
Check that your STATIC_URL setting in your template is outputting the same 
string as settings.STATIC_URL. Make sure that any included 
local_settings.py files are not wiping out those settings. You can check it 
using the Django shell:

$ python manage.py shell

>>> from django.conf import settings
>>> settings.STATIC_URL
'/assets/static/'

If not, check that you're using RequestContext to render your views. You 
can do this from the Django shell as well.

>>> from django.http import HttpRequest
>>> r = HttpRequest()
>>> from django.template import Template
>>> t = Template("{{ STATIC_URL }}")
>>> from django.template import RequestContext
>>> c = RequestContext(r, {})
>>> t.render(c)
u'/assets/static/'

Check that you're including 'django.core.context_processors.static'  in 
your settings.TEMPLATE_CONTEXT_PROCESSORS tuple.

>>> settings.TEMPLATE_CONTEXT_PROCESSORS
('django.contrib.auth.context_processors.auth', 
'django.core.context_processors.debug', 
'django.core.context_processors.i18n', 
'django.core.context_processors.media', 
'django.core.context_processors.static', 
'django.core.context_processors.tz', 
'django.contrib.messages.context_processors.messages')

K


On Monday, September 16, 2013 12:43:04 PM UTC-7, Adam wrote:
>
> Maybe this is something well known. 
>
> I'm using STATIC_URL in my templates.  Worked perfectly in Django 1.4.x. 
> Upgraded to v1.5.2.  Now STATIC_URL ONLY works when the DEBUG setting is 
> True.  When set to False (For production), STATIC_URL is an empty string 
> in the template. 
>
> Anybody have any idea why this might be happening or what to look at? 
> Everything that needs to be set for STATIC_URL is set, otherwise it 
> wouldn't have worked in v1.4.x in the first place. 
>
> -- 
> Adam (ad...@csh.rit.edu ) 
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble with STATIC_URL in v1.5.2

2013-09-17 Thread Kelvin Wong
If your software works then I guess it works, but I just ran this in the 
shell on Django 1.5.4.

$ python manage.py shell
Python 2.7.3 (default, May  4 2012, 11:07:18) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> settings.STATIC_URL
'/static/'
>>> settings.DEBUG
False
>>> from django.http import HttpRequest
>>> r = HttpRequest()
>>> from django.template import Template
>>> t = Template("{{ STATIC_URL }}")
>>> from django.template import RequestContext
>>> c = RequestContext(r, {})
>>> t.render(c)
u'/static/'
>>> import django
>>> django.get_version()
'1.5.4'

If you look at django.core.context_processors you can see that the 
STATIC_URL is placed in the RequestContext unconditionally on line 65:

https://github.com/django/django/blob/stable/1.5.x/django/core/context_processors.py

K



On Tuesday, September 17, 2013 6:09:54 AM UTC-7, Adam wrote:
>
> Turns out that I had to use the new {% static %} template tag.  It seems 
> that STATIC_URL is only set in the context for template use when in 
> DEBUG mode (didn't look in the code, but it appears that way). 
>
> {% static %} works for both development and production environments.  It 
> was pretty simple for me to switch.  All STATIC_ variables were already 
> set correctly.  I just needed to add this to the top of my base template 
> file: 
>
> {% load static %} 
> {% get_static_prefix as STATIC_URL %} 
>
> and everything else remained the same. 
>
> On Tue, 2013-09-17 at 02:42 -0700, Kelvin Wong wrote: 
> > Check that your STATIC_URL setting in your template is outputting the 
> > same string as settings.STATIC_URL. Make sure that any included 
> > local_settings.py files are not wiping out those settings. You can 
> > check it using the Django shell: 
> > 
> > 
> > $ python manage.py shell 
> > 
> > 
> > >>> from django.conf import settings 
> > >>> settings.STATIC_URL 
> > '/assets/static/' 
> > 
> > 
> > If not, check that you're using RequestContext to render your views. 
> > You can do this from the Django shell as well. 
> > 
> > 
> > >>> from django.http import HttpRequest 
> > >>> r = HttpRequest() 
> > >>> from django.template import Template 
> > >>> t = Template("{{ STATIC_URL }}") 
> > >>> from django.template import RequestContext 
> > >>> c = RequestContext(r, {}) 
> > >>> t.render(c) 
> > u'/assets/static/' 
> > 
> > 
> > Check that you're including 'django.core.context_processors.static' 
> >  in your settings.TEMPLATE_CONTEXT_PROCESSORS tuple. 
> > 
> > 
> > >>> settings.TEMPLATE_CONTEXT_PROCESSORS 
> > ('django.contrib.auth.context_processors.auth', 
> > 'django.core.context_processors.debug', 
> > 'django.core.context_processors.i18n', 
> > 'django.core.context_processors.media', 
> > 'django.core.context_processors.static', 
> > 'django.core.context_processors.tz', 
> > 'django.contrib.messages.context_processors.messages') 
> > 
> > K 
> > 
> > 
> > 
> > On Monday, September 16, 2013 12:43:04 PM UTC-7, Adam wrote: 
> > Maybe this is something well known. 
> > 
> > I'm using STATIC_URL in my templates.  Worked perfectly in 
> > Django 1.4.x. 
> > Upgraded to v1.5.2.  Now STATIC_URL ONLY works when the DEBUG 
> > setting is 
> > True.  When set to False (For production), STATIC_URL is an 
> > empty string 
> > in the template. 
> > 
> > Anybody have any idea why this might be happening or what to 
> > look at? 
> > Everything that needs to be set for STATIC_URL is set, 
> > otherwise it 
> > wouldn't have worked in v1.4.x in the first place. 
> > 
> > -- 
> > Adam (ad...@csh.rit.edu) 
> > 
> > 
> > -- 
> > 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. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
> -- 
> Adam (ad...@csh.rit.edu ) 
>
>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Upload de musicas (music upload)

2013-09-19 Thread Kelvin Wong
I just wrote a blog post on uploading files using generic class based 
views. It has a sample app as well.

https://bit.ly/14m6Q65

Let me know if you have any questions.

K


On Monday, September 16, 2013 8:41:06 AM UTC-7, Carlos Andre wrote:
>
> Olá pessoal, tudo bom?
> Eu gostaria de uma ajuda de como fazer upload de músicas no banco de 
> dados, como faço upload de arquivo. Gostaria de exemplos.
>
> Hello guys, how are you?
> I would like some help on how to upload songs in the database, how do I 
> upload file. I would like examples.
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Copy all the data from an existing database when create the testing database.

2013-10-05 Thread Kelvin Wong
Consider using model factories (you can roll your own) or FactoryBoy

https://factoryboy.readthedocs.org/en/latest/

K


On Friday, October 4, 2013 9:17:51 AM UTC-7, Tianyi Wang wrote:
>
> Yes, it'd be nice to have all the data from the existing database.
> I am aware the loading fixtures way, but I will need to do that every time 
> I know the existing database has changed a lot. 
> So just copy the data when creating the test database seems more 
> convenient. 
>
> Tianyi
>
> On Friday, 4 October 2013 17:08:02 UTC+1, C. Kirby wrote:
>>
>> Do you always want all of the data from the existing database, or is this 
>> just a quick way to have "real data" for testing.
>> If it is the latter I would use manage.py dumpdata to generate test 
>> fixtures. You can load the fixtures in you tests as needed.
>>
>> Chaim
>>
>> On Friday, October 4, 2013 8:48:45 AM UTC-5, Tianyi Wang wrote:
>>>
>>> Hi,
>>>
>>> When I run my tests, I'd like it to copy an existing database with all 
>>> the data when create the testing database.
>>>
>>> I never thought about this till one of my colleague uses 
>>> POSTGIS_TEMPLATE = DATABASES['default']['NAME'] for his tests. 
>>> Because we use GeoDjango for our project, so POSTGIS_TEMPLATE exists for 
>>> letting the test runner know which postgis database template to use.
>>> And when he define it as mentioned above, it actually creates the test 
>>> database with all the data as well. It's kinda handy for us, so we don't 
>>> need to create the fixture files.
>>> But if we can not do the same with the projects which do not use 
>>> GeoDjango. 
>>>
>>> So I have two questions here:
>>>
>>>1. Is it good idea to use the data already exists in the project 
>>>database? (For some tests, I may need to delete all the data first for a 
>>>certain table, but in many cases, we test against non empty data set.)
>>>2. If it's not a bad idea, for the project which does not use 
>>>GeoDjango, is there anyway I can set it to copy the data from the 
>>> existing 
>>>database?
>>>
>>> Thanks
>>>
>>> Tianyi
>>>
>>

-- 
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/30ec34b2-e35e-4442-9ea1-ad2a1a77b980%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Implementation of a Search Engine. How??

2013-10-09 Thread Kelvin Wong
Look up Solr because it does everything you want. You can crawl with Nutch. 
Django can be used as a front end to that.

http://en.wikipedia.org/wiki/Apache_Solr

K


On Wednesday, October 9, 2013 11:57:25 AM UTC-7, Mithil Bhoras wrote:
>
> Hello, I am a newbie in Django. I am required to do a project in Python 
> and I've chosen Django as the Web Framework. My project is a 'Smart' Search 
> Engine that retrieves results most relevant to user's query. This website 
> will:
>
>1. Index all the web pages available
>2. Use Page Ranking algorithm to update the database as the user uses 
>it
>3. Give suggestions for more appropriate queries based on the most 
>recent queries that other users world wide entered.
>4. Correct queries if user makes a spelling mistake.
>
>

-- 
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/3f55fdc5-ec38-4edd-861c-8cc5e1d16deb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: View not working / how can I test it in the shell?

2013-10-11 Thread Kelvin Wong
In the shell:

>>> from django.test import Client
>>> c = Client()
>>> r = c.get('/about')
>>> r.context

https://docs.djangoproject.com/en/1.5/topics/testing/overview/#module-django.test.client

K



On Friday, October 11, 2013 3:14:38 PM UTC-7, Mario Osorio wrote:
>
> You are right, I fixed that after posting as someone else point it out to 
> me, but this is not working out for me nonetheless
>
>
> On Friday, October 11, 2013 6:11:54 PM UTC-4, donarb wrote:
>>
>> On Friday, October 11, 2013 2:48:13 PM UTC-7, Mario Osorio wrote:
>>>
>>> Hello all, working with mezzanine, I created in an app (newsroom) 
>>> folder, a views.py http://dpaste.com/1413587/. This view is an addition 
>>> to the blog app in site-packages. I then I put a section in my 
>>> blog_post_list.html template file to (supposedly) show the data from that 
>>> view 
>>> http://dpaste.net/show/6cHStytzI5cqfICpFVAT/,
>>>  
>>> but I cannot see this data. blog_post_list.html is my home. Will someone 
>>> please point my mistake here? How can I test this view in the shell.TIA!
>>>
>>
>> What is featured_post_list? You assign it in the context, but it doesn't 
>> appear anywhere (except as the name of the view method). Perhaps you meant 
>> to pass "blog_posts" instead?
>>
>

-- 
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/ee87ee00-d4a2-4ab6-8311-8f61370f8c50%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: View not working / how can I test it in the shell?

2013-10-12 Thread Kelvin Wong
You need to understand what ALLOWED_HOSTS does if you want to ever deploy 
your app. Please read it.

https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts

Check your settings in the shell

>>> from django.conf import settings as s
>>> s.DEBUG
True
>>> s.ALLOWED_HOSTS
['.example.com', '192.168.0.2']

If your DEBUG is False and your ALLOWED_HOSTS is an empty list [] then you 
will not get far. You will get a "SuspiciousOperation: Invalid HTTP_HOST 
header (you may need to set ALLOWED_HOSTS)" message.

You can try putting something like this into the template (pretty much 
straight from the Django blog example), and it will tell you nicely when it 
has nothing matching your query or if your db is empty:

{% block featured_posts %}
  {% if featured_posts_list %}
{% for blog_post in featured_posts_list %}
{{ blog_post.title }}

{% endfor %}
  {% else %}
No posts found
  {% endif %}
{% endblock %}

You might also want to ensure that your view is rendering the right 
template and that the template hierarchy is correct (ie. {% extends 
"my_templates/base.html" %} is at the top of your template and it is 
correct). If your parent template that you're extending doesn't have a 
block named 'featured_posts' then it won't display anywhere. You won't see 
the "No posts found" message nor will you see your list of blogs - nada.

If there is an exception in the shell, it will print out a trace. This is 
an actual Dj1.5 trace from a made up exception I planted in the view. You 
can also put objects like your queryset into the Exception message and see 
if your set is producing what you think it should be.

>>> from django.test import Client
>>> c = Client()
>>> c.get('/')

Internal Server Error: /
Traceback (most recent call last):
  File 
"/Users/kelvin/.virtualenvs/myproject/lib/python2.7/site-packages/django/core/handlers/base.py",
 
line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
  File 
"/Users/kelvin/.virtualenvs/myproject/lib/python2.7/site-packages/django/views/generic/base.py",
 
line 68, in view
return self.dispatch(request, *args, **kwargs)
  File 
"/Users/kelvin/.virtualenvs/myproject/lib/python2.7/site-packages/django/views/generic/base.py",
 
line 86, in dispatch
return handler(request, *args, **kwargs)
  File 
"/Users/kelvin/repos/myproject_files/myproject_repo/myproject/firstweb/views.py",
 
line 14, in get
raise Exception("Freek out!")
Exception: Freek out!



On Friday, October 11, 2013 5:25:54 PM UTC-7, Mario Osorio wrote:
>
> From the server; I am getting the page I need but the block where the data 
> from the view in question is supposed to be comes out empty.
>
> I am indeed geting the ALLOWED_HOSTS warning, which I don't fully 
> understand and don't know hoe to fix. I do have ALLOWED_HOSTS = 
> ('localhost', '.local') and DEBUG = True as I read in Rod's excellent 
> tutorial , 
> but that did not 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/997818db-a73c-40d2-9e81-386b533609b6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: unable to access django development server on firefox/chrome

2013-10-12 Thread Kelvin Wong
You can also try this

$ python manage.py runserver 0.0.0.0:8000

You can get your IP from ifconfig, open that in a browser (it might be 
192.168.0.10, etc). You can test your site from another machine in this way

K



On Saturday, October 12, 2013 10:02:40 AM UTC-7, gitrookie wrote:
>
> hi
>
> I have just started to learn django. so I followed the instruction given 
> in the link below. I am using ubuntu 13.04 and using python 3.3.1 in a 
> virtual environment
>
> https://docs.djangoproject.com/en/1.5/intro/tutorial01/
>
> I ran the following command 
>
> *python manage.py runserver*
>
> it gave the following output 
>
> *Validating models...
>
> 0 errors found
> October 12, 2013 - 11:37:58
> Django version 1.5.4, using settings 'mywebsite.settings'
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CONTROL-C.*
>
> But I am unable to access the url http://127.0.0.1:8000/ on firefox. It 
> says unable to connect
>

-- 
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/af6f9e6b-619e-4dd6-970c-0d7ab06ce9e2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: add custom action button on each admin row

2013-10-17 Thread Kelvin Wong
Take a look at Admin Actions. It should be able to do what you are thinking.

You can also make a Admin-only view and tie it into the admin.

K


On Thursday, October 17, 2013 1:12:59 PM UTC-7, Laurent GARTNER wrote:
>
> Hi,
>
> Is there a simple way to add custom action button (maybe links, 
> buttons...) on each row in admin site ?
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ee4b397-3661-41a4-a512-8d12a6872e42%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Read a csv file and save data in postgresql

2015-02-24 Thread Kelvin Wong
Looking at your code, maybe this one is better

https://pypi.python.org/pypi/unicodecsv/0.9.4

This thing will make a dict, which you can make into a object by feeding it 
to a modelform.

K


On Tuesday, February 24, 2015 at 3:53:19 PM UTC-8, elcaiaimar wrote:
>
> Hello,
>
> I have a website and I need that users can introduce a csv file and save 
> their data in a postgresql database. I can introduce a file and save it in 
> media_dir and in the database (only the url). But what I want is save each 
> row as a register in a table. I've searched some examples but I haven't 
> found exactly this.
>
> Is it possible to do? Has anyone done this before? I put my code to save 
> the file in a database and in media below:
>
> *views*
> if 'formularioarchivo' in request.POST:
> formularioarchivo = UploadForm(request.POST, request.FILES)
> if formularioarchivo.is_valid():
>   newdoc = Archivo(docfile = request.FILES['docfile'])
>   newdoc.save(formularioarchivo)
>   return HttpResponseRedirect('/edicioncuenca/')
>
> else:
> formularioarchivo = UploadForm()
>
> *models*
> class Archivo(models.Model):
> # gid_archivo = models.IntegerField(primary_key=True)
> docfile = models.FileField(upload_to='%Y/%m/%d')
>
> *forms*
> class UploadForm(forms.Form):
> docfile = forms.FileField(
> label='Selecciona un archivo'
> )
>
> *template*
>  enctype="multipart/form-data">
>   {% csrf_token %}
>   {{ formularioarchivo.as_p }}
>   
> 
>

-- 
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/73c23c31-f3b3-4064-bee5-45bad3e508cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Porting to Django Linux with SQL Server Backend

2014-10-15 Thread Kelvin Wong
I have a working system running Django 1.6/Python 2.7 on RHEL 7 connecting 
to MSSQL2012 SP 2 on Win Server.

On the Linux box we are installing this with Pip requirements:

 git+https://code.google.com/p/pyodbc@3.0.7#egg=pyodbc
 django-pyodbc-azure==1.1.5

The local_settings.py contains:

DATABASES = {
"default": {
...
"HOST": "192.168.0.10",
"PORT": "",
"OPTIONS": {
"driver": "FreeTDS",
"dsn": "sqlserverdatasource",
'host_is_server': True,
'autocommit': True,
'unicode_results': True,
'extra_params': 'tds_version=8.0'
}
}
}

We are running the latest FreeTDS from 2011.

$ tsql -C
...
freetds v0.91

We've had quirky problems with it and a few mysterious segfaults on the 
application server from time to time. It does work for the most part, but 
the application isn't under any kind of load at the moment.

If I had a choice, I wouldn't run Django on MSSQL Server.

- K


On Wednesday, October 15, 2014 7:13:04 AM UTC-7, robert brook wrote:
>
> Sorry I guess I should have focused the question better.
>
> I have a working connector on my windows machine using django-pyodbc-azure
>
> I can and will use this connector on the new Linux installation.
>
> Since I have never tested this on a Linux machine yet, I wanted to see if 
> anyone had any successful experiences with this connector
> or any other connector  on a Red Hat Linux box.
>
> By the way I looked at the link below and the comments on the git page 
> seem that they are lagging behind on developing this package with
> the current releases of both python and django
>
> Thanks
> Bob
>
> On Wednesday, October 15, 2014 9:34:46 AM UTC-4, Michael Manfre wrote:
>>
>> It's hard to give constructive feedback without knowing any of the 
>> specific errors you encountered, but django-mssql only works on Windows. 
>> Depending on the error you encountered with pymssql, you could try 
>> django-pymssql (https://github.com/aaugustin/django-pymssql).
>>
>> Regards,
>> Michael Manfre
>>
>> On Wednesday, October 15, 2014 9:03:54 AM UTC-4, robert brook wrote:
>>>
>>> The group has been developing locally with sqllite on Windows.
>>>
>>> We are porting the installation to a Linux environment /windows sql 
>>> server.
>>>
>>> Looking for suggestions for database connectors from Linux to sql server 
>>> 2014
>>> using:
>>> python3.3
>>> django 1.7
>>>
>>> I have installed a local copy of sql server to try and find a connector 
>>> package
>>> I have tried the following packages on my windows machine with a local 
>>> copy of sql server
>>>
>>> django-pyodbc-azure   -This worked after creating a local odbc connection
>>>
>>> The following failed with a variety of errors.
>>> django-pyodbc
>>> pymssql
>>> django-sqlserver
>>> django-mssql
>>>
>>> Any suggestions for the sql server connection for any of these would be 
>>> appreciated.
>>>
>>> Thanks in advance
>>>
>>

-- 
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/787235a9-bda8-4fc7-9068-77b1d369401e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Porting to Django Linux with SQL Server Backend

2014-10-16 Thread Kelvin Wong
Your options are limited if you want to connect to a 2012 SQL Server. The 
azure driver is the only one that would work for us and we tested 
everything we could find.

K


On Thursday, October 16, 2014 7:50:15 AM UTC-7, robert brook wrote:
>
> Thanks for your response.
>
> I am in the process of porting this.  I am concerned that I really only 
> have one potential option of pyodbc-azure in the event that there is a 
> problem.
>
>
>

-- 
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/2f591740-d988-4f5b-be77-392cb49fddd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to display BST (British Summer Time)?

2014-10-17 Thread Kelvin Wong
https://docs.djangoproject.com/en/1.6/ref/templates/builtins/#date

K



On Friday, October 17, 2014 8:14:12 AM UTC-7, Daniel Grace wrote:
>
> Hi,
> I have the time zone set as follows:
> TIME_ZONE='Europe/London'
> USE_TZ = True
>
> This is the same as GMT.  But what I want is BST (British Summer Time) for 
> display purposes, which is UTC + 1 for the "summer" and UTC for the rest of 
> the year.
>
> How do I convert to this the value in my templates?
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0591c36f-288a-49f5-96f5-5c7f12491df2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to deny access to a logged user directly to a specific URL

2014-10-17 Thread Kelvin Wong
Have you reviewed this?

https://docs.djangoproject.com/en/1.6/ref/contrib/formtools/form-wizard/

K


On Friday, October 17, 2014 10:08:08 AM UTC-7, Martin Torre Castro wrote:
>
> Hello,
>
> at my project we need some sort of system for allowing/denying some access 
> to an URL.
>
> The example, we want to make some kind of wizard. 
>
>
>1. The user inputs the first object at the the first screen (A 
>screen), and then he press "Continue".
>2. Now we get the data and redirect to a second screen (B screen), 
>where we the user should enter a second object.
>3. The wizard goes on...
>
> The problem is that if we do so, the user can write the B url at the 
> browser and access the B screen. The user has made the login, but even so, 
> we don't want him to get there without passing through A screen.
>
> We don't know how to achieve this or look for this in internet. We only 
> know about user session for doing this.
>
> Is there another way? Some help?
>
> Thanks in advance.
>

-- 
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/2468cedf-36a8-4241-9205-1774a728d7c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installing django on red hat linux box

2014-10-22 Thread Kelvin Wong
Take a look at the Software Collections (ver 1.1 works on RHEL 7)

http://developerblog.redhat.com/2013/01/28/software-collections-on-red-hat-enterprise-linux/


$ sudo yum install python33-python-devel
$ scl enable python33 bash

You can then install everything locally in your application user's home 
directory.

This snip is from a virtualenv build script. I use virtualenvs on my 
deployments.

$ curl https://bootstrap.pypa.io/get-pip.py | python3.3 - --user
$ echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bash_profile
$ source ~/.bash_profile
$ which pip
/home/youruser/.local/bin/pip

$ pip install --user virtualenv virtualenvwrapper
$ echo 'source $HOME/.local/bin/virtualenvwrapper.sh' >> $HOME/.bash_profile
$ source ~/.bash_profile

K



On Wednesday, October 22, 2014 9:59:32 AM UTC-7, robert brook wrote:
>
> I am a contractor in a large organziation.  They must have everything 
> locked down.
>
> I downloaded get-pip.py and got errors that seemed to be proxy, firewall 
> security issues, that is why I fell back to implementing through setup.py
> and ran into the header issues.
>
> Thanks
>
> On Wednesday, October 22, 2014 12:55:26 PM UTC-4, Pat Claffey wrote:
>>
>> once I got pip sorted out it was really easy install django (just pip 
>> install django)  - so advise is to get pip working.  You will need it for 
>> other python packages also.
>>
>> On Wednesday, October 22, 2014 5:12:10 PM UTC+1, robert brook wrote:
>>>
>>>
>>> I have alot of experience installing packages on windows and mac and it 
>>> goes very smoothly.
>>> I do not have alot of experience doing the installs on a Linux box.
>>>
>>> I am running into problems installing 4 packages.
>>>
>>> The Lan team tried yum, but the basic django packages were not available.
>>>
>>> Then I tried installing pip and I got proxy errors using the get-pip.py 
>>> script
>>>
>>> So I fell back to installing the dowloaded packages with the old standy 
>>>  setup.py install which fails.
>>>
>>> I am attaching the top of the log
>>>
>>> Anyone have any suggestions how to proceed?
>>>
>>> **
>>>
>>> running install
>>>
>>> running bdist_egg
>>>
>>> running egg_info
>>>
>>> writing pyodbc.egg-info/PKG-INFO
>>>
>>> writing top-level names to pyodbc.egg-info/top_level.txt
>>>
>>> writing dependency_links to pyodbc.egg-info/dependency_links.txt
>>>
>>> reading manifest file 'pyodbc.egg-info/SOURCES.txt'
>>>
>>> reading manifest template 'MANIFEST.in'
>>>
>>> warning: no files found matching 'tests/*'
>>>
>>> writing manifest file 'pyodbc.egg-info/SOURCES.txt'
>>>
>>> installing library code to build/bdist.linux-x86_64/egg
>>>
>>> running install_lib
>>>
>>> running build_ext
>>>
>>> building 'pyodbc' extension
>>>
>>> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall 
>>> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
>>> --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv 
>>> -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
>>> -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic 
>>> -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=3.0.7 
>>> -I/usr/include/python2.6 -c /home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.cpp 
>>> -o build/temp.linux-x86_64-2.6/home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.o 
>>> -Wno-write-strings
>>>
>>> In file included from /home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.cpp:12:
>>>
>>> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:41:20: error: Python.h: No such 
>>> file or directory
>>>
>>> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:42:25: error: floatobject.h: No 
>>> such file or directory
>>>
>>> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:43:24: error: longobject.h: No 
>>> such file or directory
>>>
>>> *
>>>
>>>
>>>

-- 
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/0543f7d8-fce6-458c-ac76-b7605145ef37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: template url reverse and namespacing is driving me crazy

2014-11-30 Thread Kelvin Wong
Change all instances of this in your templates

{% url 'greet' greeter.pk %}

To this

{% url 'greeter:greet' greeter.pk %}.

Since you are now using the 'greeter' namespace. Also, the other one is 

{% url 'greeter:list' %} and not {% url 'list' %} because you are using the 
'greeter' namespace.

K

On Sunday, November 30, 2014 11:51:17 AM UTC-8, pjotr wrote:
>
> Alright, I'm already crazy, so the subject is a bit of a lie. But 
> nevermind.
>
> I think I like namespacing, it is really nice. But there is something not 
> that clear in the documentation of Django, and how to make usage of 
> namespace, in a consistent way. Lets take it by example.
>
> I'm using this pretty amazing app "greeter" that was written by a 
> superuser from a country far away from my own. It is a pretty simple app, 
> that has two url mappings:
>
> url(r'^list/$', HelloWorldList.as_view(), name='list'),
> url(r'^greet/(?P\d+)/$', HelloWorldGreet.as_view(), name='greet'),
>
>
> The template of HelloWorldList view is using the template tag url like this: 
> {% url 'greet' greeter.pk %}.
>
> After that I hook up the application in my project by including it in my 
> project urls.py:
>
> url(r'^greeter/', include('greeter.urls')),
>
>
> Everything works well, I felt like a Django guru integrating the hello 
> world app to my own project. I can access /greeter/list and clicking on the 
> greetings works well.
>
> Later that night I go to bed, feeling confident, kissing my wife goodnight 
> with a smile on my face. I wake up warm, sweaty, with my heart beating. I 
> run to my laptop, just realized I forgot to namespace the greet app, 
> because I just realized I am using the list name in another place in my 
> project, and I don't have any automated tests, so I better namespace it 
> quickly.
>
> So, I change my project url mapping to this:
>
> url(r'^greeter/', include('greeter.urls', namespace='greeter')),
>
>
> Boom crash. Visiting the /greeter/list/ page gives me:
>
>
> Reverse for 'greet' with arguments '()' and keyword arguments '{pk:1}' not 
> found. 0 pattern(s) tried: []
>
>
> I start to doubt the author of the 'greeter' app, that he didn't prepare his 
> app for being used in other projects, where the project might need 
> namespacing to avoid conflicts.
>
>
> Digging into Django documentation, I don't really find any argument for the 
> author of the 'greeter' app to be sloppy and not caring of details.
>
>
> Someone who can enlighten me why django doesn't try to default to the current 
> app when resolving namespaces? Or can someone enlighten me how I can help out 
> the author of the 'greeting' app, so it really is reusable in other projects?
>
>

-- 
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/8769089c-3dcc-4eb2-b3d6-f26e4de11d74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: 'NoneType' object has no attribute 'strip'

2014-12-01 Thread Kelvin Wong
Comment out the earlier slug field. What happens?

# slug = models.SlugField(null=True, blank=True)

K

On Monday, December 1, 2014 4:12:45 AM UTC-8, Danish Ali wrote:
>
> Hello,
>
> I am getting this error: Error: 'NoneType' object has no attribute 'strip'
> I have created a model and I am trying to autofill slug field in it. When 
> I save the record in database I get this error: Error: 'NoneType' object 
> has no attribute 'strip'
>
> My model is:
>
> from django.db import models
> from autoslug import AutoSlugField
>
> # Create your models here.
>
> class Shop(models.Model):
> name = models.CharField(max_length=200)
> image = models.CharField(max_length=200)
> description = models.TextField()
> slug = models.SlugField(null=True, blank=True)
> slug = AutoSlugField(populate_from='name')
>
>
> If I remove: slug = AutoSlugField(populate_from='name') then it works 
> fine. So, can someone tell me what is the issue here?
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/16970138-6267-4711-bbc4-feb6371d2c43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: 'NoneType' object has no attribute 'strip'

2014-12-01 Thread Kelvin Wong
Post the full trace. I looked at the source for auto slug field and they 
don't use strip, so the source of this error must be somewhere else. You 
are looking for code like this:

slug = None
slug.strip()

K


On Monday, December 1, 2014 5:11:17 AM UTC-8, Danish Ali wrote:
>
> still same error.
>
> On Monday, December 1, 2014 5:36:52 PM UTC+5, WongoBongo wrote:
>>
>> Comment out the earlier slug field. What happens?
>>
>> # slug = models.SlugField(null=True, blank=True)
>>
>> K
>>
>> On Monday, December 1, 2014 4:12:45 AM UTC-8, Danish Ali wrote:
>>>
>>> Hello,
>>>
>>> I am getting this error: Error: 'NoneType' object has no attribute 
>>> 'strip'
>>> I have created a model and I am trying to autofill slug field in it. 
>>> When I save the record in database I get this error: Error: 'NoneType' 
>>> object has no attribute 'strip'
>>>
>>> My model is:
>>>
>>> from django.db import models
>>> from autoslug import AutoSlugField
>>>
>>> # Create your models here.
>>>
>>> class Shop(models.Model):
>>> name = models.CharField(max_length=200)
>>> image = models.CharField(max_length=200)
>>> description = models.TextField()
>>> slug = models.SlugField(null=True, blank=True)
>>> slug = AutoSlugField(populate_from='name')
>>>
>>>
>>> If I remove: slug = AutoSlugField(populate_from='name') then it works 
>>> fine. So, can someone tell me what is the issue here?
>>>
>>> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4f10a3be-1e44-4a14-8c7b-cce231ae1734%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django, multi-tenancy and urls

2014-12-05 Thread Kelvin Wong
Take a look at Cartridge. It has multi-tenancy out of the box.

The rewriting can be done in Nginx or Apache.

K


On Friday, December 5, 2014 3:10:36 AM UTC-8, vijay shanker wrote:
>
>  am writing a e-commerce application where different people can have 
> stores with urls like this: www.store-one.saas.com, www.store-two.saas.com, 
> and so on.
>
> These domains have to be generated automatically when a user signs up for 
> store.
>
> I have read somewhere that www.saas.com/store-one can be rewritten as 
> store-one.saas.com (ofcourse, they din told me how :( ).
>
> Is it possible and how it can be done, how can i achieve it in production 
> and with my local machine?
>

-- 
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/26d8ac72-9fe6-43e8-a70c-1a2c2220e58a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Database Error (SQLite) Database is locked

2014-03-28 Thread Kelvin Wong
You can try finding the lock (assuming you are on unix):

$ which fuser
/usr/bin/fuser

$ fuser db.sqlite3 
db.sqlite3: 84349

$ ps aux | grep 84349
kelvin   84349   0.0  0.1   491220   4776   ??  SFri03PM   3:24.57 
/Applications/SQLite Database Browser.app

This shows candidates that might have locks on the db. You can try closing 
them or killing them (ie. kill 84349)

fuser - list process IDs of all processes that have one or more files open

K

On Friday, March 28, 2014 6:22:33 AM UTC-7, KEVIN HUNGAI wrote:
>
> Hi all  am using django-registration app in one of my projects and sqlite3 
> for the database. I keep getting  Database Error (SQLite) Database is 
> locked   everytime i try access the login page. Can someone please assist 
> me on where the issue might be 
>
> Thank you
>

-- 
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/3a5530aa-faf6-46eb-9263-bc6e808b9200%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Nesting custom template tags

2014-04-01 Thread Kelvin Wong
You might want to look at the code for making a tag like:

URLNode(Node)

line 408 of

https://github.com/django/django/blob/stable/1.6.x/django/template/defaulttags.py

Then extend that.

class MyAnchor(URLNode):

override the init function to accept the params your are sending and 
override render so that it returns the HTML that you want.

{% my_anchor URL %}this is text between opening and closing tags{% 
end_my_anchor %}

would yield

this is 
text between opening and closing tags

K


On Saturday, March 29, 2014 8:24:16 AM UTC-7, Jon Dufresne wrote:
>
> Hi,
>
> I am trying to create a custom template tag that generates a repetitive 
> HTML snippet. This tag is an anchor tag "a" with extra classes and styles, 
> plus some logic to apply additional classes and styles. I want the syntax 
> in the template to look something like:
>
> {% my_anchor URL %}this is text between opening and closing tags{% 
> end_my_anchor %}
>
> Where URL is set to the href attribute of the anchor tag.
>
> The rendered result should look something like:
>
> this is 
> text between opening and closing tags
>
> I also do not want to hard code my URLs. So as one might expect, I am 
> using the "url" template tag to create correct URLs. Naively, I tried to 
> nest the tags:
>
> {% my_anchor {% url ... %} %}this is text between opening and closing 
> tags{% end_my_anchor %}
>
> But this is invalid syntax. Is there a way to handle this?
>
> 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/c28b85a4-fc5a-4a03-8f4d-d10588177395%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django: Having trouble with nesting URLS

2014-04-01 Thread Kelvin Wong
You might try this

# settings.py

INSTALLED_APPS += ('registration',)

# urls.py -- In appropriate section

url(r'^accounts/', include('registration.backends.simple.urls')),

-- 
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/1471be46-0b55-4c29-8872-ba8f2f0ef8e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django on rhel5 with both python2.4 and python2.7 confusion

2014-05-07 Thread Kelvin Wong
Question one...

The gist is:

1. Set up Virtualenv and Virtualenvwrapper (lots of howtos on the web for 
this - find one written in the last year)
2. Set correct environment keys to point to the right Python (similar to 
the following, you paths may be different)

# ~/.bashrc
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/.local/bin/virtualenv-2.7
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
source $HOME/.local/bin/virtualenvwrapper.sh

3. Make a virtualenv: like this $ mkvirtualenv myappenv
4. Install Django into the virtualenv (you should have been dumped into it 
after you made it): (myappenv) $ pip install Django
5. Check which django-admin.py you are using

$ which django-admin.py
/home/myuser/.virtualenvs/myappenv/bin/django-admin.py

Hint: Webfaction uses CentOS with many different types of Pythons. 
Searching their support website may be helpful.

---

Question two: Use mod_wsgi rather than mod_python. See warning at the top 
of the Dj1.4 docs

https://docs.djangoproject.com/en/1.4/howto/deployment/modpython/

Setting up a Django app is more complex than setting up a PHP app (one 
persons opinion). The benefit is that at the end of the ordeal you will be 
running Python and not PHP (one persons opinion).

:)

K

-- 
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/a5356de2-3b61-45d6-a9de-8c76472d2a4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Registration in 1.8

2014-05-10 Thread Kelvin Wong
Unless you want to hack on Django core, stick with the stable Django 
releases. You say that you are three days in. Maybe try Django 1.4 to start.

K


On Saturday, May 10, 2014 12:00:04 PM UTC-7, erip wrote:
>
> Jon,
>
> I found this. https://docs.djangoproject.com/en/dev/releases/1.8/
>
> I don't know exactly how I got 1.8, but here we are.
>
> From the documentation, there should be no reason why django 1.6 or 1.7 
> registration shouldn't work, but I can't seem to get any concrete examples 
> of user registration in django.
>
> erip
>
>>
>>  

-- 
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/8d1054e8-c486-4ab2-bb54-194e8a2f5b41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Registration in 1.8

2014-05-16 Thread Kelvin Wong
OP is new to Django. There are tons of old blog posts, working code, etc 
dealing with registration and basic app set-ups using 1.4.

Also Django-registration works with 1.4, does it work with 1.6?

K


On Sunday, May 11, 2014 1:41:48 AM UTC-7, Lee wrote:
>
> What's the value in starting with 1.4?
>
> I'd start with the current release - 1.6.4
>

-- 
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/e3f26d02-33e7-46bf-ac17-e54fc5b9371d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django RequestFactory() secure not working

2014-05-16 Thread Kelvin Wong
If you print out your code you will see that you are adding a key-value to 
the WSGI environ:

# print factory.post('/', secure=True)

,
POST:,
COOKIES:{},
META:{
 ...
 'PATH_INFO': u'/',
 ...
 'REQUEST_METHOD': 'POST',
 ...
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'secure': True,
 ...
 'wsgi.url_scheme': 'http',
 ...
>

This is because factory.post has the following parameters:

post(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)

Your secure=True gets pushed into extra and it appears in the environ as 
expected.

The solution for modeling TLS requests is to set the 'wsgi.url_scheme' to 
'https' using an unpacked dictionary.

# obj = factory.post('/', **{'wsgi.url_scheme': 'https'})
# print obj
# print obj.is_secure()

,
POST:,
COOKIES:{},
META:{
 ...
 'PATH_INFO': u'/',
 ...
 'REQUEST_METHOD': 'POST',
 ...
 'wsgi.url_scheme': u'https',
 ...
>
True

---

See line 109

https://github.com/django/django/blob/stable/1.6.x/django/core/handlers/wsgi.py

K


On Tuesday, May 13, 2014 1:12:46 AM UTC-7, jvc26 wrote:
>
> Could anyone explain what is going wrong here:
>
> factory = RequestFactory()
> factory.post('/', secure=True).is_secure()
>
> Surely that should be True?
>
> J
>

-- 
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/a392facb-7846-496f-aa7c-38f4ab7c50b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't get i18n/setLang to match any urls

2014-05-16 Thread Kelvin Wong
The L in setLang should be setlang as in the L is lowercase

>From my Django log "POST /i18n/setlang/ HTTP/1.1" 302 0

K



On Wednesday, May 14, 2014 2:45:43 PM UTC-7, Shawn H wrote:
>
> I'm beginning the process of adding some translations to one public page, 
> and I can't get my setLang url to match, getting a 404 instead. I've got 
> USE_I18N = True in my settings.  I've got 
> 'django.core.context_processors.i18n', in my TEMPLATE_CONTEXT_PROCESSORS. 
>  Copied the directly from the docs, version 1.6
>
> My urls.py
>
> from django.conf.urls import patterns, include, url
> from sdcgis import settings
>
> urlpatterns = patterns('',
> 
> #index
> url('^sdc/home/',include('sdc_home.urls', namespace='sdc_home')),
> 
> #user language
> (r'^i18n/', include('django.conf.urls.i18n')),
>
>  #I tried url(r'^i18n/', include('django.conf.urls.i18n')), too, with no 
> luck
>
>  ...
>
>
>  I'm making an jQuery post:
>
> var data = {'name':'language', 'value':'en-us'};
>
>  
>
> $.post('/i18n/setLang/', data, function() {
>
> });
>
> My browser says I'm requesting via POST http://localhost/i18n/setLang/, 
> with form data of name: language and value:en-us.  I get 404.  What am I 
> missing?
>

-- 
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/d14f8b3a-3bc9-4c2a-bd41-5fdcbcb6bc39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django on rhel5 with both python2.4 and python2.7 confusion

2014-05-16 Thread Kelvin Wong
I haven't used mod_python in such a long time that I don't recall the 
configuration details. Off the top of my head, you might want to check how 
to add the Python 2.7 site-packages folder to the path that mod_python 
searches for python modules like Django.

Also, check this out on SO.

http://stackoverflow.com/questions/2147695/how-do-i-change-which-version-of-python-mod-python-uses

K


On Monday, May 12, 2014 4:09:38 AM UTC-7, David Malcolm wrote:
>
> thanks for your reply WB. 
>
> I was hoping to avoid virtualenv. My webapp is a frontend to a 
> vulnerability scanner in a large corporation.
> They are very picky about what I can use and what I can't. Is virtualenv 
> suitable for such a production system?
> They insist that I cannot use mod_wsgi (it annoys me intensely, but hey 
> that's life) and HAVE to use mod_python.
> Is there any other way to get this working without virtualenv?
>
> I also have no choice about OS. rhel6 is undergoing an approval process as 
> an SOE but it won't happen any time soon :(
>
> I am so close to getting this working now but it does indeed look like 
> django (httpd) is using python2.4.
> Note that "which python" gives me 2.7 - what is causing django to use 
> python & mod_python 2.4? mod_python is installed for 2.7.
>
> Mod_python error: "PythonHandler django.core.handlers.modpython"
> Traceback (most recent call last):
>   File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 
> 287, in HandlerDispatch
> log=debug)
>   File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 
> 461, in import_module
> f, p, d = imp.find_module(parts[i], path)
> ImportError: No module named django
>
> thanks for your help.
> cheers Dave
>
>

-- 
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/649d98d0-9a44-40a1-8a89-4da387487833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL lookup fails in apache/wsgi unless mapped to server root.

2014-05-21 Thread Kelvin Wong
Maybe

WSGIScriptAlias /awma /var/www/djangoapp/djangoapp/wsgi.py

K

On Wednesday, May 21, 2014 9:27:14 PM UTC-7, Spaceman Paul wrote:
>
> My application works fine in runserver and in apache/wsgi mapped to root, 
> but when I map wsgi to a directory, url lookups fail.
>
> E.g. 
>
> Request URL: http://server/awma/times
> ...
> ^times$ [name='times']
> ...
> The current URL, times, didn't match any of these.
>
> Every single URL in the (full) list fails (including "^$", but weirdly 
> enough /admin works fine).
>
> Again, I stress that this all works fine in runserver, and if 
> WSGIScriptAlias is mapped to the server root.
>
> I cannot make sense of this as the URL getting passed to the URL resolver 
> is correct and should match.
>
> Any suggestions?
>
> Python 2.7.  
> Django 1.6.5, but I see the same behaviour with Django 1.4.13.
>
> P.
>

-- 
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/833b116f-bfa1-4b3a-b0f0-9c70053146e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL lookup fails in apache/wsgi unless mapped to server root.

2014-05-22 Thread Kelvin Wong
Maybe post your apache.conf or/and your wsgi file. Maybe check your Apache 
logs.

K

On Wednesday, May 21, 2014 11:01:29 PM UTC-7, Spaceman Paul wrote:
>
> No that's what I've got.
>
> P.
>
>
>>>

-- 
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/9f15951e-e22d-43d2-b6bb-2d1cd50c4d28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to execute query for multiple table using cursor in Django

2014-05-23 Thread Kelvin Wong
https://docs.djangoproject.com/en/1.6/topics/db/sql/

K

On Thursday, May 22, 2014 11:31:26 PM UTC-7, swapnil srivastava wrote:
>
> Hi Experts,
>
> I just want to execute queries and subqueries in Django .
> Can anybody please tell me how to use cursor for execute queries in Django 
> framework in views.py 
>
> Thanks and Regards 
> Swapnil
>

-- 
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/048d65e4-36a8-4850-8aa2-f0f307ed7282%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: AttributeError when trying to reference ForeignKey attributes

2014-05-24 Thread Kelvin Wong
Might try removing the default from x_pos then try setting it by overriding 
the save method

https://docs.djangoproject.com/en/1.4/topics/db/models/#overriding-predefined-model-methods

K

On Saturday, May 24, 2014 8:28:17 PM UTC-7, Robbie Edwards wrote:
>
> Hi, I have some code like such...
>
>
> def gen_planet_pos( max_dim ):
> return random.randint( 0, max_dim )
>
>
> class Universe( models.Model ):
> width = models.IntegerField( default=100 )
> ...
>
>
> class Planet( models.Model ):
> universe = models.ForeignKey( Universe )
> ...
> x_pos = models.IntegerField( default=gen_planet_pos( universe.width ) )
>
>
> When I try to use this, I get "AttributeError: 'ForeignKey' object has no 
> attribute 'width'".  That message appears when I try to even enter the 
> shell.  I'm not sure what to do to prevent this error.  Your help is 
> appreciated.
>
> robbie 
>

-- 
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/c6856a3e-6be2-407e-9f23-d3e815733552%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-25 Thread Kelvin Wong
Try

name = [name.encode("utf8") for name in Staff.objects.filter(id = 
3).values_list('user_name', *flat=True*)]

The other returns one-tuples in a list

https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list

K

On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>
> Hi,
> I want to encode in utf8 but don't know how can i to ?
>
> i have the errors is here:
>
> AttributeError: 'tuple' object has no attribute 'encode'
>
> My code is here :
>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
> 3).values_list('user_name')]
>
>
>

-- 
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/857b95a3-4c38-4a0a-9231-211fe6f2757f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-25 Thread Kelvin Wong
Python 3.4.0 (default, Mar 20 2014, 12:50:31) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
'哈斯朝魯'

K

On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto wrote:
>
> Hi,
>
> I7m try that's this time not the error but output the  
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>
>
>
>
>
>
> 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo:
>>
>> Try
>>
>> name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>> 3).values_list('user_name', *flat=True*)]
>>
>> The other returns one-tuples in a list
>>
>> https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list
>>
>> K
>>
>> On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>>>
>>> Hi,
>>> I want to encode in utf8 but don't know how can i to ?
>>>
>>> i have the errors is here:
>>>
>>> AttributeError: 'tuple' object has no attribute 'encode'
>>>
>>> My code is here :
>>>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>>> 3).values_list('user_name')]
>>>
>>>
>>>

-- 
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/1f00a58a-7311-4e9c-a4c8-6ac0e266350b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
Okay, I re-read your first post. You said that you wanted to get a UTF-8 
string.

name = [name.encode("utf8") for name in Staff.objects.filter(id = 
3).values_list('user_name', flat=True)]

This variable 'name' now contains a UTF-8 encoded string in a list-like 
object.

Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> name = ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>>> print name[0]
哈斯朝魯
>>>

Copy and paste the code. Don't retype it.

K


On Sunday, May 25, 2014 11:34:12 PM UTC-7, hito koto wrote:
>
> Hi,
> I have this:
> >>> x = name
> >>> import locale
> >>> locale.getdefaultlocale()[1]
> 'UTF8'
> >>> print x
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>
> after i try this :
>
> >>> name
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
> >>> type(name)
> 
>
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'list' object has no attribute 'decode'
>
>
>
>
>
>
>
> 2014年5月26日月曜日 15時26分03秒 UTC+9 WongoBongo:
>>
>> Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
>> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> x = u'\u54c8\u65af\u671d\u9b6f'
>> >>> print(x)
>> 哈斯朝魯
>> >>> import locale
>> >>> locale.getdefaultlocale()[1]
>> 'UTF-8'
>> >>>
>>
>> K
>>
>> On Sunday, May 25, 2014 10:24:36 PM UTC-7, hito koto wrote:
>>>
>>> Hi, 
>>>
>>> I'm try tha's but results:
>>> >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
>>> u'\u54c8\u65af\u671d\u9b6f'
>>>
>>>
>>>
>>>
>>> 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo:

 Python 3.4.0 (default, Mar 20 2014, 12:50:31) 
 [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.

 >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8')
 '哈斯朝魯'

 K

 On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto wrote:
>
> Hi,
>
> I7m try that's this time not the error but output the  
> ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf']
>
>
>
>
>
>
> 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo:
>>
>> Try
>>
>> name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>> 3).values_list('user_name', *flat=True*)]
>>
>> The other returns one-tuples in a list
>>
>>
>> https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list
>>
>> K
>>
>> On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote:
>>>
>>> Hi,
>>> I want to encode in utf8 but don't know how can i to ?
>>>
>>> i have the errors is here:
>>>
>>> AttributeError: 'tuple' object has no attribute 'encode'
>>>
>>> My code is here :
>>>  name = [name.encode("utf8") for name in Staff.objects.filter(id = 
>>> 3).values_list('user_name')]
>>>
>>>
>>>

-- 
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/2e276f07-ea2e-42a8-afac-96d1e492709c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
If you want all the user_name's in Staff as UTF-8:

staff = Staff.objects.all()
staff_list = [s.user_name.encode('utf-8') for s in staff]

I'm not familiar with the encoding you mentioned in your last message. Try 
it.

K


On Monday, May 26, 2014 2:12:14 AM UTC-7, hito koto wrote:
>
> Hi,
>
> this is output the one name, but i want to output all name, so i can't 
> logic  
> >>> name[0].encode("Shift_JIS")
>
>
>

-- 
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/fe86810b-f9bf-45ae-bd04-7bedede31a12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: hoping for a quick code review of a few simple class-based generic views

2014-05-27 Thread Kelvin Wong
I'd recommend removing the login_required checks from the views. Put them 
in the UrlConf instead:

from django.contrib.auth.decorators import login_required

from yourapp.views import MyListsView

urlpatterns = patterns('',
url(r'^$', login_required(MyListsView.as_view()), name='yourapp_list'),
)

This will allow you to write simpler tests for your views.

http://tech.novapost.fr/django-unit-test-your-views-en.html#don-t-decorate-views-in-place

Also, if you restrict your queryset to display only objects for the current 
user then the generic view will be smart enough to return Http404 for 
requests for object pks that they do not own. Depending on your models, you 
might need to write a Manager for it.

class ItemDetailView(DetailView):
model = ItemModel
template_name = 'cmv_app/item_detail.html'

def get_queryset(self):
q = self.model.lists.for_user(self.request.user)
return q

K


On Tuesday, May 27, 2014 2:43:03 PM UTC-7, Howard Edson wrote:
>
> I am working on a simple "to do list" app in django (two models: List and 
> Item). Trying to learn and make use of class-based generic views. I have 
> the following three display views working, but am requesting a quick code 
> review to see if there's anything I can do to improve my 
> usage/understanding of django's ListView and DetailView before I move on to 
> creating, updating and deleting. Thanks in advance for any advice.
>
>
> # class-based generic views for my lists, a list's items, and item 
> detail...
> class MyListsView(ListView):
> """Display the current user's Lists"""
> template_name = 'cmv_app/my_lists.html'
> context_object_name = 'my_lists'
>
> @method_decorator(login_required)
> def dispatch(self, *args, **kwargs):
> return super(MyListsView, self).dispatch(*args, **kwargs)
>
> def get_queryset(self):
> return 
> List.objects.filter(user=self.request.user).order_by('-last_modified')
>
>
> class ListItemsView(ListView):
> """Display a list's items"""
> template_name = 'cmv_app/list_items.html'
> context_object_name = 'list_items'
>
> @method_decorator(login_required)
> def dispatch(self, request, *args, **kwargs):
> self.list = get_object_or_404(List, pk=kwargs['list_id'])
> request = list_valid_for_user(request, self.list) # security check
> return super(ListItemsView, self).dispatch(request, *args, 
> **kwargs)
>
> def get_queryset(self):
> return 
> Item.objects.filter(list=self.list).order_by('-created_date')
>
> def get_context_data(self, **kwargs):
> context = super(ListItemsView, self).get_context_data(**kwargs)
> context['list'] = self.list
> return context
>
>
> class ItemDetailView(DetailView):
> """Display detail for one list item"""
> template_name = 'cmv_app/item_detail.html'
>
> @method_decorator(login_required)
> def dispatch(self, request, *args, **kwargs):
> self.list = get_object_or_404(List, pk=kwargs['list_id'])
> self.item = get_object_or_404(Item, pk=kwargs['item_id'])
> request = list_valid_for_user(request, self.list)  # security check
> request = item_valid_for_list(request, self.item, self.list)  # 
> security check
> return super(ItemDetailView, self).dispatch(request, *args, 
> **kwargs)
>
> def get_object(self):
> return self.item
>
> def get_context_data(self, **kwargs):
> context = super(ItemDetailView, self).get_context_data(**kwargs)
> context['list'] = self.list
> return context
>
>

-- 
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/50104058-5c07-4d2e-a797-6045d5208dec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: virtualenv help needed

2014-05-28 Thread Kelvin Wong
Why are you placing user media in your /usr/local/.../dist-package 
directories? (Debian?)

Wouldn't it make more sense to place them somewhere in /srv or /var?

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

K

On Wednesday, May 28, 2014 9:40:54 AM UTC-7, Deepak Sharma wrote:
>
> A year before I developed an applciation in django==1.4.5 version. Few 
> days before I installed virtualenv with django version 1.4.5. In my 
> application I have to place "media" folder inside 
> /usr/local/lib/[ython2.7/dist-package/django/contrib/admin/media but after 
> installating virtualenv I didn't find any django folder inside 
> dist-package. Can anyone help me out with this, how should I allocate 
> proper path to it?
>
> Thank you.
>

-- 
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/82e56ae6-3a52-4776-b307-de269997ac46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help - Django App on Heroku & local dev machine

2014-05-28 Thread Kelvin Wong
Clone the app locally

http://stackoverflow.com/questions/1872113/how-do-i-clone-a-github-project-to-run-locally

Create a virtualenv

http://virtualenv.readthedocs.org/en/latest/virtualenv.html#usage

Install your requirements

$ pip -r your_app_path/requirements.txt

Run the dev server

https://docs.djangoproject.com/en/1.6/ref/django-admin/#runserver-port-or-address-port

To get the code back on the machine, look for a fabfile and use it, or just 
push to origin and update it manually over SSH.

If you don't already know Python or Django, I'd recommend

http://www.diveintopython.net/

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

K

On Wednesday, May 28, 2014 7:03:04 AM UTC-7, Dr Shauny wrote:
>
> Hi,
>
> I have a Django app already deployed and fully functional on Heroku. The 
> app was purchased from a third party that transferred the codebase via 
> github.
>
> I need to make changes and redeploy the app but understand that this is 
> not possible (or advisable) directly from github itself.
>
> I therefore need to set up a local development environment for the app 
> from where I can deploy changes to the github repository and also deploy 
> updates to the installation on Heroku.
>
> Heroku have an article that explains how to create a new app and upload 
> this to Heroku ("Getting started with Django on Heroku") , however many of 
> the details appear to be for a new app rather than for my situation where I 
> already have a fully functional app. I am unsure as to what I should and 
> shouldnt do as I am unclear about the relevancy of some of the instructions.
>
> Can anyone walk me through the process of transferring an app from github 
> to a local machine so that I can dev on the local machine. OS would be 
> ubuntu 12.04 and ideally want to set up dev and prod repos on github (and 
> eventually dev and prod apps on heroku). I believe I have done most of the 
> local work with postgres, python virtualenv, heroku and django toolbelts 
> etc, but would really appreciate an expert to bounce some queries off?
>
> Anyone able to help?
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/05347d8b-a4f2-46e2-b0a6-08dedd4edf2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom user model backend

2014-05-28 Thread Kelvin Wong
In your settings.py you might have to set the SESSION_COOKIE_AGE

https://docs.djangoproject.com/en/1.4/topics/http/sessions/#session-cookie-age

K


On Wednesday, May 28, 2014 5:49:01 AM UTC-7, Domagoj Kovač wrote:
>
> Hi guys,
>
> I extended base user model with certain fields. My code is as follows:
>
> #!/usr/bin/env python
>> # -*- coding: utf-8 -*-
>> from django.utils import timezone
>> from django.conf import settings
>> from django.contrib.auth.backends import ModelBackend
>> from django.core.exceptions import ImproperlyConfigured
>> from django.db.models import get_model
>
>  
>
>  
>
> class CustomUserModelBackend(ModelBackend):
>> def authenticate(self, username=None, password=None):
>> try:
>> user = self.user_class.objects.get(username=username)
>> if user.login_duration is None or user.login_duration >= 
>> timezone.now():
>> if user.check_password(password):
>> return user
>> else:
>> return None
>> except self.user_class.DoesNotExist:
>> return None
>
>
>> def get_user(self, user_id):
>> try:
>> return self.user_class.objects.get(pk=user_id)
>> except self.user_class.DoesNotExist:
>> return None
>> @property
>> def user_class(self):
>> if not hasattr(self, '_user_class'):
>> self._user_class = 
>> get_model(*settings.CUSTOM_USER_MODEL.split('.', 2))
>> if not self._user_class:
>> raise ImproperlyConfigured('Could not get custom user 
>> model')
>> return self._user_class
>
>
> Everything works as it should but if i am logged in system logs me out 
> after certain time even i am using application. Is there something i missed 
> that controls how login persistence is handled?
>
> Best,
> Domagoj 
>
>

-- 
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/755ef023-fc6a-46fb-8dc2-f4960e2e39db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom user model backend

2014-05-29 Thread Kelvin Wong
Maybe try putting some logging in your CustomUserModelBackend.

Near the top, put in some logging boilerplate:

import logging
logger = logging.getLogger(__name__)

Then in your backend, something like this:

class CustomUserModelBackend(ModelBackend):
...
def get_user(self, user_id):
try:
return self.user_class.objects.get(pk=user_id)
except self.user_class.DoesNotExist:
logger.info('User.id={}: User not found, attaching 
AnonymousUser'.format(user_id))
return None

This backend method is checked by the AuthenticationMiddleware when it 
attaches the user to the request

https://github.com/django/django/blob/stable/1.6.x/django/contrib/auth/middleware.py#L18

https://github.com/django/django/blob/stable/1.6.x/django/contrib/auth/__init__.py#L133

When you make a backend like this it is also a good idea to make a test 
suite for it.

If these are all fruitless, maybe try looking at your session setup. I'm 
assuming you are running the db backend for the sessions. If you are using 
memcached or something else, check the usual settings (TIMEOUT, OPTIONS, 
etc)

K

On Wednesday, May 28, 2014 11:52:58 PM UTC-7, Domagoj Kovač wrote:
>
> I already know about SESSION_COOKIE_AGE. I set it to be 30 minutes, but 
> the problem is that even if i am doing something system logs me out, and 
> this should not happen. It work properly before i implemented custom auth 
> backend.
>

-- 
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/3bade907-e3b1-4252-b7fd-6613d87a8cf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: reverse function

2014-05-29 Thread Kelvin Wong
The functions reverse and reverse_lazy are useful for figuring out the 
paths from labels. If you or someone else changes the urlconf in the 
future, your app uses the new paths without difficulty.

If you have in your urls.py

url(r'^home/$', views.home, name='home'),
url(r'^specifics/(?P\d+)/$', views.detail, name='detail'),

Then in your views.py you have:

print reverse('home')
# prints /home/

print reverse('detail', args=[12])
# prints /detail/12/

As for render_to_response, it is still there and everybody still uses it.

K

On Thursday, May 29, 2014 3:46:21 AM UTC-7, joy wrote:
>
> Good morning everyone, i was using django as of django 0.9 and now i'm 
> looking again in the tutorial and i have to say that a lot has changed. I 
> undestand che basics (even if i cannot understan why in the tutorial they 
> use the context and doesn'use any more "render_to_response") but however 
> what i cannot understand is che function "reverse" which is used in the 
> views, what is its use? San you explain it to me while i'm going through 
> the tutorial again to understand? Thank you. Agnese 

-- 
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/ba68138e-d004-4fa7-bfdd-b530337c0be7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: reverse function

2014-05-29 Thread Kelvin Wong
Oooppps!

print reverse('detail', args=[12])
# prints /specifics/12/

K

On Thursday, May 29, 2014 4:04:47 AM UTC-7, Kelvin Wong wrote:
>
> The functions reverse and reverse_lazy are useful for figuring out the 
> paths from labels. If you or someone else changes the urlconf in the 
> future, your app uses the new paths without difficulty.
>
> If you have in your urls.py
>
> url(r'^home/$', views.home, name='home'),
> url(r'^specifics/(?P\d+)/$', views.detail, name='detail'),
>
> Then in your views.py you have:
>
> print reverse('home')
> # prints /home/
>
> print reverse('detail', args=[12])
> # prints /detail/12/
>
> As for render_to_response, it is still there and everybody still uses it.
>
> K
>
> On Thursday, May 29, 2014 3:46:21 AM UTC-7, joy wrote:
>>
>> Good morning everyone, i was using django as of django 0.9 and now i'm 
>> looking again in the tutorial and i have to say that a lot has changed. I 
>> undestand che basics (even if i cannot understan why in the tutorial they 
>> use the context and doesn'use any more "render_to_response") but however 
>> what i cannot understand is che function "reverse" which is used in the 
>> views, what is its use? San you explain it to me while i'm going through 
>> the tutorial again to understand? Thank you. Agnese 
>
>

-- 
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/e929d4f5-03b8-4737-bdb9-e1650c0d15ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template - problema

2014-05-30 Thread Kelvin Wong
In relacaoconjugetipouniao_form.html

Add this tag...then refresh...

{{ form.fields }}

Should give you more info about what fields are in the form and what widget 
they are using.

ie. 'tipo_conjuge': django.forms.fields.TypedChoiceField object

Also check your html source in a browser. Sometimes CSS mistakes hide 
things.

K


On Friday, May 30, 2014 7:40:01 AM UTC-7, ebrockes wrote:
>
> I have the following problem. The field "tipo_conjuge" is not showing as I 
> wanted. Could somebody tell me what is the problem? 
>
> Best regards,
> Erick
>
>
> url. py
>
> ...
> url(r'relacao/(?P\d+)/$', 
> login_required(CreateTipoRelacaoView.as_view()), 
> name='cadastrarRelacaoTipo'),
> ...
>
>
> views.py
>
> ...
> class CreateTipoRelacaoView(CreateView):
> model = RelacaoConjugeTipoUniao
> fields = ['tipo_conjuge','data_inicio','data_fim']
>
> def form_valid(self, form):
> relacao = get_object_or_404(RelacaoConjuge, 
> id=self.kwargs['relacao'])
> form.instance.relacao = relacao
> return super(CreateTipoRelacaoView, self).form_valid(form)
>
>
> models.py
>
> class RelacaoConjugeTipoUniao(models.Model):
>
> TIPO_CONJUGE = (
> ('CA', _('Casados')),
> ('UE', _('União estável')),
> ('OU', _('Outros')),
> )
>
> tipo_conjuge = models.CharField(_('Tipo'), max_length=2, 
> choices=TIPO_CONJUGE, blank=False, null=False)
> data_inicio = models.DateField(_('Data de início'))
> data_fim = models.DateField(_('Data de término'))
>...
>
>
> relacaoconjugetipouniao_form.html
>
> {% extends 'pessoa/base_voltar.html' %}
> {% block content %}
> {% csrf_token %}
> {{ form.non_field_errors }}
> 
> {{ form.tipo_conjuge.errors }}
> Tipo de União:
> {{ form.tipo_conjuge }}
> 
> 
> {{ form.data_inicio.errors }}
> Data de início:
> {{ form.data_inicio }}
> 
> 
> {{ form.data_fim.errors }}
> Data de término:
> {{ form.data_fim }}
> 
> 
> 
> 
> 
> Voltar
> {% endblock content %}
>  
>

-- 
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/2c343d4f-48e4-4e5a-a02f-137edc1b0de2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Registration extend nightmare

2014-05-30 Thread Kelvin Wong
This is not an answer to your question, but I have used Django-registration 
before and ran into its limitations. Consider all the time you spent trying 
to debug this then consider that you'd probably already be done if you had 
just wrote a custom user and maybe salvaged some of the nicer code 
from Django-registration.

I've seen that error before. I seem to recall it comes from the way 
postgres handles transactions when one part of the transaction craps out. 
You might find some good info if you search for that specific message with 
the term postgres. Maybe also review the docs on Django transactions.

https://docs.djangoproject.com/en/1.6/topics/db/transactions/

K


On Friday, May 30, 2014 7:26:04 AM UTC-7, Matt Guy wrote:
>
> I am trying to add an extra user profile registration field using 
> registration. Should be so simple but this is bringing me to the edge.
>

-- 
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/c52d14c1-17ef-4d6b-98d2-0670b7676da7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Template - problema

2014-05-31 Thread Kelvin Wong
At the very top of the models.py file add:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

I'm not sure this will work, but it might.

K



On Friday, May 30, 2014 8:35:58 PM UTC-7, ebrockes wrote:
>
> Problem solved by replacing on models.py:
>
> TIPO_CONJUGE = (
> ('CA', _('Casados')),
> ('UE', _('União estável')),
> ('OU', _('Outros')),
> )
>
> by
>
> TIPO_CONJUGE = (
> ('CA', _('Casados')),
> ('UE', _('Uniao estavel')),
> ('OU', _('Outros')),
> )
>
> I'll see how to solve this issue. Any clues?
>
>
> 2014-05-31 0:11 GMT-03:00 Erick Brockes >:
>
>> Kevin, Thank you.
>>
>> If you don't mind, I'm kind of new in django.
>>
>> I've got the following response in the browser:
>>
>> {'tipo_conjuge': > 0xb4dcb7ec>}
>>
>> Could you help me out on how to proceed?
>>
>>
>> 2014-05-30 18:45 GMT-03:00 Kelvin Wong >:
>>
>> In relacaoconjugetipouniao_form.html
>>>
>>> Add this tag...then refresh...
>>>
>>> {{ form.fields }}
>>>
>>> Should give you more info about what fields are in the form and what 
>>> widget they are using.
>>>
>>> ie. 'tipo_conjuge': django.forms.fields.TypedChoiceField object
>>>
>>> Also check your html source in a browser. Sometimes CSS mistakes hide 
>>> things.
>>>
>>> K
>>>
>>>
>>> On Friday, May 30, 2014 7:40:01 AM UTC-7, ebrockes wrote:
>>>>
>>>> I have the following problem. The field "tipo_conjuge" is not showing 
>>>> as I wanted. Could somebody tell me what is the problem? 
>>>>
>>>> Best regards,
>>>> Erick
>>>>
>>>>
>>>> url. py
>>>>
>>>> ...
>>>> url(r'relacao/(?P\d+)/$', login_required(
>>>> CreateTipoRelacaoView.as_view()), name='cadastrarRelacaoTipo'),
>>>> ...
>>>>
>>>>
>>>> views.py
>>>>
>>>> ...
>>>> class CreateTipoRelacaoView(CreateView):
>>>> model = RelacaoConjugeTipoUniao
>>>> fields = ['tipo_conjuge','data_inicio','data_fim']
>>>>
>>>> def form_valid(self, form):
>>>> relacao = get_object_or_404(RelacaoConjuge, 
>>>> id=self.kwargs['relacao'])
>>>> form.instance.relacao = relacao
>>>> return super(CreateTipoRelacaoView, self).form_valid(form)
>>>>
>>>>
>>>> models.py
>>>>
>>>> class RelacaoConjugeTipoUniao(models.Model):
>>>>
>>>> TIPO_CONJUGE = (
>>>> ('CA', _('Casados')),
>>>> ('UE', _('União estável')),
>>>> ('OU', _('Outros')),
>>>> )
>>>>
>>>> tipo_conjuge = models.CharField(_('Tipo'), max_length=2, 
>>>> choices=TIPO_CONJUGE, blank=False, null=False)
>>>> data_inicio = models.DateField(_('Data de início'))
>>>> data_fim = models.DateField(_('Data de término'))
>>>>...
>>>>
>>>>
>>>> relacaoconjugetipouniao_form.html
>>>>
>>>> {% extends 'pessoa/base_voltar.html' %}
>>>> {% block content %}
>>>> {% csrf_token %}
>>>> {{ form.non_field_errors }}
>>>> 
>>>> {{ form.tipo_conjuge.errors }}
>>>> Tipo de União:
>>>> {{ form.tipo_conjuge }}
>>>> 
>>>> 
>>>> {{ form.data_inicio.errors }}
>>>> Data de início:
>>>> {{ form.data_inicio }}
>>>> 
>>>> 
>>>> {{ form.data_fim.errors }}
>>>> Data de término:
>>>> {{ form.data_fim }}
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Voltar
>>>> {% endblock content %}
>>>>  
>>>>  -- 
>>> 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/2c343d4f-48e4-4e5a-a02f-137edc1b0de2%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/2c343d4f-48e4-4e5a-a02f-137edc1b0de2%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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/e8e23e48-3b52-42bd-983d-cd47f92d63ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need help my first Django app

2014-05-31 Thread Kelvin Wong
https://docs.djangoproject.com/en/1.6/intro/tutorial01/

K

On Saturday, May 31, 2014 12:06:20 AM UTC-7, Mamdou Attallah wrote:
>
> Since I have never delveoped any Django app before I need to find an easy 
> tutorial to kick start my first app
> I am using free trial of py charm
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2593e51e-f3bb-46dc-8c8f-f450bede7d9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django auth customing error

2014-05-31 Thread Kelvin Wong
In your helpdesk app you have leftover references to auth.User. Replace all 
of them with something like this:

user = models.ForeignKey(settings.AUTH_USER_MODEL)

K


On Saturday, May 31, 2014 6:25:28 AM UTC-7, Jackie wrote:
>
> I want to custom the django auth app, since the default auth app can not 
> meet our project's requierment. Then I figure it out on my own by checking 
> the django document at here.
> https://docs.djangoproject.com/en/1.6/topics/auth/customizing/#a-full-example.
>  
> I tried to do that example exactly. Finally, I added AUTH_USER_MODEL = 
> "intelic_auth.MyUser" setting in my settings.py. But I got this error below 
> when I tried to run "python manage.py syncdb". I don't know why. I would be 
> very appreciated if someone can help me figure it out.
>
> CommandError: One or more models did not validate:
>>
>> helpdesk.ticket: 'assigned_to' defines a relation with the model 
>> 'auth.User', which has been swapped out. Update the relation to point at 
>> settings.AUTH_USER_MODEL.
>>
>> helpdesk.followup: 'user' defines a relation with the model 'auth.User', 
>> which has been swapped out. Update the relation to point at 
>> settings.AUTH_USER_MODEL.
>>
>> helpdesk.savedsearch: 'user' defines a relation with the model 'auth.User', 
>> which has been swapped out. Update the relation to point at 
>> settings.AUTH_USER_MODEL.
>>
>> helpdesk.usersettings: 'user' defines a relation with the model 'auth.User', 
>> which has been swapped out. Update the relation to point at 
>> settings.AUTH_USER_MODEL.
>>
>> helpdesk.ticketcc: 'user' defines a relation with the model 'auth.User', 
>> which has been swapped out. Update the relation to point at 
>> settings.AUTH_USER_MODEL.
>>
>>

-- 
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/d8408fff-38e1-4ed7-9c85-5e8d3ee610f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kelvin Wong
You need to be in the first superlists directory. You have a db created so 
you must have run syncdb at some point. Go back to that folder:

$ pwd
/home/you/superlists

$ ls
__init__.py   db.sqlite3superlistslistsmanage.py

$ ls lists/tests.py
lists/tests.py

$ python manage.py test

Creating test database for alias 'default'...
...etc...



On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote:
>
> Hi,
>
> I started learning Django and am using "Test Driven Web Development with 
> Python" book. 
>
> On page 21, the book mentions to test using lists/tests.py.
> The book uses the code:
> $ python3 manage.py test
> to run the test. 
>
> However, the manage.py file sits in the upper superlists folder and the 
> tests.py sits in lists folder. 
> I keep getting an error message saying "ImportError: No module named 
> lists.tests”. 
>
> Could someone help me figure this out? 
>
> My Django project directory looks like below. 
>
> superlists
>   db.sqlite3
>   functional_test.py
>   manage.py
>   lists
> __init__.py
> admin.py
> models.py
> tests.py
> views.py
>   superlists
> __init__.py
> settings.py
> urls.py 
> wsgi.py
> __init__.py
>
> The error message is below:
>
> $ python manage.py test
> Creating test database for alias 'default'...
> E
> ==
> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
> --
> ImportError: Failed to import test module: superlists.lists.tests
> Traceback (most recent call last):
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>  
> line 254, in _find_tests
> module = self._get_module_from_name(name)
>   File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>  
> line 232, in _get_module_from_name
> __import__(name)
> ImportError: No module named lists.tests
>
>
> --
> Ran 1 test in 0.000s
>
> FAILED (errors=1)
> Destroying test database for alias 'default'...
>

-- 
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/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kelvin Wong
Find out which versions you are using

$ python --version
Python 2.7.6

$ django-admin.py version
1.4.10

Try importing the lists app from the shell

$ python manage.py shell

Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import lists
>>> lists.__file__
'/users/you/superlists/lists/__init__.py'
>>> from lists.tests import *
>>>

If you see all that, run the lists app explicitly by label

$ python manage.py test lists

If that doesn't work, maybe there is something weird in your manage.py 
messing the paths. Paste it.

K


On Sunday, June 8, 2014 7:43:43 PM UTC-7, Kim wrote:
>
> Hi Kelvin,
>
> Thank you very much for your reply!
> I tried your codes above but I still get the same error...
>
> Kind regards,
> Kim
>
>
> On Mon, Jun 9, 2014 at 3:33 AM, Kelvin Wong  > wrote:
>
>> You need to be in the first superlists directory. You have a 
>> db created so you must have run syncdb at some point. Go back to that 
>> folder:
>>
>> $ pwd
>> /home/you/superlists
>>
>> $ ls
>> __init__.py   db.sqlite3superlistslistsmanage.py
>>
>> $ ls lists/tests.py
>> lists/tests.py
>>
>> $ python manage.py test
>>
>> Creating test database for alias 'default'...
>> ...etc...
>>
>>
>>
>> On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote:
>>>
>>> Hi,
>>>
>>> I started learning Django and am using "Test Driven Web Development with 
>>> Python" book. 
>>>
>>> On page 21, the book mentions to test using lists/tests.py.
>>> The book uses the code:
>>> $ python3 manage.py test
>>> to run the test. 
>>>
>>> However, the manage.py file sits in the upper superlists folder and the 
>>> tests.py sits in lists folder. 
>>> I keep getting an error message saying "ImportError: No module named 
>>> lists.tests”. 
>>>
>>> Could someone help me figure this out? 
>>>
>>> My Django project directory looks like below. 
>>>
>>> superlists
>>>   db.sqlite3
>>>   functional_test.py
>>>   manage.py
>>>   lists
>>> __init__.py
>>> admin.py
>>> models.py
>>> tests.py
>>> views.py
>>>   superlists
>>> __init__.py
>>> settings.py
>>> urls.py 
>>> wsgi.py
>>> __init__.py
>>>
>>> The error message is below:
>>>
>>> $ python manage.py test
>>> Creating test database for alias 'default'...
>>> E
>>> ==
>>> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
>>> --
>>> ImportError: Failed to import test module: superlists.lists.tests
>>> Traceback (most recent call last):
>>>   File 
>>> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>>>  
>>> line 254, in _find_tests
>>> module = self._get_module_from_name(name)
>>>   File 
>>> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/loader.py",
>>>  
>>> line 232, in _get_module_from_name
>>> __import__(name)
>>> ImportError: No module named lists.tests
>>>
>>>
>>> --
>>> Ran 1 test in 0.000s
>>>
>>> FAILED (errors=1)
>>> Destroying test database for alias 'default'...
>>>
>>  -- 
>> 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/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/46587e62-3642-4709-9ccf-ae91fec50d20%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> 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/6e741dc9-c97e-413b-97f4-2f1244e5bd59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HELP on unittest.loader.ModuleImportFailure

2014-06-08 Thread Kelvin Wong
Open this file

/Users/kim/Desktop/Python/python3/superlists/lists/tests.py

On line 3 change

from superlists.lists.views import home_page

to

from lists.views import home_page

For the future, check your paths with the following

import sys; print(sys.path)

K



On Sunday, June 8, 2014 9:31:03 PM UTC-7, Kim wrote:
>
> Thank you very much for the reply!
>
> Going through your suggestion below,
> at ">>> from lists.tests import *” part, I got an error which is below. 
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/Users/kim/Desktop/Python/python3/superlists/lists/tests.py", line 
> 3, in 
> from superlists.lists.views import home_page
> ImportError: No module named lists.views
>
> The code of the manage.py file is:
> #!/usr/bin/env python
> import os
> import sys
>
> if __name__ == "__main__":
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "superlists.settings")
>
> from django.core.management import execute_from_command_line
>
> execute_from_command_line(sys.argv)
>
> Kind regards,
> Kim
>
>
> On 2014年6月9日 at 12:11:44, Kelvin Wong (wong...@gmail.com ) 
> wrote:
>
>  Find out which versions you are using
>
> $ python --version
> Python 2.7.6
>
> $ django-admin.py version
> 1.4.10
>
> Try importing the lists app from the shell
>
> $ python manage.py shell
>
> Python 2.7.6 (default, Jan 13 2014, 04:26:18) 
> [GCC 4.2.1 (Apple Inc. build 5577)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import lists
> >>> lists.__file__
> '/users/you/superlists/lists/__init__.py'
> >>> from lists.tests import *
> >>>
>
> If you see all that, run the lists app explicitly by label
>
> $ python manage.py test lists
>
> If that doesn't work, maybe there is something weird in your manage.py 
> messing the paths. Paste it.
>
> K
>
>
> On Sunday, June 8, 2014 7:43:43 PM UTC-7, Kim wrote: 
>>
>> Hi Kelvin, 
>>
>> Thank you very much for your reply!
>> I tried your codes above but I still get the same error...
>>
>> Kind regards,
>> Kim
>>  
>>
>> On Mon, Jun 9, 2014 at 3:33 AM, Kelvin Wong  wrote:
>>
>>>  You need to be in the first superlists directory. You have a 
>>> db created so you must have run syncdb at some point. Go back to that 
>>> folder:
>>>
>>> $ pwd
>>> /home/you/superlists
>>>
>>> $ ls
>>> __init__.py   db.sqlite3superlistslistsmanage.py
>>>
>>> $ ls lists/tests.py
>>> lists/tests.py
>>>  
>>> $ python manage.py test
>>>
>>> Creating test database for alias 'default'...
>>>  ...etc...
>>>  
>>>
>>>
>>> On Saturday, June 7, 2014 2:00:39 AM UTC-7, Kim wrote: 
>>>>
>>>> Hi, 
>>>>
>>>> I started learning Django and am using "Test Driven Web Development 
>>>> with Python" book.  
>>>>
>>>>  On page 21, the book mentions to test using lists/tests.py.
>>>> The book uses the code:
>>>> $ python3 manage.py test
>>>> to run the test. 
>>>>
>>>> However, the manage.py file sits in the upper superlists folder and the 
>>>> tests.py sits in lists folder. 
>>>> I keep getting an error message saying "ImportError: No module named 
>>>> lists.tests”. 
>>>>
>>>> Could someone help me figure this out? 
>>>>
>>>>  My Django project directory looks like below. 
>>>>
>>>> superlists
>>>>db.sqlite3
>>>>   functional_test.py
>>>>   manage.py
>>>>lists
>>>> __init__.py
>>>> admin.py
>>>> models.py
>>>> tests.py
>>>> views.py
>>>>   superlists
>>>> __init__.py
>>>> settings.py
>>>> urls.py 
>>>> wsgi.py
>>>> __init__.py
>>>>
>>>>  The error message is below:
>>>>
>>>>  $ python manage.py test
>>>> Creating test database for alias 'default'...
>>>> E
>>>>  ==
>>>> ERROR: superlists.lists.tests (unittest.loader.ModuleImportFailure)
>>>>  --

Re: Can't get MySQLdb

2014-06-09 Thread Kelvin Wong
You better check that the MySQL connector actually runs on Py3. I recall 
reading that it does not run on Py3.

I don't use MySQL with Django though. Maybe someone else familiar has 
better info.

Try to import it from the shell.

K

On Monday, June 9, 2014 5:38:13 PM UTC-7, Alan Sawyer wrote:
>
> Please excuse me if this is a dumb question, but I've been stuck on this 
> for about 3 hours, and getting a bit frustrated
> I am a noob to Django/Python.   I am trying to get this setup on Windows 7 
> laptop.
>
> I installed Python 3.4 but have also tried 3.3
> I then installed Pip
> I then installed Django 1.6.5 though have also tried 1.6
>
> I also installed the MySQL/Python 1.2.2 connector, though I had to use the 
> Generic .py version because the Windows one is not a zip like it states in 
> the documentation, but an msi and it doesn't seem to work.
>
> I generated an application, and changed the settings.py to point to my 
> local MySQL server.
>
> I can create a test.py that just connects to my database and that seems to 
> work.
>
> Now I already have quite a extensive database that I want to use in 
> DJango, so I am trying
> python manage.py inspectdb
> but it is telling me that I don't have a module called mysqldb
>
> I just want to get it going so I don't care if I have the latest versions 
> of everything but I must be missing something in the instructions or 
> something because I'm sure I'm not the only person in the world wanting to 
> do this.
>
> Thanks for any help anyone is willing to give.
>
> A Sawyer
>
>

-- 
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/48ed7944-66fb-4541-9d73-8e8ffb698746%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Expected URL with primary key when testing SimpleTestCase.assertRedirects()

2014-06-18 Thread Kelvin Wong
This is how I usually do redirect tests:

self.assertEqual(response.status_code, 302)
self.assertRedirects(
response,
'http://testserver' + reverse('pizza:deleted')
)

I recommend using named URLs, that way your message_id would be similar to 
this:

reverse('pizza:delete', args=[pizza.id])

Here is the complete app's tests if you want to take a look

https://github.com/kelvinwong-ca/django-select-multiple-field/blob/master/test_projects/django14/pizzagigi/tests.py

K



On Tuesday, June 17, 2014 7:26:27 PM UTC-7, Antonio Alaniz wrote:
>
> I'm testing a redirect that would include the primary key. Can anyone tell 
> me how I can test the redirect URL if it involves the primary key? Will the 
> following work?:
>
> self.assertRedirects(response, 'message/(?P\d+)/', 200)
>

-- 
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/f0ddc82c-67f8-4b2d-aef1-6fcde2eb3c72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: converting the format of datetime from datetime.datetime( yyyy mm dd hh mm tzinfo=) to yyyy mm dd hh mm

2014-06-22 Thread Kelvin Wong
$ python

Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import datetime
>>> dt = datetime.datetime.utcnow()
>>> fmt = "%Y %m %d %H %M"
>>> print dt.strftime(fmt)
2014 06 23 03 54
>>> 

See also

https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

http://strftime.org/

K



On Saturday, June 21, 2014 11:37:17 PM UTC-7, Rini Michael wrote:
>
> Hi 
> I am working in datetime in django,this is the code in my forms.py 
>
> from_time = forms.DateTimeField(label="FromTime",
> required=True,
> input_formats=["%Y-%m-%d 
> %H:%M:%S"],
> 
> widget=DateTimeInput(format="%Y-%m-%d %H:%M:%S"))
> all the values of fields are stored in a dictionary variable say dd,when i 
> try to write the value of the dictionary in a file it is in the form
>
> from_time   datetime.datetime( mm dd hh mm tzinfo=)
>
> can anyone suggest me how can i just get the value 2014 6 21 12 0 which is 
>  mm dd hh mm i need to take this value and set it as cron task
>
> Thanks and regards 
> Rini
>

-- 
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/2c1c6158-e47f-4c08-ad09-5e1df0df58bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: page not found errors for most urls but main landing page displaying okay

2014-06-25 Thread Kelvin Wong
If you have access to your logs, check your logs to figure out where those 
requests are going.

You can also SSH into the server and temporarily turn on the DEBUG=True, 
TEMPLATE_DEBUG=True and let Django tell you what is going on.

Without seeing your fcgi script, my guess is that it is Apache not mapping 
the request to your WSGI file/fcgi script. Double check your htaccess file 
mod_rewrite directives.

K



On Wednesday, June 25, 2014 2:53:21 PM UTC-7, Lee wrote:
>
> Thanks - it must be a problem with the site accessing templates but I 
> can't figure it out. This django project works on another server but I have 
> copied it to a shared host webserver  (Bluehost) and am running it with 
> fcgi so maybe the problem is in the setup.
>
> I am focusing on one url and template, but all have the same problem 
> except the main landing page, which does work.
>
> The url http://mysite/project/map/nav/ shows the right text without any 
> styling
> This is the url pattern for this page in urls.py.
> url(r'^map/nav/$', 'citi_digits.views.mapNavigation', name='mav_nav'),
>
> The view for this url references the template:
> def mapNavigation(request):
> """
> Loads the map navigation elements
> """
> #get all classes
> #get classes
> classes = Teacher.objects.values_list('className', flat=True)
> return 
> render_to_response('map_navigation.html',{'classes':classes},context_instance=RequestContext(request))
>
> In the settings.py the setting for templates is:
> TEMPLATE_DIRS = (
> os.path.join(PROJECT_ROOT, '..', 'citi_digits','templates'),
>
> I also tried an absolute path and put the templates in www but this did 
> not work.
>
> My static settings are:
>
> STATIC_ROOT = '/home5/user/public_html/project/static/'
> STATIC_URL = 'http://mysite.org/project/static/'
>
> Lee
>
>
>
> On Wednesday, June 25, 2014 3:36:52 PM UTC-4, Michael Lind Hjulskov wrote:
>>
>> Hi
>>
>> I had the exact same problem a few days ago. It was one of my templates 
>> that suddenntly was emty. very spooky
>> Or maybe you have an "extends" somewhere that is not correct
>> I would debug by looking in the relevant view and see which template is 
>> called, and the simplify that template to test if bug is in templates or 
>> elsewhere
>>
>> Michael
>>
>> Den onsdag den 25. juni 2014 21.08.35 UTC+2 skrev Lee:
>>>
>>> I have copied a Django project to my web server from a repo and am 
>>> getting the correct initial landing page for the website with the right 
>>> styling when I go to the main URL. Most other urls give "page not found" 
>>> errors. This includes the divs that are called on to make menus on the main 
>>> page so the "Page not found" error is printing over the main landing page. 
>>>
>>> I'm not sure where to start with diagnosis - any thoughts would be 
>>> appreciated.
>>>
>>> I have checked the urls.py file and have tried to go directly to the 
>>> URLs listed starting with http://mysite.org/project/ ...
>>>
>>> urlpatterns = patterns('',
>>> # index.html gives a page not found error
>>>  url(r'^$', 'project.views.index', name='index'),
>>>
>>>
>>> # These go to an unstyled page with correct text
>>> url(r'^signup/$', 'project.views.signUp', name='signup'),
>>> url(r'^login/$', 'project.views.login', name='login'),
>>> url(r'^logout/$', 'project.views.logout', name='logout'),
>>>
>>>
>>> # These also give a page not found error
>>>
>>> url(r'^$', 'project.views.index', name='index'),
>>> url(r'^map/nav/$', 'project.views.mapNavigation', name='mav_nav'),
>>> url(r'^interview/new/$', 'project.views.interviewSelect', 
>>> name='interview_select'),
>>> url(r'^interview/player/$', 'project.views.interviewPlayer', 
>>> name='interview_player'),
>>> url(r'^interview/retailer/$', 'project.views.interviewRetailer', 
>>> name='interview_retailer'),
>>>
>>> url(r'^popup/(?P.+)/(?P.+)/(?P.+)/(?P.+)/(?P.+)/(?P.+)/(?P.+)/(?P.+)/(?P.+)/$','project.views.popup',name='popup'),
>>>
>>>
>>> Lee
>>>
>>>

-- 
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/2de669cf-c2cd-4013-b1ad-f54e73b5e933%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: crm app

2014-06-27 Thread Kelvin Wong
If you don't want to help the fellow when he runs into issues, give him a 
supported product like Zoho CRM. It is free for 3 users.

I'm currently reviewing Tree.io for a client and while it looks nice, it 
uses Piston (abandonware), Jinja (unnecessary), Dajaxice (a bad idea 
generally). I wouldn't recommend it at this point.

K


On Friday, June 27, 2014 8:01:43 PM UTC-7, Mike Dewhirst wrote:
>
> I have a non-technical colleague who needs a fairly simple CRM system. 
> SugarCRM Community Edition is overkill. 
>

-- 
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/247fd82c-0b64-4731-a409-37b8f3a22870%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: crm app

2014-06-28 Thread Kelvin Wong
I've not used Django-CRM.

I've used Salesforce in the past, but it is even more overkill than 
SugarCRM. It is incredibly flexible though. It depends on what your 
client's requirements are.

Keep in mind what they are going to do for on-going support (backup, etc). 
Non-tech users always need support and training. As developers it is easy 
to take this for granted.

K


On Friday, June 27, 2014 10:42:48 PM UTC-7, Mike Dewhirst wrote:
>
> Thanks Kelvin. It looks good at first glance. 
>
> Do you know if Django-CRM is suitable for an end user? 
>
> Mike 
>

-- 
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/bfb40a14-fa55-463a-b0a3-1c2ec4f231a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Installing MySQLdb for python2.7 in RHEL 6

2016-02-22 Thread Kelvin Wong
Install the MariaDB/MySQL header files.

# yum install mysql-devel

or

# yum install MariaDB.devel

Depends on what fork you are planning on running

K



On Monday, February 22, 2016 at 6:17:58 PM UTC-8, larry@gmail.com wrote:
>
> Not strictly a django question, but it's something required to get 
> django running. 
>
> I am trying to get django 1.9 running in RHEL 6. I have installed 
> python2.7 and when I try to install MySQLdb, I get the errors shown 
> below. I have googled and googled and tried many different things, all 
> with no success. Can anyone please let me know how I can get this 
> going? 
>
> # /usr/local/bin/pip2.7 install MySQL-python 
> Collecting MySQL-python 
>   Downloading MySQL-python-1.2.5.zip (108kB) 
> 100% || 110kB 3.2MB/s 
> Installing collected packages: MySQL-python 
>   Running setup.py install for MySQL-python ... error 
> Complete output from command /usr/local/bin/python2.7 -u -c 
> "import setuptools, 
> tokenize;__file__='/tmp/pip-build-SPMNQU/MySQL-python/setup.py';exec(compile(getattr(tokenize,
>  
>
> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 
> 'exec'))" install --record /tmp/pip-QrpP1S-record/install-record.txt 
> --single-version-externally-managed --compile: 
> running install 
> running build 
> running build_py 
> creating build 
> creating build/lib.linux-x86_64-2.7 
> copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7 
> creating build/lib.linux-x86_64-2.7/MySQLdb 
> copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb 
> copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb 
> copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb 
> copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb 
> copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb 
> copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb 
> creating build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/__init__.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/CR.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/FIELD_TYPE.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/ER.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/FLAG.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/REFRESH.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> copying MySQLdb/constants/CLIENT.py -> 
> build/lib.linux-x86_64-2.7/MySQLdb/constants 
> running build_ext 
> building '_mysql' extension 
> creating build/temp.linux-x86_64-2.7 
> gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 
> -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) 
> -D__version__=1.2.5 -I/usr/include/mysql 
> -I/usr/local/include/python2.7 -c _mysql.c -o 
> build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 
> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 
> -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE 
> -fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc 
> -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1 
> _mysql.c:44:23: error: my_config.h: No such file or directory 
> _mysql.c:46:19: error: mysql.h: No such file or directory 
> _mysql.c:47:26: error: mysqld_error.h: No such file or directory 
> _mysql.c:48:20: error: errmsg.h: No such file or directory 
> _mysql.c:88: error: expected specifier-qualifier-list before ‘MYSQL’ 
> _mysql.c:102: error: expected specifier-qualifier-list before 
> ‘MYSQL_RES’ 
> _mysql.c: In function ‘_mysql_Exception’: 
> _mysql.c:146: warning: implicit declaration of function ‘mysql_errno’ 
> _mysql.c:146: error: ‘_mysql_ConnectionObject’ has no member named 
> ‘connection’ 
> _mysql.c:149: error: ‘CR_MAX_ERROR’ undeclared (first use in this 
> function) 
> _mysql.c:149: error: (Each undeclared identifier is reported only once 
> _mysql.c:149: error: for each function it appears in.) 
> _mysql.c:161: error: ‘CR_COMMANDS_OUT_OF_SYNC’ undeclared (first 
> use in this function) 
> _mysql.c:162: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use 
> in this function) 
> _mysql.c:163: error: ‘ER_SYNTAX_ERROR’ undeclared (first use in 
> this function) 
> _mysql.c:164: error: ‘ER_PARSE_ERROR’ undeclared (first use in 
> this function) 
> _mysql.c:165: error: ‘ER_NO_SUCH_TABLE’ undeclared (first use in 
> this function) 
> _mysql.c:166: error: ‘ER_WRONG_DB_NAME’ undeclared (first use in 
> this function) 
> _mysql.c:167: error: ‘ER_WRONG_TABLE_NAME’ undeclared (first use 
> in this function) 
> _mysql.c:168: error: ‘ER_FIELD_SPECIFIED_TWICE’ undeclared (first 
> use in this function) 
> _mysql.c:169: er

Re: Installing MySQLdb for python2.7 in RHEL 6

2016-02-22 Thread Kelvin Wong
You need to locate the header files in order for that to compile.

You might want to see if they are located somewhere on your system by using 
'find' or else check 'yum list installed' to see if you have already 
installed the mysql devel package for your version of the database server 
(i'm guessing that you haven't got the headers).

If you haven't got them on your machine then you have to install them.

K

On Monday, February 22, 2016 at 7:10:34 PM UTC-8, larry@gmail.com wrote:
>
> That failed: 
>
> # yum install mysql-devel 
> Loaded plugins: dellsysid, product-id, refresh-packagekit, security, 
> subscription-manager 
> Setting up Install Process 
> Package mysql-devel is obsoleted by mysql-community-devel, trying to 
> install mysql-community-devel-5.7.11-1.el6.x86_64 instead 
> Resolving Dependencies 
> --> Running transaction check 
> ---> Package mysql-community-devel.x86_64 0:5.7.11-1.el6 will be installed 
> --> Processing Dependency: mysql-community-libs(x86-64) = 5.7.11-1.el6 
> for package: mysql-community-devel-5.7.11-1.el6.x86_64 
> --> Processing Dependency: libmysqlclient.so.20()(64bit) for package: 
> mysql-community-devel-5.7.11-1.el6.x86_64 
> --> Running transaction check 
> ---> Package mysql-community-libs.x86_64 0:5.7.11-1.el6 will be obsoleting 
> --> Processing Dependency: mysql-community-common(x86-64) = 
> 5.7.11-1.el6 for package: mysql-community-libs-5.7.11-1.el6.x86_64 
> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 
> php-mysql-5.4.43-1.el6.remi.x86_64 
> --> Processing Dependency: 
> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package: 
> php-mysql-5.4.43-1.el6.remi.x86_64 
> --> Processing Dependency: 
> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 
> php-mysql-5.4.43-1.el6.remi.x86_64 
> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi 
> for package: mysql-server-5.5.44-1.el6.remi.x86_64 
> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi 
> for package: mysql-5.5.44-1.el6.remi.x86_64 
> --> Running transaction check 
> ---> Package mysql.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> ---> Package mysql-community-client.x86_64 0:5.7.11-1.el6 will be 
> obsoleting 
> ---> Package mysql-community-common.x86_64 0:5.7.11-1.el6 will be 
> installed 
> ---> Package mysql-community-server.x86_64 0:5.7.11-1.el6 will be 
> obsoleting 
> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 
> php-mysql-5.4.43-1.el6.remi.x86_64 
> --> Processing Dependency: 
> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package: 
> php-mysql-5.4.43-1.el6.remi.x86_64 
> --> Processing Dependency: 
> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 
> php-mysql-5.4.43-1.el6.remi.x86_64 
> ---> Package mysql-server.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> --> Finished Dependency Resolution 
> Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi) 
>Requires: libmysqlclient.so.18(libmysqlclient_16)(64bit) 
>Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi) 
>libmysqlclient.so.18(libmysqlclient_16)(64bit) 
>Obsoleted By: mysql-community-libs-5.7.11-1.el6.x86_64 
> (mysql57-community) 
>Not found 
> Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi) 
>Requires: libmysqlclient.so.18()(64bit) 
>Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi) 
>libmysqlclient.so.18()(64bit) 
>Obsoleted By: mysql-community-libs-5.7.11-1.el6.x86_64 
> (mysql57-community) 
>Not found 
> Error: Package: php-mysql-5.4.43-1.el6.remi.x86_64 (@remi) 
>Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit) 
>Removing: mysql-libs-5.5.44-1.el6.remi.x86_64 (@remi) 
>libmysqlclient.so.18(libmysqlclient_18)(64bit) 
>Obsoleted By: mysql-community-libs-5.7.11-1.el6.x86_64 
> (mysql57-community) 
>Not found 
>  You could try using --skip-broken to work around the problem 
>  You could try running: rpm -Va --nofiles --nodigest 
>
>
> On Mon, Feb 22, 2016 at 10:07 PM, Kelvin Wong  > wrote: 
> > Install the MariaDB/MySQL header files. 
> > 
> > # yum install mysql-devel 
> > 
> > or 
> > 
> > # yum install MariaDB.devel 
> > 
> > Depends on what fork you are planning on running 
> > 
> > K 
> > 
> > 
> > 
> > 
&

Re: Installing MySQLdb for python2.7 in RHEL 6

2016-02-22 Thread Kelvin Wong
You are mixing the repos (remi and the regular redhat one). You should 
decide which one you want to use for mysql and stick to it.

The remi repo has the devel package available

http://rpms.famillecollet.com/enterprise/6/remi/x86_64/repoview/applications.databases.group.html

You can isolate a repo to see what it offers

$ yum --disablerepo "*" --enablerepo "remi" list available 

K


On Monday, February 22, 2016 at 7:37:43 PM UTC-8, larry@gmail.com wrote:
>
> Not really sure what I am looking for or what to do. 
>
> # yum list installed | grep mysql 
> compat-mysql51.x86_64   5.1.54-1.el6.remi   @remi 
> mysql.x86_645.5.44-1.el6.remi   @remi 
> mysql-libs.x86_64   5.5.44-1.el6.remi   @remi 
> mysql-server.x86_64 5.5.44-1.el6.remi   @remi 
> mysql57-community-release.noarchel6-7 
> @/mysql57-community-release-el6-7.noarch 
> php-mysql.x86_645.4.43-1.el6.remi   @remi 
>
> I don't see the devel package, but when I try to install it it fails 
> as shown below. 
>
> On Mon, Feb 22, 2016 at 10:20 PM, Kelvin Wong  > wrote: 
> > You need to locate the header files in order for that to compile. 
> > 
> > You might want to see if they are located somewhere on your system by 
> using 
> > 'find' or else check 'yum list installed' to see if you have already 
> > installed the mysql devel package for your version of the database 
> server 
> > (i'm guessing that you haven't got the headers). 
> > 
> > If you haven't got them on your machine then you have to install them. 
> > 
> > K 
> > 
> > On Monday, February 22, 2016 at 7:10:34 PM UTC-8, larry@gmail.com 
> wrote: 
> >> 
> >> That failed: 
> >> 
> >> # yum install mysql-devel 
> >> Loaded plugins: dellsysid, product-id, refresh-packagekit, security, 
> >> subscription-manager 
> >> Setting up Install Process 
> >> Package mysql-devel is obsoleted by mysql-community-devel, trying to 
> >> install mysql-community-devel-5.7.11-1.el6.x86_64 instead 
> >> Resolving Dependencies 
> >> --> Running transaction check 
> >> ---> Package mysql-community-devel.x86_64 0:5.7.11-1.el6 will be 
> installed 
> >> --> Processing Dependency: mysql-community-libs(x86-64) = 5.7.11-1.el6 
> >> for package: mysql-community-devel-5.7.11-1.el6.x86_64 
> >> --> Processing Dependency: libmysqlclient.so.20()(64bit) for package: 
> >> mysql-community-devel-5.7.11-1.el6.x86_64 
> >> --> Running transaction check 
> >> ---> Package mysql-community-libs.x86_64 0:5.7.11-1.el6 will be 
> obsoleting 
> >> --> Processing Dependency: mysql-community-common(x86-64) = 
> >> 5.7.11-1.el6 for package: mysql-community-libs-5.7.11-1.el6.x86_64 
> >> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> >> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 
> >> php-mysql-5.4.43-1.el6.remi.x86_64 
> >> --> Processing Dependency: 
> >> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package: 
> >> php-mysql-5.4.43-1.el6.remi.x86_64 
> >> --> Processing Dependency: 
> >> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 
> >> php-mysql-5.4.43-1.el6.remi.x86_64 
> >> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi 
> >> for package: mysql-server-5.5.44-1.el6.remi.x86_64 
> >> --> Processing Dependency: real-mysql-libs(x86-64) = 5.5.44-1.el6.remi 
> >> for package: mysql-5.5.44-1.el6.remi.x86_64 
> >> --> Running transaction check 
> >> ---> Package mysql.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> >> ---> Package mysql-community-client.x86_64 0:5.7.11-1.el6 will be 
> >> obsoleting 
> >> ---> Package mysql-community-common.x86_64 0:5.7.11-1.el6 will be 
> >> installed 
> >> ---> Package mysql-community-server.x86_64 0:5.7.11-1.el6 will be 
> >> obsoleting 
> >> ---> Package mysql-libs.x86_64 0:5.5.44-1.el6.remi will be obsoleted 
> >> --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 
> >> php-mysql-5.4.43-1.el6.remi.x86_64 
> >> --> Processing Dependency: 
> >> libmysqlclient.so.18(libmysqlclient_16)(64bit) for package: 
> >> php-mysql-5.4.43-1.el6.remi.x86_64 
> >> --> Processing Dependency: 
> >> libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 
> >> php-mysql-5.4.43-1.el6.remi.x86_64 
&