unique_together modifed after data is loaded

2013-08-27 Thread Subramanyam

Hi
 
Initially when we created the table we had two fields as unique_together = 
( 'field1',field2') and quite some data has been added with the same

Later we added one more field to unique_together = ( 
'field1',field2','field3')

how can I flush the old indexes created and add the new ones


Thanks
-Subramanyam


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


help required on how to modify constraints/indexes of unique_together after data is loaded

2013-08-27 Thread Subramanyam

Hi
 
Initially when we created the table we had two fields as unique_together = 
( 'field1',field2') and quite some data has been added with the same

Later we added one more field to unique_together = ( 
'field1',field2','field3')

how can I flush the old constraints/indexes created and add the new ones


Thanks
-Subramanyam

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


Implementation and maintainability of an app deployed multiple times in the same website

2013-08-27 Thread J . C . Leitão
Hi.

I'm using Django in a website and I need to use a given app in the website 
more than one time. I know this is kind of tricky to do in Django since 
there can be no name collisions.

*What I'm searching* is more or less equivalent to what stack exchange 
network does: a "framework" applied on specific topics. In my case I want 
this to be on the same website, for instance for *different topics*, or 
*different 
languages/communities* (in the sense that the app is translated differently 
*and* the users also add content in different languages/tables that *are 
not meant* to be translated/shared between communities). However, like in 
stack, I want most of the the server-side code and logic to be preserved 
(what I here call the framework).

Notice that each specific instance of the framework must be a Django's app 
since it needs specific tables.

*The problem* I'm already able to implement this, but the way I'm doing is 
not easily maintainable.

*The question:* I'm asking for help and general suggestions on the 
approach. Ultimately, I would like to know: is this because I'm having some 
bad design choice on web development in general, am I doing a bad design 
choice in Django in particular, or is this because Django was not prepared 
for this situation?

Next I explain how I did this, in the bottom I explain the maintainability 
issue.

Implementation

The idea is: I have a main app for controlling the website and its 
authentication (with a MainUser model with a one-to-one to the default 
user) and I attach apps.

The app I want to repeat on the website has a specific name appname(something 
that cannot possibly collide with any string), and a specific 
user (appname.User), a subclass of main.MainUser.

What I learn during this whole process:

One requirement for repeating an app is that every connection of itself to 
other app requires a custom related_name, as explained in django docs 
be-careful-with-related-name.
 
In my case, *so far* there is only one connection, the appname.User, that 
has a field of the form:
 
# this is because a copy of this app would make mainuser.user to clash
mainuser_ptr = models.OneToOneField(MainUser, 
related_name="%(app_label)s_%(class)s", parent_link=True)

The next requirement is avoiding url collisions: I use names for every url 
and I prefixed them with appname_.

The next requirement is static and templates. They are set to be of the 
form static/appname/ and equivalent to templates.

Given these requirements, I can repeat the app by doing the following magic:

1. I make a copy of the app's directory.
2. Change its name to the new app's name, newappname, and every directory 
herein from appname to newappname (e.g. static,templates).
3. For every string in the app's directory, I substitute the appname with 
newappname.
4. I run ./manage.py syncdb (if it was the first time the app was created, 
or use south to migrate the tables, since the migrations are already made).

I can then change templates, static and translations for the new app (in 
templates/, static/, locale/ respectively).

Maintainability

If I want to implement a new feature in the framework (a feature that is 
new to all apps), I have to implement it on one app and then re-deploy it 
on every app. That or code the implementation on each app. As you might 
understand, this is not efficient: by design this is code difficult to 
maintain (e.g. the version control will have lots of changes that are only 
due to copy/paste).

So, bottom line, I have a copy of the same framework with different names. 
I made this choice because I needed the same logic with different databases 
and static content (static, translations). It seems to me that I'm 
searching for an Abstract app, in the same spirit of an Abstract model. 
However, I'm not sure this even makes sense, either in Django or in Web 
development in general.

Thank you for your time,
Jorge

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


Re: Passing variables to css file in django

2013-08-27 Thread Giulio Calacoci

May I suggest to save user defined css to a file saved in a specific path?

for example if user John_Doe submits a customized css, save it in 
//css/users/john_doe/override.css


then in the head of the html file load the user defined css always after 
the default one.


this way is always static, and the result is cleaner than any 

Re: DecimalField

2013-08-27 Thread Derrick Jackson
Thanks Tom.  I actually tried that at one point and this is the error I 
received:  not all arguments converted during string formatting.

The required and invalid error message keys work fine but it appears the 
max_decimal_places key is being ignored. Has anyone seen this before?  BTW, 
I am using Django 1.5.2 

On Sunday, August 25, 2013 5:47:00 AM UTC-4, Derrick Jackson wrote:
>
> Hi All,
>
> My Model has a DecimalField:  
>
> amount = models.DecimalField(max_digits=19, decimal_places=2, 
> verbose_name='Amount')
>
> My ModelForm has the following:  
>
> self.fields['amount'] = forms.DecimalField(error_messages={
> 'required': 'Amount is required.',
> 'invalid': 'Numbers only.',
> 'max_decimal_places': 'Only 2 decimal places.'})
>
> However the max_decimal_places validation check does not seem to be 
> working.  Is there a certain way I need to use this that will properly 
> allow the error to be thrown?
>  

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


Re: Django + Bamboo

2013-08-27 Thread Germán
Daniel, any luck with Bamboo?

On Friday, April 19, 2013 3:25:52 AM UTC-3, daniel.franca wrote:
>
> Anyone has any experience configuring Django with Bamboo for deployment 
> and tests?
> I'm trying to setup an environment, but there's not much about how to make 
> this work.
>
> What's is the best approach? cloud or local server?
> Is it better to work with simple bash scripts or you recommend some other 
> tools?
>
>
> Best,
> -- 
> Daniel França,
> about.me/danielfranca
>  

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


Re: Implementation and maintainability of an app deployed multiple times in the same website

2013-08-27 Thread C. Kirby
Can each of the different requirements websites be on a different 
third-level or subdomain? (If your site is foo.com either bar.foo.com, 
baz.foo.com or foo.com/bar, foo.com/baz_
If so, I would deploy multiple Apache VirtualHosts, each serving an 
instance of your project. That way the projects can be identical, you have 
a single codebase to work from, and your different requirements can be 
handled  in each projects settings.py.

Would this work?


On Tuesday, August 27, 2013 4:20:29 AM UTC-5, J. C. Leitão wrote:
>
> Hi.
>
> I'm using Django in a website and I need to use a given app in the website 
> more than one time. I know this is kind of tricky to do in Django since 
> there can be no name collisions.
>
> *What I'm searching* is more or less equivalent to what stack exchange 
> network does: a "framework" applied on specific topics. In my case I want 
> this to be on the same website, for instance for *different topics*, or 
> *different 
> languages/communities* (in the sense that the app is translated 
> differently *and* the users also add content in different 
> languages/tables that *are not meant* to be translated/shared between 
> communities). However, like in stack, I want most of the the server-side 
> code and logic to be preserved (what I here call the framework).
>
> Notice that each specific instance of the framework must be a Django's app 
> since it needs specific tables.
>
> *The problem* I'm already able to implement this, but the way I'm doing 
> is not easily maintainable.
>
> *The question:* I'm asking for help and general suggestions on the 
> approach. Ultimately, I would like to know: is this because I'm having some 
> bad design choice on web development in general, am I doing a bad design 
> choice in Django in particular, or is this because Django was not prepared 
> for this situation?
>
> Next I explain how I did this, in the bottom I explain the maintainability 
> issue.
>
> Implementation
>
> The idea is: I have a main app for controlling the website and its 
> authentication (with a MainUser model with a one-to-one to the default 
> user) and I attach apps.
>
> The app I want to repeat on the website has a specific name appname(something 
> that cannot possibly collide with any string), and a specific 
> user (appname.User), a subclass of main.MainUser.
>
> What I learn during this whole process:
>
> One requirement for repeating an app is that every connection of itself to 
> other app requires a custom related_name, as explained in django docs 
> be-careful-with-related-name.
>  
> In my case, *so far* there is only one connection, the appname.User, that 
> has a field of the form:
>  
> # this is because a copy of this app would make mainuser.user to clash
> mainuser_ptr = models.OneToOneField(MainUser, 
> related_name="%(app_label)s_%(class)s", parent_link=True)
>
> The next requirement is avoiding url collisions: I use names for every url 
> and I prefixed them with appname_.
>
> The next requirement is static and templates. They are set to be of the 
> form static/appname/ and equivalent to templates.
>
> Given these requirements, I can repeat the app by doing the following 
> magic:
>
> 1. I make a copy of the app's directory.
> 2. Change its name to the new app's name, newappname, and every directory 
> herein from appname to newappname (e.g. static,templates).
> 3. For every string in the app's directory, I substitute the appname with 
> newappname.
> 4. I run ./manage.py syncdb (if it was the first time the app was created, 
> or use south to migrate the tables, since the migrations are already made).
>
> I can then change templates, static and translations for the new app (in 
> templates/, static/, locale/ respectively).
>
> Maintainability
>
> If I want to implement a new feature in the framework (a feature that is 
> new to all apps), I have to implement it on one app and then re-deploy it 
> on every app. That or code the implementation on each app. As you might 
> understand, this is not efficient: by design this is code difficult to 
> maintain (e.g. the version control will have lots of changes that are only 
> due to copy/paste).
>
> So, bottom line, I have a copy of the same framework with different names. 
> I made this choice because I needed the same logic with different databases 
> and static content (static, translations). It seems to me that I'm 
> searching for an Abstract app, in the same spirit of an Abstract model. 
> However, I'm not sure this even makes sense, either in Django or in Web 
> development in general.
>
> Thank you for your time,
> Jorge
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit 

Problems using django 1.6.x and uwsgi

2013-08-27 Thread Rafael Reuber

I'm working on a project that needs a feature that it's only available on 
the 1.6.x version. But I'm having problems when I run it using uswgi. 
Apparently it could be a bug on 1.6.x because when I run the project using 
1.5.x the error doesn't appear.

uwsgi --http :8000 --wsgi-file drover/wsgi.py


*** Starting uWSGI 1.9.14 (64bit) on [Tue Aug 27 13:00:10 2013] ***
compiled with version: 4.7.3 on 23 August 2013 13:35:22
os: Linux-3.8.0-29-generic #42-Ubuntu SMP Tue Aug 13 19:40:39 UTC 2013
nodename: s0120704
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/u30941/drover
detected binary path: /usr/local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 7811
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 2362)
uwsgi socket 0 bound to TCP address 127.0.0.1:56867 (port auto-assigned) fd 
3
Python version: 2.7.4 (default, Apr 19 2013, 18:30:41)  [GCC 4.7.3]
*** Python threads support is disabled. You can enable it with 
--enable-threads ***
Python main interpreter initialized at 0x11dc180
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72776 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
  File "drover/wsgi.py", line 27, in 
from django.core.wsgi import get_wsgi_application
  File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 
1, in 
from django.core.handlers.wsgi import WSGIHandler
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 
11, in 
from django.core.handlers import base
  File 
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 
12, in 
from django.db import connections, transaction
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 
83, in 
signals.request_started.connect(reset_queries)
  File 
"/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", 
line 88, in connect
if settings.DEBUG:
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", 
line 54, in __getattr__
self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", 
line 49, in _setup
self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", 
line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'drover.settings' (Is it on 
sys.path? Is there an import error in the settings file?): cannot import 
name BaseHandler
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 2361, cores: 1)

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


Re: Script to move django 1.4.3 to 1.5.1

2013-08-27 Thread Harjot Mann


On Thursday, June 20, 2013 8:55:07 AM UTC+5:30, Deepak Sharma wrote:
>
> Okay but my situation is bit different. I am updating my university 
> software. That software is wrote in django version 1.3.1. My challenge was 
> to run that software on 1.5.1 and i completed that. As many things changed 
> in django 1.5.1 like < direct_to_template > changed to  < TemplateView> and 
> few more. So my next target is that, that i make one script ( shell script 
> ) so that i give command in terminal like $ sudo apt-get install  and 
> it install. Shifting from 1.3 to 1.5.1 is it possible? If yes than how? 
>
> If i want to run my software which is currently running on 1.5.1 with 
> command in terminal i.e i write $ sudo apt-get install mysoftware and it 
> install. I don't want to install it manually. How i do that process with 
> shell script? 
>

  I also want to shift my app from django version 1.4.5 to 1.5.1. You are 
right there should be some script which automatically upgrades the version 
without affecting the application. Right now I upgraded to 1.5.1 but I ma 
getting Internal server error in my app. Dont have any idea what to do?
Can you tell me how the urls should be like in this version?

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


Re: Script to move django 1.4.3 to 1.5.1

2013-08-27 Thread Sithembewena Lloyd Dube
Error analysis + reading documentation = solution. Well, most of the time
anyway. For help with errors, please share the errors?



On Tue, Aug 27, 2013 at 7:37 PM, Harjot Mann wrote:

>
>
> On Thursday, June 20, 2013 8:55:07 AM UTC+5:30, Deepak Sharma wrote:
>>
>> Okay but my situation is bit different. I am updating my university
>> software. That software is wrote in django version 1.3.1. My challenge was
>> to run that software on 1.5.1 and i completed that. As many things changed
>> in django 1.5.1 like < direct_to_template > changed to  < TemplateView> and
>> few more. So my next target is that, that i make one script ( shell script
>> ) so that i give command in terminal like $ sudo apt-get install  and
>> it install. Shifting from 1.3 to 1.5.1 is it possible? If yes than how?
>>
>> If i want to run my software which is currently running on 1.5.1 with
>> command in terminal i.e i write $ sudo apt-get install mysoftware and it
>> install. I don't want to install it manually. How i do that process with
>> shell script?
>>
>
>   I also want to shift my app from django version 1.4.5 to 1.5.1. You are
> right there should be some script which automatically upgrades the version
> without affecting the application. Right now I upgraded to 1.5.1 but I ma
> getting Internal server error in my app. Dont have any idea what to do?
> Can you tell me how the urls should be like in this version?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Regards,
Sithu Lloyd Dube

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


Django Sites set current domain to site_id

2013-08-27 Thread Gerd Koetje
Hi all,

I got a django application that is called by difrant domains for the same 
code (some minor changes for each domain)


When i visit my application trough domain1.com or domain2.com its keep 
outputting data from the set site_id in settings
How can i change the site_id based on the incomming domain


so if i visit trough domain1.com it should set the site_id to  the id of 
domein1.com in the database , not the set site_id in settings.


How do i do this?

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


Django: How to combine 3-party apps!

2013-08-27 Thread alekto . antarctica
Hello!
I am quite new to django. I have been creating a virtualenv project, where 
I have have installed the Zinnia-blog  
following 
the instructions on their web page.
The directory structure on my project is like this:
*├── design*
*├── django_project*
*│   ├── admin*
*│   ├── django_project*
*├── __init__.py*
*├── __init__.pyc*
*├── settings.py*
*├── settings.pyc
*
*├── urls.py*
*├── urls.pyc
*
*├── wsgi.py*
*└── wsgi.pyc*

*│   ├── fabfile.py*
*│   ├── fabfile.py~*
*│   ├── fabfile.pyc*
*│   ├── manage.py*
*│   ├── media*
*│   ├── myapp*
*│   ├── slav0nic-djangobb_project-9e331fc82d25 ├── basic_project*
*│  ├── 
djangobb_index*
*│  ├── 
forms.py*
*│  ├── 
__init__.py*
*│  ├── 
local_settings.py*
*│  ├── 
manage.py*
*│  ├── 
media*
*│  ├── 
settings.py*
*│  ├── 
sitemap.py*
*│  ├── 
static*
*│  ├── 
templates*
*│  └── 
urls.py*
*└── requirements.txt*
*
*
**
*│   ├── south*
*│   ├── statics*
*│   ├── templates*
*│   ├── tip.tar.gz*
*│   ├── uploads*
*│   └── zinnia├── config.rb*
*  ├── css*
*  ├── img*
*  ├── js*
*  └── sass*
*
*
*├── docs*
*│   ├── command_reference*
*│   ├── command_reference~*
*│   └── troubleshooting*
*├── README.rst*
*├── README.rst~*
*└── requirements.txt*
*
*

So the zinnia blog, is working as expected, while the DjangoBB forum is not 
working at all when trying to brows for the localhost/forum path!
Whats confuses me is the fact that the DjangoBB forum directory (*
slav0nic-djangobb_project-9e331fc82d25*) contains it's own settings.py and 
urls.py.
I already have these configurations files in my overall django project. Is 
there some way to combine these settings together in the main project 
configuration?
*
*
And I also wonder what is the difference between install an app like 
zinnia, using pip and then adding zinnia to the main settings.py 
under INSTALLED_APPS.
And installing it like this as I did for djangoBB:

 wget https://bitbucket.org/slav0nic/djangobb_project/get/tip.tar.gz
 tar zxvf tip.tar.gz
 cd slav0nic-djangobb_project-tip/
 pip install -r requirements.txt
 cd basic_project/
 touch local_settings.py
 # set DATABASE ./manage.py syncdb --all
 ./manage.py collectstatic 

 ./manage.py runserver*  *
*
*
I will be happy for all hint/tips etc. on how to glue together 2-part apps 
on a project.
Thanks in advance for your help!

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


django 2 tables one query?

2013-08-27 Thread piasek piasek
Hi 

I was wondering is it possible to get information about two tables in one 
query?
I have two models 
Team (id, name, active, country) and Player (id, first_name, second_name, 
active, team)
where Player.team = ForeignKey(Team)
Of course one team may have several players and one player have one team.

Is it possible to get only one, random, player of each team?
for db i use mysql

best regards
slawek

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


Re: Django Sites set current domain to site_id

2013-08-27 Thread Mike Dewhirst

On 28/08/2013 4:01am, Gerd Koetje wrote:

Hi all,

I got a django application that is called by difrant domains for the
same code (some minor changes for each domain)


When i visit my application trough domain1.com or domain2.com its keep
outputting data from the set site_id in settings
How can i change the site_id based on the incomming domain


so if i visit trough domain1.com it should set the site_id to  the id of
domein1.com in the database , not the set site_id in settings.


How do i do this?


You need to have all the various domains listed in the sites table and 
after importing Site from django.contrib.sites.models you can return 
Site.objects.get_current() for use in your responses.


I only have three sites dev, staging and production and use settings.py 
on the three machines to set the site. You will need to detect which 
site is making the the request and establish the site_id from there.


hth



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


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


Re: Django Sites set current domain to site_id

2013-08-27 Thread Mike Dewhirst

On 28/08/2013 9:08am, Mike Dewhirst wrote:

On 28/08/2013 4:01am, Gerd Koetje wrote:

Hi all,

I got a django application that is called by difrant domains for the
same code (some minor changes for each domain)


When i visit my application trough domain1.com or domain2.com its keep
outputting data from the set site_id in settings
How can i change the site_id based on the incomming domain


so if i visit trough domain1.com it should set the site_id to  the id of
domein1.com in the database , not the set site_id in settings.


How do i do this?


You need to have all the various domains listed in the sites table and
after importing Site from django.contrib.sites.models you can return
Site.objects.get_current() for use in your responses.

I only have three sites dev, staging and production and use settings.py
on the three machines to set the site. You will need to detect which
site is making the the request and establish the site_id from there.


I know what I meant despite what I said. You will have to detect the 
domain from the url in the request and get the site_id from that then 
pass that in so your response uses the correct domain.




hth



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





--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9787 6598
M: 0411 704 143


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