Saturday, March 29, 2014

Re: Allowed Hosts

Did you find any solution for this? I have the same problem.

Den söndagen den 7:e juli 2013 kl. 05:33:09 UTC+2 skrev deJa:
Hello, 
I'm developing an application with 1.6b1 and getting "ERROR: Invalid HTTP_HOST header: www.foo.com.'.You may need to add u'www.foo.com.' to ALLOWED_HOSTS. 

And I'm getting same error with my naked domain or server's IP address like '.You may need to add u'.foo.com.'  or '.You may need to add u'xxx.xxx.xxx.xxx'

The thing is all of these 3 hosts are already in allowed hosts in my settings file as 
ALLOWED_HOSTS = [u'.foo.com', u'www.foo.com', u'xxx.xxx.xxx.xxx'] 

In the mail body it only says "No stack trace available Request repr() unavailable."

So, is this a bug or do I have an error somewhere or do you need more data to get a conclusion?

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+unsubscribe@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/da777f59-7ae1-49b6-9677-b884a2883717%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

register for mIRC

Hi everyone,

I am new at python and I want to start to learn django.
I have small question, how can I register my ID to join #django in mIRC?

CS

--
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+unsubscribe@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/677c008b-7bfb-46cb-8185-4142f0883728%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ManytoManyField refuses to show up when I syncdb

when I syncdb and use south schemamigration, I still can't get the ManyToManyField to show up.
what am I doing wrong. Any parameters I can pass to make it work?

Thank you guys


class Products(models.Model):

    #product_id = models.AutoField(primary_key=True)
    hs_number = models.CharField(primary_key=True, max_length=6)
    product_description = models.ManyToManyField(Countries, through='Imports')

--
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+unsubscribe@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/e38457f8-0910-4de6-9039-ccf7915656a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Annotate concat() of two fields

Hi, I want to annotate the concatenation of two string fields, something like

Domain.objects.annotate(annotation=F('field1')+F('field2'))

however it is not possible to use F expressions on annotate().

I'm trying to accomplish the same thing using extra() however I don't
know how to do it right, :(

I have the following Domain model:

class Domain(models.Model):
name = models.CharField(max_length=256, unique=True)
top = models.ForeignKey('domains.Domain', null=True)

which top being a self referencing field,

I want an annotation with the concatenation of "obj.top.name + obj.name"

What I have so far is something like

Domain.objects.select_related('top').extra(select={
'structured_name': 'CONCAT(T2.name, domains_domain.name)'
})

Notice that I'm using T2 which is the JOIN table, But this doesn't
always work, because it depends on the total number of joins performed
by the queryset, (so the name changes to T4, etc)

What would be the right way of doing this concat() annotation?

thanks!!
--
Marc

--
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+unsubscribe@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/CA%2BDCN_v5zus5GXQ_KvdPthr5bRCS5xNwL4SVsK8eF8CiE2XUkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Nesting custom template tags

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:

<a class="myclass1 myclass2" style="mystyle1; mystyle2" href="URL">this is text between opening and closing tags</a>

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+unsubscribe@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/e3f4e619-0560-4f62-ad28-dd4775e2e3c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Friday, March 28, 2014

Re: settings set in stone on import?

Hi Erik,

hey, that worked! I had to reload both the django.conf and django.core.management modules, but after doing that calling Django management commands that depend on valid settings seems to work just fine. Thank you for the suggestion.

Before you replied I was contemplating just calling the call_command('startproject', ...) function in another process using multiprocessing. Maybe I'll try that just to see if it'd work, but I'll be sticking with reloading.

Cheers!

On Friday, March 28, 2014 2:43:56 PM UTC+1, Erik Cederstrand wrote:
Hello Tin,

Den 27/03/2014 kl. 22.45 skrev Tin Tvrtković <tinch...@gmail.com>:

> Is there a way to make Django reread DJANGO_SETTINGS_MODULE after it has been imported? Also, it would seem django.core.management.call_command doesn't take a 'settings' keyword argument, like django-admin.py does.

The standard Python built-in function reload() http://docs.python.org/2.7/library/functions.html#reload should be able to do this.

Erik

--
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+unsubscribe@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/a0a8eb3c-c607-4ea8-92c7-b79c29e9ac1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Database Error (SQLite) Database is locked

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   ??  S    Fri03PM   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+unsubscribe@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.