Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen

Tested against latest master. Same behaviour.

In Oracle backend base.py is following piece of code:

# Check whether cx_Oracle was compiled with the WITH_UNICODE option. 
This will

# also be True in Python 3.0.
if int(Database.version.split('.', 1)[0]) >= 5 and not hasattr(Database, 
'UNICODE'):

convert_unicode = force_text
else:
convert_unicode = force_bytes

Which was added in 

Thing is that my cx_Oracle is version 5.1.2, it has cx_Oracle.UNICODE 
definition.


And Django uses smart_str / force_bytes.

If I remove that and use convert_unicode as force_text / force_unicode 
everything works as expected.


9.1.2013 8:56, Jani Tiainen kirjoitti:

8.1.2013 21:00, akaariai kirjoitti:

I created the following test case into django's test suite modeltests/
basic/tests.py:
 def test_unicode(self):
 # Note: from __future__ import unicode_literals is in
effect...
 a = Article.objects.create(headline='0
\u0442\u0435\u0441\u0442 test', pub_date=datetime.n  ow())
 self.assertEqual(Article.objects.get(pk=a.pk).headline, '0
\u0442\u0435\u0441\u0442 test'   )

This does pass on Oracle when using Django's master branch, both with
Python 2.7 and 3.3.

Django's backend is doing all sorts of trickery behind the scenes to
get correct unicode handling. I am not sure where the problem is. What
Django version are you using?


Sorry about forgotting version info. I tested with 1.3.1 and 1.4.1 and
both gave same behaviour.

And I know that there is quite a lot of trickery going on. I'll try to
figure out what causes that problem.


On 8 tammi, 17:34, Jani Tiainen  wrote:

Hi,

I've been trying to save UTF-8 characters to oracle database without
success.

I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
  txt = CharField(max_length=128)

s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'

So what happens here? It looks like Django trashes my unicode string at
some (unknown point).

Additional note:

If I use cursor() from Django connection object strings get broken also.
So it must be django Oracle backend doing something evil for me.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient
before...








--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen

8.1.2013 21:00, akaariai kirjoitti:

I created the following test case into django's test suite modeltests/
basic/tests.py:
 def test_unicode(self):
 # Note: from __future__ import unicode_literals is in
effect...
 a = Article.objects.create(headline='0
\u0442\u0435\u0441\u0442 test', pub_date=datetime.n  ow())
 self.assertEqual(Article.objects.get(pk=a.pk).headline, '0
\u0442\u0435\u0441\u0442 test'   )

This does pass on Oracle when using Django's master branch, both with
Python 2.7 and 3.3.

Django's backend is doing all sorts of trickery behind the scenes to
get correct unicode handling. I am not sure where the problem is. What
Django version are you using?


Sorry about forgotting version info. I tested with 1.3.1 and 1.4.1 and 
both gave same behaviour.


And I know that there is quite a lot of trickery going on. I'll try to 
figure out what causes that problem.



On 8 tammi, 17:34, Jani Tiainen  wrote:

Hi,

I've been trying to save UTF-8 characters to oracle database without
success.

I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
  txt = CharField(max_length=128)

s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'

So what happens here? It looks like Django trashes my unicode string at
some (unknown point).

Additional note:

If I use cursor() from Django connection object strings get broken also.
So it must be django Oracle backend doing something evil for me.

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...





--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Admin and ForeignKey

2013-01-08 Thread Kristofer
Hello, 

I have three models, defined like the following (code below simplified): 

class Shirt(Model): 
sku = CharField() 
description = CharField() 

class Color(Model) 
name = CharField() 
shirt = ForeignKey(Shirt) 
price = Decimal() 

class Order(Model) 
shirt = ForeignKey(Shirt) 
color = ForeignKey(Color) 

The admin page for shirt shows Color options inline, so that the name and price 
can be typed in. 

My views for the order form from customers are set so that only the appropriate 
colors are displayed for the shirt selected. 

However, in the Admin Order page, the Color field shows all of the colors for 
all shirts. How can I restrict the Color field to only show colors where the 
Color.Shirt foreignkey matches the Order.Shirt foreignkey? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't sync DB

2013-01-08 Thread Nick Sandford
Since you have already created the table using syncdb, you need to instruct
South to fake the initial migration. Try the command ./manage.py migrate
auth --fake and see if that works. You only need to run this once and then
all future migrations don't need the --fake flag.

Cheers,
Nick


On Tue, Jan 8, 2013 at 9:21 AM, galgal  wrote:

> I try to use new User model. I made my custom model, attached it
> by: AUTH_USER_MODEL = 'account.Account'
> Model:
>
> class Account(AbstractBaseUser, PermissionsMixin):
> email = models.EmailField(
> verbose_name=_('email address'),
> max_length=255,
> unique=True,
> db_index=True,
> )
> username = models.CharField(
> _('username'),
> max_length=75,
> unique=True,
> help_text=_('Required. 75 characters or fewer. Letters, numbers
> and @/./+/-/_ characters'),
> validators=[
> validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter
> a valid username.'),
>   'invalid')
> ])
> is_staff = models.BooleanField(
> _('staff status'), default=False,
> help_text=_('Designates whether the user can log into this admin
> site.'))
> is_active = models.BooleanField(default=True)
> is_admin = models.BooleanField(default=False)
> date_joined = models.DateTimeField(_('date joined'),
> default=timezone.now)
>
> objects = AccountManager()
>
> USERNAME_FIELD = 'email'
> REQUIRED_FIELDS = ['username']
>
> def get_full_name(self):
> # The user is identified by their email address
> return self.email
>
> def get_short_name(self):
> # The user is identified by their email address
> return self.email
>
> def __unicode__(self):
> return self.email
>
>
> I can't sync my DB, when south is added. When I turn South off, run
> syncdb, all is ok. Then when I turn South on and try to make  migrate, I
> get:
>
> ./manage.py migrate
>> Running migrations for auth:
>>  - Migrating forwards to 0001_initial.
>>  > auth:0001_initial
>> FATAL ERROR - The following SQL query failed: CREATE TABLE
>> `auth_permission` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name`
>> varchar(50) NOT NULL, `content_type_id` integer NOT NULL, `codename`
>> varchar(100) NOT NULL);
>> The error was: (1050, "Table 'auth_permission' already exists")
>>  ! Error found during real run of migration! Aborting.
>>  ! Since you have a database that does not support running
>>  ! schema-altering statements in transactions, we have had
>>  ! to leave it in an interim state between migrations.
>> ! You *might* be able to recover with:   - no dry run output for
>> delete_unique_column() due to dynamic DDL, sorry
>>= DROP TABLE `auth_permission` CASCADE; []
>>= DROP TABLE `auth_group` CASCADE; []
>>= DROP TABLE `auth_group_permissions` CASCADE; []
>>= DROP TABLE `auth_user` CASCADE; []
>>= DROP TABLE `auth_user_groups` CASCADE; []
>>= DROP TABLE `auth_user_user_permissions` CASCADE; []
>>  ! The South developers regret this has happened, and would
>>  ! like to gently persuade you to consider a slightly
>>  ! easier-to-deal-with DBMS (one that supports DDL transactions)
>>  ! NOTE: The error which caused the migration to fail is further up.
>> Error in migration: auth:0001_initial
>> DatabaseError: (1050, "Table 'auth_permission' already exists")
>>
>> Any ideas what do I do wrong?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/WR_xxyrJGusJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF Verification error appeared after I changed DNS

2013-01-08 Thread Amirouche


On Wednesday, January 9, 2013 3:21:08 AM UTC+1, Saqib Ali wrote:
>
> Yes, I checked my cookies and there is a csrftoken: 
> jrQ4T0IZPqFpbjoPLlzJSnsEPQxzHAJh
> I didn't change the SESSION_COOKIE_DOMAIN value. There is no such setting 
> in my settings.py.
>
>
I don't know then : /

Maybe restart gunicorn or whatever runs django...
 

> I did no
>
> On Tuesday, January 8, 2013 8:09:03 PM UTC-5, Amirouche wrote:
>>
>> Did you check your cookies, is there any csrftoken ?
>>
>> Did you change SESSION_COOKIE_DOMAIN ?
>>
>> On Wednesday, January 9, 2013 1:19:35 AM UTC+1, Saqib Ali wrote:
>>>
>>> BTW, I forgot to mention that my template contains the following HTML:
>>>
>>> {% csrf_token %}
>>>
>>> E-mail:>> type="text" class="required" name="email" maxlength="75" />
>>> 
>>> 
>>>
>>>
>>>
>>> On Tuesday, January 8, 2013 6:44:49 PM UTC-5, Saqib Ali wrote:


 Hi.

 I have been using Django successfully for a few days now. I was running 
 my django application on an Amazon Web Service machine. 
 I was assigned some arbitrary DNS name that looked like this: 
 http://ec2-XXX.XXX.XXX.XXX.compute-1.amazonaws.com.
 My Django app was working find with my model and several views with 
 templates.

 Last night, I went out and bought a real DNS name from register.comand 
 have that DNS name now pointing to my django application.
 Since I made that change however, when I submit my django form, I get 
 the following CSRF error:


 Forbidden (403)

 CSRF verification failed. Request aborted.



 I tried clearing the cookies in my browser, but that didn't help. I 
 even tried it from other machines that I had never tried before. But still 
 the same problem.

 Why did assigning a new DNS name for this IP address cause this CSRF 
 error? And how do I get rid of it?




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/AYFEJ1viWPMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF Verification error appeared after I changed DNS

2013-01-08 Thread Saqib Ali
Yes, I checked my cookies and there is a csrftoken: 
jrQ4T0IZPqFpbjoPLlzJSnsEPQxzHAJh
I didn't change the SESSION_COOKIE_DOMAIN value. There is no such setting 
in my settings.py.

I did no

On Tuesday, January 8, 2013 8:09:03 PM UTC-5, Amirouche wrote:
>
> Did you check your cookies, is there any csrftoken ?
>
> Did you change SESSION_COOKIE_DOMAIN ?
>
> On Wednesday, January 9, 2013 1:19:35 AM UTC+1, Saqib Ali wrote:
>>
>> BTW, I forgot to mention that my template contains the following HTML:
>>
>> {% csrf_token %}
>>
>> E-mail:> type="text" class="required" name="email" maxlength="75" />
>> 
>> 
>>
>>
>>
>> On Tuesday, January 8, 2013 6:44:49 PM UTC-5, Saqib Ali wrote:
>>>
>>>
>>> Hi.
>>>
>>> I have been using Django successfully for a few days now. I was running 
>>> my django application on an Amazon Web Service machine. 
>>> I was assigned some arbitrary DNS name that looked like this: 
>>> http://ec2-XXX.XXX.XXX.XXX.compute-1.amazonaws.com.
>>> My Django app was working find with my model and several views with 
>>> templates.
>>>
>>> Last night, I went out and bought a real DNS name from register.com and 
>>> have that DNS name now pointing to my django application.
>>> Since I made that change however, when I submit my django form, I get 
>>> the following CSRF error:
>>>
>>>
>>> Forbidden (403)
>>>
>>> CSRF verification failed. Request aborted.
>>>
>>>
>>>
>>> I tried clearing the cookies in my browser, but that didn't help. I even 
>>> tried it from other machines that I had never tried before. But still the 
>>> same problem.
>>>
>>> Why did assigning a new DNS name for this IP address cause this CSRF 
>>> error? And how do I get rid of it?
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/wFsEG03Qeu0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: HTML Source on Browser Rendering

2013-01-08 Thread Ryoichiro Kamiya
Thanks all for seeing this thread.

With further experiment, the result shows the HTML source with  tag 
even after emptying the contents of the Django template file. When I tested 
it in various browsers, the browser automatically added basic HTML 
structure with  tag on top of my contents. I compared the line endings 
and encoding with another page that working correctly, but couldn't find 
any difference.

I'll mark this as closed as it seemed not an issue resulting from Django.
Everyone, thanks for replying to my question. Have a nice day!

Regards,
Ryo

On Tuesday, January 8, 2013 2:31:16 PM UTC+9, djangobie wrote:
>
> Than  is the issues, as it 'll display the content (inside it) as it 
> is .. making it preformated.
> can't guess how you got your code wrapped in it in the first place.
>
> Thanks
>
> On Tuesday, January 8, 2013 6:29:53 AM UTC+5, Ryoichiro Kamiya wrote:
>>
>> Thanks jjmutumi, stauros!
>>
>> I am not using "autoescape" tag in my template. Thanks.
>>
>> I am just checking the source on the back of HTML source displayed with 
>> Firebug as jmutumi suggested.
>> It seemed an auto-inserted  tag before & after the source. (Please 
>> find the attached. thanks)
>>
>> Any ideas how this can be added?
>>
>> Ryo
>>
>> On Monday, January 7, 2013 5:22:30 AM UTC+9, stauros wrote:
>>>
>>> Hello,
>>> maybe any "autoescape"  template tags on the wrong spot?
>>>
>>>
>>> On Sun, Jan 6, 2013 at 9:46 PM, Joseph Mutumi  wrote:
>>>
 Hello,

 I think you should also check the 'Content-Type' being received 
 client-side
 in the HTTP headers. You can use something curl or Firebug.


 On Sun, Jan 6, 2013 at 1:40 PM, Ryoichiro Kamiya >>> > wrote:

> Hi,
>
> I'm testing Django template rendering in development environment, but 
> one of the page shows HTML source (after all Django tag executed) instead 
> of HTML.
>
> 1. Content Type
> The first thing I check is the Content Type but it's correctly set up 
> (and it's in header template and shared with other pages that show 
> contents 
> correctly.
>
> 
>
>
> When I copied & pasted to another template and it works.
>
>
> 2. Browser
>
> I checked it in another browser (i.e. Chrome) but it returned the same 
> result.
>
>
> 3. Reboot runserver
>
> also it didn't change the output.
>
>
> Is there anything else I should check?
>
> Thanks in advance.
>
>
> Regards,
>
> Ryo
>
>  -- 
> You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/FyjKgMAxm0YJ.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

  -- 
 You received this message because you are subscribed to the Google 
 Groups "Django users" group.
 To post to this group, send email to django...@googlegroups.com.
 To unsubscribe from this group, send email to 
 django-users...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/django-users?hl=en.

>>>
>>>
>>>
>>> -- 
>>> Stavros 
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/vMWtxe-ZXBkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF Verification error appeared after I changed DNS

2013-01-08 Thread Amirouche
Did you check your cookies, is there any csrftoken ?

Did you change SESSION_COOKIE_DOMAIN ?

On Wednesday, January 9, 2013 1:19:35 AM UTC+1, Saqib Ali wrote:
>
> BTW, I forgot to mention that my template contains the following HTML:
>
> {% csrf_token %}
>
> E-mail: type="text" class="required" name="email" maxlength="75" />
> 
> 
>
>
>
> On Tuesday, January 8, 2013 6:44:49 PM UTC-5, Saqib Ali wrote:
>>
>>
>> Hi.
>>
>> I have been using Django successfully for a few days now. I was running 
>> my django application on an Amazon Web Service machine. 
>> I was assigned some arbitrary DNS name that looked like this: 
>> http://ec2-XXX.XXX.XXX.XXX.compute-1.amazonaws.com.
>> My Django app was working find with my model and several views with 
>> templates.
>>
>> Last night, I went out and bought a real DNS name from register.com and 
>> have that DNS name now pointing to my django application.
>> Since I made that change however, when I submit my django form, I get the 
>> following CSRF error:
>>
>>
>> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>>
>>
>>
>> I tried clearing the cookies in my browser, but that didn't help. I even 
>> tried it from other machines that I had never tried before. But still the 
>> same problem.
>>
>> Why did assigning a new DNS name for this IP address cause this CSRF 
>> error? And how do I get rid of it?
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4iEX7t7Wt3kJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Documentation of app_directories.Loader

2013-01-08 Thread Amirouche
Héllo Per-Olof,

On Saturday, January 5, 2013 4:17:14 PM UTC+1, Per-Olof Åstrand wrote:
>
> I had a problem interpreting the documentation of app_directories.Loader 
> in 
> https://docs.djangoproject.com/en/dev/ref/templates/api/#loading-templates(I 
> use the dev version of Django). As I read the documentation, I should 
> put the templates for an app in
>
> app_name/templates/*.html
>>
>
>
Yes, it should work if you reference the template *without* the app_name 
for instance 

{% extends "base.html" %}
{% include "footer.html" %}

or in python with «render(request, "base.html", ctx)» but you never render 
the base html or footer directly so this is dummy example
 

> whereas to get it to work, I had to put them in
>
> app_name/templates/app_name/*.html
>>
>

it only works if you reference the app_name when you call the template for 
instance «render(request, "app_name/index.html", ctx)» same for include and 
extends.

It's a convention to avoid clash between templates names, it a way to 
namespace templates, otherwise you would need to namespace the names of the 
templates like: «app_name_index.html» which is not nice...


> It also seems like it looks for templates in (which I could see from the 
> error message when failing with the first approach)
>
> app_name1/templates/app_name2/*.html
>
>
> I can see the power of that when having a hierarchy of apps. Am I missing 
> something here?
>
> Per-Olof
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/K3jp_MpGpEIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: CSRF Verification error appeared after I changed DNS

2013-01-08 Thread Saqib Ali
BTW, I forgot to mention that my template contains the following HTML:

{% csrf_token %}

E-mail:





On Tuesday, January 8, 2013 6:44:49 PM UTC-5, Saqib Ali wrote:
>
>
> Hi.
>
> I have been using Django successfully for a few days now. I was running my 
> django application on an Amazon Web Service machine. 
> I was assigned some arbitrary DNS name that looked like this: 
> http://ec2-XXX.XXX.XXX.XXX.compute-1.amazonaws.com.
> My Django app was working find with my model and several views with 
> templates.
>
> Last night, I went out and bought a real DNS name from register.com and 
> have that DNS name now pointing to my django application.
> Since I made that change however, when I submit my django form, I get the 
> following CSRF error:
>
>
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
>
>
>
> I tried clearing the cookies in my browser, but that didn't help. I even 
> tried it from other machines that I had never tried before. But still the 
> same problem.
>
> Why did assigning a new DNS name for this IP address cause this CSRF 
> error? And how do I get rid of it?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/bfNeyTDIf2AJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



CSRF Verification error appeared after I changed DNS

2013-01-08 Thread Saqib Ali

Hi.

I have been using Django successfully for a few days now. I was running my 
django application on an Amazon Web Service machine. 
I was assigned some arbitrary DNS name that looked like 
this: http://ec2-XXX.XXX.XXX.XXX.compute-1.amazonaws.com.
My Django app was working find with my model and several views with 
templates.

Last night, I went out and bought a real DNS name from register.com and 
have that DNS name now pointing to my django application.
Since I made that change however, when I submit my django form, I get the 
following CSRF error:


Forbidden (403)

CSRF verification failed. Request aborted.



I tried clearing the cookies in my browser, but that didn't help. I even 
tried it from other machines that I had never tried before. But still the 
same problem.

Why did assigning a new DNS name for this IP address cause this CSRF error? 
And how do I get rid of it?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/ooaNm-tytpkJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Announcment - django-databrowse

2013-01-08 Thread Alir3z4
Hi,

Since Django 1.4 released, `django.contrib.databrowse` get deprecated.
And it's removed from 1.5.
Actually I hope django.contrib.* completely get wiped off django, I guess 
django development
will be faster and cleaner without those app.

I've extracted and adopted it.
Now it's available as stand-alone package pypi.

pypi:
http://pypi.python.org/pypi/django-databrowse

source/git repo:
https://github.com/Alir3z4/django-databrowse


Regards,
Alireza Savand

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zpKP-nBTULQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Project Structure - Lots of scattered custom views

2013-01-08 Thread Amirouche
Héllo Chad,

I'd like to help but I need more infos if you don't mind and is granted to 
provide them.

On Monday, January 7, 2013 9:52:35 PM UTC+1, chad petzoldt wrote:
>
> Right now my project only has 2 apps that use a database (*real* apps). 
> The rest of the website is composed of many custom views, scattered all 
> over the place. I am new to Django, and I havn't quite figured out how to 
> structure my project directory just yet.
>

What do this two apps ?

The other *issue* is related to my design/develop workflow. Working 
> completely through an internet browser just isnt possible for 80% of the 
> project cycle. We have many programs which want to work directly on the 
> filesystem (on an offline machine), mostly coming from the Adobe Creative 
> Suite.
>

I don't understand this part, are you programming in the browser ? or is it 
just about the design phase of each «Articles/bundle», work prior or in 
parallel of programming the site ?
 

> There are all kinds of media documents and markups forming "Articles". 
> These Articles are passed around as bundles during design, and then when 
> they get to me I have to tie them together very neatly and push them onto 
> the website. The one thing I do have control over is the Url layout, and 
> the navigation of these articles.
>

> Should I be splitting each of these "articles" into their own apps (a 
> directory with little more than 'templates/' and 'static/'). 

 
I'm not sure but what you describe looks like a (e)magazine with several 
issues (you call them Articles/bundle) where each issue has it's own 
layout/design - and probably navigation but it seems also there is a global 
menu - a cross issues menu - present on all issues.

This makes synchronization easy with the server, there is no database 
> interaction required;


I assume by «synchronization» you mean «putting the new "Articles" in 
production».
 

> the only task left after the sync is for me to update my navigation 
> widgets (which I currently just do by hand). 


Can you describe this navigation widget ? Is it available over all 
apps/Articles/issues ?

Do the Articles gets modified after the first synchronization ? Do you have 
somekind of administration to edit them ?

In the other mail you say «But I still find myself creating bare apps with 
some crazy model defined that only has 1 table row.», could you describe 
one of this table/row and generalize to the other similar tables ?

Regards,

Amirouche

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UoXiPGxq-FIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: show an image in django

2013-01-08 Thread Mario Gudelj
Try removing .. from the path. Also make sure your static path is set
correctly in settings.py
On 9 Jan, 2013 1:42 AM, "jianhui chen"  wrote:

> Hi all,
> I want to show an image in project in which the folder DIR looks like this:
> images/a.jpg
> templates/introduction.html
>
> In introduction.html I use
> 
>
> It can show image correctly when I open the "introduction.html" directly
> using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 "
> when I open it in http://127.0.0.1:8000/introduction/, and there is no
> image in the webpage.
>
> I used the last method in
> http://stackoverflow.com/questions/2148738/cannot-get-images-to-display-in-simple-django-site.
>  But it doesn't work.
>
> Could anyone give me some suggestions?
>
> jianhui
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread akaariai
I created the following test case into django's test suite modeltests/
basic/tests.py:
def test_unicode(self):
# Note: from __future__ import unicode_literals is in
effect...
a = Article.objects.create(headline='0
\u0442\u0435\u0441\u0442 test', pub_date=datetime.n  ow())
self.assertEqual(Article.objects.get(pk=a.pk).headline, '0
\u0442\u0435\u0441\u0442 test'   )

This does pass on Oracle when using Django's master branch, both with
Python 2.7 and 3.3.

Django's backend is doing all sorts of trickery behind the scenes to
get correct unicode handling. I am not sure where the problem is. What
Django version are you using?

 - Anssi

On 8 tammi, 17:34, Jani Tiainen  wrote:
> Hi,
>
> I've been trying to save UTF-8 characters to oracle database without
> success.
>
> I've verified that database is indeed UTF-8 capable.
>
> I can insert UTF-8 characters directly using cx_Oracle.
>
> But when I use ORM it will trash characters.
>
> Model I use:
>
> class MyTest(models.Model):
>      txt = CharField(max_length=128)
>
> s = u'0 \u0442\u0435\u0441\u0442 test'
>
> i = MyTest()
> i.txt = s
> i.save()
>
> i2 = MyTest.objects.get(id=i.id)
> print i2.txt
>
> u'0 \xbf\xbf\xbf\xbf test'
>
> So what happens here? It looks like Django trashes my unicode string at
> some (unknown point).
>
> Additional note:
>
> If I use cursor() from Django connection object strings get broken also.
> So it must be django Oracle backend doing something evil for me.
>
> --
> Jani Tiainen
>
> - Well planned is half done and a half done has been sufficient before...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sort cache

2013-01-08 Thread psychok7
hi there. redis does seem like a better solution than the cache.

i need redis (or the cache) because of performance reasons. i know they are 
faster for the insert and retrieve that i need in a FIFO order. Found this 
http://rediscookbook.org/implement_a_fifo_queue.html and it seems it will 
do the trick

thanks for your time

On Tuesday, January 8, 2013 12:45:07 PM UTC, psychok7 wrote:
>
> Hi guys, just wondering if its possible to sort a django cache? I need to 
> add data with an auto increment id to the cache and sort it in reverse 
> order to get it back. I no this can be easily accomplished with the normal 
> mysql database but since the cache is faster i would like to do it there
>
> thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BhIxefC4e-IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Project Structure - Lots of scattered custom views

2013-01-08 Thread Sanjay Bhangar
hey all,

This seems to be an itch I've had to scratch myself in the past - let
me see if I understand the situation vaguely correctly:

You have a site that uses Django / database features for some things,
but then you also have a lot of content that's being designed in some
design tool and needs to be manually crafted into precise (sometimes
hackish) html and uploaded, and you almost want to just work with
plain html files on a file-system so you can use the tools you're used
to - Komodo / vim, version control, etc. This content is in the form
of "article bundles" which need to have some sequencing between pages.

The 'new app for every article' definitely sounds like a clusterf
it maybe an interesting experiment, but it just *feels* wrong at so
many levels .. you do want some way to generalize this into a single
app .. but my guess is you also are unable to wrap things into common
templates and editing the html in the database / django admin is just
too messy .. even if you let individual "articles" or "article
bundles" have their own custom css that's specified some-how in the
db, and their own custom html that you some-how populate from html
files you upload. It may work, and it is perhaps the correct way to do
this. I just know the situation where you're fighting with some silly
html generated by a design tool and actually want simple html files
and css resources, and the database "structure" can feel like its
getting in the way ..

So, here is my radical (?) suggestion :) -

Have a simple model like this:
class Item(models.Model):
  title = models.CharField(..)
  slug = models.SlugField(..)
  ... any extra metadata fields you need for the "article bundles"

Then, for each item "slug" name, you create a new folder on the
file-system in some path you define in settings.py or so like
CUSTOM_HTML_PATH or anything - so, say you have a series of articles
on "Why not to do webdesign in Indesign" with a slug like
"why-not-indesign", you create a folder inside CUSTOM_HTML_PATH with
the name "why-not-indesign". Then create the various articles in that
"bundle" like 1.html, 2.html, 3.html, etc. and include all the css /
js files that specific bundle needs inside a static folder in that
directory.

Then you just need a view which takes , looks for the
appropriate folder on the file-system, and renders 1.html inside
whatever master template you may have. The view can also check for all
the .html files in the directory to handle next / previous.
You would probably need to do a bit of magic with STATICFILE_DIRS or
so to make sure each of the static file folders inside the directories
are collected by collectstatic so you can still serve the static files
through the web server and not through django.

Of course, I don't know the details of your work-flow so I maybe
missing something, but I do in general find the idea of storing some
things just on the file-system quite interesting, and the code to
manage it is generally pretty straightforward.

Of course, this may also be a terrible idea, but I'd also love to hear why .. :)

Cheers,
Sanjay





On Tue, Jan 8, 2013 at 9:52 AM, Lachlan Musicman  wrote:
>>
>> There are some cases where they send me Indesign, but when I export to HTML
>> some of the layouts break. So then I have to manually rig it until I feel
>> its close enough (but then it turns out it wasn't, so I mod again). Some
>> imagemaps made from sliced up Photoshops with some cute rollover effects
>> added on. And then some of the Articles form sequential "stories", so they
>> need linking in between to make them feel seamless.
>>
>> The major point is that I have small bundles of files that are very
>> interconnected, and keeping them close and organized makes the
>> reviewing/editing/handling process much easier. Most of my hacking has been
>> from KomodeIDE, and then VIM/SSH (and thats even when Im doing the design
>> work!). Im having a hard time breaking away from the direct editing.
>
> So it sounds like a model like this would work:
>
> def BundleFiles(models.Model):
> file = models.FileField()
> articlw = models.ManyToMany(Article)
> # or maybe article = models.ForeignKey(Article)
>
> def Article(models.Model):
>  html = models.TextField() #for the end product
> # or html = models.FileField()
> cssfile = models.FileField() #this can be abstracted out to it's own
> model if used across many articles
>  previous = models.FK(Article, blank = True, null= True)
>  next = models.FK(Article, blank = True, null= True)
>
> See how these are more like folders to hold each set of info. For the
> final product/page, you would need to write appropriate views and
> methods that extracted the important bits and put them in the
> appropriate places.
>
>
>
>>>
>>> > I think that splitting each article into it's own app sounds like a
>>> > disaster waiting to happen.
>>>
>>
>> I agree, thats why I posted here. I am already starting to see the
>> problems... I have started breaking the 

Re: Syncdb error with new 1.5rc1

2013-01-08 Thread galgal
As for my problem, I solved it by making manage.py migrate --fake 
But I don't know that is the best and good solution. So far it works somehow :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Suged2nr3fMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: sort cache

2013-01-08 Thread Amirouche
Héllo psychok7,

On Tuesday, January 8, 2013 1:45:07 PM UTC+1, psychok7 wrote:
>
> Hi guys, just wondering if its possible to sort a django cache? I need to 
> add data with an auto increment id to the cache and sort it in reverse 
> order to get it back. I no this can be easily accomplished with the normal 
> mysql database but since the cache is faster i would like to do it there


Yes and no.

Django cache backend alone can't do this sort of things, the only methods 
that are 
definedare:

- get
- get_many
- set
- set_many
- incr
- decr
- delete
- delete_many

With those, you can do what you want, you have to set up a «schema» with 
cache keys that will allow you to do what you want.

Similarly you can also do this sort of things using 
redis, 
which is also pretty fast since it's also a in memory key/value store, 
using higher level methods on higher level data structures like lists, 
sets, sorteds sets, hashes. You might as well fallback on creating your own 
data structures relying on existing datastructures usings 
scripts
.

The usecase you are discribing is not clear, why not just do the sorting 
with mysql, store in the cache with an expiration key the results, ids or 
rendered templates ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/izl57HRb4YUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't set static file directory.

2013-01-08 Thread jianhui chen
Hi,
   I am not to interrupt your question, actually I have the same problems
as you. It seems that Django comers suffer this problem so much.
   I use Manager Static File as a guide, but still has problem.
   1, Put your static files somewhere that staticfiles will find them
  I set following in the setting.py
  STATIC_URL = '/static/'

 # Additional locations of static files
STATICFILES_DIRS = (
   # Put strings here, like "/home/html/static" or
"C:/www/django/static".
   # Always use forward slashes, even on Windows.
   # Don't forget to use absolute paths, not relative paths.
   "E:/code/python/djangoBook/django-testapp-develop/static"  #this is
only used in my local test
  )
   2, Make sure that django.contrib.staticfiles is included in your
INSTALLED_APPS
.
  So I set that:
   INSTALLED_APPS = (
#'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.staticfiles',   #this
'djangotoolbox',
'autoload',
'dbindexer',
'shape_practice',

# djangoappengine should come last, so it can override a few manage.py
commands
'djangoappengine',

)
   TEMPLATE_CONTEXT_PROCESSORS = (
 'django.contrib.auth.context_processors.auth',
   'django.core.context_processors.request',
   'django.core.context_processors.media',
'django.core.context_processors.static',  #this
 )
  3, You’ll probably need to refer to these files in your templates.
   So I did this:

  

  And, so someone pointed out that : using
RequestContext,
so I dit that
  def introduction(request):
t = loader.get_template('introduction.html')
c = RequestContext(request, {})   #this
return HttpResponse(t.render(c))

  The problem is that when I comment out
"E:/code/python/djangoBook/django-testapp-develop/static" in the
STATICFILES_DIRS , it has an error :

"NetworkError: 500  -
http://127.0.0.1:8000/static/images/gauge_example.jpg";. When I didn't
commented out, it works. So I think STATICFILES_DIRS and STATIC_URL
actually works in

my app, the problem is that how to set it to the correct path. In my
case, I want to STATIC_URL can find my "static" folder which is in the
project home directory.

  I was puzzled by this problem many days, right now I have no way but
to use local folder
"E:/code/python/djangoBook/django-testapp-develop/static" to code and
test in my PC.

  Thanks.

Jianhui








On Sat, Jan 5, 2013 at 1:38 PM, Mārtiņš Jakubovičs <
martins.jakubov...@gmail.com> wrote:

> Hello.
>
> I try a lot of things and can't understand, why not working STATIC_ROOT
> and MEDIA_ROOT in settings.py.
>
> I want, that all my media and static folders is in different place that
> python files, so I set media, static and templates to different place.
> Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT and STATIC_ROOT not.
>
> I try setup like this:
>
> /home/domain/www/my_proj/ there is project folder and all apps, and there
> I place my htdocs folder, in which is static, templates and media folders.
>
> When i set in STATIC_ROOT = '/home/domain/www/my_proj/htdocs/static'
>
> In apache error log i got:
>
> File does not exist: /home/domain/www/my_proj/my_proj/static
>
> I don't get, why django don't want to take new setting...
>
> I use django 1.4.
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/crL9a25SIWMJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't set static file directory.

2013-01-08 Thread Agnese Camellini
I've foud a tutorial , finally.


Interesting, but it speaks about an older version of Django.

Thank you all for the answers.

2013/1/8 Jonathan 

>  Assuming that you have settings.STATIC_ROOT configured, you can use the
> following snippet to handle URL routing for static files with the dev
> server:
>
> # urls.py
> if settings.DEBUG:
> urlpatterns += patterns('',
> (r'^static/(?P.*)$', 'django.views.static.serve', {
> 'document_root': settings.STATIC_ROOT,
> }),
> )
>
> Feel free to add a similar pattern for media files as well.
>
> Hope this helps,
> Jonathan
>
>
> On 01/08/2013 04:25 AM, Agnese Camellini wrote:
>
> I'm not using apache now, i'm just using the development server into
> django.
> Why is it so difficult to serve static files?
> joy
>
> 2013/1/8 Mike Dewhirst 
>
>> On 8/01/2013 10:03pm, joy wrote:
>>
>>> I have the same problem, the tutorial speaks about a list of things to
>>> do:
>>>
>>>   * Push your code up to the deployment server.
>>>   * On the server, run collectstatic
>>> <
>>> https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#django-admin-collectstatic
>>> >
>>> to copy all the static files into STATIC_ROOT
>>> <
>>> https://docs.djangoproject.com/en/1.4/ref/settings/#std:setting-STATIC_ROOT
>>> >.
>>>   * Point your web server at STATIC_ROOT
>>> <
>>> https://docs.djangoproject.com/en/1.4/ref/settings/#std:setting-STATIC_ROOT
>>> >.
>>>
>>> I have arrived at the second point. But the static files are not served,
>>> i have set up the STATIC ROOT and the STATIC_URL, but what should i add
>>> to the template src tag to find the pages? The tutorial speaks about the
>>> template context processor, but it doesn't exist in my setting.py file.
>>>
>>> TEMPLATE_CONTEXT_PROCESSORS  =  (
>>>  'django.core.context_processors.debug',
>>>  'django.core.context_processors.i18n',
>>>  'django.core.context_processors.media',
>>>  'django.core.context_processors.static',
>>>  'django.contrib.auth.context_processors.auth',
>>>  'django.contrib.messages.context_processors.messages',
>>> )
>>>
>>> i cannot make my css and javascript work, please, can you explain me
>>> what is happening behind the interface?
>>> Agnese
>>>
>>>
>>> Il giorno sabato 5 gennaio 2013 19:38:32 UTC+1, MÄ rtiņš JakuboviÄ s
>>> ha scritto:
>>>
>>> Hello.
>>>
>>> I try a lot of things and can't understand, why not working
>>> STATIC_ROOT and MEDIA_ROOT in settings.py.
>>>
>>> I want, that all my media and static folders is in different place
>>> that python files, so I set media, static and templates to different
>>> place. Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT
>>> and STATIC_ROOT not.
>>>
>>> I try setup like this:
>>>
>>> /home/domain/www/my_proj/ there is project folder and all apps, and
>>> there I place my htdocs folder, in which is static, templates and
>>> media folders.
>>>
>>> When i set in STATIC_ROOT = '/home/domain/www/my_proj/htdocs/static'
>>>
>>> In apache error log i got:
>>>
>>> File does not exist: /home/domain/www/my_proj/my_proj/static
>>>
>>> I don't get, why django don't want to take new setting...
>>>
>>> I use django 1.4.
>>>
>>
>> I think you need to set up Apache to serve the static and media files.
>> Here is how mine works ...
>>
>>  # lock the public out
>>  
>>   AllowOverride None
>>   Order deny,allow
>>   Deny from all
>>  
>>
>>  # serve uploaded media from here
>>  
>>   AllowOverride None
>>   Order deny,allow
>>   Allow from all
>>  
>>
>>  # serve static stuff from here
>>  
>>   AllowOverride None
>>   Order deny,allow
>>   Allow from all
>>  
>>
>>  
>>   Alias /media/ /var/www/media/my_proj/
>>   Alias /static/ /var/www/static/my_proj/
>>   Alias /tiny_mce/ /var/www/static/my_proj/js/tiny_mce/
>>   Alias /jquery/ /var/www/static/my_proj/js/jquery/
>>  
>>
>> Then in your template you can use {{ STATIC_URL }}/whatever
>>
>> Hope this helps
>>
>> Mike
>>
>>
>>> Thanks.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/django-users/-/fwNEyOLpFb4J.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
> --
> You received this message because you are

ORM, Oracle and UTF-8 encoding problem.

2013-01-08 Thread Jani Tiainen

Hi,

I've been trying to save UTF-8 characters to oracle database without 
success.


I've verified that database is indeed UTF-8 capable.

I can insert UTF-8 characters directly using cx_Oracle.

But when I use ORM it will trash characters.

Model I use:

class MyTest(models.Model):
txt = CharField(max_length=128)


s = u'0 \u0442\u0435\u0441\u0442 test'

i = MyTest()
i.txt = s
i.save()

i2 = MyTest.objects.get(id=i.id)
print i2.txt

u'0 \xbf\xbf\xbf\xbf test'


So what happens here? It looks like Django trashes my unicode string at 
some (unknown point).


Additional note:

If I use cursor() from Django connection object strings get broken also. 
So it must be django Oracle backend doing something evil for me.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: image list

2013-01-08 Thread Bill Freeman
On Tue, Jan 8, 2013 at 6:03 AM, Randa Hisham  wrote:

>
> i have list of images
> i send it and display as table in django template
> i make user to change add delete images
> how to save back this changes
> --
> Randa Hesham
> Software Developer
>
> When you say you allow the user to add images, where do the images come
from?

If these are images already available on your server, which the user simply
selects,
using JavaScript that you have written, then have only to send the
rearranged list
back to the server.  This can be done with a POST, either using AJAX, or a
more
traditional FORM tag POST that also reloads the page.  The latter is the
simpler
approach to make functional, at the cost of letting the user see the page
reload, but
once it is working, it serves as a head start on the AJAX approach.

In either case your first task is to decide how the image selection
information is to
be stored in the server's database.  A flexible approach is to have a
"Picture" model
which mostly contains an ImageField, allowing for image upload withing
Django,
among other things.  Then the model of the pages containing the images is
related
to the Picture model via a ManyToMany relation, though one "through" an
intermediate
model which has an order integer field, or perhaps row and column integer
fields.
This may be a more complex structure than you require, but should suffice
for most
needs.

Next, the JavaScript that re-orders/selects/deselects the images must also
update a
field or fields in a form tag so that when the form's submit button is
clicked, the new
arrangement is transmitted to the server.  (You could, alternatively, catch
the submit
and update the form field at that time.)  Because the number of images, and,
presumably, the number of rows, is variable, I suggest a single textarea
field in which
you store JSON for the arrangement (e.g.; arrays of arrays of integers,
where the
integers are the database IDs of the Picture models).  Again, other
arrangements are
possible.  One might be to send information about what changed, rather than
the
entire arrangement of images, but this is more brittle.

Finally, the view which receives the POST is responsible for decoding the
JSON
and updating the intermediate model instances to correspond to the new
arrangement.  One approach is to delete all the intermediate model instances
(relations) and recreate new ones from the submitted data, and I suggest
that you
start with this.  It may (or may not) save database overhead to figure out
what
changed and just update or replace relations that have changed.

The AJAX approach will also be doing a POST, using, for example, jQuery's
post
method, and the view will be nearly the same (it need not return the new
HTML
version of the page in this case).  The AJAX POSTs would happen if response
to
a user change to the page, rather than requiring a submit button be
pressed, and
are much more likely to benefit from transmitting only what has changed,
rather
than the entire arrangement, but this can be left as an eventual
optimization.

Bill

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")

2013-01-08 Thread Javier Guerra Giraldez
On Tue, Jan 8, 2013 at 4:04 AM, Diederik van der Boor  wrote:
> When you ask the mysql driver to connect to localhost, it will use the
> socket.
> To avoid this issue, better use 127.0.0.1.

which issue?   what's wrong with using socket?

--
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



show an image in django

2013-01-08 Thread jianhui chen
Hi all,
I want to show an image in project in which the folder DIR looks like this:
images/a.jpg
templates/introduction.html

In introduction.html I use


It can show image correctly when I open the "introduction.html" directly
using firefox, but it shows ""GET /images/gauge_example.jpg HTTP/1.1" 404 "
when I open it in http://127.0.0.1:8000/introduction/, and there is no
image in the webpage.

I used the last method in
http://stackoverflow.com/questions/2148738/cannot-get-images-to-display-in-simple-django-site.
But it doesn't work.

Could anyone give me some suggestions?

jianhui

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: strangle url error in django with google app engine

2013-01-08 Thread jianhui chen
The problem is solved. Thanks.


On Mon, Jan 7, 2013 at 10:02 AM, Daniel Roseman wrote:

> On Monday, 7 January 2013 13:54:59 UTC, jianhui chen wrote:
>
>> Hi all.
>>I use djangoappengine http://www.allbuttonspressed.**
>> com/projects/djangoappengine#**zip-packagesto
>>  manage google app engine.
>>I test a very simple project:
>>url.py:
>>from django.conf.urls.defaults import *
>> from shape_practice.views import introduction
>> handler500 = 'djangotoolbox.errorviews.**server_error'
>>
>> urlpatterns = patterns('',
>> ('^_ah/warmup$', 'djangoappengine.views.warmup'**),
>>  (r'^introduction/$', introduction),
>> )
>>
>> views.py:
>>
>> from django.conf import settings
>> from django.http import HttpResponse
>> from django.utils.importlib import import_module
>> from django.template import loader, Context, RequestContext
>>
>> def introduction(request):
>> t = loader.get_template('**introduction.html')
>> c = Context({})
>> return HttpResponse(t.render(c))
>>
>> but when I type 
>> http://127.0.0.1:8000/**introduction/. 
>> The browser doesn't show "introduction.html", but another "html", let's
>> say A.html. But A.html can't be found in the urlpatterns. Anywhere else can
>> set .html file?
>> Another strange thing is that: in the url.py file, I can use "from
>> shape_practice.views import introduction", but I can't use
>> shape_practice.views.**introduction which has an "shape_practice
>> undefined error"
>>
>> Thanks.
>>
>>
>>
> You should ask App Engine questions on the App Engine users group.
> Presumably you have something in your app.yaml file which is sending the
> user to static page rather than the Django app.
> If you don't import shape_practice, you can't reference it.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/GoDD8oHllVEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb error with new 1.5rc1

2013-01-08 Thread Thiago Carvalho D' Ávila
I found out what I was doing wrong in my model. I was using UserManager
without having 'is_active' and 'is_admin' fields. Solved!

As with galgal's problem. I had no luck using South to migrate from
auth_mixin to django 1.5. I am doing it manually =/

2013/1/8 galgal 

> I also get strange error:
> https://groups.google.com/forum/#!topic/django-users/lVUZ3hClyUg
>
>
> On Monday, January 7, 2013 10:46:18 PM UTC+1, Thiago wrote:
>>
>> I used auth mixin before in my app, then made the changes to make it work
>> on the official Django with new custom user.
>>
>> The problem is that, when I run on my new empty db:
>> python manage.py syncdb --all
>>
>> ...
>> You just installed Django's auth system, which means you don't have any
>> superusers defined.
>> Would you like to create one now? (yes/no): yes
>> E-mail address: e...@il.xx
>> Password:
>> Password (again):
>> TypeError: create_superuser() takes exactly 4 arguments (3 given)
>>
>> Do you know what is wrong?
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/N6aoa9nWW9IJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: mod_wsgi performance problem

2013-01-08 Thread Javier Guerra Giraldez
On Mon, Jan 7, 2013 at 10:51 PM, carlos  wrote:
> maybe try deploy with gunicorn and nginx http://gunicorn.org/
> http://wiki.nginx.org/Main

while nginx/gunicorn is a very good setup, there's nothing wrong with
apache/mod_wsgi.  i find unlikely that changing a good choice for
another equally good would solve anything.

--
Javier

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't set static file directory.

2013-01-08 Thread Jonathan
Assuming that you have settings.STATIC_ROOT configured, you can use the
following snippet to handle URL routing for static files with the dev
server:

# urls.py
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static/(?P.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)

Feel free to add a similar pattern for media files as well.

Hope this helps,
Jonathan

On 01/08/2013 04:25 AM, Agnese Camellini wrote:
> I'm not using apache now, i'm just using the development server into
> django.
> Why is it so difficult to serve static files?
> joy
>
> 2013/1/8 Mike Dewhirst  >
>
> On 8/01/2013 10:03pm, joy wrote:
>
> I have the same problem, the tutorial speaks about a list of
> things to do:
>
>   * Push your code up to the deployment server.
>   * On the server, run collectstatic
>
> 
> 
> to copy all the static files into STATIC_ROOT
>
> 
> .
>   * Point your web server at STATIC_ROOT
>
> 
> .
>
> I have arrived at the second point. But the static files are
> not served,
> i have set up the STATIC ROOT and the STATIC_URL, but what
> should i add
> to the template src tag to find the pages? The tutorial speaks
> about the
> template context processor, but it doesn't exist in my
> setting.py file.
>
> TEMPLATE_CONTEXT_PROCESSORS  =  (
>  'django.core.context_processors.debug',
>  'django.core.context_processors.i18n',
>  'django.core.context_processors.media',
>  'django.core.context_processors.static',
>  'django.contrib.auth.context_processors.auth',
>  'django.contrib.messages.context_processors.messages',
> )
>
> i cannot make my css and javascript work, please, can you
> explain me what is happening behind the interface?
> Agnese
>
>
> Il giorno sabato 5 gennaio 2013 19:38:32 UTC+1, MÄ rtiņš
> JakuboviÄ s
> ha scritto:
>
> Hello.
>
> I try a lot of things and can't understand, why not working
> STATIC_ROOT and MEDIA_ROOT in settings.py.
>
> I want, that all my media and static folders is in
> different place
> that python files, so I set media, static and templates to
> different
> place. Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT
> and STATIC_ROOT not.
>
> I try setup like this:
>
> /home/domain/www/my_proj/ there is project folder and all
> apps, and
> there I place my htdocs folder, in which is static,
> templates and
> media folders.
>
> When i set in STATIC_ROOT =
> '/home/domain/www/my_proj/htdocs/static'
>
> In apache error log i got:
>
> File does not exist: /home/domain/www/my_proj/my_proj/static
>
> I don't get, why django don't want to take new setting...
>
> I use django 1.4.
>
>
> I think you need to set up Apache to serve the static and media
> files. Here is how mine works ...
>
>  # lock the public out
>  
>   AllowOverride None
>   Order deny,allow
>   Deny from all
>  
>
>  # serve uploaded media from here
>  
>   AllowOverride None
>   Order deny,allow
>   Allow from all
>  
>
>  # serve static stuff from here
>  
>   AllowOverride None
>   Order deny,allow
>   Allow from all
>  
>
>  
>   Alias /media/ /var/www/media/my_proj/
>   Alias /static/ /var/www/static/my_proj/
>   Alias /tiny_mce/ /var/www/static/my_proj/js/tiny_mce/
>   Alias /jquery/ /var/www/static/my_proj/js/jquery/
>  
>
> Then in your template you can use {{ STATIC_URL }}/whatever
>
> Hope this helps
>
> Mike
>
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/fwNEyOLpFb4J.
> To post to this group, send email to
> django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
> -- 
> You received th

Re: Syncdb error with new 1.5rc1

2013-01-08 Thread galgal
I also get strange error: 
https://groups.google.com/forum/#!topic/django-users/lVUZ3hClyUg

On Monday, January 7, 2013 10:46:18 PM UTC+1, Thiago wrote:
>
> I used auth mixin before in my app, then made the changes to make it work 
> on the official Django with new custom user.
>
> The problem is that, when I run on my new empty db:
> python manage.py syncdb --all
>
> ...
> You just installed Django's auth system, which means you don't have any 
> superusers defined.
> Would you like to create one now? (yes/no): yes
> E-mail address: e...@il.xx
> Password: 
> Password (again): 
> TypeError: create_superuser() takes exactly 4 arguments (3 given)
>
> Do you know what is wrong?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/N6aoa9nWW9IJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Syncdb error with new 1.5rc1

2013-01-08 Thread Thiago Carvalho D' Ávila
Basically, I am using Person class as my AUTH_USER_MODEL. I realized it was
missing 'username' in REQUIRED_FIELDS.

from django.contrib.auth.models import UserManager, AbstractBaseUser
...

class Person(AbstractBaseUser):
objects = UserManager()
username = models.CharField(_('username'), max_length=30, unique=True,
help_text=_('Required. 30 characters or fewer. Letters, numbers and
'
'@/./+/-/_ characters'))
email = models.EmailField(_('e-mail address'), unique=True, blank=True,
null=True)
...
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']

But it continues to give me error to syncdb:
You just installed Django's auth system, which means you don't have any
superusers defined.
Would you like to create one now? (yes/no): yes
E-mail address: e...@il.xx
Username: test
Password:
Password (again):
TypeError: 'is_active' is an invalid keyword argument for this function

There is no is_active reference in my model.

2013/1/8 Russell Keith-Magee 

>
> On Tue, Jan 8, 2013 at 5:46 AM, Thiago Carvalho D' Ávila <
> thiagocav...@gmail.com> wrote:
>
>> I used auth mixin before in my app, then made the changes to make it work
>> on the official Django with new custom user.
>>
>> The problem is that, when I run on my new empty db:
>> python manage.py syncdb --all
>>
>> ...
>> You just installed Django's auth system, which means you don't have any
>> superusers defined.
>> Would you like to create one now? (yes/no): yes
>> E-mail address: e...@il.xx
>> Password:
>> Password (again):
>> TypeError: create_superuser() takes exactly 4 arguments (3 given)
>>
>> Do you know what is wrong?
>
>
> It's impossible to tell you the exact problem without seeing code, but
> from the look of it, your user manager isn't defined correctly.
>
> The arguments of the create_superuser() method on your user manager must
> match the required fields on your user model (i.e., the contents of
> REQUIRED_FIELDS, plus username and password). Based on the error you're
> describing, you've defined a create_superuser() that takes an argument that
> isn't listed as a required field.
>
> Yours,
> Russ Magee %-)
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



sort cache

2013-01-08 Thread psychok7
Hi guys, just wondering if its possible to sort a django cache? I need to 
add data with an auto increment id to the cache and sort it in reverse 
order to get it back. I no this can be easily accomplished with the normal 
mysql database but since the cache is faster i would like to do it there

thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/x6xxD_1QICIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't set static file directory.

2013-01-08 Thread Agnese Camellini
I'm not using apache now, i'm just using the development server into
django.
Why is it so difficult to serve static files?
joy

2013/1/8 Mike Dewhirst 

> On 8/01/2013 10:03pm, joy wrote:
>
>> I have the same problem, the tutorial speaks about a list of things to do:
>>
>>   * Push your code up to the deployment server.
>>   * On the server, run collectstatic
>> > staticfiles/#django-admin-**collectstatic
>> >
>> to copy all the static files into STATIC_ROOT
>> > setting-STATIC_ROOT
>> >.
>>   * Point your web server at STATIC_ROOT
>> > setting-STATIC_ROOT
>> >.
>>
>> I have arrived at the second point. But the static files are not served,
>> i have set up the STATIC ROOT and the STATIC_URL, but what should i add
>> to the template src tag to find the pages? The tutorial speaks about the
>> template context processor, but it doesn't exist in my setting.py file.
>>
>> TEMPLATE_CONTEXT_PROCESSORS  =  (
>>  'django.core.context_**processors.debug',
>>  'django.core.context_**processors.i18n',
>>  'django.core.context_**processors.media',
>>  'django.core.context_**processors.static',
>>  'django.contrib.auth.context_**processors.auth',
>>  'django.contrib.messages.**context_processors.messages',
>> )
>>
>> i cannot make my css and javascript work, please, can you explain me what
>> is happening behind the interface?
>> Agnese
>>
>>
>> Il giorno sabato 5 gennaio 2013 19:38:32 UTC+1, MÄ rtiņš JakuboviÄ s
>> ha scritto:
>>
>> Hello.
>>
>> I try a lot of things and can't understand, why not working
>> STATIC_ROOT and MEDIA_ROOT in settings.py.
>>
>> I want, that all my media and static folders is in different place
>> that python files, so I set media, static and templates to different
>> place. Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT
>> and STATIC_ROOT not.
>>
>> I try setup like this:
>>
>> /home/domain/www/my_proj/ there is project folder and all apps, and
>> there I place my htdocs folder, in which is static, templates and
>> media folders.
>>
>> When i set in STATIC_ROOT = '/home/domain/www/my_proj/**
>> htdocs/static'
>>
>> In apache error log i got:
>>
>> File does not exist: /home/domain/www/my_proj/my_**proj/static
>>
>> I don't get, why django don't want to take new setting...
>>
>> I use django 1.4.
>>
>
> I think you need to set up Apache to serve the static and media files.
> Here is how mine works ...
>
>  # lock the public out
>  
>   AllowOverride None
>   Order deny,allow
>   Deny from all
>  
>
>  # serve uploaded media from here
>  
>   AllowOverride None
>   Order deny,allow
>   Allow from all
>  
>
>  # serve static stuff from here
>  
>   AllowOverride None
>   Order deny,allow
>   Allow from all
>  
>
>  
>   Alias /media/ /var/www/media/my_proj/
>   Alias /static/ /var/www/static/my_proj/
>   Alias /tiny_mce/ /var/www/static/my_proj/js/**tiny_mce/
>   Alias /jquery/ /var/www/static/my_proj/js/**jquery/
>  
>
> Then in your template you can use {{ STATIC_URL }}/whatever
>
> Hope this helps
>
> Mike
>
>
>> Thanks.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/**msg/django-users/-/**fwNEyOLpFb4J
>> .
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscribe@**googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/**group/django-users?hl=en
>> .
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't set static file directory.

2013-01-08 Thread Mike Dewhirst

On 8/01/2013 10:03pm, joy wrote:

I have the same problem, the tutorial speaks about a list of things to do:

  * Push your code up to the deployment server.
  * On the server, run collectstatic


to copy all the static files into STATIC_ROOT

.
  * Point your web server at STATIC_ROOT

.

I have arrived at the second point. But the static files are not served,
i have set up the STATIC ROOT and the STATIC_URL, but what should i add
to the template src tag to find the pages? The tutorial speaks about the
template context processor, but it doesn't exist in my setting.py file.

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

i cannot make my css and javascript work, please, can you explain me what is 
happening behind the interface?
Agnese


Il giorno sabato 5 gennaio 2013 19:38:32 UTC+1, MÄ rtiņš JakuboviÄ s
ha scritto:

Hello.

I try a lot of things and can't understand, why not working
STATIC_ROOT and MEDIA_ROOT in settings.py.

I want, that all my media and static folders is in different place
that python files, so I set media, static and templates to different
place. Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT
and STATIC_ROOT not.

I try setup like this:

/home/domain/www/my_proj/ there is project folder and all apps, and
there I place my htdocs folder, in which is static, templates and
media folders.

When i set in STATIC_ROOT = '/home/domain/www/my_proj/htdocs/static'

In apache error log i got:

File does not exist: /home/domain/www/my_proj/my_proj/static

I don't get, why django don't want to take new setting...

I use django 1.4.


I think you need to set up Apache to serve the static and media files. 
Here is how mine works ...


 # lock the public out
 
  AllowOverride None
  Order deny,allow
  Deny from all
 

 # serve uploaded media from here
 
  AllowOverride None
  Order deny,allow
  Allow from all
 

 # serve static stuff from here
 
  AllowOverride None
  Order deny,allow
  Allow from all
 

 
  Alias /media/ /var/www/media/my_proj/
  Alias /static/ /var/www/static/my_proj/
  Alias /tiny_mce/ /var/www/static/my_proj/js/tiny_mce/
  Alias /jquery/ /var/www/static/my_proj/js/jquery/
 

Then in your template you can use {{ STATIC_URL }}/whatever

Hope this helps

Mike



Thanks.

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/fwNEyOLpFb4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Can't set static file directory.

2013-01-08 Thread joy
I have the same problem, the tutorial speaks about a list of things to do:

   - Push your code up to the deployment server.
   - On the server, run 
collectstaticto
 copy all the static files into 
   
STATIC_ROOT
   .
   - Point your web server at 
STATIC_ROOT
   .

I have arrived at the second point. But the static files are not served, i 
have set up the STATIC ROOT and the STATIC_URL, but what should i add to 
the template src tag to find the pages? The tutorial speaks about the 
template context processor, but it doesn't exist in my setting.py file.

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

i cannot make my css and javascript work, please, can you explain me what is 
happening behind the interface?
Agnese


Il giorno sabato 5 gennaio 2013 19:38:32 UTC+1, Mārtiņš Jakubovičs ha 
scritto:
>
> Hello.
>
> I try a lot of things and can't understand, why not working STATIC_ROOT 
> and MEDIA_ROOT in settings.py.
>
> I want, that all my media and static folders is in different place that 
> python files, so I set media, static and templates to different place. 
> Templates TEMPLATE_DIRS works well, bet MEDIA_ROOT and STATIC_ROOT not.
>
> I try setup like this:
>
> /home/domain/www/my_proj/ there is project folder and all apps, and there 
> I place my htdocs folder, in which is static, templates and media folders.
>
> When i set in STATIC_ROOT = '/home/domain/www/my_proj/htdocs/static'
>
> In apache error log i got:
>
> File does not exist: /home/domain/www/my_proj/my_proj/static
>
> I don't get, why django don't want to take new setting...
>
> I use django 1.4.
>
> Thanks.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/fwNEyOLpFb4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



image list

2013-01-08 Thread Randa Hisham
i have list of images
i send it and display as table in django template
i make user to change add delete images
how to save back this changes
-- 
Randa Hesham
Software Developer

Twitter:@ro0oraa 
FaceBook:Randa Hisham 

ٍ

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")

2013-01-08 Thread Diederik van der Boor
The hostname "localhost" has a special meaning for MySQL, at least on Linux it 
has.
When you ask the mysql driver to connect to localhost, it will use the socket.
To avoid this issue, better use 127.0.0.1.

Also check whether the MySQL server is running on that port (netstat -a ?),
whether the service is up (see services panel),
and whether your Windows Firewall allows connections to it.

Greetings,
Diederik

Op 6 jan. 2013, om 18:28 heeft Александр Соколов  
het volgende geschreven:

> Hi! Recently I had the same problem and this site has helped me: 
> http://stackoverflow.com/questions/11121819/mysqldb-in-python-cant-connect-to-mysql-server-on-localhost
> I've set the next properties:
> 'ENGINE': 'django.db.backends.mysql', 
> 'NAME': 'yourdbname',  
> 'USER': 'root',  
> 'PASSWORD': 'your password', 
> 'HOST': '127.0.0.1', 
> 'PORT': '3306', 
> 
> Hope, it will help you.
> 
> P.S. By the way in the beginning, I've installed the latest version of 
> MySQLdb. But this is unlikely has been causing of my problem.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/dFs9n5ZCuDEJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.