Re: How to undisplay the field with empty value in django admin?

2018-03-24 Thread Cictani

Hi,

I think you have a misconception in your model. What you need is a many to 
many relation so it does not matter how many metabolites each Reaction has. 
I am not so fimilar with Chemistry. So each stoichiometry belongs to 
exactly one metabolite?

if yes you could create an additional Model call it for example 
StoichiometryMetabolite which has three fields:

stoichiometry = models.CharField(max_length=255, blank=True, null=True)
metabolite = models.ForeignKey('Metabolites', on_delete=models.CASCADE)

reaction = models.ForeignKey('Reactionsmeta', on_delete=models.CASCADE


In your admin.py you have to create an InlineAdmin for 
StoichiometryMetabolite:

class StoichiometryMetaboliteInline(admin.StackedInline):
model = StoichiometryMetabolite
extra = 6

Than you have to add it to your inlines in your Reactionsmeta admin

 inlines = [StoichiometryMetaboliteInline

Everytime you have numbered columns in your model you should consider 
refactor it since it is not good database design.





-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/463d4bef-6105-4175-94ab-afb23b79e313%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to undisplay the field with empty value in django admin?

2018-03-24 Thread Cictani

Sorry it is not a many to many relation anymore but a one to many (from the 
new models perspective)

Am Samstag, 24. März 2018 11:24:48 UTC+1 schrieb Cictani:
>
>
> I think you have a misconception in your model. What you need is a* many 
> to many* relation so it does not matter how many metabolites each 
> Reaction has. I am not so fimilar with Chemistry. So each stoichiometry 
> belongs to exactly one metabolite?
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f98a3894-4f2e-4fb3-a962-3d2c16b1aece%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to undisplay the field with empty value in django admin?

2018-03-24 Thread Cictani

Grammarly messed up my post quite badly...

You should set the extra attribute to 0 (so only if there is data admin 
will display an entry. If you set it to 6 it will display 6 empty entries 
but that's what you wanted to prevent)

In your admin.py you have to create an InlineAdmin for 
> StoichiometryMetabolite:
>
> class StoichiometryMetaboliteInline(admin.StackedInline):
> model = StoichiometryMetabolite
> extra = 0
>
> also the ending ] was missing
>
>  inlines = [StoichiometryMetaboliteInline]
>
>
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ca584dd7-3525-47db-bacb-042b72f5334b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to undisplay the field with empty value in django admin?

2018-03-24 Thread shawnmhy
Dear Cictani:

Thank you for your great kindness!

However, if I create the additional model which maybe called stoichiometry 
metabolite, then I should I arrange the database t accommodate this class?

To make my question better understood, I posted my database of Reactionmeta 
as below:




在 2018年3月24日星期六 UTC+1上午11:35:07,Cictani写道:
>
>
> Grammarly messed up my post quite badly...
>
> You should set the extra attribute to 0 (so only if there is data admin 
> will display an entry. If you set it to 6 it will display 6 empty entries 
> but that's what you wanted to prevent)
>
> In your admin.py you have to create an InlineAdmin for 
>> StoichiometryMetabolite:
>>
>> class StoichiometryMetaboliteInline(admin.StackedInline):
>> model = StoichiometryMetabolite
>> extra = 0
>>
>> also the ending ] was missing
>>
>>  inlines = [StoichiometryMetaboliteInline]
>>
>>
>>
>>
>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0b298120-c481-4a7d-b3fd-0d6e964d3539%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to undisplay the field with empty value in django admin?

2018-03-24 Thread Cictani
After adding the new model and doing the migration you have to write a 
small script which will convert the data. You have to go through all the 
Reactionsmeta objects with

for reaction in Reactionsmeta.objects.all():

Then within the for loop you have to create another for loop which will go 
through all metabolite columns from 1 to 6:

for i in range(1, 7):

Then you would have to check if the column is not None:

current_metabolite = getattr(reaction, 'metabolite' + i, None)
current_stoichiometry = getattr(reaction, 'stoichimetry' + i, None)
if current_metabolite is not None and current_stoichiomentry is not None:

If current_metabolite is not none you can add a new StoichiometryMetabolite 
object:

StoichiometryMetabolite.objects.create(metabolite=current_metabolite, 
stoichiometry=current_stoichiomentry, reaction=reaction)


That' basically it. You should probably also write a test which makes sure 
that all data has successfully converted. If everything worked fine and all 
views, templates etc have been updated you can remove the old fields from 
the model.





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


Django deployment

2018-03-24 Thread Goran Radanovic
I have set up a server with Ubuntu, Nginx, uwisg, Postgres and Django.  I 
got this part figured out its running multiple sites with each of its own 
virtalenv.

My development is on Windows 10 and pycharm, what I haven't figured out is 
how I can develop in pyCharm and then deploy to my server.

Do the environments have to be the same in development and production?

Is it possible to develop locally with f.ex SQLite and then deploy to the 
server that runs Postgres?

I don't know if I'm totally out of bounds here, please help me understand 
deployment.

Regards
Goran
 

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cce6daf0-e617-4bac-a3e0-773c85b80885%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django deployment

2018-03-24 Thread graeme


On Saturday, March 24, 2018 at 12:42:52 PM UTC, Goran Radanovic wrote:
>
> I have set up a server with Ubuntu, Nginx, uwisg, Postgres and Django.  I 
> got this part figured out its running multiple sites with each of its own 
> virtalenv.
>
> My development is on Windows 10 and pycharm, what I haven't figured out is 
> how I can develop in pyCharm and then deploy to my server.
>

I suggest you set up virtualenvs much as you did on the server.

>
> Do the environments have to be the same in development and production?
>
 
No. There are advantages to them being the same though. Not necessarily 
identical, but I develop on Ubuntu and its near enough that things work the 
same on any Linux distro used for production by clients - I have run into 
problems with different Postgres versions when copying database dumps from 
production to development, and that is about it.

Is it possible to develop locally with f.ex SQLite and then deploy to the 
> server that runs Postgres?
>

Yes, but you cannot use the postgres specific features provided by recent 
versions of 
Django: https://docs.djangoproject.com/en/1.11/ref/contrib/postgres/

Why not just install Postgres? 

>
> I don't know if I'm totally out of bounds here, please help me understand 
> deployment.
>
> Regards
> Goran
>  
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0fb28790-e5f8-44e8-a332-7baa42e56ce9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search by entering to value in JSONField PostgreSQL

2018-03-24 Thread Алексей Кузуб
Thank's for your answer. As I know when we are using JSONField Django translate 
__contains in SQL with @> that check entering json in json. So it can't help 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/142edfb4-d7e4-4490-a958-ce4a3b05d015%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django deployment

2018-03-24 Thread Dylan Reinhold
First off nothing wrong with using your windows 10 box for development.
Now using sqllite for your test could lead to issues when you go to deploy.
I am guilty of doing to also some times.

But here is my deployment flow:

Develop on my laptop, check my changes into  git
Push my changes to github or bitbucket (I use both)
My projecst have CircleCI hooks, which will checkout my code and my run
test cases (It will run them ageist a postgress DB, so here I get a test
using postgress if i'm not using it local)
Then if the test cases pass, it runs a post script.
The post script checks out that branch on my server, and runs migrate,
collectstatic, and has my web instances restart.

Dylan


On Sat, Mar 24, 2018 at 6:21 AM, graeme  wrote:

>
>
> On Saturday, March 24, 2018 at 12:42:52 PM UTC, Goran Radanovic wrote:
>>
>> I have set up a server with Ubuntu, Nginx, uwisg, Postgres and Django.  I
>> got this part figured out its running multiple sites with each of its own
>> virtalenv.
>>
>> My development is on Windows 10 and pycharm, what I haven't figured out
>> is how I can develop in pyCharm and then deploy to my server.
>>
>
> I suggest you set up virtualenvs much as you did on the server.
>
>>
>> Do the environments have to be the same in development and production?
>>
>
> No. There are advantages to them being the same though. Not necessarily
> identical, but I develop on Ubuntu and its near enough that things work the
> same on any Linux distro used for production by clients - I have run into
> problems with different Postgres versions when copying database dumps from
> production to development, and that is about it.
>
> Is it possible to develop locally with f.ex SQLite and then deploy to the
>> server that runs Postgres?
>>
>
> Yes, but you cannot use the postgres specific features provided by recent
> versions of Django: https://docs.djangoproject.com/en/1.11/ref/
> contrib/postgres/
>
> Why not just install Postgres?
>
>>
>> I don't know if I'm totally out of bounds here, please help me understand
>> deployment.
>>
>> Regards
>> Goran
>>
>>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0fb28790-e5f8-44e8-a332-7baa42e56ce9%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHtg44BtGnu8%2BdhLLHtm%2B9uWTdaiFk3m%2BMn7OFoSS7-A--vKAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django 2 ajax search example

2018-03-24 Thread Carl Brubaker
I am having much trouble getting an AJAX search to work. I am working with 
django 2, and all the examples and tutorials I can find are django 1.x. The 
code that I have that almost worked once(I think - it put the request 
through but never displayed results) has been greatly butchered as I've 
tried different things to make it work. If I had a working example, I could 
see how it all fits together. I just haven't gotten there yet. Please help! 
Thanks!

I would like to see:

views.py
urls.py
ajax.js
template.html

I can take something apart and figure out how it works, I just haven't 
found one together yet. If you can point me to a working example (in django 
2), I would greatly appreciate it.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b90f217c-a27d-4296-b43c-936c41b06838%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Advertising a new Django open source project?

2018-03-24 Thread 'Simon Connah' via Django users
Hi,
First of all, I am sorry because I know that this is off-topic but I couldn't 
think of a better place to ask the question.
I'm in the process of developing a cross between a blog, a media gallery and 
some essential e-commerce features which is designed for end users rather than 
other Django developers (much like Wordpress is although I am not saying my 
project is going to be anything like Wordpress). I want to advertise the 
project so that other people can help with its development and offer ideas on 
features as well as use it if they want to.
I have no idea where to advertise my open source project? Is there a decent 
place to make people aware of what I am doing? I'm fine doing all the backend 
tasks, but it would be great to have some help on the frontend design aspects. 
I can handle the JavaScript as well. I'm just not so hot on CSS.
Any help is appreciated.
Simon.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1400150805.2759758.1521918783407%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advertising a new Django open source project?

2018-03-24 Thread Egor Smolyakov
Hello, Simon.

I had a similar question a few months ago when I advertised my project
https://github.com/egorsmkv/simple-django-login-and-register

So, I posted the url of my project to these Reddit hubs:

- https://www.reddit.com/r/django/
- https://www.reddit.com/r/Python/

Also, I posted the url to the show's section of Hacker News:
https://news.ycombinator.com/show

I think, it helps you.


On 24 March 2018 at 21:13, 'Simon Connah' via Django users <
django-users@googlegroups.com> wrote:

> Hi,
>
> First of all, I am sorry because I know that this is off-topic but I
> couldn't think of a better place to ask the question.
>
> I'm in the process of developing a cross between a blog, a media gallery
> and some essential e-commerce features which is designed for end users
> rather than other Django developers (much like Wordpress is although I am
> not saying my project is going to be anything like Wordpress). I want to
> advertise the project so that other people can help with its development
> and offer ideas on features as well as use it if they want to.
>
> I have no idea where to advertise my open source project? Is there a
> decent place to make people aware of what I am doing? I'm fine doing all
> the backend tasks, but it would be great to have some help on the frontend
> design aspects. I can handle the JavaScript as well. I'm just not so hot on
> CSS.
>
> Any help is appreciated.
>
> Simon.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1400150805.2759758.1521918783407%40mail.yahoo.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Kind Regards, Yehor Smoliakov.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACL14xpzuP4oQrO_fFBkdo5R-c9SG9HU1cDYCOHQCsVacu2vyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django channels 2 and data binding

2018-03-24 Thread Fabio Andrés García Sánchez
Is there any example about how to use data binding with django channels? I 
could not find any source to insertando how to do it.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1c3803e2-a049-47d3-ab11-25f58b06a826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advertising a new Django open source project?

2018-03-24 Thread 'Simon Connah' via Django users
 Hi Egor,
Thank you for the reply. When I get a bit nearer to completion I'll certainly 
follow your advice.
Thanks for the links.
Simon.
On Saturday, 24 March 2018, 20:03:41 GMT, Egor Smolyakov 
 wrote:  
 
 Hello, Simon.

I had a similar question a few months ago when I advertised my project 
https://github.com/egorsmkv/simple-django-login-and-register

So, I posted the url of my project to these Reddit hubs:

- https://www.reddit.com/r/django/
- https://www.reddit.com/r/Python/

Also, I posted the url to the show's section of Hacker News: 
https://news.ycombinator.com/show
I think, it helps you.


On 24 March 2018 at 21:13, 'Simon Connah' via Django users 
 wrote:

Hi,
First of all, I am sorry because I know that this is off-topic but I couldn't 
think of a better place to ask the question.
I'm in the process of developing a cross between a blog, a media gallery and 
some essential e-commerce features which is designed for end users rather than 
other Django developers (much like Wordpress is although I am not saying my 
project is going to be anything like Wordpress). I want to advertise the 
project so that other people can help with its development and offer ideas on 
features as well as use it if they want to.
I have no idea where to advertise my open source project? Is there a decent 
place to make people aware of what I am doing? I'm fine doing all the backend 
tasks, but it would be great to have some help on the frontend design aspects. 
I can handle the JavaScript as well. I'm just not so hot on CSS.
Any help is appreciated.
Simon.

-- 
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 https://groups.google.com/ group/django-users.
To view this discussion on the web visit https://groups.google.com/d/ 
msgid/django-users/1400150805. 2759758.1521918783407%40mail. yahoo.com.
For more options, visit https://groups.google.com/d/ optout.




-- 
Kind Regards, Yehor Smoliakov.





-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACL14xpzuP4oQrO_fFBkdo5R-c9SG9HU1cDYCOHQCsVacu2vyw%40mail.gmail.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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/230395608.2795627.1521944994252%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django channels 2 and data binding

2018-03-24 Thread Andrew Godwin
There are no examples yet - I removed data binding from core Channels in
the 2.0 release because it had a high maintenance overhead and as yet
there's not a replacement. I was hoping someone might volunteer to help
build it as an external package but if not, I may eventually get time to
write it later in the year.

Andrew

On Sat, Mar 24, 2018 at 7:07 PM, Fabio Andrés García Sánchez <
fabio.garcia.sanc...@gmail.com> wrote:

> Is there any example about how to use data binding with django channels? I
> could not find any source to insertando how to do it.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1c3803e2-a049-47d3-ab11-25f58b06a826%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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFwN1uqdx%3DZ4jSxNran%3D%3DQ%2BUPNyHZfUwMnR%3DC9JKziwDgObt4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django channels 2 and data binding

2018-03-24 Thread Fabio Andrés García Sánchez
Thank Andrew.
I would like to know if it is a good idea to keep using django 1.x to get data 
binding or would you recomend another path to keep update my frontend with my 
lastest data?

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8552069b-fd61-48a2-85e9-ff1c2ee5a2e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.