how to descript the many to one relationship in model when there are more than 1 tables

2015-08-06 Thread Holland_zwz
Sometimes table have more than one foreign key reference to other tables. 
Then how to descript it in model?

For eg:

Table A:
create table A (
   oid  varchar(10)  not null,
   pid  varchar(10)  not null,
   color   varchar(20)  null
)
alter table A add constraint A_PK primary key (oid)

Table B:
create table B(
   oid  varchar(10) not null,
   pid  varchar(10) not null,
   name  varchar(100)null
)
alter table B add constraint B_PK primary key (oid)

Table C:
create table  C (
   id   varchar(10)  null,
   cid  varchar(10)  null,
   oid  varchar(10)  null
)

alter table  C add constraint C_FK1 foreign key (oid) references A(oid)
alter table C add constraint C_FK2 foreign key (oid)  references B(oid)


in this case, how to descript it in model?

class ModelA(models.Model):
  oid = models.CharField(max_length=10,primary_key=True)
  ...

class ModelB(models.Model):
  oid = models.CharField(max_length=10,primary_key=True)
  ...

class ModelC(models.Model):
  oid = models.ForeignKey(...) ?



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b1318e7-87b4-49b2-aad2-3a1dff41fa7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to descript the many to one relationship in model when there are more than 1 tables

2015-08-06 Thread James Schneider
You are probably looking for a many-to-many relationship using an
intermediary table:

https://docs.djangoproject.com/en/1.8/topics/db/models/#intermediary-manytomany

-James
On Aug 6, 2015 3:06 AM, "Holland_zwz"  wrote:

> Sometimes table have more than one foreign key reference to other tables.
> Then how to descript it in model?
>
> For eg:
>
> Table A:
> create table A (
>oid  varchar(10)  not null,
>pid  varchar(10)  not null,
>color   varchar(20)  null
> )
> alter table A add constraint A_PK primary key (oid)
>
> Table B:
> create table B(
>oid  varchar(10) not null,
>pid  varchar(10) not null,
>name  varchar(100)null
> )
> alter table B add constraint B_PK primary key (oid)
>
> Table C:
> create table  C (
>id   varchar(10)  null,
>cid  varchar(10)  null,
>oid  varchar(10)  null
> )
>
> alter table  C add constraint C_FK1 foreign key (oid) references A(oid)
> alter table C add constraint C_FK2 foreign key (oid)  references B(oid)
>
>
> in this case, how to descript it in model?
>
> class ModelA(models.Model):
>   oid = models.CharField(max_length=10,primary_key=True)
>   ...
>
> class ModelB(models.Model):
>   oid = models.CharField(max_length=10,primary_key=True)
>   ...
>
> class ModelC(models.Model):
>   oid = models.ForeignKey(...) ?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9b1318e7-87b4-49b2-aad2-3a1dff41fa7f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Speedy Mail Software

2015-08-06 Thread Uri Even-Chen
Hi Abdulhakim,

I'm sorry that only now I saw your message. You are welcome to contribute
to Speedy Mail Software. I only use Sourceforge to find more developers, I
think I prefer to use Github for Git. If you have any questions, contact me
at u...@speedy.net

Thanks,
Uri.

*Uri Even-Chen*   [image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    
> Speedypedia in Hebrew and English


On Sat, Aug 1, 2015 at 4:20 PM, Abdulhakim Haliru 
wrote:

> Interesting. I have once contemplated building a webmail software that
> reads emails so customers don't lose emails upon switching webhosts. Hence,
> your Speedy Mail Software interests me. I'd love to be a part of the team.
>
> Great idea it's.
>
> Regards.
> Abdulhakim
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1eb6823e-387d-4731-9e98-9550dc55300c%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Speedy Mail Software

2015-08-06 Thread Uri Even-Chen
Hi Stuart,

Are you interested in participating in writing code for Speedy Mail
Software? And thanks for the link to pyjs, I was not aware of this libraby.
So I guess we can just use it and we don't have to create it. I want to use
pyjs also for Speedy Mail Software. Please let me know if you can
participate in Speedy Mail Software.

Thanks,
Uri.

*Uri Even-Chen*   [image: photo] Phone: +972-54-3995700
Email: u...@speedy.net
Website: http://www.speedysoftware.com/uri/en/
  
    
> Speedypedia in Hebrew and English


On Sun, Aug 2, 2015 at 11:29 AM, Stuart Longland <
stua...@longlandclan.yi.org> wrote:

> On 01/08/15 22:56, Uri Even-Chen wrote:
> > I'm interested in creating a new webmail platform based on Python and
> > Django (with jQuery and JavaScript), which will be free software & open
> > source - Speedy Mail Software. I created a project called Speedy Mail
> > Software  on
> > sourceforge, and I'm looking for people who will participate in writing
> > code for this project. I renamed the project to Speedy Mail Software
> > because Speedy Mail will be the webmail itself, based on Speedy Mail
> > Software but with a domain and a mail server(s), so people will able to
> > create an account there and use the mail services of the website. I'm
> > also trying to convince computer science students from the college I
> > graduated (The academic college of Tel Aviv - Yaffo) to participate in
> > this project.
>
> Well, there are lots of webmail systems out there today, from classical
> ones like SqurrelMail and Horde to more modern ones like RoundCube.
>
> One possibility that might be interesting to explore, and could perhaps
> make a JavaScript front-end easier to develop would be to expose the
> email via a WebDAV-based interface, much as we have CalDAV and CardDAV
> for calendaring and contacts, you'd have "MailDAV" which would
> facilitate IMAP-like functionality over WebDAV.
>
> I think a similar scheme is used with Outlook Web Access, although you
> probably want to avoid the insanity that is MAPI, the email should be
> stored in the form it was received.  I've seen what happens when mail
> systems try to be "clever": Zarafa is one such system and it's a hideous
> mess.
>
> > I also have another idea - I want to create a Python Web Toolkit, which
> > will be similar to Google Web Toolkit - people will write code in
> > Python, and it will run on the server side, and on the client side with
> > JavaScript (it will compile Python code to JavaScript, like Google Web
> > Toolkit from Java to JavaScript).
>
> That sounds an awful lot like the Pyjamas (now called PyJS) framework.
> http://pyjs.org/
> --
> Stuart Longland (aka Redhatter, VK4MSL)
>
> I haven't lost my mind...
>   ...it's backed up on a tape somewhere.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/55BDD4E3.7060801%40longlandclan.yi.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: how to descript the many to one relationship in model when there are more than 1 tables

2015-08-06 Thread Holland_zwz
Hi James,
   Thanks for reply. 

   But i am not got the main point. The problem is the table C's oid column 
data comes from  A or  B.  I think this is not same as many-to-many 
relationships.

Thanks
-hollandz


在 2015年8月6日星期四 UTC+8下午6:14:25,James Schneider写道:
>
> You are probably looking for a many-to-many relationship using an 
> intermediary table:
>
>
> https://docs.djangoproject.com/en/1.8/topics/db/models/#intermediary-manytomany
>
> -James
> On Aug 6, 2015 3:06 AM, "Holland_zwz" > 
> wrote:
>
>> Sometimes table have more than one foreign key reference to other tables. 
>> Then how to descript it in model?
>>
>> For eg:
>>
>> Table A:
>> create table A (
>>oid  varchar(10)  not null,
>>pid  varchar(10)  not null,
>>color   varchar(20)  null
>> )
>> alter table A add constraint A_PK primary key (oid)
>>
>> Table B:
>> create table B(
>>oid  varchar(10) not null,
>>pid  varchar(10) not null,
>>name  varchar(100)null
>> )
>> alter table B add constraint B_PK primary key (oid)
>>
>> Table C:
>> create table  C (
>>id   varchar(10)  null,
>>cid  varchar(10)  null,
>>oid  varchar(10)  null
>> )
>>
>> alter table  C add constraint C_FK1 foreign key (oid) references A(oid)
>> alter table C add constraint C_FK2 foreign key (oid)  references B(oid)
>>
>>
>> in this case, how to descript it in model?
>>
>> class ModelA(models.Model):
>>   oid = models.CharField(max_length=10,primary_key=True)
>>   ...
>>
>> class ModelB(models.Model):
>>   oid = models.CharField(max_length=10,primary_key=True)
>>   ...
>>
>> class ModelC(models.Model):
>>   oid = models.ForeignKey(...) ?
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9b1318e7-87b4-49b2-aad2-3a1dff41fa7f%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


Re: how to descript the many to one relationship in model when there are more than 1 tables

2015-08-06 Thread Javier Guerra Giraldez
On Thu, Aug 6, 2015 at 8:18 AM, Holland_zwz  wrote:
> But i am not got the main point. The problem is the table C's oid column
> data comes from  A or  B.


I don't think SQL works that way.  at least, it's very much against
any normalization guideline.

-- 
Javier

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


PULPO-FORMS: A DJANGO’S DYNAMIC FORM BUILDER

2015-08-06 Thread Luciano Ferrari
Hi Everyone,

as some of you may already know, last week we release a new open source 
tool.

Here is the link to that introduction post:

https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/django-users/9DsIk9w7FGY

Today I announce the release of a new post with more details about this new 
open source tool.

Here is the link to the post in our 
blog: http://blog.octobot.io/pulpo-forms-a-djangos-dynamic-form-builder/

Let me know if you have any questions or improvements suggestions.

Luciano

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6b687d00-9cc6-406e-805b-a45ef9337e57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Issue when rendering manually a form's HiddenInput

2015-08-06 Thread durirompepc
So, I'm trying to use inputs with the *hidden* attr. I have my form class (
*IndexForm*) that has this:
field = HiddenInput()
Then, I pass the instance of IndexForm (*index_form*) to the template, and 
manually render the field (*index_form.field*). It is alright, but then, in 
the HTML, the render of the field is this...

Why I'm seeing the str representation of the object, and not an HTML hidden 
input?

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


Invalid syntax in url.py

2015-08-06 Thread Matthew Yankey


this is the url.py


from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^', .newsletter.views.home, name="home")  => this is the 
line 20
#   url(r'^admin/', include(admin.site.urls)),



error below


Exception Type: SyntaxError at /
Exception Value: invalid syntax (urls.py, line 20)





Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.8.3
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')


Traceback:
File 
"C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\handlers\base.py" 
in get_response
  119. resolver_match = resolver.resolve(request.path_info)
File 
"C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\urlresolvers.py" in 
resolve
  366. for pattern in self.url_patterns:
File 
"C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\urlresolvers.py" in 
url_patterns
  402. patterns = getattr(self.urlconf_module, "urlpatterns", 
self.urlconf_module)
File 
"C:\Users\matt\Desktop\mysite\lib\site-packages\django\core\urlresolvers.py" in 
urlconf_module
  396. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\Lib\importlib\__init__.py" in import_module
  37. __import__(name)






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


Adding a sidebar to the admin

2015-08-06 Thread 'Hugo Osvaldo Barrera' via Django users
I'd like to add a sidebar on the left side of all admin pages (including
change_list, change_details, etc), with a list of all my models. In
other words, I'd like to move the index with a list of models into a
sidebar on the left.

After poking around the docs and templates a bit, it seems that I'd need
to override templates/admin/base.html entirely (which I'd rather avoid
for easier maintenence), or work with some CSS hacks (to make content
narrower, and move sidebar up and on the left.

Have I missed something? What would the recomended approach be? Has
anybody done something alike?

Cheers!

-- 
Hugo Osvaldo Barrera

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


Re: auto_created getting ignored by makemigrations

2015-08-06 Thread zubair alam
Hi Joey.

I was trying to understand your models, relationship and logic behind them.

How you are supposed to create a League object? 
I tried creating as follows.
p=Player.objects.create(name='Shahid Afridi')
l=League(name='FootballDevils')
l.save() // not calling directly objects.create on League as you're 
checking some boolean in its save method.

and as i expected, it says that you have to create League object via 
LeaguePlayer intermediary Model, but in LeaguePlayer model you need to pass 
a League object first.

This might clear what i'm trying to say 
https://docs.djangoproject.com/en/1.8/topics/db/models/#extra-fields-on-many-to-many-relationships

I will suggest you to not override save method in League model as you want 
an Intermediary table as well and Django doesn't let you use add method, 
rather use post_save signal on League object save event and attach all 
available player objects to newly created league via LeaguePlayer.

I've created a pastebin here for the same. http://paste.ubuntu.com/12015824/

Zubair Alam


On Thursday, August 6, 2015 at 8:47:09 AM UTC+5:30, JoeLinux wrote:
>
> Dear Anyone,
>
> I'm having an issue with a ManyToMany "through" table not being recognized 
> by the makemigrations command. Please consider the model definitions at the 
> following pastebin: http://pastebin.ubuntu.com/12011412/
>
> So, I have a Player model. Players are stored and updated in that model 
> (also for clarification, the Player model is in a separate app because it's 
> used for other purposes). The League model, when created, makes available 
> all of the Player objects in the DB for drafting to a LeagueTeam. That's 
> why there's a "through" table for LeaguePlayer, since I don't want to 
> affect the original Player object, and I want to add the additional 
> information as to what LeagueTeam the LeaguePlayer got drafted to (think 
> fantasy football).
>
> However, I'm getting errors in the console about the draft_leagueplayer 
> (the relevant app's name is "draft") table not existing, and I noticed it's 
> not getting created in the db. After a little digging, I realized that 
> ultimately the django.apps.config module's AppConfig.get_models() method is 
> set to ignore any apps with "auto_created = True" by default, thus ignoring 
> LeaguePlayer. If you look at the pastebin above, I am adding Player objects 
> to the League as soon as it's created, and the "auto_created = True" meta 
> attribute helps me do that easily.
>
> I'm wondering if there is a way around this. I need extra information in 
> this Many-to-Many relationship (the team the player is drafted to), and I'm 
> surprised the auto_created attribute exists and doesn't seem to work (since 
> the migration ignores the model). Is this a bug, or should I be manually 
> creating LeaguePlayer objects on-the-fly when adding to the League object 
> instead of using auto_created? Am I misusing auto_created?
>  
> Joey "JoeLinux" Espinosa
> about.me/joelinux
> [image: Joey "JoeLinux" Espinosa on about.me]
>   
>
>

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


Re: Invalid syntax in url.py

2015-08-06 Thread Javier Guerra Giraldez
On Thu, Aug 6, 2015 at 2:03 PM, Matthew Yankey  wrote:
> url(r'^', .newsletter.views.home, name="home")

.newsletter  looks like import syntax, but this isn't valid in an expression

at the top include a line like

from .newsletter.views import home

and then the url entry becomes

url(r'^', home, name="home"),


-- 
Javier

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


Re: Adding a sidebar to the admin

2015-08-06 Thread Бранко Мајић
Дана Thu, 06 Aug 2015 16:39:41 -0300
"'Hugo Osvaldo Barrera' via Django users"
 написа:

> I'd like to add a sidebar on the left side of all admin pages
> (including change_list, change_details, etc), with a list of all my
> models. In other words, I'd like to move the index with a list of
> models into a sidebar on the left.
> 
> After poking around the docs and templates a bit, it seems that I'd
> need to override templates/admin/base.html entirely (which I'd rather
> avoid for easier maintenence), or work with some CSS hacks (to make
> content narrower, and move sidebar up and on the left.
> 
> Have I missed something? What would the recomended approach be? Has
> anybody done something alike?
> 
> Cheers!
> 

This may not help you completely (and I have not had a look at admin's
base.html, truth be told), but there is small convenient Django
application called django-apptemplates
(https://pypi.python.org/pypi/django-apptemplates/).

The application adds a template tag that allows you to both override
and extend one of the existing templates. So perhaps you would still
need to duplicate _some_ part of base.html, but with perhaps you would
bring it to a minimum.

Best regards

-- 
Branko Majic
Jabber: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
Џабер: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.

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


What Did I Do Right? (url and domain name change)

2015-08-06 Thread Malik Rumi
I have 1 model from my django project up and running on django. Before 
adding more models and content, I wanted to use my actual domain name, 
instead of whatever.herokuapp.com. So after I got that straight, I realized 
that while the home page was mysite.com, the links were still 
mystite.herokuapp.com, which I think is a problem. But I also thought there 
had to be an easy fix for this, especially after I saw a post while I was 
searching for solutions that said django only cares about the stuff that 
comes *after* the domain name. So the first thing I did was change a 
hardcoded link in my navbar from mysite.herokuapp/newpage to mysite/newpage 
in my dev site. But testing it the url still said 
mysite.herokuapp.com/newpage. Then I got an idea, and I just manually 
changed the url to mysite/newpage and what do you know, it came up 
correctly. then I clicked around and suddenly all the pages on my model are 
coming up that way, which they were not half an hour ago. So the question: 
What did I do right?

Here are my working theories:

1. The dns change, which I also did half an hour ago, worked for the home 
page immediately (I tested it at the time) but needed to propagate more for 
the other pages to work, which they do now.

2. By changing the url manually, django just fed the pages as requested 
without concern about the domain part of the url. If I start from 
mysite.herokuapp.com home page, the links still come up with that domain 
name.

But how do I make this both universal and permanent?

A. I could change allowed hosts setting, taking the herokuapp part out

B. Do nothing, it works now and I should leave well enough alone.

C. ? Your answer here ...


Thanks

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


Re: auto_created getting ignored by makemigrations

2015-08-06 Thread Joey Espinosa
@zubair: The reason Django complained about wanting to create the
LeaguePlayer intermediary model when you used "add()" is because you didn't
have auto_created=True. That allows Django to link the objects correctly
via the intermediary model automatically without populating any of the
extra fields in the relationship. That's *exactly* what I want, since I
don't need to populate "drafted_to" at all until later in the application.
I'm just really wondering why auto_created is available as an option if
Django is just going to skip that model when creating tables. I'm trying to
question whether this is a bug, because I figured if Django is going to
give me a straightforward and concise way to do what I want, then I'd
rather do that instead of having to resort to more complex solutions. The
relationship doesn't work at all if I use auto_created.

On Thu, Aug 6, 2015 at 4:05 PM zubair alam 
wrote:

> Hi Joey.
>
> I was trying to understand your models, relationship and logic behind them.
>
> How you are supposed to create a League object?
> I tried creating as follows.
> p=Player.objects.create(name='Shahid Afridi')
> l=League(name='FootballDevils')
> l.save() // not calling directly objects.create on League as you're
> checking some boolean in its save method.
>
> and as i expected, it says that you have to create League object via
> LeaguePlayer intermediary Model, but in LeaguePlayer model you need to pass
> a League object first.
>
> This might clear what i'm trying to say
> https://docs.djangoproject.com/en/1.8/topics/db/models/#extra-fields-on-many-to-many-relationships
>
> I will suggest you to not override save method in League model as you want
> an Intermediary table as well and Django doesn't let you use add method,
> rather use post_save signal on League object save event and attach all
> available player objects to newly created league via LeaguePlayer.
>
> I've created a pastebin here for the same.
> http://paste.ubuntu.com/12015824/
>
> Zubair Alam
>
>
> On Thursday, August 6, 2015 at 8:47:09 AM UTC+5:30, JoeLinux wrote:
>>
>> Dear Anyone,
>>
>> I'm having an issue with a ManyToMany "through" table not being
>> recognized by the makemigrations command. Please consider the model
>> definitions at the following pastebin:
>> http://pastebin.ubuntu.com/12011412/
>>
>> So, I have a Player model. Players are stored and updated in that model
>> (also for clarification, the Player model is in a separate app because it's
>> used for other purposes). The League model, when created, makes available
>> all of the Player objects in the DB for drafting to a LeagueTeam. That's
>> why there's a "through" table for LeaguePlayer, since I don't want to
>> affect the original Player object, and I want to add the additional
>> information as to what LeagueTeam the LeaguePlayer got drafted to (think
>> fantasy football).
>>
>> However, I'm getting errors in the console about the draft_leagueplayer
>> (the relevant app's name is "draft") table not existing, and I noticed it's
>> not getting created in the db. After a little digging, I realized that
>> ultimately the django.apps.config module's AppConfig.get_models() method is
>> set to ignore any apps with "auto_created = True" by default, thus ignoring
>> LeaguePlayer. If you look at the pastebin above, I am adding Player objects
>> to the League as soon as it's created, and the "auto_created = True" meta
>> attribute helps me do that easily.
>>
>> I'm wondering if there is a way around this. I need extra information in
>> this Many-to-Many relationship (the team the player is drafted to), and I'm
>> surprised the auto_created attribute exists and doesn't seem to work (since
>> the migration ignores the model). Is this a bug, or should I be manually
>> creating LeaguePlayer objects on-the-fly when adding to the League object
>> instead of using auto_created? Am I misusing auto_created?
>>
>> Joey "JoeLinux" Espinosa
>> about.me/joelinux
>> [image: Joey "JoeLinux" Espinosa on about.me]
>>   
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a6cc21bf-b352-4501-9cb7-6db54ac4c1b8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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

Re: What Did I Do Right? (url and domain name change)

2015-08-06 Thread Bill Freeman
Look at "Sites" in the admin.

On Thu, Aug 6, 2015 at 5:03 PM, Malik Rumi  wrote:

> I have 1 model from my django project up and running on django. Before
> adding more models and content, I wanted to use my actual domain name,
> instead of whatever.herokuapp.com. So after I got that straight, I
> realized that while the home page was mysite.com, the links were still
> mystite.herokuapp.com, which I think is a problem. But I also thought
> there had to be an easy fix for this, especially after I saw a post while I
> was searching for solutions that said django only cares about the stuff
> that comes *after* the domain name. So the first thing I did was change a
> hardcoded link in my navbar from mysite.herokuapp/newpage to mysite/newpage
> in my dev site. But testing it the url still said
> mysite.herokuapp.com/newpage. Then I got an idea, and I just manually
> changed the url to mysite/newpage and what do you know, it came up
> correctly. then I clicked around and suddenly all the pages on my model are
> coming up that way, which they were not half an hour ago. So the question:
> What did I do right?
>
> Here are my working theories:
>
> 1. The dns change, which I also did half an hour ago, worked for the home
> page immediately (I tested it at the time) but needed to propagate more for
> the other pages to work, which they do now.
>
> 2. By changing the url manually, django just fed the pages as requested
> without concern about the domain part of the url. If I start from
> mysite.herokuapp.com home page, the links still come up with that domain
> name.
>
> But how do I make this both universal and permanent?
>
> A. I could change allowed hosts setting, taking the herokuapp part out
>
> B. Do nothing, it works now and I should leave well enough alone.
>
> C. ? Your answer here ...
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3ded9a89-b20f-489d-aadb-667ab62fdb53%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: What Did I Do Right? (url and domain name change)

2015-08-06 Thread Aaron C. de Bruyn
1. DNS doesn't really work that way in most situations.  Your browser
should cache it, your computer should cache it (especially Windows),
and your upstream DNS (usually your router) should cache it.  Your
computer literally stores 'mysite.com' = '1.2.3.4'.  It doesn't store
it per-page, but for the whole domain name.

2. How are the URLs generated in your application?  If your HTML
template literally has:  http://mysite.herokuapp.com/{% url
'home' %}">Home pagethen the only way to update the URLs for
your app would be to edit the template and fix them.  If you are
relying on django-sites to 'know' the base URL for your site, go into
the admin section and click on 'Sites'.  I think it's best practice to
not prefix my URLs with http://whatever...  Just use {% url 'home' %}
as it should return something like '/' for the URL (without
http://mysite.com).

A. Your ALLOWED_HOSTS setting should probably have both domains if you
want your transition to be smooth.  (i.e. the site works through both
URLs).  ALLOWED_HOSTS has no affect on what URLs you application
displays.

B. Definitely not.  Tweak, break, learn.  ;)

Hope that helps.

-A


On Thu, Aug 6, 2015 at 2:03 PM, Malik Rumi  wrote:
> I have 1 model from my django project up and running on django. Before
> adding more models and content, I wanted to use my actual domain name,
> instead of whatever.herokuapp.com. So after I got that straight, I realized
> that while the home page was mysite.com, the links were still
> mystite.herokuapp.com, which I think is a problem. But I also thought there
> had to be an easy fix for this, especially after I saw a post while I was
> searching for solutions that said django only cares about the stuff that
> comes after the domain name. So the first thing I did was change a hardcoded
> link in my navbar from mysite.herokuapp/newpage to mysite/newpage in my dev
> site. But testing it the url still said mysite.herokuapp.com/newpage. Then I
> got an idea, and I just manually changed the url to mysite/newpage and what
> do you know, it came up correctly. then I clicked around and suddenly all
> the pages on my model are coming up that way, which they were not half an
> hour ago. So the question: What did I do right?
>
> Here are my working theories:
>
> 1. The dns change, which I also did half an hour ago, worked for the home
> page immediately (I tested it at the time) but needed to propagate more for
> the other pages to work, which they do now.
>
> 2. By changing the url manually, django just fed the pages as requested
> without concern about the domain part of the url. If I start from
> mysite.herokuapp.com home page, the links still come up with that domain
> name.
>
> But how do I make this both universal and permanent?
>
> A. I could change allowed hosts setting, taking the herokuapp part out
>
> B. Do nothing, it works now and I should leave well enough alone.
>
> C. ? Your answer here ...
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3ded9a89-b20f-489d-aadb-667ab62fdb53%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

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