New FOSS project built with Django: tradero

2023-06-30 Thread Matemática A3K
tradero is a tool for achieving self-funding via trading.

Self-funding means generating the means independently to cover a budget in
order to opt by the value it produces rather than out of economic necessity.

It tracks Symbols in an Exchange with a time resolution, calculates
indicators and presents them in an useful way so the user can perform
trading more effectively.

The application is available at https://tradero.dev

The full documentation is at https://tradero.readthedocs.io or the /docs
directory.

Community:
* GitHub: https://github.com/math-a3k/tradero
* Discord: https://discord.gg/zACSJmtP
* Mailing list: https://groups.google.com/g/tradero

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BFDnhKhT4EqVrwGg1Q1hV3uf3csYF7C0ETLQADQL7OFeUTp4g%40mail.gmail.com.


[ANN] The covid-ht project

2021-01-15 Thread Matemática A3K
>From https://covid-ht.herokuapp.com/about:

According to Dr. Eugenia Barrientos[1], an ongoing viral infection can be
detected from the results of an hemogram test, and, given the current
COVID19 pandemic, all viral infections with cold and flu symptoms should be
treated as COVID19 cases.

The inference from the hemogram test results is done based on the knowledge
and experience of the Health Professional.

If that process could be automatized and widely available, the detection
toolkit of Health Professionals will be improved.

In many places (i.e. Perú) where specific COVID19 testing is not widely
available - saturated hospitals, not affordable or unavailable - hemogram
blood testing is in the opposite: affordable and in widely distributed
facilities.

If a viral infection classifier with an adequate accuracy through hemograms
can be built and made publicly available, all Health Professionals with a
smart-phone and Internet access could classify any hemogram with the same
accuracy as top-level experts on the matter.

Early detection is deemed to be the greatest success factor in COVID19
treatments.

This project aims to provide a tool to efficiently build and manage that
classifier and make it effectively available for widespread use in order to
improve detection and increase the use efficiency of specific testing of
COVID19.

This tool is totally transparent: you may audit it entirely to fully
understand how it works, what it provides and its limitations. It is
distributed under the GNU LGPLv3 license.

Improvements in early detection should increase successful treatments,
potentially saving lives.

Better resource efficiency can also be achieved with the tool, i.e. only
use expensive specific COVID19 testing for recovery after the hemogram does
not indicate infection.

The tool is not a replacement of Health Professionals.

Any diagnostic and treatment should be decided by a Health Professional
with the patient. If you are an individual with a recent hemogram result,
the tool may indicate to take preemptive care and seek a Health
Professional.

Also, don't blame the knife providers: This program is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

Everybody is welcome to join the community for building it and use it:
covid-ht+subscr...@googlegroups.com and https://github.com/math-a3k/covid-ht
.

Made with love for all humans of the world.

[1] https://youtu.be/ZO6EaAz465Y?t=570

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BFDnhLFSnj56XO1DpbfCPuXSvjNiCapMGuNvTypfqe98ma9xw%40mail.gmail.com.


Re: What happened to CollapsedFieldsets.js?

2018-02-28 Thread Matemática A3K
On Tue, Feb 27, 2018 at 1:28 PM, Alan  wrote:

> Hi there,
>
> Well, I used that like 8 years ago. Just wondering what's the current
> solution for Django 2.0 if one want to collapse fields in forms.
>
>
AFAIK is to write your own javascript (or use a third-party library /
"toolkit") for doing that. You can see the implementation in the admin as a
reference:
https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/collapse.js


> Thanks in advance,
>
> Alan
>
> --
> I'll cycle across Britain in 2018 for a charity, would you consider
> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
> Many thanks!
> --
> Alan Wilter SOUSA da SILVA, DSc
> Senior Bioinformatician, UniProt
> European Bioinformatics Institute (EMBL-EBI)
> European Molecular Biology Laboratory
> Wellcome Trust Genome Campus
> Hinxton
> Cambridge CB10 1SD
> United Kingdom
> Tel: +44 (0)1223 494588
>
> --
> 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/CAEznbznf1TyN-LSr5apdf7LGZJDR9Lco96GcJqMS%
> 3DF4vK7jRQA%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/CA%2BFDnhKz%3Dh2A1i_%2BVn0_pZyvWx6kjEKT9%3DjXKn2jBoDFZuYmmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Static/constant dictionary for get_initial or get_form_kwargs

2018-02-28 Thread Matemática A3K
On Tue, Feb 27, 2018 at 9:10 PM, Bob Glassett 
wrote:

> Hello,
>
> Trying to bring a django app into production, and I ran into a real
> headscratcher.
>
> I have a Class based view inherited from create.  When the page reloads,
> after validation, I check the initial dictionary for a field's value to
> fill in the queryset for a different field.
>
> I'm getting sporadic errors about one of the fields not found in the
> initial object.  When I looked closer into the problem, the initial
> dicitonary matched a form for a totally different model.
>
> If I need to pre-populate the initial dictionary, I override the
> get_initial and return the dictionary that I want.  I am not setting
> initial= in the class definition.  Is this the right way to do this task?
>
> I am concerned about a static initial dictionary sticking around.  The
> base edit class returns a copy of the initial dictionary, but if the
> initial dicitonary somehow has invalid values in it, I could be seeing this
> for all my forms.
>
> This is what I did for the initial dictionary:
>
> class UserCreateView(AdminCreateView):
>
> model=User
>
> success_url='/portal/accounts/list'
>
> form_class=PortalUserForm
>
>
>
> def get_form_kwargs(self):
>
> kwargs = super(UserCreateView, self).get_form_kwargs()
>
> kwargs.update({'request' : self.request})
>
> return kwargs
>
>
>
> def get_initial(self):
>
> return {}
>
>
> On a ModelForm (unrelated to the form/model above) I was trying to access
> the self.initial for a particular field, which threw a Key exception.  The
> initial dictionary passed down on the yellow screen did not match the form
> or data for the view at all.
>
>
> kwargs:
>
>
>
> {'initial': {'agency': ,
>  'canEnterMealCounts': False,
>  'canManageCalendar': True,
>  'canManageCustomerAllergies': True,
>  'canManageFieldTrips': True,
>  'canManageSocializations': True,
>  'canManageSpecialOrders': True,
>  'canManageSupplies': False,
>  'canPrintMenus': True,
>  'chefablesUser': False,
>  'location': ,
>  'phone': PhoneNumber(country_code=1, national_number=2018158136, 
> extension=None, italian_leading_zero=None, number_of_leading_zeros=None, 
> country_code_source=1, preferred_domestic_carrier_code=None)},
>  'instance': None,
>  'prefix': None}
>
>
> I have no idea where that initial dictionary came from.  My
> get_form_kwargs looks like this:
>
>
> def get_form_kwargs(self):
>
> kwargs = super(PendingLabelsCreateView, self).get_form_kwargs()
>
> kwargs.update({'user': self.request.user})
>
> return kwargs
>
>
> The direct ancestor doesn;'t have get_form_kwargs defined, and that is
> defined as such:
>
>
> class AdminCreateView(LoginRequiredMixin, UserPassesTestMixin,
> CreateView):
>
>
> I need to understand where that initial value came from and determine if I
> have static values where I don't want them.
>
>
> Maybe they are set in the Form?


> Thanks in advance
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+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/db24def3-f8cc-4954-bbd3-72b6ed3fa0d6%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/CA%2BFDnh%2BCu3FKXLn_-T7FT34c7bvmsSM6GMxgoM3eN37PuTF1Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is there a way to make a field both foreignKey or allow user to fill it in themself?

2018-02-28 Thread Matemática A3K
On Wed, Feb 28, 2018 at 12:46 AM, Mike Dewhirst 
wrote:

> On 28/02/2018 1:58 PM, Alexander Joseph wrote:
>
>> Sorry, I think my question was confusing. What I want to do is allow the
>> user to either select a user from a drop down list of users from the
>> ForeignKey in the Users model, or if there is not a user suitable to select
>> in the drop down, they can manually type in a name themselves.
>>
>
> In the same field that would require a hack of the first water.  Way above
> my pay grade. For me, anything which equates an existing user object with a
> string typed in is likely to end in misery.
>
> Otherwise a separate CharField for the typed in name and null=True and
> blank=True in the ForeignKey ought to work.
>
> Mike
>

Indeed, what you can also do - besides the nullable FK, is process that in
the Form where if the FK is null and the the charfield is not None, then
create a User (maybe non active) with that name and assign it to the FK.


>
>
>> Thanks for your reply
>>
>>
>>
>> On Tuesday, February 27, 2018 at 7:45:51 PM UTC-7, Mike Dewhirst wrote:
>>
>> On 28/02/2018 1:26 AM, Alexander Joseph wrote:
>> > Is there a way to make a form field or model field either a foreign
>> > key reference or allow the user to fill in something themselves?
>> I'm
>> > making a fixed assets app and each fixed asset has an owner field,
>> > which I would like to assign to an app user if possible, and if not
>> > possible be able to fill in a name myself.
>>
>> Yes. Make the ForeignKey in the model null=True and blank=True so
>> it can
>> exist all alone. Then you can limit_choices_to whatever whatever
>> suits
>> your requirements ...
>>
>> https://docs.djangoproject.com/en/1.11/ref/models/fields/#
>> django.db.models.ForeignKey.limit_choices_to
>> > django.db.models.ForeignKey.limit_choices_to>
>>
>>
>> hth
>> Mike
>>
>>
>> >
>> > 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...@googlegroups.com 
>> > .
>> > To post to this group, send email to django...@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/98c44317-0993
>> -4d41-9d25-33f8a9821dce%40googlegroups.com
>> > 3-4d41-9d25-33f8a9821dce%40googlegroups.com>
>>
>> >
>> > 3-4d41-9d25-33f8a9821dce%40googlegroups.com?utm_medium=email
>> _source=footer
>> > 3-4d41-9d25-33f8a9821dce%40googlegroups.com?utm_medium=email
>> _source=footer>>.
>>
>> > 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 > 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/ms
>> gid/django-users/dd78c8cf-1892-4740-b3cb-1e384b9bd788%40googlegroups.com
>> > 2-4740-b3cb-1e384b9bd788%40googlegroups.com?utm_medium=email
>> _source=footer>.
>> 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/ms
> gid/django-users/4facfe44-e50e-e7d4-e41a-1c82775a8f7f%40dewhirst.com.au.
>
> 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 

Re: Industrial Analytics

2018-02-26 Thread Matemática A3K
On Sun, Feb 25, 2018 at 12:12 PM, Raj  wrote:

> Dear All,
>
> Can we use  Django for  Industrial Analytics ? . Where data volume is huge
> & with frequency in Mill seconds.
>

Yes :)


>
> Can someone name some examples of such industrial analytics application
> developed using Django.
>

Not to my knowledge.
Here is an example of metric processing in Django:
http://django-ai.readthedocs.io/en/latest/apps/examples.html#clustering-with-bayesian-networks-example-2
The whole process is described there, it can tweak it to your needs


>
> Thanks,
> Raj
>
> --
> 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/9ef756da-8b50-4575-9c54-17830f277b51%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/CA%2BFDnhKkj4OKTFm41prS%3D%2BUp284b0HnHDGNhNE89hw7kpBX7OA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trying to use tooltips in django 2.0 form

2018-02-26 Thread Matemática A3K
On Mon, Feb 26, 2018 at 9:16 AM, Alan  wrote:

> Hi there,
>
> I have this in my forms.py:
>
> class SubmissionForm(forms.Form):
>
>
> molecule_file = 
> forms.FileField(validators=[FileExtensionValidator(settings.CONTENT_TYPES),
> file_size], help_text="Required: Select a PDB, MDL or MOL2 file")
>
> But I am failing to make it work in my submit.html template. Currently, I
> am "hacking" with:
>
> 
> {{form.molecule_file.label}}{{ form.molecule_file }}
>
> That will show the tooltip "Required: Sel..." if mouse pause over this
> field in the browser, but this is silly, I wish I could use something like:
>
> {{form.
> molecule_file.label}}{{ form.molecule_file }}
>
> But that is not working, neither any combination I tried with .title etc.
>
> Any suggestion would be very much appreciated.
>
> Many thanks in advance,
>
> Alan
>

Alan,

The use of "help_text" in a template is shown here:
https://docs.djangoproject.com/en/2.0/topics/forms/#looping-over-the-form-s-fields

That is an example of how you should render a form field "manually". You
may also try seeing the output of {{ form.as_p }} and then tweak it to your
needs (you can use that in whatever tooltip wrapper - like bootstrap or
other css frameworks).

HTH!

>
> --
> I'll cycle across Britain in 2018 for a charity, would you consider
> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
> Many thanks!
> --
> Alan Wilter SOUSA da SILVA, DSc
> Senior Bioinformatician, UniProt
> European Bioinformatics Institute (EMBL-EBI)
> European Molecular Biology Laboratory
> Wellcome Trust Genome Campus
> Hinxton
> Cambridge CB10 1SD
> United Kingdom
> Tel: +44 (0)1223 494588
>
> --
> 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/CAEznbzmoK07JfXPp_MOvmYFe84a%3D5YiBQMEFJOtUsUzpjPjTGg%
> 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/CA%2BFDnhJROhWhC8mMx2ycsVX2m37rRyaXR_Mg3EALJfZhFFskJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please support Django Girls Fundraising Campaign (sorry for irrelevant topic in this group)

2018-02-06 Thread Matemática A3K
On Tue, Feb 6, 2018 at 4:12 PM, Etienne Robillard 
wrote:

>
>
> Le 2018-02-06 à 13:55, Gerardo Palazuelos Guerrero a écrit :
>
> the django girls project was my introduction to django, and it was a good
> one.
>
> I don't know man.
> Basically I guess programming Django/Python is not gender specific, so it
> makes very little difference to me.
>

It is not, so it is not country specific yet there are Python/Django
communities in almost every country... but seems like a long way to go
until humanity realizes the stupidity of borders and give up segregation in
whatever condition they put in their minds :)

Artificial divisions are one of the causes of the worst problems :)

I know "bad" women in tech, "good" women in tech, "bad" women outside tech,
"good" women outside tech, "good" and "bad" men in and out tech. It's not
about that.

Any group that promotes to gain an ability or do something that otherwise
seems subjectively unachievable by the mental framework imposed to that
people with whatever condition (nor good or bad, gender, nationality,
sexual orientation, race, money, whatever...) is a great thing, because it
leverage an artificial division that made people felt like they were dumb,
"less" or whatever... feeling unhappy and living way below their potential.

It's about helping to overcome that mental barrier :)

And if you do that while contributing to the core of the community and
including more people, its AMAZING! A hell of a work!

More people happy in every place! Yay!

So, GO DJANGO GIRLS!!!


>
> thanks to all people and their time...
> and good luck
>
>
> Best regards,
> Etienne
>
>
>
>
>
> --
> Gerardo Palazuelos Guerrero
>
>
> On Tue, Feb 6, 2018 at 4:46 AM, Anna Makarudze 
> wrote:
>
>> Hello all,
>>
>> My name is Anna Makarudze. I am the Django Girls Foundation Fundraising
>> Coordinator.
>>
>> I would like to take this opportunity to inform you about the
>> crowdfunding project we launched this week to raise funds which we need to
>> continue our work in bringing in more women to coding. Since Django
>> Girls was started three years ago, over 12,000 women have attended our
>> workshops and learnt to code using Python and Django. We would like to
>> continue growing the number in 2018. We are running our fundraising
>> project through crowdfunding on Indiegogo Generosity, an online
>> crowdfunding platform (https://www.generosity.com/co
>> mmunity-fundraising/django-girls-fundraising-campaign/x/17493288). Our
>> target is to raise USD 10,000 in four to six weeks through corporate
>> sponsorships and crowdfunding. We are hoping you will support us and help
>> us reach our goal.
>>
>> If your company is interested in corporate sponsorship, please contact me
>> and I will share with you our Sponsors Deck for 2018 which contains
>> information about our corporate sponsorship packages. We hope you can share
>> the within your organisation as well as spread the word about the campaign
>> to your friends, family and colleagues.
>>
>> Please feel free to ask me any questions you may have.
>>
>> Thank you.
>>
>> P.S Sorry for the post which may be irrelevant in this group.
>>
>> Cupcakes and high-fives,
>>
>> Anna Makarudze
>>
>> Django Girls Fundraising Coordinator
>> --
>> 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/ms
>> gid/django-users/c3cd0983-4c0e-492b-9183-2eb2c33b7760%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/CAJ8iCyOfov04jCSAJKioD_Ha7Uqj49LZ%
> 3DxvPaLhrd4w8V9G4nA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Etienne Robillardtkadm30@yandex.comhttps://www.isotopesoftware.ca/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group 

Re: Preventing apps installing duplicate models

2018-02-06 Thread Matemática A3K
On Tue, Feb 6, 2018 at 1:23 PM, Murat Sert  wrote:

> Hi,
>
> I'm working on a project upgrade from Django 1.8 to 1.11. They've used a
> custom registration app which is inheriting from Django Registration Redux
> package.
> Both packages are listed on installed_apps list. All works fine however
> when I try to run tests, where it creates test tables back to back, it
> errors at the following lines:
> ```
> 
> Creating table profile_preferences
> Creating table registration_registrationprofile
> Creating table registration_registrationprofile
> django.db.utils.ProgrammingError: relation 
> "registration_registrationprofile"
> already exists
> ```
>
> This is because both Apps are listed within the installed_apps list. Is
> there a way around this?
>
> Removing the django-registration-redux from installed_apps causes
> ```RuntimeError: Model class registration.models.RegistrationProfile
> doesn't declare an explicit app_label and isn't in an application in
> INSTALLED_APPS.``` error.
>

If you provide an app_label in the Model's Meta (whatever installed app),
does it run?


>
>
> Regards
>
> Murat
>
> --
> 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/f9774a9a-cc7e-444d-b7d3-432192d3b5df%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/CA%2BFDnhKoQ9OvQEx2bCA8hzHQOb8rasmdtpSA%2Be5Zy7UWF3YFgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please support Django Girls Fundraising Campaign (sorry for irrelevant topic in this group)

2018-02-06 Thread Matemática A3K
On Tue, Feb 6, 2018 at 8:46 AM, Anna Makarudze  wrote:

> Hello all,
>
>
> My name is Anna Makarudze. I am the Django Girls Foundation Fundraising
> Coordinator.
>
>
> I would like to take this opportunity to inform you about the crowdfunding
> project we launched this week to raise funds which we need to continue our
> work in bringing in more women to coding. Since Django Girls was started
> three years ago, over 12,000 women have attended our workshops and learnt
> to code using Python and Django. We would like to continue growing the
> number in 2018. We are running our fundraising project through
> crowdfunding on Indiegogo Generosity, an online crowdfunding platform (
> https://www.generosity.com/community-fundraising/django-gir
> ls-fundraising-campaign/x/17493288). Our target is to raise USD 10,000 in
> four to six weeks through corporate sponsorships and crowdfunding. We are
> hoping you will support us and help us reach our goal.
>
> If your company is interested in corporate sponsorship, please contact me
> and I will share with you our Sponsors Deck for 2018 which contains
> information about our corporate sponsorship packages. We hope you can share
> the within your organisation as well as spread the word about the campaign
> to your friends, family and colleagues.
>
>
> Please feel free to ask me any questions you may have.
>
> Thank you.
>
>
> P.S Sorry for the post which may be irrelevant in this group.
>

Not at all, best of luck with your campaign! :)


>
> Cupcakes and high-fives,
>
> Anna Makarudze
>
> Django Girls Fundraising Coordinator
>
> --
> 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/c3cd0983-4c0e-492b-9183-2eb2c33b7760%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/CA%2BFDnh%2BU03gJzPGKtvE_NenR2RY9GsJXwQkdieV-Zctzm2eY_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dynamic creation of models

2018-02-06 Thread Matemática A3K
On Tue, Feb 6, 2018 at 8:35 AM, Marc  wrote:

> Hello
>
>
>
> Currently working on a project to allow researchers to upload data files
> into a repository. The system will only handle the import, validation and
> transformation of the data, so that it meets the required standards. When a
> file is upload the for the first time the user has to be able to define the
> structure of the destination based on the csv/xls. This includes key field,
> data types, foreign keys etc. There is no requirement for the data to be
> displayed or edited once in the repository by this system, currently. We
> are currently planning on using PostgreSQL as the database.
>
>
>
> Our organisation already has another system, with a similar requirement,
> that is partially written by an external contractor in Ruby on Rails. The
> dynamic creation of the tables is no problem but it is the dynamic creation
> of the models and controllers that is proving difficult and is the reason
> why this other project is not finished.
>
>
>
> Reading through the forums it looks like Django may offer a better
> solution through meta-programming. https://code.djangoproject.
> com/wiki/DynamicModels This does look like quite an old article though.
>
>
>
> The other solution would be to have one table that holds all the records
> for all the imported files and have a JSONB (in PostgreSQL) to hold the
> columns that differ between files. This means that we would not be able to
> represent the relationships between files though. Ideally the organisation
> would like the data in a relational form to make subsequent analysis with
> other tools easier.
>
>
>
> Above all it is important that the system is robust and maintainable. Any
> solution will of course be tested by creating a proof of concept first.
>
>
>
> Is it still possible to dynamically create the models in the latest
> versions of Django (1.11 and 2.02)?
>
>
>
> Thank you
>
> Marc
>

This can help you with the modelling:
https://github.com/sromero84/django-eav

Still, seems that the structure and its content will be tied to Django -
you will have to access it through your Django app. If you want to have it
in a "normalized" form in the database, what you need to write in Django is
the frontend to a python import tool and then for displaying the data. In
this case, you "decouple Django from the data", your app contains history
about the imports and how to retrieve the info. In the first case, you
access the data through your Django models which gives you the structure of
the data.

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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/d707e803-3dbf-43e6-95a8-13869043c280%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/CA%2BFDnhLxm24GTN-mQUbi6gDrzJj4iSFRFzc%3DNOMA9sFP%3D8CeNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I hope to increase OneToOne mode GenericForeignKey

2018-02-06 Thread Matemática A3K
On Mon, Feb 5, 2018 at 6:57 PM, Ma Mars  wrote:

> I hope to increase OneToOne mode GenericForeignKey,
> For example, a passport (one user has only one passport, but there are
> many user roles, such as staff, drivers, customers, but they are one to one)
>

It's hard to understand what you are trying to do, please try to be more
verbose in order to get 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/41d3d6c1-16ec-4f61-badb-4522c7caad4a%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/CA%2BFDnhL8Owc_HGcjuwXwZfmzOvvwnse540af3tsSnKe5J1DJCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Travis Problem

2018-02-05 Thread Matemática A3K
(.env) rodrigo@enoch:~/code/django-secrets$ python --version
Python 3.5.2
(.env) rodrigo@enoch:~/code/django-secrets$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.3 LTS"
(.env) rodrigo@enoch:~/code/django-secrets$


On Mon, Feb 5, 2018 at 1:50 PM, Andy <kakulu...@gmail.com> wrote:

> which python version did you use and which operating system?
>
>
> Am Montag, 5. Februar 2018 16:49:26 UTC+1 schrieb Matemática A3K:
>
>> rodrigo@enoch:~/code$ git clone g...@github.com:kakulukia/djang
>> o-secrets.git
>> Clonar en «django-secrets»...
>> remote: Counting objects: 157, done.
>> remote: Compressing objects: 100% (58/58), done.
>> remote: Total 157 (delta 48), reused 66 (delta 30), pack-reused 67
>> Receiving objects: 100% (157/157), 34.45 KiB | 0 bytes/s, done.
>> Resolving deltas: 100% (74/74), done.
>> Comprobando la conectividad… hecho.
>> rodrigo@enoch:~/code$ cd django-
>> bash: cd: django-: No existe el archivo o el directorio
>> rodrigo@enoch:~/code$ cd django-secrets/
>> rodrigo@enoch:~/code/django-secrets$ ls
>> django_secrets  LICENSE  Makefile  manage.py  Pipfile  README.rst
>> setup.cfg  setup.py
>> rodrigo@enoch:~/code/django-secrets$ python3 -m venv .env
>> rodrigo@enoch:~/code/django-secrets$ source .env/bin/activate
>> (.env) rodrigo@enoch:~/code/django-secrets$ pip install --upgrade pip
>> Collecting pip
>>   Using cached pip-9.0.1-py2.py3-none-any.whl
>> Installing collected packages: pip
>>   Found existing installation: pip 8.1.1
>> Uninstalling pip-8.1.1:
>>   Successfully uninstalled pip-8.1.1
>> Successfully installed pip-9.0.1
>> (.env) rodrigo@enoch:~/code/django-secrets$ cd django_secrets/
>> (.env) rodrigo@enoch:~/code/django-secrets/django_secrets$ ls
>> __init__.py  management  settings.py  startup.py  tests.py  urls.py
>> utils.py  wsgi.py
>> (.env) rodrigo@enoch:~/code/django-secrets/django_secrets$ cd ..
>> (.env) rodrigo@enoch:~/code/django-secrets$ python manage.py test
>> Traceback (most recent call last):
>>   File "manage.py", line 7, in 
>> from django_secrets.startup import check
>>   File "/home/rodrigo/code/django-secrets/django_secrets/startup.py",
>> line 4, in 
>> from six.moves import input
>> ImportError: No module named 'six'
>> (.env) rodrigo@enoch:~/code/django-secrets$ pip install six
>> Collecting six
>>   Using cached six-1.11.0-py2.py3-none-any.whl
>> Installing collected packages: six
>> Successfully installed six-1.11.0
>> (.env) rodrigo@enoch:~/code/django-secrets$ python manage.py test
>>
>> Secret definitions initialized under secrets/definitions.py
>> Add your secrets there and fill the values on the next use of a manage.py
>> command.
>>
>>
>>
>> Secret missing, please fill in the blanks ..
>>
>> SECRET_KEY: secret
>> Traceback (most recent call last):
>>   File "manage.py", line 12, in 
>> from django.core.management import execute_from_command_line
>> ImportError: No module named 'django'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 18, in 
>> import django  # noqa
>> ImportError: No module named 'django'
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File "manage.py", line 21, in 
>> "Couldn't import Django. Are you sure it's installed and "
>> ImportError: Couldn't import Django. Are you sure it's installed and
>> available on your PYTHONPATH environment variable? Did you forget to
>> activate a virtual environment?
>> (.env) rodrigo@enoch:~/code/django-secrets$ pip install django
>> Collecting django
>>   Downloading Django-2.0.2-py3-none-any.whl (7.1MB)
>> 100% || 7.1MB 203kB/s
>> Collecting pytz (from django)
>>   Using cached pytz-2017.3-py2.py3-none-any.whl
>> Installing collected packages: pytz, django
>> Successfully installed django-2.0.2 pytz-2017.3
>> (.env) rodrigo@enoch:~/code/django-secrets$ python manage.py test
>> Creating test database for alias 'default'...
>> System check identified no issues (0 silenced).
>> .
>> Secret definitions initialized under secrets/definitions.py
>> Add your secrets there and fill the values on the next use of a manage.py
>> command.
>>
>>
>> got secret from environme

Re: Travis Problem

2018-02-05 Thread Matemática A3K
   print('export %s="%s"' % (key, getattr(secrets, key)))
AttributeError: module 'secrets.secrets' has no attribute 'SECOND_SECRET'

--
Ran 3 tests in 0.004s

FAILED (errors=2)
Destroying test database for alias 'default'...
(.env) rodrigo@enoch:~/code/django-secrets$


On Mon, Feb 5, 2018 at 12:37 PM, Andy <kakulu...@gmail.com> wrote:

> No, the actual problem is, that the secrets modules was not reloaded
> correctly and thus the tested SECOND_SECRET could not be found.
> BUT the question is, why this is happening, because testing the same thing
> locally (under the same python version failing at travis) works like it
> should.
>
> If you have some minutes to spare, please test it and tell me if you can
> reproduce the problem.
>
>
>
> Am Montag, 5. Februar 2018 16:30:21 UTC+1 schrieb Matemática A3K:
>>
>>
>>
>> On Mon, Feb 5, 2018 at 12:23 PM, Andy <kaku...@gmail.com> wrote:
>>
>>> Which line number are you referring to?
>>> i didnt notice missing  vars.
>>>
>>
>> got secret from environment variable (SECOND_SECRET)
>> E
>> Use these lines to initialize your secrets ..
>> export SECRET_KEY="travis"
>> E
>>
>> ...
>>
>> ==
>> ERROR: test_export (django_secrets.tests.SecretTest)
>> --
>> Traceback (most recent call last):
>>   File 
>> "/home/travis/build/kakulukia/django-secrets/django_secrets/tests.py", line 
>> 32, in test_export
>> command.handle()
>>   File 
>> "/home/travis/build/kakulukia/django-secrets/django_secrets/management/commands/export_secrets.py",
>>  line 15, in handle
>> print('export %s="%s"' % (key, getattr(secrets, key)))
>> AttributeError: 'module' object has no attribute 'SECOND_SECRET'
>>
>>
>>
>>
>>>
>>>
>>> Am Montag, 5. Februar 2018 15:50:14 UTC+1 schrieb Matemática A3K:
>>>>
>>>>
>>>>
>>>> On Thu, Feb 1, 2018 at 9:58 AM, Andy <kaku...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> im trying to convince Travis to test my app:
>>>>> https://github.com/kakulukia/django-secrets
>>>>>
>>>>> But its failing for all python3 versions. Because my system python 3
>>>>> is 3.6.4 i just installed pyenv, created a 3.6.3 (latest python 3.6 at
>>>>> Travis) virtualenv and ran the tests. On my local system they are working,
>>>>> but travis reports problems and i dont really know how to fix them when 
>>>>> the
>>>>> tests are not failing locally.
>>>>>
>>>>> Does sombody have a clue, whats wrong here?
>>>>>
>>>>> Weird evough: now that i pushed a new commit (not relating python code
>>>>> though) two confgigurations do pass the tests:
>>>>> https://travis-ci.org/kakulukia/django-secrets/
>>>>>
>>>>
>>>> This is more like a Travis problem, according the log, the env vars are
>>>> not being picked by it:
>>>> https://travis-ci.org/kakulukia/django-secrets/jobs/336123060
>>>>
>>>>
>>>>
>>>>>
>>>>> --
>>>>> 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 https://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/01cb4387-5ad1
>>>>> -4d24-9ae4-42a2b83c7ab1%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-users/01cb4387-5ad1-4d24-9ae4-42a2b83c7ab1%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>> 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-

Re: Travis Problem

2018-02-05 Thread Matemática A3K
On Mon, Feb 5, 2018 at 12:23 PM, Andy <kakulu...@gmail.com> wrote:

> Which line number are you referring to?
> i didnt notice missing  vars.
>

got secret from environment variable (SECOND_SECRET)
E
Use these lines to initialize your secrets ..
export SECRET_KEY="travis"
E

...

==
ERROR: test_export (django_secrets.tests.SecretTest)
--
Traceback (most recent call last):
  File "/home/travis/build/kakulukia/django-secrets/django_secrets/tests.py",
line 32, in test_export
command.handle()
  File 
"/home/travis/build/kakulukia/django-secrets/django_secrets/management/commands/export_secrets.py",
line 15, in handle
print('export %s="%s"' % (key, getattr(secrets, key)))
AttributeError: 'module' object has no attribute 'SECOND_SECRET'




>
>
> Am Montag, 5. Februar 2018 15:50:14 UTC+1 schrieb Matemática A3K:
>>
>>
>>
>> On Thu, Feb 1, 2018 at 9:58 AM, Andy <kaku...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> im trying to convince Travis to test my app:
>>> https://github.com/kakulukia/django-secrets
>>>
>>> But its failing for all python3 versions. Because my system python 3 is
>>> 3.6.4 i just installed pyenv, created a 3.6.3 (latest python 3.6 at Travis)
>>> virtualenv and ran the tests. On my local system they are working, but
>>> travis reports problems and i dont really know how to fix them when the
>>> tests are not failing locally.
>>>
>>> Does sombody have a clue, whats wrong here?
>>>
>>> Weird evough: now that i pushed a new commit (not relating python code
>>> though) two confgigurations do pass the tests:
>>> https://travis-ci.org/kakulukia/django-secrets/
>>>
>>
>> This is more like a Travis problem, according the log, the env vars are
>> not being picked by it:
>> https://travis-ci.org/kakulukia/django-secrets/jobs/336123060
>>
>>
>>
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/01cb4387-5ad1-4d24-9ae4-42a2b83c7ab1%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/01cb4387-5ad1-4d24-9ae4-42a2b83c7ab1%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/08261ca0-c0dd-4d70-9ce1-e8cb2e401059%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/08261ca0-c0dd-4d70-9ce1-e8cb2e401059%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhJ4iHGEeQBMtFX42PEgoamH1tu%2B54KD3o6Faa1BfbRksw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: javascript transpilers

2018-02-05 Thread Matemática A3K
On Thu, Feb 1, 2018 at 8:27 PM, Mike Dewhirst  wrote:

> On 2/02/2018 12:54 AM, Jason wrote:
>
>> https://caniuse.com/#feat=wasm
>>
>>
>>  IIRC wasm is not polyfillable or transpilable, so if you're targeting
>> users on any of those red cells, then wasm is not for you.
>>
>
> Agreed. I think it is interesting anyway but I already decided it is not
> within my event horizon.
>

I wasn't sure about writing this, but anyway...

Mike,

I know how you feel, I have been there (avoiding JS), this is how I solved
it:
https://books.google.com.pe/books/about/JavaScript.html?id=PXa2bby0oQ0C=frontcover=kp_read_button_esc=y#v=onepage=false
and:
http://learn.knockoutjs.com/#/?tutorial=intro
(it will give you the concepts about ""modern"" UI development in JS (not
"pure" jQuery) before jumping into the big js framework world, and it also
may solve your UI needs)

About the python transpiler, you still need to write code for the JS
libraries, so you need to understand roughly how they work and how the
coding is done for the browser. The problem is not JS here (which can be
grasped easily with Crockford's book), but the coding pattern you have
apply and how things are done - and you get that only by coding on it. Once
you know that, you can write it on Python or JS.

When reading JS articles, have in mind this:
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f

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 > 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/ms
>> gid/django-users/19bbbae1-eac0-4fea-b6f2-a1c72cfdb471%40googlegroups.com
>> > 0-4fea-b6f2-a1c72cfdb471%40googlegroups.com?utm_medium=email
>> _source=footer>.
>> 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/ms
> gid/django-users/1f24a791-1a13-ecd8-f97c-6d5118ef8d41%40dewhirst.com.au.
>
> 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/CA%2BFDnh%2BPxgV9drcsO8r38mvBBpU1eJra2sTcQ2BdstdRpEhErg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Login Popup forms.

2018-02-05 Thread Matemática A3K
On Wed, Jan 31, 2018 at 8:36 PM, Udit Vashisht 
wrote:

> Hi, I want to create a popup form for login. I have implemented the same
> for signup by creating jsonresponse from signup view. But i could not do
> the same for the login form. Can anyone help.
>
>
Popus are regular HTML files with client-side code (javascript) to "look
like popups". Otherwise, it the same as a regular "non-popup" page (same
view, etc. on the django side)


>
> --
> 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/7f53bd94-a0ce-4ddd-9273-730b6ef5b0f4%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/CA%2BFDnhLda3DD8xgOaFk-AFAVJW0QwU4dLY4PGi%2BuYoNAkgxfiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-05 Thread Matemática A3K
On Thu, Feb 1, 2018 at 7:46 AM, Rakhee Menon 
wrote:

> Hi Andreas,
>
> Yeah you are right I want to create a backend solution for storing the
> information about the invoices once any changes are done in the invoice
> format.
> For instance a customer might change the fontsize of any column, add any
> column or one might change the position of their company name etc..and I
> want to store the changed positions and save it in the database ie  I want
> to create an editable invoice in all ways.
>

Still too broad :)


>
>
> Thanks Once Again
>> Regards  ,
>> Rakhee
>>
> --
> 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/cfaa0e5c-06d4-40c1-bdde-3f378aed9a0d%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/CA%2BFDnhJ%3DBqP2DFZ_oL_Be%2B8A9P4gJyBKYQUNLtFgURdGY7Stkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Travis Problem

2018-02-05 Thread Matemática A3K
On Thu, Feb 1, 2018 at 9:58 AM, Andy  wrote:

> Hi,
>
> im trying to convince Travis to test my app:
> https://github.com/kakulukia/django-secrets
>
> But its failing for all python3 versions. Because my system python 3 is
> 3.6.4 i just installed pyenv, created a 3.6.3 (latest python 3.6 at Travis)
> virtualenv and ran the tests. On my local system they are working, but
> travis reports problems and i dont really know how to fix them when the
> tests are not failing locally.
>
> Does sombody have a clue, whats wrong here?
>
> Weird evough: now that i pushed a new commit (not relating python code
> though) two confgigurations do pass the tests:
> https://travis-ci.org/kakulukia/django-secrets/
>

This is more like a Travis problem, according the log, the env vars are not
being picked by it:
https://travis-ci.org/kakulukia/django-secrets/jobs/336123060



>
> --
> 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/01cb4387-5ad1-4d24-9ae4-42a2b83c7ab1%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/CA%2BFDnhLNBF-U3q2x18jYtEcFfHeX8qvkzWyJ5e5kd7y%2ByUiafA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-05 Thread Matemática A3K
On Fri, Feb 2, 2018 at 3:23 PM, Paul Tiplady  wrote:

> Currently it's simple to configure a filter on a foreign key in the admin:
>
> `list_filter = ['theforeignkeyfield']`
>
> However in practice this is barely usable in most cases that I've
> encountered, since the admin uses RelatedFieldListFilter, which fetches the
> full list of objects from the DB and loads them into the browser. For any
> production site that either times out or makes the admin unusably slow, not
> to mention the UX is terrible as it inserts a list of all of the items into
> the filter bar that needs to be scrolled through.
>
> I'm not sure if this is fixed in 2.0 (I haven't played with the new
> select2 integration that was added), but is there a plugin / workaround to
> use something like django-autocomplete-light, or a `raw_id_field` type
> approach in pre-2.0?
>

https://djangopackages.org/grids/g/auto-complete/

> --
> 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/4e610074-ff8c-494d-977e-cf701c8cd92f%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/CA%2BFDnhLF6YWwH6%2BQZP%3D7hPYSnLhpHaGgFrBzMUSe8UDWxvUaKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0.2 not work with Jinja 2 (admin side)

2018-02-05 Thread Matemática A3K
You have to provide a traceback in order to get some help

On Sat, Feb 3, 2018 at 9:26 PM, Николай Инкогнито  wrote:

> /admin/
> - raise error
>
> --
> 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/be335026-0d3e-4c05-ad19-e259d9ec5aa3%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/CA%2BFDnhLqqQh1e2kYRCexMaM5%2B_GXzy%3DCK8CONaRoPDj-6WC%3Dhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: import error

2018-02-05 Thread Matemática A3K
On Mon, Feb 5, 2018 at 10:59 AM, sarvit sarvit 
wrote:

> is not app
> views.py
> from django.http import HttpRequest
>
> def index(request):
>return HttpRequest("Hello World.")
>
> urls.py
>
> from django.shortcuts import render
> from django.conf.urls import url
> from django.contrib import admin
> from django.urls import path
> from views.py import views
>
> urlpatterns = [
>path('admin/', admin.site.urls),
>url(r'^$',views.index),
>
>
> ]
>
>
>
Judging from this, you are trying to import the views from your "main"
urls.py, and generally the views are within an django app. In that case,
you should use your_app_name.views as stated before. "Relative imports"
(from . import views) will work only if the file is on the same directory
you are working (i.e. inside an app).
 .

>
>
> On Monday, February 5, 2018 at 4:54:59 PM UTC+3:30, sarvit sarvit wrote:
>>
>> Hello
>> I importing error
>> Please help me
>> from django.shortcuts import render
>> from django.conf.urls import url
>> from django.contrib import admin
>> from django.urls import path
>> from . import views
>>
>>
>> Traceback (most recent call last):
>>   File "c:\Users\saeid\Desktop\sade\env\Post\Post\urls.py", line 20, in
>> 
>> from . import views
>> ImportError: cannot import name 'views'
>>
>>
>>
>> --
> 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/1d3b5804-123c-40ce-9ec9-fa4bb5fc8495%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/CA%2BFDnhLCgR_6AjyYXSZ8Nu%2BOpkQnLsLaCpUkBSJ21Ekuw39Baw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django development -

2018-01-29 Thread Matemática A3K
On Thu, Jan 25, 2018 at 10:27 AM, Matt  wrote:

> Hi all,
>
> First time poster  - so hi! & hope I'm asking things here in the right
> way. I've used django, on and off, for a while for personal little
> projects, and found it fun to use.  But I'm, no pro, and its not my day job.
>
> Now I've started a project locally, which I'd like to flesh out, make it
> more robust and then go-live with the idea as an actual website.  I've
> tried to adhere to the structure of building the site up in the correct way
> to be like an app, but again I'm no pro.
>
> So I'd love to hear some experience of people that have moved a prototype
> through dev, into prod.
>
> As I see it, I'd need;
> 1) a dev to work with me to turn the prototype (amateur code) into
> something better -> where's the best place to look for them?
>

There is no "right" answer for this. There are a lot freelancers
marketplaces and/or job posting sites, which one is the best is highly
subjective, can be considered as propaganda and / or flame starting bait.


> 2) a platform to deploy it on (AWS, heroku, or similar)
>
Each platform has its ups and down, depending on you application,
resources, etc. and has the same problems as the previous question.


> - and potentially someone different to do that for me - again, where's the
> best place to look for them?
>

(same)


>
> So if you've got some experience in taking a django site through this, I'd
> love to hear about how you did it.
>
> Finally - I hope I've asked the right type of question here in the group -
> I know its not the classic feature / debug question - but I didn't knwo
> where else to ask.
>

No, I think you didn't. You should ask google about experiences deploying
and where to hire :)


>
> Thanks!
> -Matt
>
> --
> 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/7cf7cc54-9f3d-4830-82eb-45e085c4c6e5%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/CA%2BFDnhJzk3856uUy1K8p-uJztj3LoyEoszjAa4V1ZRKAi5tFhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: wsgi error

2018-01-29 Thread Matemática A3K
On Sat, Jan 27, 2018 at 12:05 AM, tango ward  wrote:

> Hi Team,
>
> Not sure if this issue covered here but I am getting an error uploading my
> pet project in Heroku.
>
> ModuleNotFoundError: No module named 'animals.wsgi'
>
> 2018-01-27T02:59:26.637953+00:00 app[web.1]: [2018-01-27 02:59:26 +] [8] 
> [INFO] Worker exiting (pid: 8)
>
> 2018-01-27T02:59:26.669632+00:00 app[web.1]: [2018-01-27 02:59:26 +] [4] 
> [INFO] Shutting down: Master
>
> 2018-01-27T02:59:26.669770+00:00 app[web.1]: [2018-01-27 02:59:26 +] [4] 
> [INFO] Reason: Worker failed to boot.
>
>
>
> my Procfile in my root folder contains this:
>
> web: gunicorn animals.wsgi:application --log-file - --log-level debug
>
> where animals is the name of my project, where my wsgi.py file is residing.
>
> I tried searching this in StackOverflow but most of the answers are saying
> that it must be "web: gunicorn PROJECT_NAME.wsgi:application --log-file -
> --log-level debug" which I already did in my Procfile.
>
>
> Any suggestions?
>
>
This is more a Heroku question, you should seek help in their docs, forums
/ communication channels.

AFAIK, a Procfile with "web: gunicorn animals.wsgi" should be enough and
work.

HTH!


>
>
> Regards,
> Jarvis
>
> --
> 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/ms
> gid/django-users/CAA6wQLKi4vjKpVByRykvkXoPkpPUBprVq2pvmn-
> OabzSkAFoyQ%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/CA%2BFDnhLr9p%3DHnCj-L0u3MXU3VGbwoLE3wNH2uCgZX7c2wqsD-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get request, has PK, how do I access the PK data with in the model

2018-01-27 Thread Matemática A3K
https://docs.djangoproject.com/en/2.0/intro/tutorial01/

On Sat, Jan 27, 2018 at 8:19 AM, Travis Pickle 
wrote:

> Andy,
>
> Do you have a link for this? 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/7bc86b9f-57d4-4a57-aa2e-bf6f1a163458%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/CA%2BFDnhL3K4gYr0ohD-eANW2jtzPN%2BUcBROqG2U7--XNOsBQPNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issues with image.path being reported wrong causing failing of a Celery task

2018-01-17 Thread Matemática A3K
b
On Wed, Jan 17, 2018 at 12:17 PM, Paul  wrote:

> I have the following model:
>
>
> class Image(models.Model): image = models.ImageField(upload_to=fi
> le_upload_to)
>
>
> I have a dynamic file_upload function:
>
>
> def file_upload_to(instance, filename):
>   base = '_'.join([str(instance.item.pk), instance.item.slug])
>   return os.path.join('accounts', base, 'item', base_2, 'images', filename)
>
> and in a ModelForm:
>
>
> class ImageModelForm(ModelForm)
>  def save(self, commit=True):
>   image_obj = super().save(commit=commit)
>   product_image__task.delay(image_obj.image.path, image_obj.image.name, 
> image_obj.product_id) return image_obj
>
>
>
> I tried also to wait for transaction:
>
>
> transaction.on_commit( lambda: 
> product_image_crop_task.delay(image_obj.image.path, image_obj.image.name, 
> image_obj.product_id))
>
>
>
> The file is saved properly in a path like:
>
>
> media/account/12_blue/images/image_name.jpeg
>
>
>
> The problem is that image_obj.image.path is not reporting the correct
> path, but this path:
>
>
> media/image_name.jpeg
>
>
> I use the image path, further passing it as an argument to a task, but
> because I received the wrong path, it will fail.
>
>
> How can I fix this, and receive the correct path ?  I tried also using
> time.sleep(), nothing works, the path/location returned is wrong, even if
> is saved to the correct one.
>

The first thing I would do is to comment out all the celery tasks to see if
those are messing with path property (you are not using a custom storage,
right?) Also, the upload_to function you posted does not correspond to the
path generated, try to post the latest code :)


>
> --
> 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/7d57595e-95b5-49f4-a29a-34f73e30620d%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/CA%2BFDnhKGAnNxw3O%2BEtXTsMaWmhC-6bToaL7nOpFAh53Ky_YCxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Let users either upload a file or provide an URL to a file

2018-01-17 Thread Matemática A3K
On Wed, Jan 17, 2018 at 11:53 AM, Tony  wrote:

> I would like to let users either upload a video file(to AWS S3) or provide
> an URL to a video, e.g. Youtube/Vimeo.
>
>
> I found a similar question for Rails: Rails: upload a file OR store a url
> 
>
>
>
> 
>
> But how do I do that in Django(1.11)?
>
>
> Should I create 2 separate models, or model inheritance with abstract
> model, let users choose what they want to do in the frontend, then display
> the appropriate form?
>
> class VideoModel(models.Model):
> title = models.CharField(max_length=200)
> post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
> created = models.DateTimeField(auto_now_add=True)
> modified = models.DateTimeField(auto_now=True)
>
> class Meta:
> abstract = True
> class VideoFile(VideoModel):
> video = models.FileField(upload_to='uploads/')
> class Videolink(VideoModel):
> URL = URLField(max_length=200)
>
>

> Would it be better if there is only 1 model with both a FileField and
> URLField.
>
IMO, yes, indeed

> They are both set to blank = true. Put a message on the page, saying
> either upload a file or provide a Youtube link. In the backend, check the
> request.POST whether one of these fields is filled in, if not, render the
> form again with an error message.
>
class VideoModel(models.Model):
title = models.CharField(max_length=200)
post_by = models.OneToOneField(settings.AUTH_USER_MODEL)
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)video =
models.FileField(upload_to='uploads/', blank=True, null=True)
url = URLField(max_length=200, blank=True, null=True)

def clean(self):

super().clean()

if not self.url and not self.video:

 raise(ValidationError({"url": "Both url and video can't be null"})

 def get_video_url(self):

 return(url if self.url else self.video.url)


 This is a way of doing it. If you use a ModelForm, then it will show the
error message automatically. You can add some javascript for showing only
the one that was chosen. You should have for convenience a function or
method that return the url for the video independently of the source.

>
> Which one is better to handle such situation? Or they are equally
> horrible? I couldn't think of a third option.
>
> --
> 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/31186b81-e108-47f9-8594-a140dcad3097%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/CA%2BFDnhJuyZGN9_nSbmOoZcknxA3r8LFFRPEx3QQQj9bwPx8hZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django http request to api error

2018-01-16 Thread Matemática A3K
On Wed, Jan 17, 2018 at 1:42 AM,  wrote:

> As this is the first time I'm trying this out, I do not know what is wrong
> with the problem. So it would be great if someone can help me solve this
> problem
>
>
> The code I'm using is at the bottom page of this website:
> https://www.twilio.com/blog/2014/11/build-your-
> own-pokedex-with-django-mms-and-pokeapi.html
>
> Where it give example on how you can make HTTP request function and
> retrieve database on your query.
>
>
> The code on the website is this.
>
> *query.py*
>
> import requestsimport json
>
> BASE_URL = 'http://pokeapi.co'
>
> def query_pokeapi(resource_url):
> url = '{0}{1}'.format(BASE_URL, resource_url)
> response = requests.get(url)
>
> if response.status_code == 200:
> return json.loads(response.text)
> return None
>
> If there is not a 200 response it returns None

>
>
>
> charizard = query_pokeapi('/api/v1/pokemon/charizard/')
>
>
It's because charizard is None

>
> sprite_uri = charizard['sprites'][0]['resource_uri']
>
> that can't do None['sprites']...

>
> description_uri = charizard['descriptions'][0]['resource_uri']
>
> sprite = query_pokeapi(sprite_uri)
> description = query_pokeapi(description_uri)
> print
> charizard['name']print
> description['description']print
> BASE_URL + sprite['image']
>
>
> In my edit, I only change these print line at the bottom of this
>
> *query.py*
>
> print(charizard['name'])print(description['description'])print(BASE_URL + 
> sprite['image'])
>
>
> But i got this error instead
>
> Traceback (most recent call last): File "query2.py", line 46, in
> sprite_uri = charizard['sprites'][0]['resource_uri'] TypeError:
> 'NoneType' object is not subscriptable
>
> And that's why the error


> --
> 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/af20ad33-1843-4fff-93fb-8681f7d5b88e%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/CA%2BFDnhL16ko3%3Dcc%3D5f91t6_PKLcKPLNbK%3DEq-ap61G8GgYCRmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django view not working for practice project

2018-01-16 Thread Matemática A3K
views.py

>   def index(request):
> latest_comic = Comic.objects.order_by('-comic_pub_date')[:2]
>
> This has an implicit .all(), it's the same than doing

Comic.objects.all().order_by('-comic_pub_date')[:2]

Then you are slicing it for the first 2 records, that's why you see 2
records. Use .first() instead the slicing to get only one record (or
slice 1, [:1] or [0]). Your template code also support several
elements, you should check it


> context = {'latest_comic': latest_comic}
> return HttpResponse(context)
> # return render(request, 'futureFleet/index.html', context) This sends to 
> the template but doesn’t work at the moment
>
>

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


Re: I want to update records, I use View instated of UpdateView, is this right way ? can anyone tell me, is this right way or wrong?

2018-01-16 Thread Matemática A3K
Does it work?

On Mon, Jan 15, 2018 at 5:05 AM, Amitkumar Satpute <
satpute.amitku...@gmail.com> wrote:

>
>1.
>2.
>3.
>4. views.py
>5. ---
>6. class UpdateUser(View):
>7. def post(self,request,pk):
>8. user=get_object_or_404(User,pk=pk)
>9. userinfo=get_object_or_404(UserCreation,user=user)
>10. user_form=UserUpdateForm(request.POST,instance=user)
>11. user_creation_form=UserCreationForm(request.POST,instance=userinfo)
>12. if user_form.is_valid() and user_creation_form.is_valid():
>13. user=user_form.save(commit=False)
>14. user.save()
>15. user_create=user_creation_form.save(commit=False)
>16. user_create.modified_date()
>17. user_create.save()
>18. return redirect('adminaccount:add_user')
>19. return render(request,'adminaccount/add_new_user.html',{'user_form'
>:user_form,'user_creation_form':user_creation_form,'btn':'Update'})
>20.
>21. def get(self,request,pk):
>22. user=get_object_or_404(User,pk=pk)
>23. userinfo=get_object_or_404(UserCreation,user=user)
>24. user_form=UserUpdateForm(instance=user)
>25. user_creation_form=UserCreationForm(instance=userinfo)
>26. return render(request,'adminaccount/add_new_user.html',{'user_form'
>:user_form,'user_creation_form':user_creation_form,'btn':'Update'})
>
> --
> 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/ef2efcff-ed34-4fd6-8764-6af4aba4ad5a%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/CA%2BFDnhJ6ZqzhZc-CR8n-R4yj_%2B_WjHt9AB7YYeT9ewCT11ROnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using the ModelAdmin.inlines class, there is no DELETE button

2018-01-16 Thread Matemática A3K
On Tue, Jan 16, 2018 at 6:15 PM, Matemática A3K <matematica@gmail.com>
wrote:

> According to https://code.djangoproject.com/ticket/15910:
> "When adding a form to an inline formset in the admin interface it has a
> nice "Remove" link added automatically. These links are however missing
> from empty rows that have been created as a result from the "extra" option.
> They are also removed when the form is saved and validation of the form as
> a whole fails"
>
> Could be that something is invalid and you are not rendering errors in the
> template?
>
This is unlikely, you are not overriding the admin's template, right?



>
> On Sat, Jan 13, 2018 at 11:12 AM, FernandoJMM <ferna...@lagunadeduero.com>
> wrote:
>
>> Good Morning,
>>
>> I'm customizing the ModelAdmin class inlines attribute. The code is this.
>>
>> class NaveInline(admin.TabularInline):
>> model = Nave
>> fields = ['codigoNave', 'nave', 'tipoPuesta']
>> ordering = ['codigoNave']
>> extra = 1
>>
>>
>> class GranjaAdmin(admin.ModelAdmin):
>> fieldsets = [
>> (None, {'fields': [('codigoGranja', 'granja'), ('empresa',
>> 'tipoGranja'), ('regimen')]}),
>> ('Datos adicionales', {'fields': [('direccion', 'localidad',
>> 'codigoPostal',
>> 'provincia', 'region', 'pais', 'telefonoPrincipal',
>> 'telefonoMovil',
>> 'fax', 'email', 'ceence','cea', 'maquina',
>> 'clasificacionZootecnica',
>> 'formaDeCria', 'notas')], 'classes': ['collapse']}),
>> ]
>>
>> inlines = [NaveInline]
>>
>>
>>
>> . . . . . .
>>
>>
>>
>> Everything works perfectly, I can add granjas / naves, edit granjas /
>> naves, and clear granjas. . but I can not do it is to delete naves that in
>> this case are the lines (inlines).
>>
>> I do not get any errors, I can see the line selection check but the line
>> deletion button DOES NOT APPEAR.
>>
>> Thanks for your help,
>> Fernando
>>
>> --
>> 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/ms
>> gid/django-users/c21e2ff0-a1d0-4f83-b6c9-bc91a8d1e7e2%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/c21e2ff0-a1d0-4f83-b6c9-bc91a8d1e7e2%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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/CA%2BFDnhKpHvZ7S1be6AaY0D-NaGnB4%2BjcqO8aVKb7aS_oS2GSww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using the ModelAdmin.inlines class, there is no DELETE button

2018-01-16 Thread Matemática A3K
According to https://code.djangoproject.com/ticket/15910:
"When adding a form to an inline formset in the admin interface it has a
nice "Remove" link added automatically. These links are however missing
from empty rows that have been created as a result from the "extra" option.
They are also removed when the form is saved and validation of the form as
a whole fails"

Could be that something is invalid and you are not rendering errors in the
template?

On Sat, Jan 13, 2018 at 11:12 AM, FernandoJMM 
wrote:

> Good Morning,
>
> I'm customizing the ModelAdmin class inlines attribute. The code is this.
>
> class NaveInline(admin.TabularInline):
> model = Nave
> fields = ['codigoNave', 'nave', 'tipoPuesta']
> ordering = ['codigoNave']
> extra = 1
>
>
> class GranjaAdmin(admin.ModelAdmin):
> fieldsets = [
> (None, {'fields': [('codigoGranja', 'granja'), ('empresa',
> 'tipoGranja'), ('regimen')]}),
> ('Datos adicionales', {'fields': [('direccion', 'localidad',
> 'codigoPostal',
> 'provincia', 'region', 'pais', 'telefonoPrincipal',
> 'telefonoMovil',
> 'fax', 'email', 'ceence','cea', 'maquina',
> 'clasificacionZootecnica',
> 'formaDeCria', 'notas')], 'classes': ['collapse']}),
> ]
>
> inlines = [NaveInline]
>
>
>
> . . . . . .
>
>
>
> Everything works perfectly, I can add granjas / naves, edit granjas /
> naves, and clear granjas. . but I can not do it is to delete naves that in
> this case are the lines (inlines).
>
> I do not get any errors, I can see the line selection check but the line
> deletion button DOES NOT APPEAR.
>
> Thanks for your help,
> Fernando
>
> --
> 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/c21e2ff0-a1d0-4f83-b6c9-bc91a8d1e7e2%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/CA%2BFDnh%2BwdiQvM550ZXQN2-xVybqCS98mC_xXFef7QWdpK4i6bQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Simple file uploading app

2018-01-16 Thread Matemática A3K
https://codereview.stackexchange.com/questions/124699/multi-threading-upload-tool

On Wed, Jan 10, 2018 at 11:46 AM, guettli  wrote:

>
>
> Am Dienstag, 9. Januar 2018 01:08:48 UTC+1 schrieb Mike Morris:
>>
>> Though it is not a Drupal app, there is an excellent drop box type app in
>> PHP called "Download Ticket Service"... simple, no frills, entirely
>> cross-platform and open:
>>
>> http://www.thregr.org/~wavexx/software/dl/
>> I have no idea if it could be readily incorporated into your app, but
>> just FYI
>>
>>
>
> Yes, this php project does a lot. My uploader does much less. But maybe we
> could agree on the basic http stuff...
>
>
>
> From their website:
>>
>> “dl” is a simple file sharing service for quick/one-off file transfers.
>> Upload a file to get a link you can share. Or create a sharing link to
>> receive files from others. The uploaded files are automatically removed
>> when left unused, requiring zero additional maintenance.
>>
>> “dl” is *built for your users*: easy to use with any browser, integrates
>> smoothly with Thunderbird
>>  for large
>> attachments, works on Android
>> , Windows, OSX
>>  or straight
>> from the command line
>> 
>>  for maximum convenience.
>>
>>
>>
>>
>>
>>
>> On 01/08/2018 04:16 AM, guettli wrote:
>>
>> Just for the records: Since I found no matching solution I wrote a
>> generic http upload tool: https://pypi.python.org/pypi/tbzuploader/
>>
>> For ftp there are thousands of clients, for automated upload via http I
>> found none. That's why I wrote above tool.
>>
>> Regards,
>>   Thomas
>>
>> Am Mittwoch, 25. Oktober 2017 16:57:31 UTC+2 schrieb guettli:
>>>
>>> I need a simple file uploading app.
>>>
>>> Every user should be able to upload files to his own area.
>>>
>>> This is the basic feature. You could think of additional goodies, but
>>> the first step is
>>> above feature.
>>>
>>> I tried to find an application which implements this, but failed.
>>>
>>> I tried this and other searches:
>>>
>>> https://djangopackages.org/search/?q=upload
>>>
>>>
>>> Before I start coding, I wanted to ask here, because I prefer re-using
>>> to re-inventing :-)
>>>
>>> Do you know an app which gives me this feature?
>>>
>>> Regards,
>>>   Thomas Güttler
>>>
>>>
>>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/016f37e6-3d91-40bc-bef5-8da625125117%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/ea66ee06-b01c-4972-a3ce-db8089a5e7af%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/CA%2BFDnhKWLLNWdw08jw0hZ4G75yek3bnpSKH_Q%3D8OnJg44%2Bq-wQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New release of django-ai: Spam Filtering systems

2018-01-15 Thread Matemática A3K
I’m very happy of announcing the second release of django-ai: Artificial
Intelligence for Django.

https://github.com/math-a3k/django-ai

https://django-ai.readthedocs.io/en/latest/readme.html

The main exciting features of this version are Spam Filtering systems and
Classification with Support Vector Machines ready to be plugged into any
Django application.
Spam Filtering

This *system* uses the scikit-learn framework  as
engine and allows you to incorporate to any Django Model susceptible to
spamming a self-updating filter capable of learning from labelled history
to discern Spam content so you can act accordingly.

The classifier can be chosen and all the parameters in the process can be
fine-tunned conveniently via the admin front-end. See the example

and the documentation

for more.

Plugging Spam Filters to your project has never been so easy!! :)
Classification

A new app is introduced: *Supervised Learning*, which provides
Classification and Regression models ready to be plugged into django-ai
systems or to be used stand-alone in your application where deemed
necessary.

Support Vector Machines (SVM), one of the most understood and best
performing classifier for high-dimensional data is featured in this app.

Cheers!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/CA%2BFDnhKvgc6RFu-poCBqfXqQRnEZUaUWmGCcEVuF4YUwz9huyQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:51 PM, Ronnie Raney  wrote:

> *You can't change the of a user from a view unless you do a redirect. You
> can issue a redirect to /post/ where the id is what you picked at
> random at the "random_post" view*
>
> I can't change the *what *of a user from the view? Also, what user? I've
> tried putting  in there and it causes errors. I've also tried ,
> , , , and 
>
> *Is your template for a "random_obj" or for a "post" object? What does it
> expect? You can insert a "import ipdb; ipdb.set_trace()" after "context" in
> your view and inspect if it is right - it will probably be OK.*
> *Did you rename the post template to random_post and did not change the
> variables inside? If so, just use something like {"post": random_obj}.*
>
> The template is asking for the name of the url - "random_post". The
> template is loading right now at */post/random/* - confirmed by
> inspecting the page. The template expects to get the random_post view, I
> would assume. There are no errors telling me otherwise. Once again, the
> template is named random_post. So what I think you're suggesting is to
> change the contex to this:
>
> *context = {'random_obj':random_post,}*
>
> I also tried switching these:
>
> *context = {'random_post':random_obj,}*
>
> 'random_obj' is what was established here: *random_obj =
> Post.objects.get(post_id=random.choice(list(post_ids)))*
> 'random_post' is the name of my urlpattern, and the name of my template
> link
>
> Am I getting anywhere near understanding what you're saying? All of the
> things that I've tried are leading me to a template with blank fields.
>

Listen to Mattew's summary


> --
> 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/6e2224c1-ebbc-4f44-947b-a9115b56e4e8%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/CA%2BFDnhJotU9bNvtL5ct1jjg2f1DMuUbmPjwT5W8Cfhpk1_VXGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing a process from Django

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:41 PM, Kasper Laudrup <laud...@stacktrace.dk>
wrote:

> Hi Matemática A3K,
>
> On 2018-01-08 17:58, Matemática A3K wrote:
>
>>
>> With this https://stackoverflow.com/questions/89228/calling-an-externa
>> l-command-in-python
>> you can find out which distribution is using, then for each distribution
>> there's a different command for restarting DHCP (systemctl, upstart,
>> system-v) and with the same execute it with sudo to some user with
>> privileges to just do that. You can call that function ("restart_dhcp()")
>> from any django view.
>>
>>
> Thanks a lot for your answer.
>
> I would rather avoid using any kind of init system for managing dhcpd,
> since I would like to run the Django app in a docker container (running
> systemd inside docker is not a good idea) and the options given for eg.
> logging and configuration would be quite different from the standard
> installation of dhcpd on any distro.
>

Then it will be easier for you :)


>
> So my question is more related to any kind of process that should be
> managed from a Django app.
>
>
Django does not manages processes, Django is a web framework. Python can
manage processes. What kind? Any :)


> But thanks a lot for your input.
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> 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/ms
> gid/django-users/8325b598-5db5-2a34-8fc5-aa4c1daf0ad5%40stacktrace.dk.
>
> 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/CA%2BFDnh%2BeBKrh0p-a%2BEBxn%2B2NJm6Xj-vVs6Y_Ugjw7%2BQ9OabQsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:11 PM, Ronnie Raney  wrote:

> Thanks - for clarification. Yes! good advice on remaining calm. Apologies
> if I seemed intense.
>
> If I use this urlpattern, it takes me to the correct template.
>
> *path('post/random/', views.random_post, name='random_post'),*
>
> But there is no data. I really wanted to include the pk in the URL, to see
> which one it was picking at random.
>

You can't change the of a user from a view unless you do a redirect. You
can issue a redirect to /post/ where the id is what you picked at
random at the "random_post" view


> But it appears the data is not being queried correctly, or it's not being
> sent over as part of the view.
>
> Revised view:
>
> *def random_post(request):*
> *post_ids = Post.objects.all().values_list('post_id', flat=True)*
> *random_obj =
> Post.objects.get(post_id=random.choice(list(post_ids)))   I am still unsure
> if this is the correct variable. *
> *context = {'random_obj':random_obj,}*
> *return render(request, 'blog/random_post.html', context)*
>

Is your template for a "random_obj" or for a "post" object? What does it
expect? You can insert a "import ipdb; ipdb.set_trace()" after "context" in
your view and inspect if it is right - it will probably be OK.
Did you rename the post template to random_post and did not change the
variables inside? If so, just use something like {"post": random_obj}.

>
>
> Also, the here are my imports. Maybe there's something missing:
>
> *from django.shortcuts import render, redirect*
> *from .forms import ContactForm*
> *from django.http import HttpResponse, HttpResponseRedirect*
> *from django.shortcuts import render, redirect*
> *from django.core.mail import send_mail, BadHeaderError*
> *from django.http import HttpResponse, HttpResponseRedirect*
> *from django.utils import timezone*
> *from .models import Book, Writer, Translator, Post*
> *import random*
>
>
> --
> 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/7f118b95-c122-4fc3-bfee-f1d008919b5d%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/CA%2BFDnh%2B%3DdYw%2BLJVcy1quLpxx-KRBLMxBvXxxY5whPi6-GeZagA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django local development server hangs after calling pandas df.plot a second time

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 2:07 PM, asilver <asil...@net-sense.com> wrote:

> I looked around for a django-pandas forum/group but could not find one...
>  I didnt' provide any errors or stack traces because there are none... The
> web server just hangs and I have to go into Windows task manager and kill
> the cmd window and sometime even that is not enough (I need to also
> separately kill the python2.7 process).  Any other recommendations for
> troubleshooting?  I'm not really a python expert by any means...
>
> Thx
>

Sorry, but I haven't used Pandas, django-pandas and I don't use Windows, so
I can't help you. Why don't you try opening an issue in
https://github.com/chrisdev/django-pandas or contacting the listed
contributors? I don't think they are reading this list...

HTH


>
>
> On Sunday, January 7, 2018 at 2:53:45 PM UTC-5, Matemática A3K wrote:
>>
>> Hi! This may be better suited for the django-pandas community, as it
>> involves its internals. It is also very hard to debug without errors or
>> stack traces.
>>
>> HTH
>>
>> On Sun, Jan 7, 2018 at 3:51 PM, asilver <asi...@net-sense.com> wrote:
>>
>>> I'm trying to build a small website, using django, that stores network
>>> performance data. The user will be able to use filters to retrieve the
>>> exact data he/she wants and then have the option to graph that data. I'm
>>> using django-pandas to convert filtered queryset to a dataframe and from
>>> there to create a plot. Everything works fine the first time the plot
>>> function is called. When the plot function is called a second time, the
>>> python web server just hangs (started from python2.7.exe manage.py
>>> runserver).
>>>
>>> Here is the django view function:
>>>
>>>
>>> def FilteredPerformanceChartsView(request):
>>> f = PerfvRtrOnlyFilter(request.GET, queryset=PerfvRtrOnly.objects.all())
>>> df = read_frame(f.qs, fieldnames=['runDate', 'deviceName', 'aggrPPS', 
>>> 'jdmVersion'])
>>>
>>> #
>>> # Let's pass the Pandas DataFrame off to a seperate function for
>>> # further processing and to generate a chart.
>>> # This should return an image (png or jpeg)
>>> #
>>> chart = pandas_generate_chart(f.qs)
>>>
>>> return render(request,
>>>   'performance_charts.html',
>>>   context={'filter': f,
>>> 'chart': chart,
>>> 'dataFrame': df,
>>> },
>>>
>>>   )
>>>
>>>
>>>
>>> The function *pandas_generate_chart* is where the problem is. After
>>> performing a lot of troubleshooting, what appears to trigger the hang is
>>> calling df.plot a second time. In other words, when the user hits the
>>> button to generate a different chart. Until that second request to generate
>>> a chart is submitted, the website still works perfect. You will also notice
>>> that plt.close() is commented out below. If I uncomment that out, the
>>> webserver will hang the first time this function is called. (Note, it will
>>> display the chart). I've been looking into the pyplot interactive vs
>>> non-interactive modes to see if that was the cause of the problem. From the
>>> troubleshooting I've done, it is running in non-interactive mode.
>>>
>>>
>>> def pandas_generate_chart(filtered_queryset):
>>>
>>> df = read_frame(filtered_queryset, fieldnames=['jdmVersion', 
>>> 'hardware', 'deviceName', 'aggrPPS'])
>>> df = df.set_index('jdmVersion')
>>>
>>> # Plot
>>> myplot = df.plot(kind='barh', figsize=(12,7), grid=True)
>>> myplot.set_ylabel('JDM Version')
>>>
>>> format="png"
>>> sio_file = StringIO()
>>> plt.savefig(sio_file, format=format)
>>> image = base64.b64encode(sio_file.getvalue())#   plt.close()
>>> sio_file.close()
>>> return image
>>>
>>>
>>>
>>> Thank you 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...@googlegroups.com.
>>>

Re: Simple file uploading app

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 9:16 AM, guettli  wrote:

> Just for the records: Since I found no matching solution I wrote a generic
> http upload tool: https://pypi.python.org/pypi/tbzuploader/
>
> For ftp there are thousands of clients, for automated upload via http I
> found none. That's why I wrote above tool.
>
> Regards,
>   Thomas
>

Good initiative! I think you didn't find anything because you might have
search it for Django and not for Python (but just a guess).
Here's one that can give you more ideas, like the progress bar:
https://github.com/tokland/youtube-upload

It's not generic enough for general use - at least to me - as for the
glance I took, it looks for pairs of files for your tbz site / software (I
don't know German), and I don't need an uploader, but I will have it in
mind :)


> Am Mittwoch, 25. Oktober 2017 16:57:31 UTC+2 schrieb guettli:
>>
>> I need a simple file uploading app.
>>
>> Every user should be able to upload files to his own area.
>>
>> This is the basic feature. You could think of additional goodies, but the
>> first step is
>> above feature.
>>
>> I tried to find an application which implements this, but failed.
>>
>> I tried this and other searches:
>>
>> https://djangopackages.org/search/?q=upload
>>
>>
>> Before I start coding, I wanted to ask here, because I prefer re-using to
>> re-inventing :-)
>>
>> Do you know an app which gives me this feature?
>>
>> Regards,
>>   Thomas Güttler
>>
>>
>> --
> 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/016f37e6-3d91-40bc-bef5-8da625125117%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/CA%2BFDnh%2BiW-gRyU%3DR9GqxcGvc39gumKZ9tpdBi15WwgUuTnb7Xg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Managing a process from Django

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 12:48 PM, Kasper Laudrup 
wrote:

> Hi fellow Django users,
>
> I'm working on creating a Django application for managing DHCP leases and
> DNS entries and for that I would like to be able to (re)start the DHCP
> daemon from Djano.
>
> I think it would be best to simply use a popen object from pythons
> subprocess module (most likely wrapped in a class), but I'm not really sure
> which place would be the most logical place to keep that object? Of course
> there should only be a single instance of that object.
>
> I have also been looking into using some kind of service framework, but
> what I have found so far seems to be aimed at task queues (celery etc.),
> which would definitely be an overkill for my use case.
>
> It could also be that I'm approaching this the wrong way, in which case I
> would be happy to hear better ideas on how to do this.
>
> Thanks a lot for any input.
>
> Kind regards,
>
> Kasper Laudrup
>

With this
https://stackoverflow.com/questions/89228/calling-an-external-command-in-python
you can find out which distribution is using, then for each distribution
there's a different command for restarting DHCP (systemctl, upstart,
system-v) and with the same execute it with sudo to some user with
privileges to just do that. You can call that function ("restart_dhcp()")
from any django view.

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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/f86f877c-3462-b8bd-95ac-3da1c77c8f72%40stacktrace.dk.
> 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/CA%2BFDnh%2Bpzu%3DE2yKHEkcPZhj8X3nA-29pwRfTo%3DSqk%2BOmjQUxkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 1:37 PM, Ronnie Raney  wrote:

> Ugh. Sorry for the confusion. Here again are the pieces where I need
> suggestions. Please suggest actual code. I can't decipher things written in
> plain language on forums. Code is key for me.
>

OK, first, calm down, seems that your feelings aren't letting you think and
you are "running in circles". Code is a language, just as English, you can
understand both, you just need to read it slowly and calmed.


>
> path('post//', views.PostDetailView.as_view(),
> name='post_detail'),
>


> path('post/*random/???*', views.RandomDetailView.as_view(),
> name='random_post'),* ### I don't know what to put here*
>

No id and point it to the FBV:

> path('post/*random/*', views.random_post, name='random_post'),* ###
> I don't know what to put here*
>



>
>
> Also my view:
>
> def random_post(request):
> post_ids = Post.objects.all().values_list('post_id', flat=True)
>   * ### Is 'post_id' correct? YES That's my field name that is my primary
> key*
> random_obj = Post.objects.get(post_id=random.choice(list(post_ids)
> ))
> *### What do I put here? id? pk? post_id? -> You may have to convert the
> queryset to a list / evaluate but I'm not sure, you'll have to ty it*
> context = {'random_obj':random_obj,}
> return render(request, 'blog/random_post.html', context)
>
> I have tried a bunch of different configurations for my urlpattern. I have
> tried different variable names in my view. I'm not sure that my data is
> actually being inserted into my view. I don't know what my urlpattern is
> supposed to be. I don't know which variables to use in my view, regarding
> the primary key.
>

Calm down, yes you do, just re-read the thread slowly and you'll find the
answers :)


> --
> 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/d5ba26c4-dacc-4ad4-9050-55c1f44cdd8c%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/CA%2BFDnhJULft7MhQUXEF2sitqSZxKSn5ixbtt6HznXdwUX%2BpV0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 11:50 AM, Ronnie Raney  wrote:

> Also, would something like this work, and would it be a way to create the
> view?
>

No, it won't work, you should read
https://docs.djangoproject.com/en/2.0/topics/class-based-views/intro/

>
> class RandomDetailView(DetailView):
> model = Post
> def random_post(request):
> post_ids = Post.objects.all().values_list('post_id', flat=True)
> random_obj = Post.objects.get(post_id=random.choice(post_ids))
> ###  Is "id" here supposed to be pk, or post_id?
> context = {'random_obj':random_obj,}
> return render(request, 'blog/random_post.html', context)
>
>
CBV have a standarized way of getting their object, "get_object()", you
have to override that method (or override the "get_queryset()") and make it
return your random post (which you already know). But also, you may need to
hack more the DetailView because it expects an id - and in the case of
random you won't have it, you are choosing the id at random.

Using a "lower level" CBV, like TemplateView may be easier, but if you
can't read
https://docs.djangoproject.com/en/2.0/topics/class-based-views/intro/
because of the hurry, a FBV will work and it's not a bad option :)


>
>
> --
> 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/e647327a-6f64-4cb1-a4fc-c5188db010ee%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/CA%2BFDnhLEpDjCqRR91Arw%3DFSzHFZBFq-DecPQCxU3_hwPGbOL8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-08 Thread Matemática A3K
On Mon, Jan 8, 2018 at 11:30 AM, Ronnie Raney  wrote:

> Thanks Mat-A3K
>
> Here's what I have so far...
>
> *models.py*
> class Post(models.Model):
> post_id = models.AutoField(primary_key=True)
>  all the other fields...
>
> *views.py*
>
> #Normal (not random) post detail view
> class PostDetailView(DetailView):
> model = Post
> template_name = 'blog/post_detail.html'
>
> # Random view
> def random_post(request):
> post_ids = Post.objects.all().values_list('post_id', flat=True)
> random_obj = Post.objects.get(id=random.choice(post_ids))
> context = {'random_obj':random_obj,}
> return render(request, 'blog/random_post.html', context)
>
> *urls.py*
>
> urlpatterns = [
> 
> path('post//', views.PostDetailView.as_view(),
> name='post_detail'), ### I included this to show my normal Post Detail view
> path('post//', views.random_post, name='random_post'),
> 
> ]
>
> The error I'm getting now has to do with template rendering. I am confused
> about what I should be using and where - id, post_id, pk, etc.
>
> Reverse for 'random_post' with no arguments not found. 1 pattern(s) tried: 
> ['post\\/random\\/(?P[0-9]+)\\/$']
>
>
> Please help me figure out my urlpattern, and corrections to my view. I think 
> we are very close!
>
>
You have the same url pointing to different views - 'post//' - in
what you pasted - that's a problem, in the best case only one will be used,
don't know which. On the other hand, the error is complaining that what it
could resolve has a non-optional id parameter - /post/random// -
which you are not passing (probably a "{% url 'random_post' %}"). Remove
the  from the pattern or add it to the url template tag if you need it.
And you probably need to clean up and fix your urls.py... :)


> --
> 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/176a1d46-d74e-4999-bb86-b90eac05882f%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/CA%2BFDnhJ4L%2BbSRSB-9-1HaPjNciEdkZ-5ETKGEb--npKN_HU4EA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-07 Thread Matemática A3K
On Sun, Jan 7, 2018 at 7:44 PM, Ronnie Raney  wrote:

>
> def random_post(request):
> posts_ids = Post.objects.all().values_list("id", flat=True)
> random_obj = Post.objects.get(id=random.choice(posts_ids))
> context = {'random_obj': random_obj,}
> return render(request, 'blog/random_post.html', context)
>
> Is “”id”” actually post_id in my case?
>

*Model*: I created a model called Post with all the typical fields,
> including a unique autofield. My intention was to randomly select a pk
> using this autofield. I thought about using a property to do some of the
> querying/logic for my random functionality, but I'm not sure if this is the
> best way to do it.
>

It should be your pk, if you did it the "standard way" should be "id", the
idea is to sample one from all your existing pks - whatever it is.

This is a view right? not part of the model?
>

Yup


>
> --
> 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/b1080eca-fd1c-407f-bd26-46f3740a603f%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/CA%2BFDnh%2Bt-ScM5TMTSmv0%2By1G6ho5t1MLhfZsdFAjckQZfg-ogg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django local development server hangs after calling pandas df.plot a second time

2018-01-07 Thread Matemática A3K
Hi! This may be better suited for the django-pandas community, as it
involves its internals. It is also very hard to debug without errors or
stack traces.

HTH

On Sun, Jan 7, 2018 at 3:51 PM, asilver  wrote:

> I'm trying to build a small website, using django, that stores network
> performance data. The user will be able to use filters to retrieve the
> exact data he/she wants and then have the option to graph that data. I'm
> using django-pandas to convert filtered queryset to a dataframe and from
> there to create a plot. Everything works fine the first time the plot
> function is called. When the plot function is called a second time, the
> python web server just hangs (started from python2.7.exe manage.py
> runserver).
>
> Here is the django view function:
>
>
> def FilteredPerformanceChartsView(request):
> f = PerfvRtrOnlyFilter(request.GET, queryset=PerfvRtrOnly.objects.all())
> df = read_frame(f.qs, fieldnames=['runDate', 'deviceName', 'aggrPPS', 
> 'jdmVersion'])
>
> #
> # Let's pass the Pandas DataFrame off to a seperate function for
> # further processing and to generate a chart.
> # This should return an image (png or jpeg)
> #
> chart = pandas_generate_chart(f.qs)
>
> return render(request,
>   'performance_charts.html',
>   context={'filter': f,
> 'chart': chart,
> 'dataFrame': df,
> },
>
>   )
>
>
>
> The function *pandas_generate_chart* is where the problem is. After
> performing a lot of troubleshooting, what appears to trigger the hang is
> calling df.plot a second time. In other words, when the user hits the
> button to generate a different chart. Until that second request to generate
> a chart is submitted, the website still works perfect. You will also notice
> that plt.close() is commented out below. If I uncomment that out, the
> webserver will hang the first time this function is called. (Note, it will
> display the chart). I've been looking into the pyplot interactive vs
> non-interactive modes to see if that was the cause of the problem. From the
> troubleshooting I've done, it is running in non-interactive mode.
>
>
> def pandas_generate_chart(filtered_queryset):
>
> df = read_frame(filtered_queryset, fieldnames=['jdmVersion', 'hardware', 
> 'deviceName', 'aggrPPS'])
> df = df.set_index('jdmVersion')
>
> # Plot
> myplot = df.plot(kind='barh', figsize=(12,7), grid=True)
> myplot.set_ylabel('JDM Version')
>
> format="png"
> sio_file = StringIO()
> plt.savefig(sio_file, format=format)
> image = base64.b64encode(sio_file.getvalue())#   plt.close()
> sio_file.close()
> return image
>
>
>
> Thank you 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ed7e5391-3172-4914-bbd4-568e0f76d4f3%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/CA%2BFDnh%2B%2Bj760gOXHpKf-MB2r58kchtEj-89ODv2SAjNtLz0rqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Select random blog post Object from "Post" Model and render In View/Template

2018-01-07 Thread Matemática A3K
def random_post(request):
posts_ids = Post.objects.all().values_list("id", flat=True)
random_obj = Post.objects.get(id=random.choice(posts_ids))
context = {'random_obj': random_obj,}
return render(request, 'blog/random_post.html', context)

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


Re: Django User module extend

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 1:52 PM, Ketul Suthar  wrote:

> class Profile(models.Model):
> user = models.OneToOneField(User, on_delete=models.CASCADE)
> is_manager  = models.BooleanField(default=False)
> manager = models.ForeignKey(User,related_name='user_manager',
> on_delete=
> models.CASCADE, blank=True,null=True)
> def __str__(self):  # __unicode__ for Python 2
> return self.user.username
>
> Is it right ?


Seems so

how can i create form ?
>

One way:
https://simpleisbetterthancomplex.com/tutorial/2016/11/23/how-to-add-user-profile-to-django-admin.html


>
> On 1/5/18, Ketul Suthar  wrote:
> > Can you give me example?
> >
> > On Jan 5, 2018 10:09 PM, "Jani Tiainen"  wrote:
> >
> >> Hi,
> >>
> >> There are numerous ways to achieve what you're asking for, I've been
> >> using
> >> following two:
> >>
> >> You can (and if this a new project, should) create custom user,
> >> regardless
> >> of which one approaches you use.
> >>
> >> 1) For a custom manager add user type field to a custom user model which
> >> says is user a manager or ordinary user. And then add foreign key (or
> >> many
> >> to many if user can have multiple managers) to custom user model to
> self.
> >>
> >> 2)  Have so called "profile", a model with one to one relation to user
> >> model where you put all the same attributes as above.
> >>
> >> Admin can work with both approaches, it's up to you to decide which one
> >> approach suits for you.
> >>
> >> On Fri, Jan 5, 2018 at 6:26 PM, Ketul Suthar 
> wrote:
> >>
> >>> I am beginner to djnago.
> >>>
> >>>
> >>> I want to create app in which admin can create User and Manager and
> >>> manager is assign to user ?
> >>>
> >>> so how can i achieve ? For  that I have to extend user class bacause
> >>> user
> >>> and manager and admin all three can login in system
> >>>
> >>> --
> >>> 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/ms
> >>> gid/django-users/810439c8-6515-4dc6-808d-643b0f1e38d0%40
> googlegroups.com
> >>>  6515-4dc6-808d-643b0f1e38d0%40googlegroups.com?utm_medium=
> email_source=footer>
> >>> .
> >>> For more options, visit https://groups.google.com/d/optout.
> >>>
> >>
> >>
> >>
> >> --
> >> Jani Tiainen
> >>
> >> - Well planned is half done, and a half done has been sufficient
> >> before...
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To 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/CAHn91oeYGMRN0PcxPHUYtu1k8HheW
> FzwNru5FK%2BmcPZGOkCf8Q%
> >> 40mail.gmail.com
> >>  CAHn91oeYGMRN0PcxPHUYtu1k8HheWFzwNru5FK%2BmcPZGOkCf8Q%
> 40mail.gmail.com?utm_medium=email_source=footer>
> >> .
> >> 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/CANuqdaXN3oFWBPifvfX5ZS-baU6wNVcORp1Jg9dsBp%3Du9Bf0FA%
> 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/CA%2BFDnhK8mQFZPHadTRCV1zd5tqKJLydQ9s5SsUrDXDS3YtESgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Links to files

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 1:50 PM, Karl Ritchie  wrote:

> Hi I'm very new to Django. I tried searching for this but the answers I
> found aren't very clear. I'm wanting to create links to PDF documents.
> I've created an app called writing with a static folder with PDF files. At
> first I just put an html  link in the template file but it when I ran it it
> said it couldn't find the file.
> I think I have to change the View.py and URL.py in Writing but what do I
> change it to and what do I put in the template file for the link?
>
>
Karl,

"A static file is a static file", it doesn't matter if it is a jpg or a
pdf. You should read
https://docs.djangoproject.com/en/2.0/howto/static-files/ and think that
instead of img tags for jpgs you will use a tags for pdfs

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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/dcd1a1fc-3aac-4562-a8c3-159b846a44c0%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/CA%2BFDnh%2Bjz9SSTyivi3DmuY7ZDAbz8rSJbZS7sxocuao%2BZ6F0cQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trapping underlying exceptions

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 1:45 PM, Stephan Doliov 
wrote:

> Hi,
> I am diving ever deeper into Django and I came upon some behavior that
> frustrated me but perhaps I am just misunderstanding what should happen and
> why.
>
> In writing unit tests for code, I wanted to write one that traps a
> json.decoder.JSONDecodeError by passing in some malformed JSON.
>
> What appears to happen however, is that Django only reports back the very
> last exception that was raised.
>
> In the case of json.decoder.JSONDecodeError, it's initialization raises a
> ValueError here is the code of json.decoder.JSONDecodeError (from my python
> 3.5 install)
>
> class JSONDecodeError(ValueError):
> """Subclass of ValueError with the following additional properties:
>
>
> msg: The unformatted error message
> doc: The JSON document being parsed
> pos: The start index of doc where parsing failed
> lineno: The line corresponding to pos
> colno: The column corresponding to pos
>
>
> """
> # Note that this exception is used from _json
> def __init__(self, msg, doc, pos):
> lineno = doc.count('\n', 0, pos) + 1
> colno = pos - doc.rfind('\n', 0, pos)
> errmsg = '%s: line %d column %d (char %d)' % (msg, lineno, colno,
> pos)
> ValueError.__init__(self, errmsg)
> self.msg = msg
> self.doc = doc
> self.pos = pos
> self.lineno = lineno
> self.colno = colno
>
>
> def __reduce__(self):
> return self.__class__, (self.msg, self.doc, self.pos)
>
>
>
> Once my django parsing code (default django rest framework 3.7.7) steps
> into here, it's own ParseError class sees only the ValueError (which
> redacts the faulty input JSON).
>

This is it, the exception is catch by DRF


>
> Is this a feature? A bug? Something in between?
>
> My desired behavior would be that i could access the JSONDecodeError
> instances doc property to go back and find out exactly which malformed JSON
> was ruining my ability to serve a complete request.
>
> Is there a way I can get Django to make visible the underlying
> JSONDecodeError (that drove a Value Error that django rest framework then
> presents to me wrapped in its ParseError class)?
>
> Clearly, I could change the underlying JSON Decoder code to my liking,
> either by changing it's errmsg or by subclassing (ValueError) it in a way
> to provide more rich information back upstream?  If I run some sample code
> just in python CLI (less django) I get the whole JSONDecodeError exception
> as I desire. So I suspect modding the decoder class is not really what I
> want. But it would be nice if much like a stack trace, I could access
> ParseError instantianted by ValueError instantiated by JSONDecodeError so
> that I could access all the properties of the underlying error
> (JSONDecodeError).  Should I make a feature request? Or is there already a
> toggle I can control somewhere to do this?
>

Refer to the DRF code and see if you can modify it. If you want to make a
feature request, you will have to do it in DRF


>
> Thanks,
> Steve
>
> --
> 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/15c7b76c-8dcd-4424-b336-8d0325c3a1e1%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/CA%2BFDnh%2BYRbYtO2OzYatf4r3dN8Ug%3DdRLzGUyz6QfhreoLVfdAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.0.1 admin

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 7:26 PM, Matthew Pava  wrote:

> No.  I even uninstalled Django and reinstalled Django, but the issue
> persists.
>
>
>

Seems like the admin's template tags are not being loaded correctly. Are
you using custom template tags? Did you restart your dev server? after the
upgrade (silly but can be that)?


>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *m1chael
> *Sent:* Friday, January 5, 2018 4:25 PM
> *To:* django-users@googlegroups.com
> *Subject:* Re: Django 2.0.1 admin
>
>
>
> did you ever override your admin templates?
>
>
>
> On Fri, Jan 5, 2018 at 5:20 PM, Matthew Pava  wrote:
>
> Hi everyone,
>
> I am finally able to move to Django 2.0, but I just noticed an error I
> keep getting when attempting to open the admin:
>
>
>
> TemplateSyntaxError at /admin/
>
> Invalid block tag on line 58: 'get_admin_log', expected 'endblock'. Did
> you forget to register or load this tag?
>
>
>
> Does anyone have any ideas?
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/4dbdb1ab1c37482eb2150fd8f6cd3426%40ISS1.ISS.LOCAL
> 
> .
> 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/CAAuoY6PCXSrmZpYgXwHfUMs0rcz_
> g3JFmsexHnL_JOfaWXbzTQ%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/c0ea62a85abb4060ae3e291f0f506384%40ISS1.ISS.LOCAL
> 
> .
>
> 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/CA%2BFDnh%2BAouLLYHbDP6t_nGFGyhFuRKA6chh%3DGpFEB-VzyUb4sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue with Python 3.6 and Django 2.0 App Deployment on Shared Hosting

2018-01-05 Thread Matemática A3K
On Mon, Dec 25, 2017 at 7:14 PM, Alok Vaidya  wrote:

> HI All,
>
> I'm a very new into web development as well as very recently started with
> Python 3.6.4 and Django 2.0 and built my first web application
> successfully. Currently I'm in the process of deploying the web-app on a
> shared hosting environment on Bluehost.
>
> I was able to configure both Python and Django latest versions
> successfully on Bluehost server using virstualenv and was able to create my
> test-app ass well on the server directly using SSH client.
>
> Where I'm stuck right now is to make this app work on my domain. I have
> explored everything on google and tried everything possible from my side
> but with no luck in the end. Ever time I try to access my website in my
> local browser, I get the following error message:
>
> 500 Server Error
> A misconfiguration on the server caused a hiccup. Check the server logs,
> fix the problem, then try again.
>
> I understand that it may not be sufficient information for anyone to help
> me with. I'm very new to this whole process of community and forums etc, so
> please let me know in case if you look for any additional info in this
> regard.
>
> I will greatly appreciate any help or pointing me into the right
> direction.
>

In the logs you will find detailed information about the error, you should
start looking at that


>
> Alok.
>
> --
> 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/d38290f8-dd4e-4038-a958-9fed5b32fa34%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/CA%2BFDnhLB6tOt4HvcyvLF3CnNQQvB%2BLdamiOFDzRN6%2BDjH0EV0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error following django's documentation 2.0

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 8:32 PM, FernandoJMM 
wrote:

> Hello everyone,
>
> I'm learning django. I am in the official documentation of django link:
>
> *https://docs.djangoproject.com/en/2.0/intro/overview/
> *
>
> After creating the model and doing the migrate I go to the section called 
> *Enjoy
> the free API* to test in the python terminal
>

Did you get to that python terminal by "python manage.py shell" on the base
directory of your project?


> and I get an error when executing the *import*, it says that it can not
> find the module.
>
> *The only difference with the documentation* is that I am executing it
> from a *virtualenv*.
>
> it can be fixed ?
>

I think so :)


>
> Thank you all
>
> --
> 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/c9941c85-2a42-439f-8999-856507f5f74d%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/CA%2BFDnhK6FjKY3dgv%3Dv5JnFF68FZawM7j1HWYPCWQA0S1OdL_%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Handling Celery Connection Lost Problem

2018-01-05 Thread Matemática A3K
On Fri, Jan 5, 2018 at 9:01 PM, Jason  wrote:

> To reinforce on what Jani Tianen said, this is not a django or python
> issue, nor really a Celery issue.  What you should research and investigate
> is high availability rabbitmq clusters, if this is such a concern for you.
>
> Indeed, Mukul, you should google first :)


> --
> 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/bd85fa9c-1917-45dd-84cd-b86a94993098%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/CA%2BFDnhKYePVwsAraPkWBdC4%3DX0bQBm0wVysZgwp7HR9WS8wGTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Update View not updating table when Rendering fields manually

2018-01-03 Thread Matemática A3K
On Wed, Jan 3, 2018 at 1:53 AM, Sumit Kumar  wrote:

> When I am using simply this
>
> 
> {% block content %}
>{% csrf_token %}
>{{ form }}
>
> {% endblock content %}
> 
>
> It is updating my JobFinal Table I can see *POST
> /JobSchd/jobform_final/3/update/ HTTP/1.1" 302 0* But when changing {{
> form }} to {{ form.job_name }} It doesn't update the table and doesn't
> redirect to the reverse url.And I can see *POST
> /JobSchd/jobform_final/3/update/ HTTP/1.1" 200 4492*
>
Because {{ form }} makes the template engine print all the fields (and
error handling code) of the form, while {{ form.job_name }} will do it for
just the "job_name" field. If there are more fields required for the form
being valid, in the view it will never be succesful and the get_success_url
won't be executed. You won't see any error in the template because that is
printed by {{ form }} - which is not there


> Here is my snippet of related View.py
>
> class JobFinalUpdate(UpdateView):
> model = JobFinal
> form_class = JobFormFinal
> template_name_suffix = '_update_form'
>
>
> def get_success_url(self):
> return reverse('JobSchd:user_details',kwargs={'pk': 
> self.request.user.id})
>
> Here is my form.py class JobFormFinal(forms.ModelForm):
>
> class Meta:
> model=JobFinal
> exclude=['user']
>
> Thank You!
> Kind Regards,
> Sumit Kumar| +1-480-740-7728
>
> Please consider the environment before printing.
>
>
> --
> 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/CAOvNbK5MPctf16RfaZzcfc%3Dt4USd%2B3Ey0H0mm7hT%3DGeh_
> zbyug%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/CA%2BFDnhJ4Occjs0LSSeTyy6iLtki2M%2BcB72TeJZnYgq8pdY2LQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Matemática A3K
On Wed, Jan 3, 2018 at 6:25 AM, Mukul Mantosh <mukulmantos...@gmail.com>
wrote:

> *I'm not sure about understanding you, where are you trying to call it
> again? from ipython?*
>
> I am calling from Django, the code is inside the view.
>
> *def test(request):*
> *  try:*
> *add.delay(2, 2)*
> *  except add.OperationalError as exc:*
> *print('error')*
> *return HttpResponse('working')*
>
> Point 1 - Stop RabbitMQ Server from terminal manually. (sudo service
> rabbitmq-server stop).
> Point 2 - Reload the view from the browser, it will immediately throw
> connection refused error which i could catch easily using try except block
> as provided in above example.
> Point 3 - If you try again reloading the page it hangs up over there. and
> it won't send any http response because it is still waiting and waiting to
> get response.
>

I think this might be because celery can't enqueue the task, so it does not
"return" to django


> Point 4 - You can see celery in background trying to reconnect to the
> broker every 5-10 seconds.
>

If you restart rabbitmq at this point, does it works?


>
>
> *For what I understood, your problem is assuming that if a celery task
> fails, it won't be retried :)*
>
> It should be retried but i can't make a user wait for it because signup
> process is very quick and we cannot halt any user because our connection is
> lost. I just simply want if connection lost try for 10 seconds if connected
> its good otherwise just move on don't get stuck.
>
> Even if i tried add.apply_async((2, 2), retry=False) but it is still  not
> working and the page is not giving back the HTTP Response.
>
> I think i have cleared everything what you wanted to know @Matemática A3K.
>

https://github.com/celery/celery/issues/3241
https://github.com/celery/celery/issues/3921

Seems that it is retried by celery, but with a missing rabbitmq broker it
won't work at all. If you take away the broker, you are taking away how it
works, there is no way of delivering messages. The problem is how to ensure
the broker is always working.

Again, this seems more appropriate for the celery community :)


>
> On Wednesday, January 3, 2018 at 2:08:24 PM UTC+5:30, Matemática A3K wrote:
>>
>>
>>
>> On Tue, Jan 2, 2018 at 11:14 PM, Mukul Mantosh <mukulma...@gmail.com>
>> wrote:
>>
>>> I am not using result backend my question is that when the broker
>>> connection is lost it throws a connection refused exception which i could
>>> normally catch through the following given below code.
>>>
>>> *try:*
>>> *  add.delay(2, 2)*
>>> *except add.OperationalError as exc:*
>>> *  print('error');*
>>>
>>> Reference 1: http://docs.celeryproject.org/en/latest/userguide/calling
>>> .html#connection-error-handling
>>> Reference 2: https://github.com/celery/celery/issues/3933
>>>
>>>
>>> This try except block works only one time and next time when i try to
>>> call again add.delay(2,2)the code is waiting to execute because celery
>>> is re-trying to establish the connection with the broker.
>>>
>>>
>> I'm not sure about understanding you, where are you trying to call it
>> again? from ipython?
>>
>>
>>> I just simply don't want to do, for example: There is a website where a
>>> user signup as a new user and we have to send an verification email through
>>> celery and suddenly the connection gets lost then the code will be in
>>> waiting state because celery is again retrying to establish a connection
>>> with the lost broker.
>>>
>>>
>> I agree that this may be better for a celery mailing list, as "low level"
>> celery is probably not the main expertise of most of the people reading
>> here, as Jason said, for what I understand http://docs.celeryproject.org/
>> en/latest/userguide/calling.html#calling-retry should be sufficient for
>> the "normal" cases.
>>
>> Have in mind that exception will be raised at the celery level, not
>> django because it's async, http://docs.celeryproject.org/
>> en/latest/userguide/calling.html#linking-callbacks-errbacks. Django
>> delegates the task to celery and celery takes care of executing it. If you
>> need to perfect warranty of execution, do it sync, inside the django view
>> send the verification mail, where you can show to the user that the
>> confirmation mail hasn't been sent.
>>
>>
>>> How can we solve this problem ?
>>>
>>>
>> For what I understood, your problem is assuming that if a celery task
>> fails, it

Re: Handling Celery Connection Lost Problem

2018-01-03 Thread Matemática A3K
On Tue, Jan 2, 2018 at 11:14 PM, Mukul Mantosh 
wrote:

> I am not using result backend my question is that when the broker
> connection is lost it throws a connection refused exception which i could
> normally catch through the following given below code.
>
> *try:*
> *  add.delay(2, 2)*
> *except add.OperationalError as exc:*
> *  print('error');*
>
> Reference 1: http://docs.celeryproject.org/en/latest/userguide/
> calling.html#connection-error-handling
> Reference 2: https://github.com/celery/celery/issues/3933
>
>
> This try except block works only one time and next time when i try to call
> again add.delay(2,2)the code is waiting to execute because celery is
> re-trying to establish the connection with the broker.
>
>
I'm not sure about understanding you, where are you trying to call it
again? from ipython?


> I just simply don't want to do, for example: There is a website where a
> user signup as a new user and we have to send an verification email through
> celery and suddenly the connection gets lost then the code will be in
> waiting state because celery is again retrying to establish a connection
> with the lost broker.
>
>
I agree that this may be better for a celery mailing list, as "low level"
celery is probably not the main expertise of most of the people reading
here, as Jason said, for what I understand
http://docs.celeryproject.org/en/latest/userguide/calling.html#calling-retry
should be sufficient for the "normal" cases.

Have in mind that exception will be raised at the celery level, not django
because it's async,
http://docs.celeryproject.org/en/latest/userguide/calling.html#linking-callbacks-errbacks.
Django delegates the task to celery and celery takes care of executing it.
If you need to perfect warranty of execution, do it sync, inside the django
view send the verification mail, where you can show to the user that the
confirmation mail hasn't been sent.


> How can we solve this problem ?
>
>
For what I understood, your problem is assuming that if a celery task
fails, it won't be retried :)


>
>
> On Wednesday, January 3, 2018 at 12:45:10 AM UTC+5:30, Jason wrote:
>>
>> With a broker connection loss, the only thing that will happen is your
>> workers won't pick up new tasks.
>>
>> If you're posting to a result backend like redis and lose the connection,
>> then an exception will be raised in the logs and the task will shut down.
>>
>> Remember tasks are independent processes and you can tell each worker how
>> many tasks to execute before its process is killed.
>>
> --
> 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/41026c20-3ca0-46bd-8bab-361eba75aadc%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/CA%2BFDnhJVA6n%2BNJTFYkpZN6uXMepkJOw6vxK99MkqhYAcxfMOzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 404 for some matching urls too (Version 2)

2017-12-29 Thread Matemática A3K
Please post your urls.py, this looks strange:

admin/ [name='index']
> admin/ login/ [name='login']
> admin/ logout/ [name='logout']
> admin/ r/// [name='view_on_site']
> admin/ ^(?Prsi|auth)/$ [name='app_list']
> login/ [name='login']
> logout/ [name='logout']
> authissue [name='authissue']
>

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


Re: Possible bug: OutputWrapper: TypeError: write() argument must be str, not bytes

2017-12-29 Thread Matemática A3K
On Fri, Dec 29, 2017 at 5:59 AM, emi  wrote:

> Hello all!
> I'm new to the list and mostly new to Django.
>
> I am adding django-encrypted-model-fields to my Django project and one of
> the steps to install it is to generate a key using a ./manage.py command:
> $ ./manage.py generate_encryption_key
>
> When executing it, an error is raised:
> Traceback (most recent call last):
>   File "./manage.py", line 22, in 
> execute_from_command_line(sys.argv)
>   File 
> "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py",
> line 371, in execute_from_command_line
> utility.execute()
>   File 
> "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py",
> line 365, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/usr/local/lib/python3.6/site-packages/django/core/management/base.py",
> line 288, in run_from_argv
> self.execute(*args, **cmd_options)
>   File 
> "/usr/local/lib/python3.6/site-packages/django/core/management/base.py",
> line 335, in execute
> output = self.handle(*args, **options)
>   File "/usr/local/lib/python3.6/site-packages/encrypted_model_
> fields/management/commands/generate_encryption_key.py", line 15, in handle
> self.stdout.write(key, ending=b'\n')
>   File 
> "/usr/local/lib/python3.6/site-packages/django/core/management/base.py",
> line 106, in write
> self._out.write(style_func(msg))
> TypeError: write() argument must be str, not bytes
>
>
> I have found a workaround for this, decoding output before writing to
> stdout, on django/core/management/base.py, line 106:
>
> $ diff django/core/management/base.py-original
> django/core/management/base.py
> 106c106
> < self._out.write(style_func(msg))
> ---
> > self._out.write(style_func(msg).decode(self._out.encoding))
>
> Do I have to do a pull request to Django or try to debug
> django-encrypted-model-fields and talk to their developers?
>

I don't think you should patch the core management for only a third-party
app, instead you should modify the third-party to match what django expects
(i.e. convert to string at generate_encryption_key.py). I think you may
contact their developers for including it on the package


>
> Thanks in advance!
> em and best regardsi
>
> --
> 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/b7372388-ea45-4ec7-b62e-84d0540a365a%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/CA%2BFDnhLbke9V9e6kZqSeZv7VO4ZVJKNqwfkgj6Ojf6Yhx1DnGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [SOS] Django-Oscar Front end(theme) replacement

2017-12-29 Thread Matemática A3K
On Fri, Dec 29, 2017 at 5:14 AM, Fred Grey  wrote:

> Hi,
>

Hi!

>
> Does anybody use django-oscar to build a commerce website? I have done
> most of the things to make it online. But the default theme is ugly and not
> matched with the commodity's style.
>
> We are a startup company and no UXD for the website design right now. Is
> there any other websites I can reference, and do a code based modification
> to get a better user experience?
>
>
No, I don't use it, but it's a Django project, template override /
modifications apply just as a regular Django app:
https://docs.djangoproject.com/en/2.0/howto/overriding-templates/


> Any feedback and suggestion is welcome, Thanks in advance! :)
>
>
https://github.com/django-oscar/django-oscar/tree/master/src/oscar/templates/oscar



> The default theme is like below:
>
> [image: 内嵌图片 1]
>
> Best Regards,
> -Gary
>
> --
> 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/0100ca86-a562-4b57-a4c0-96bac855123c%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/CA%2BFDnhL6iKVzve5sq79EV76cpqTG9eJaGLyahTPW66k3JyLN5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Envío de formulario con una tabla dinámica

2017-12-21 Thread Matemática A3K
Antonio,

Tu duda / problema corresponde a jQuery más que a Django, en una lista
enfocada en Javascript en Español podrás encontrar mas ayuda.

También te recomiendo que uses sitios como jsfiddle para postear tu código
en estos casos, así le va a ser mas fácil para quienes pueden ayudarte el
hacerlo.

Saludos!

2017-12-20 17:09 GMT-03:00 Antonio Veliz :

> bueno estoy ya trabajando con un formulario que tiene una tabla dinámica,
> en la tabla puedo adicionar y eliminar las filas hasta alli todo bien, lo
> que nececito que me ayuden en 2 cosas que no he podido resolver: 1-) El
> segundo select es dependiente del primero y no se hace nada no se que error
> pueda tener ,llevar las sumas totales de cada columna y fila , 2-) enviar
> el formulario completo, se que es un problema enviar la tabla dentro del
> formulario pero me sirve enviarlo como matriz yo me emmcargo después buscar
> los datos en la controladora. Trabajo con python, django,jquery, bootstrap,
> el codigo:
>
> $(document).ready(function () {
> $("#nuevoServicio").click(function () {
> var tableReg = document.getElementById("tablaserviciosprest");
> $("#tablaserviciosprest").append("" + tableReg.rows[1].innerHTML +
> "");
>
> $('.eliminalinea').off().click(function (e) {
> $(this).parent('td').parent('tr').remove();
> });
> addcambios();
> });
> });
>
> function addcambios() {
> $(".seleccionarArea1").change(function () {
> var $servselect = $(this).parents("tr").find("td")[1].children[0];
> $servselect.disabled = false;
> });
> }
> function empty(unselect) {
> for (var i = 1; i < unselect.children.length; i++) {
> unselect.children[i].remove();
> }
> }
>
>
>
> https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/
> jquery.min.js">
> https://maxcdn.bootstrapcdn.com/bootstrap/3.
> 3.7/css/bootstrap.css">
> https://maxcdn.bootstrapcdn.com/bootstrap/3.
> 3.7/js/bootstrap.js">
> 
> 
> x
> Adicionar Servicio Prestado
> 
> 
>
> 
> 
> 
> Área*:
> 
> 
> Seleccione Área ...
> {% for area in area_List %}
> {{ area.area }}
> {% endfor %}
> 
> 
> 
> 
> Cliente*:
> 
> 
> Seleccione Cliente ...
> {% for cliente in cliente_List %}
> {{ cliente.nombreEmp }}
> {% endfor %}
> 
> 
> 
> 
> Servicios
> Prestados*:
> 
> 
> 
> 
> Área
> Servicio
> Precio CUP
> Precio CUC
> Precio Total
> Cantidad
> Costo Total
> Opciones
> 
> 
> 
> 
> 
>  class="select2_single form-control select2-hidden-accessible
> seleccionarArea"
> name="seleccionarArea[]">
> Seleccione Área ...
> Comercio
> Aplicaciones Informáticas
> Desarrollo
> 
> 
> 
>  class="select2_single form-control select2-hidden-accessible
> seleccionarServicioP"
> name="seleccionarServicioP[]" disabled="">
> Seleccione Servicio ...
> 
> 
>  class="form-control">
> 
>  class="form-control">
>  class="form-control"
> placeholder="Total">
>  placeholder="Cantidad">
>  class="form-control"
> placeholder="Total">
> 
> 
> 
> 
> 
> 
> 
>  class="select2_single form-control select2-hidden-accessible
> seleccionarArea"
> name="seleccionarArea[]">
> Seleccione Área ...
> Comercio
> Aplicaciones Informáticas
> Desarrollo
> 
> 
> 
>  class="select2_single form-control select2-hidden-accessible
> seleccionarServicioP"
> name="seleccionarServicioP[]" disabled>
> Seleccione Servicio ...
> 
> 
>  placeholder="CUP"
> class="form-control">
> 
>  placeholder="CUC"
> class="form-control">
>  class="form-control"
> placeholder="Total">
>  class="form-control"
> placeholder="Cantidad">
>  class="form-control"
> placeholder="Total">
> 
> 
> 
> 
> 
> 
> 
> Nuevo Servicio
> 
> 
> 
> 
> Por Cobrar:
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  name="submit">Guardar
> Cerrar button>
> 
> 
> 
>
> Espero que me puedan ayudar ya que llevo varios dias en esto y no doy con
> la solución
>
> --
> 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/ffe4de5c-3cfa-43ee-8217-4e5f0ce7674d%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/CA%2BFDnhKdR_UFfwma%2BsF-%2B39r8z%2BxEEPAnf5YzHhwMEu_TrYVnw%40mail.gmail.com.
For more 

Re: I want to display my restaurant list for which i used a function based view and it is working fine but when i import generic list view then it's not displaying that list

2017-12-21 Thread Matemática A3K
On Thu, Dec 21, 2017 at 3:05 PM, Ruhail Ahmad 
wrote:

> def resturant_listview(request):
> template_name = 'resturants/resturants_list.html'
> queryset = ResturantLocation.objects.all()
> context= {
>"obj_list": queryset
>}
> return render(request,template_name,context)
>
> class ResturantListView(ListView):
> template_name   = 'resturants/resturants_list.html'
> queryset=  ResturantLocation.objects.all()
>
>

> {% block content %}
>
> Resturants List
> 
> {% for obj in obj_list %}
> {{obj.name}} {{obj.location}} {{obj.category}}
> {{obj.timestamp}}
> {% endfor %}
> 
> {% endblock content %}
>
>
It's because ListView makes available the queryset to the template in the
"object_list" variable, and your template is expecting "obj_list" which you
provide in your FBV
https://docs.djangoproject.com/en/2.0/ref/class-based-views/generic-display/#listview

-- 
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/CA%2BFDnh%2BiqLO%3DBXt4wg1Q9v5FoMAGoxnzjZLtihVE8x4JHzAePQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Search results in template

2017-12-19 Thread Matemática A3K
On Tue, Dec 19, 2017 at 10:12 PM, Malik Rumi  wrote:

> I am implementing search on a local Django project: Django 1.11.5, Python
> 3.6.3, Ubuntu 16.04. My issue is getting the search results onto the
> template.
>
> I am using standard CBV for everything else in the site, but for this one
> I wrote my own. It uses the same template as my ListView, which shows all
> objects fine.
>
>
>
> def serp(request):
> if request.method == 'GET' and 'searchbox' in request.GET:
> q = request.GET.get('searchbox')
> query = SearchQuery(q)
> object_list = Entry.objects.annotate(
> rank=SearchRank(F(
> 'search_vector'), query)).filter(
> search_vector=query).order_by(
> '-rank').values_list('title', 'rank')
> return render(request, 'serp_list.html', {'object_list': object_list})
>
>
> Django Debug Toolbar reports everything went as expected. The right
> template and view were called, as well as the right db query. I had
> previously tested this query in the shell, and it pulls up a 4 element
> queryset, as it should.
>
> Even though no search results show on the page, there are 4 instances of
> the html that should be surrounding each result and rows=4 loops=1 in the
> query plan.
>
> One thing I found curious is that the **mere change** in the variable name 
> 'object_list' to 'resultslist' gave me no db query! I had always thought 
> variable names didn't matter in Python,
>
> but apparently 'object_list' is virtually a reserved word when it comes to 
> views (even FBVs) and templates in Django?
>
>
No, it is not a reserved keyword, the thing is by convention, CBV's
Listview (and others with MultipleObjectsMixin) makes available in that
variable the objects retrieved the view. It's a convention so you can
easily reuse code. What is important is the name you pass to the template,

{**'object_list'**: your_retrieved_objects}

 as it expects that. If nothing evaluates the variable which contains your
query / queryset results, it might be never executed - is that your doubt?

>  Here is the template:
>
> 
> 
>   
>   {% for object in object_list %}
>   

Re: confusion in models in django

2017-12-18 Thread Matemática A3K
By registering an app you take full advantage of the framework:
https://docs.djangoproject.com/en/2.0/ref/applications/#application-registry

You can import "things" (modules, functions, etc.) from any python module
in the path, that's why you are able to import any python code from your
project directory, despite of not being registered as an app. That's a
regular python import, like "import os", it does not correspond to the
Django.

HTH

On Tue, Dec 19, 2017 at 3:26 AM, Mukul Agrawal  wrote:

> I am a bit confused that is it necessary to write the name of the app in
> the INSTALLED_APPS in settings.py. Because whether I write it or not, I am
> able to successfully run my project. Then what is the difference between
> the two method.
>
> --
> 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/f869b60a-76cf-4a95-b2f0-9c854f79101b%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/CA%2BFDnhJf4u5cDauP7iAw2Wt_aFj2OZNfgaNP935NoC5ehNx6mA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Single-page app with dynamic filtering - 2 options to proceed

2017-12-18 Thread Matemática A3K
On Mon, Dec 18, 2017 at 5:36 PM, Jack  wrote:

> I am building a real estate listings map, which dynamically refreshes its
> filter whenever the user moves the map. The page never refreshes when a
> change is made. Think Zillow/Trulia
> 
> .
>
> There are 2 main filters:
>
>- Filter properties within the user's viewport
>- Filter properties according to user's custom filter (e.g. property
>type, # of bedrooms, etc.)
>
> I see 2 methods of approaching this problem.
>
>1.
>
>On initial visit, pass ALL properties in the database to the user. And
>then filter these properties whenever the user moves his map or changes his
>filter selection.
>
> This may delay the "first page" or initialization but it would produce a
better experience after

>
>1.
>
>Create an ajax call whenever the user moves his map or changes his
>filter selection. The ajax call will only return the properties that match
>the user's current requirements.
>
> This would create more traffic to your server, depending on the roundtrip
length it may affect the user experience and your server workload, but it
would load faster and for "short navigations spans" might be better

> Which method is preferable? I estimate there will be maybe 200k-300k
> records in my database.
>
Depends on which you want to prioritize or target :)


> --
> 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/7e6179d4-2274-4aec-aa83-27fbfdc1238c%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/CA%2BFDnhKbYseVFtQBvB3d_7C3TLJeHH4o1%2BQ-X6KNN3OB1MnbTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model Design Questions

2017-12-16 Thread Matemática A3K
I use https://github.com/dmkoch/django-jsonfield for storing metadata and
works very well, the only problem that I see in using one jsonfield for all
the metadata you have for a document is searching (which I don't need).

3k, 6k or 9k of rows is "nothing" for MySQL or Postgres, a bottleneck won't
be there. The problem may be implementing searching, you can keep the data
in memory and implement the searching in Python in the case of "regular db
search" is not enough.

HTH

On Sun, Dec 17, 2017 at 2:28 AM, Dan Tagg 
wrote:

> If you switched to Postgres you could use a json data type or dictionary
> data type. Django 1.11 onwards supports the storage and retrieval of both
> types I believe.
>
> Dan
>
> On Sun, 17 Dec 2017 at 07:46, Mark Phillips 
> wrote:
>
>> I am building an electronic document management system using django and
>> mysql. The purpose of this system is to catalog and retrieve electronic
>> documents. There is no inventory of the physical documents. There are about
>> 3,000 documents (photos, pdfs, videos) now, and that number could double in
>> the next year. The purpose of the site is to search for a set of documents
>> that share some given set of metadata values. I am wrestling with the model
>> design for the metadata part of this project.
>>
>> I have identified about 30 internal metadata types particular to these
>> documents, and not related to any standards. If I use Dublin Core, there
>> are 71 types, but I would not need all of them, and there is some overlap
>> with the 30 internal metadata types - say another 25 types. Schema.org also
>> has an interesting set of metadata tags, and some may be applicable to this
>> project, and using that standard as well, could bring the number of types
>> to 75.
>>
>> As I see it, I have three options.
>>
>> Option 1 - traditional database design, with metadata types as columns,
>> and values in rows. The document model would have approx 50 - 80 fields,
>> and one could expect out of 3,000 documents about 50-70% of the values are
>> Null.
>>
>> This option is the most straight forward to create. I have no idea what
>> the performance would be for django and mysql, searching for a set of
>> documents in a model with 50-80 fields and 3,000 entries, where 60% are
>> Null. Is this a feasible design, or do I need to think of another way to
>> model this metadata? Will this scale to 6,000 documents? What if I need to
>> add another metadata standard to the site in the future? (I am not looking
>> for job security in this project)
>>
>> Option 2 - some sort of EAV design, with a table that has document_id,
>> metadatatype_id, and metadatavalue_id. I have read all sorts of posts about
>> the evils of EAV, but they seem to have peaked about 8 years ago, and now I
>> am seeing some posts that even recommend this design approach.
>>
>> Is this approach a better fit for my particular application? Will it
>> scale to the numbers of documents and metadata I am thinking about? I
>> really don't want to go to the dark side if I can help it.
>>
>> Option 3 - A hybrid solution that I have also read about. Put the more
>> common metadata types as fields in the model (columns in the database
>> table), and then JSON-ize the rest of the metadata for that document in a
>> string field in the model. This seems to put a rather large burden on the
>> application code when searching for a set of documents with a particular
>> set of metadata values.
>>
>> The performance cost of this method seems to depend heavily on the
>> distribution of metadata types in the entire document set, and being smart
>> enough to pick the best common ones. If there were a set of metadata types
>> that span 90% of the the documents, then this would probably be a good
>> solution. Span only 25% of the documents, and there is a lot of comparing
>> values in the JSON string.
>>
>> Thanks for any insights/recommendations you can provide!
>>
>> Mark
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>>
>>
>> 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/CAEqej2MYmfqaA1Gq7nByjGo%3DcxF6_x7fbz4cuRy2EgrCBmuDVA%
>> 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 

Re: Please explain "TypeError: handle_404() got an unexpected keyword argument 'exception'"

2017-12-11 Thread Matemática A3K
On Mon, Dec 11, 2017 at 10:23 PM, Chris Seberino 
wrote:

> I'm trying to get a 404 page to show instead of a 500 error when Django
> app sees a nonexistent URL.
>
> I'm still getting 500 errors with this clue in logs but I don't know what
> it means
>
> Please explain "TypeError: handle_404() got an unexpected keyword argument
> 'exception'"
>

It means literally that "handle_404() got an unexpected keyword argument
'exception'", how are you calling handle_404()?


>
> (The nonexistent URL I tried was /aaa.)
>
> Internal Server Error: /aaa
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py",
> line 35, in inner
> response = get_response(request)
>   File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py",
> line 113, in _get_response
> resolver_match = resolver.resolve(request.path_info)
>   File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py",
> line 523, in resolve
> raise Resolver404({'tried': tried, 'path': new_path})
> django.urls.exceptions.Resolver404: {'path': 'aaa', 'tried':
> [[], [],
>  [], []]}
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py",
> line 99, in get_exception_response
> response = callback(request, **dict(param_dict, exception=exception))
> TypeError: handle_404() got an unexpected keyword argument 'exception'
>
>
> --
> 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/c87198a3-327c-4dbf-a6d0-114a800fa560%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/CA%2BFDnhJ9ZLjPb5vavucHxsOyKPpYVbukHtwjc6fgmA24F1EQMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django say my login form is invalid? How can I find out why Django thinks it is?

2017-11-30 Thread Matemática A3K
Tom,

- You shouldn't use Model=User (or the Meta) as it was a ModelForm, it is
just a regular Form
- AuthenticationForm takes request as its first parameter:

def login_register(request, template="templates/login_register.html"):
if request.method == "POST":
login_form = AuthenticationForm(request, data=request.POST)
if login_form.is_valid():
print("Login form valid")
# return redirect(home_slug())
# else:
#  print "Login invalid"
else:
login_form = AuthenticationForm()
return render(request, template, {"login_form": login_form})

-- 
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/CA%2BFDnh%2B1i4eRye6qr%3DF2zWz2Nnf4mAZ1%3DnY357m01HSyeFL0UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django say my login form is invalid? How can I find out why Django thinks it is?

2017-11-29 Thread Matemática A3K
On Thu, Nov 30, 2017 at 12:35 AM, Tom Tanner <dontsendemailher...@gmail.com>
wrote:

> What would I need to change?
>
> I tried changing the ...
> fields= ("username",)
>
> ... to ...
> fields= ("username","email",)
> or...
> fields= ("email",)
>
> Nothing seemed to change. the `login_form.is_valid()` still is `False`.
>
> Sorry if the question is dumb, I'm still learning Django thru working with
> it.
>
>
Try not using fields at all, that will use the fields in AuthenticationForm


>
>
> On Wednesday, November 29, 2017 at 12:21:04 AM UTC-5, Matemática A3K wrote:
>>
>>
>> class LoginForm(AuthenticationForm):
>>>  username= forms.EmailField(label=_("Email"), max_length=254)
>>>
>>>
>>>  class Meta:
>>>  model= User
>>>
>>
>>
>>>
>>>  fields= ("username",)
>>>
>>>
>> If you use "fields = ("username")" you are restricting the fields to just
>> that field, and the authentication form needs also password to be valid
>>
>>
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/1e861f42-2115-4377-848c-67c59d122610%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/1e861f42-2115-4377-848c-67c59d122610%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/7dafbe54-6563-401b-9461-b857f9340d64%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7dafbe54-6563-401b-9461-b857f9340d64%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhKD6GXVnR2DmcuLGqscV2%2BE%2BAm-Tu7yjcsORbWgOBi2iA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin many-to-many inlines - show editable fields from parent models

2017-11-29 Thread Matemática A3K
On Wed, Nov 29, 2017 at 6:29 AM, Jan Hartman <android...@gmail.com> wrote:

> Either by specifying PairRecipeCategory or using
> Categories.recipes.through, I am referencing the model that manages the
> many-to-many relation. If I wouldn't create an intermediary model myself,
> Django would do it for me. Both options leave me with the same result -
> being unable to access the fields from the (virtual) imaginary model.
>

Indeed, I have tested the example in the documentation (
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#
working-with-many-to-many-models) and it does not work as expected (and
produces the same output that you are dealing with in your case). It seems
that it produces the inline only for the intermediary model and not linking
to the fields of the other model. The example in
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#
working-with-many-to-many-models works as expected, seems that this is the
case used for the fist one.

I think we have hit a bug, can someone confirm?


> Dne sreda, 29. november 2017 06.14.19 UTC+1 je oseba Matemática A3K
> napisala:
>>
>>
>>
>> On Tue, Nov 28, 2017 at 9:12 AM, Jan Hartman <andro...@gmail.com> wrote:
>>
>>> Hi, I'm having trouble with inlining models with a many-to-many
>>> relationship through the intermediary model. My models are recipes and
>>> categories (a category includes multiple recipes and a recipe can belong to
>>> multiple categories).
>>>
>>> Models (simplified):
>>> class Recipe(models.Model):
>>> title = models.CharField(_('Title'), max_length=100, unique=True)
>>> categories = models.ManyToManyField('Category', through='
>>> PairRecipeCategory', verbose_name=_('Categories'))
>>>
>>> class Category(models.Model):
>>> title = models.CharField(_('Title'), max_length=100, unique=True)
>>> recipes = models.ManyToManyField('Recipe', through='PairRecipeCategory',
>>> verbose_name=_('Recipes'))
>>>
>>> class PairRecipeCategory(models.Model):
>>> category = models.ForeignKey(Category, on_delete=models.CASCADE)
>>> recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
>>>
>>>
>>>
>>> Admin:
>>>
>>> class RecipeInline(admin.TabularInline):
>>> model = PairRecipeCategory
>>> # fields = ['recipe__title']
>>>
>>>
>>> class CategoryInline(admin.TabularInline):
>>> model = PairRecipeCategory
>>> # fields = ['category__title']
>>>
>>> + ordinary recipe and category ModelAdmin classes
>>>
>>> What I want to do is to show *editable* fields from the parent model
>>> (Recipe or Category) in the inlined PairRecipeCategory model instead of
>>> just listing the inlines. I get the "Unknown field for model xyz error"
>>> because the fields are not reachable from the intermediary model if I
>>> uncomment the fields lines.
>>> I've read about this on StackOverflow and such and I could not find a
>>> working solution. If anyone has any (even hacky) ideas, I would really
>>> appreciate the help.
>>>
>>>
>> I think that you are creating an inline for the intermediary model. not
>> an inline for the other model, here is how you should:
>> https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#
>> working-with-many-to-many-models
>>
>> And your code is for doing this:
>> https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#
>> working-with-many-to-many-intermediary-models
>>
>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/ms
>>> gid/django-users/c094f569-4cea-42cd-bd12-05f50e40c8f1%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/c094f569-4cea-42cd-bd12-05f50e40c8f1%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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.

Re: Django admin pagination zero based?

2017-11-28 Thread Matemática A3K
On Tue, Nov 28, 2017 at 3:00 PM, Daniel Jewett  wrote:

> I just noticed that the URL get string in my admin app is off by one from
> the auto generated pagination links. It appears that the pagination URLs
> are zero based.
>
> For example if I'm on page 4 of results according to the pagination links,
> the URL looks like '?p=3'
>
> Is this typical?
>

Yup :)


> Any suggestions on how to get them matched up?
>
>
https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_list.py#L44



> Thanks!
>
> -Dan J.
>
> --
> 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/a4d14e7f-20d0-49c7-a42d-5535e697c33b%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/CA%2BFDnhLSXthvWOPNouiMfDhVprVMzdY1%2BcP5z13ZqTw4iw5-Ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why does Django say my login form is invalid? How can I find out why Django thinks it is?

2017-11-28 Thread Matemática A3K
> class LoginForm(AuthenticationForm):
>  username= forms.EmailField(label=_("Email"), max_length=254)
>
>
>  class Meta:
>  model= User
>


>
>  fields= ("username",)
>
>
If you use "fields = ("username")" you are restricting the fields to just
that field, and the authentication form needs also password to be valid


>
> --
> 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/1e861f42-2115-4377-848c-67c59d122610%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/CA%2BFDnhK4cDkWdHuGJNhj0XAaRtPgmig9rSSDbe-XhyR7v2yiKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Admin many-to-many inlines - show editable fields from parent models

2017-11-28 Thread Matemática A3K
On Tue, Nov 28, 2017 at 9:12 AM, Jan Hartman  wrote:

> Hi, I'm having trouble with inlining models with a many-to-many
> relationship through the intermediary model. My models are recipes and
> categories (a category includes multiple recipes and a recipe can belong to
> multiple categories).
>
> Models (simplified):
> class Recipe(models.Model):
> title = models.CharField(_('Title'), max_length=100, unique=True)
> categories = models.ManyToManyField('Category', through='
> PairRecipeCategory', verbose_name=_('Categories'))
>
> class Category(models.Model):
> title = models.CharField(_('Title'), max_length=100, unique=True)
> recipes = models.ManyToManyField('Recipe', through='PairRecipeCategory',
> verbose_name=_('Recipes'))
>
> class PairRecipeCategory(models.Model):
> category = models.ForeignKey(Category, on_delete=models.CASCADE)
> recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
>
>
>
> Admin:
>
> class RecipeInline(admin.TabularInline):
> model = PairRecipeCategory
> # fields = ['recipe__title']
>
>
> class CategoryInline(admin.TabularInline):
> model = PairRecipeCategory
> # fields = ['category__title']
>
> + ordinary recipe and category ModelAdmin classes
>
> What I want to do is to show *editable* fields from the parent model
> (Recipe or Category) in the inlined PairRecipeCategory model instead of
> just listing the inlines. I get the "Unknown field for model xyz error"
> because the fields are not reachable from the intermediary model if I
> uncomment the fields lines.
> I've read about this on StackOverflow and such and I could not find a
> working solution. If anyone has any (even hacky) ideas, I would really
> appreciate the help.
>
>
I think that you are creating an inline for the intermediary model. not an
inline for the other model, here is how you should:
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#working-with-many-to-many-models

And your code is for doing this:
https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#working-with-many-to-many-intermediary-models

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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/c094f569-4cea-42cd-bd12-05f50e40c8f1%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/CA%2BFDnhLqViCqcJpnFNiuztqfFzGW0fDhBmWmS-wWiEWTe%3DmHAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ManyToMany widget in admin - the "user - permission way.."

2017-11-28 Thread Matemática A3K
>
> I have this error:
>
> Unhandled exception in thread started by  check_errors..wrapper at 0x7f2fa8d646a8>
>
> Traceback (most recent call last):
>
>   File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py",
> line 228, in wrapper
>
> fn(*args, **kwargs)
>
>   File "/usr/local/lib/python3.5/dist-packages/django/core/
> management/commands/runserver.py", line 125, in inner_run
>
> self.check(display_num_errors=True)
>
>   File 
> "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py",
> line 405, in check
>
> raise SystemCheckError(msg)
>
> django.core.management.base.SystemCheckError: *SystemCheckError: System
> check identified some issues:*
>
>
> ERRORS:
>
> *: (admin.E001) The
> value of 'raw_id_fields' must be a list or tuple.*
>
> this is my admin.py
>

Because for making a tuple of one element you need a trailing comma,
otherwise it is just a string, see below:


>
> from django.contrib import admin
>
> from bootcamp.groups_manager.models import Group, Member, GroupType,
> GroupEntity, GroupMember, GroupMemberRole
> from guardian.admin import GuardedModelAdmin
>
> # With object permissions support
> class GroupAdmin(GuardedModelAdmin):
> #fields = ('group_members', 'django_group')
> raw_id_fields = ('group_members', )
> #search_fields = ('group_members', 'django_group')
> pass
>
> #admin.site.register(models.Group)
> admin.site.register(Group, GroupAdmin)
> admin.site.register(Member)
> admin.site.register(GroupType)
> admin.site.register(GroupEntity)
> admin.site.register(GroupMember)
> admin.site.register(GroupMemberRole)
>
> --
> 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/951cd1bc-5888-4d4f-b92b-fc855cb963a2%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/CA%2BFDnhJAae_MaO6j2RaA1%2B3Ka%3DqdYP_DFcH4F3iUYiVARchimA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Permission for specific object in AdminPanel

2017-11-28 Thread Matemática A3K
Wow! That's a lot of code, please try to be more specific in order to get
other people to help you. What are you trying to achieve? Autosearch of
users in which context? I do not understand you :)

On Tue, Nov 28, 2017 at 6:55 AM, Allan Nava 
wrote:

> I have this admin.py and models.py
>
> ```
> from django.contrib import admin
>
> from bootcamp.groups_manager.models import Group, Member, GroupType,
> GroupEntity, GroupMember, GroupMemberRole
> from guardian.admin import GuardedModelAdmin
> class GroupAdmin(GuardedModelAdmin):
> pass
>
> #admin.site.register(models.Group)
> admin.site.register(Group, GroupAdmin)
> admin.site.register(Member)
> admin.site.register(GroupType)
> admin.site.register(GroupEntity)
> admin.site.register(GroupMember)
> admin.site.register(GroupMemberRole)
> ```
>
>
> ```
>
>
> class GroupMixin(GroupRelationsMixin, MPTTModel):
> name = models.CharField(max_length=255)
> codename = models.SlugField(blank=True, max_length=255)
> description = models.TextField(default='', blank=True)
> comment = models.TextField(default='', blank=True)
> parent = TreeForeignKey('self', null=True, blank=True,
> related_name='sub_%(app_label)
> s_%(class)s_set')
> full_name = models.CharField(max_length=255, default='', blank=True)
> properties = JSONField(default={}, blank=True,
> load_kwargs={'object_pairs_hook':
> OrderedDict})
>
> django_auth_sync = models.BooleanField(default=True, blank=True)
>
> #Custom permission
> background_photo = models.CharField(max_length=255, null=True,
> blank=True)
> profile_photo = models.CharField(max_length=255, null=True,
> blank=True)
> #type = models.TextField(default='', blank=True)
>
> class Meta:
> abstract = True
> ordering = ('name', )
>
> class MPTTMeta:
> level_attr = 'level'
> order_insertion_by = ['name', ]
>
> class GroupsManagerMeta(GroupRelationsMixin.GroupsManagerMeta):
> pass
>
> def __unicode__(self):
> return '%s' % self.name
>
> def __str__(self):
> return '%s' % self.name
>
> def save(self, *args, **kwargs):
> self.full_name = self._get_full_name()[:255]
> if not self.codename:
> self.codename = slugify(self.name, to_lower=True)
> super(GroupMixin, self).save(*args, **kwargs)
>
> def _get_full_name(self):
> if self.parent:
> return '%s - %s' % (self.parent._get_full_name(), self.name)
> return self.name
>
> @property
> def subgroups(self):
> message = 'The "subgroups" attribute will be removed in next
> version. ' + \
>   'Use "sub_groups_manager_group_set" instead.'
> warnings.warn(message, DeprecationWarning)
> return self.sub_groups_manager_group_set
>
> def get_members(self, subgroups=False):
> """Return group members.
> The result is a list of GroupsManagerMeta's attribute
> ``member_model`` instances.
>
> :Parameters:
>   - `subgroups`: return also descendants members (default: `False`)
> """
> member_model = self.member_model
> group_member_model = self.group_member_model
> if group_member_model == GroupMember:
> members_relation = getattr(self, self.group_members_attribute)
> if member_model == Member:
> members = list(members_relation.all())
> else:
> # proxy model
> if member_model._meta.proxy:
> members = list(member_model.objects.filter(
> id__in=members_relation.values_list('id',
> flat=True)))
> # subclassed
> else:
> members = list(member_model.objects.filter(
> member_ptr__in=members_relation.all()))
> else:
> members = [gm.member for gm in group_member_model.objects.
> filter(group=self)]
> if subgroups:
> for subgroup in self.subgroups.all():
> members += subgroup.members
> members = list(set(members))
> return members
>
> @property
> def members(self):
> """Return group members. """
> return self.get_members(True)
>
> @property
> def users(self):
> """Return group django users. """
> users = []
> for member in self.members:
> if member.django_user:
> users.append(member.django_user)
> return users
>
> def get_entities(self, subgroups=False):
> """Return group entities.
>
> :Parameters:
>   - `subgroups`: return also descendants entities (default:
> `False`)
> """
> entities = list(self.group_entities.all())
> if subgroups:
> for subgroup in self.subgroups.all():
> entities += subgroup.entities
>  

Re: NOT NULL constraint failed when trying to create form with initial values

2017-11-28 Thread Matemática A3K
On Tue, Nov 28, 2017 at 6:18 PM, Kubilay Yazoğlu <kyazog...@gmail.com>
wrote:

> That did the trick. There were some minor errors after it, but now there
> isn't. By the way, I tried this solution before I tried the "initial"
> solution but it didn't work at that time. Many thanks.
>

:) I'm glad you solved it.


>
> 28 Kasım 2017 Salı 02:49:13 UTC+3 tarihinde Matemática A3K yazdı:
>>
>>
>>
>> On Mon, Nov 27, 2017 at 7:58 PM, Kubilay Yazoğlu . <kyaz...@gmail.com>
>> wrote:
>>
>>> Oh, that's a life saver information. Thanks. I edited my code.
>>> Unfortunately, only thing that has changed is the name of the error
>>> which looks like this right now: NOT NULL constraint failed:
>>> photo_photo.contest_id
>>>
>>> I'm going to take a break and try to solve the problem tomorrow. I
>>> appreciate your help.
>>>
>>
>> Alright, for tomorrow then:
>>
>> I don't usually use "initial" but if you are excluding (or not including)
>> the field in the form, "initial" would not be useful. A workaround would be:
>>
>>
>> if form.is_valid():
>> photo = form.save(commit=False)
>>
>> photo.contest = random_item
>>
>> photo.owner = 'SUMMERSON'
>>
>> photo.save()
>>
>>
>>
>>>
>>> On Tue, Nov 28, 2017 at 1:32 AM, Matemática A3K <matemat...@gmail.com>
>>> wrote:
>>>
>>>>
>>>>
>>>> On Mon, Nov 27, 2017 at 7:30 PM, Matemática A3K <matemat...@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Mon, Nov 27, 2017 at 7:18 PM, Kubilay Yazoğlu <kyaz...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Nice try but I'm still getting this error: IntegrityError at
>>>>>> /photo/create/
>>>>>>
>>>>>> NOT NULL constraint failed: photo_photo.contest_id_id
>>>>>>
>>>>>>
>>>>>> I tried with both 'contest': random_item  and 'contest_id': 
>>>>>> random_item.contest_id. (I don't know why you wrote contest instead of 
>>>>>> contest_id. Field name is contest_id)
>>>>>>
>>>>>> That's because what you are passing is empty and the field is
>>>>> required. Are you sure that you have Contest objects?
>>>>>
>>>>> There is a convention in Django (models and ORM), "object.foreign_key"
>>>>> gives you the object, while "object.foreign_key_id" gives you the id of
>>>>> that object (and is what it is stored in the database). You should name
>>>>> your field only "contest" for avoiding confusions.
>>>>>
>>>>
>>>> Try "contest_id": random_object
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> 28 Kasım 2017 Salı 01:03:50 UTC+3 tarihinde Matemática A3K yazdı:
>>>>>>
>>>>>>>
>>>>>>> items = Contest.objects.all()
>>>>>>>> random_item = random.choice(items)
>>>>>>>>
>>>>>>>> if request.method =='POST':
>>>>>>>> data = {'contest': random_item,
>>>>>>>> 'ownername': 'SUMMERSON',
>>>>>>>> }
>>>>>>>> form=PhotoForm(request.POST, initial=data)
>>>>>>>> if form.is_valid():
>>>>>>>> photo = form.save()  # Instances go in lowercase, otherwise 
>>>>>>>> you are doing it to the class
>>>>>>>> else:
>>>>>>>> form = PhotoForm()
>>>>>>>>
>>>>>>>> --
>>>>>> 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 https://groups.google.com/group/django-users.
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/django-users/87731060

Re: NOT NULL constraint failed when trying to create form with initial values

2017-11-27 Thread Matemática A3K
On Mon, Nov 27, 2017 at 7:58 PM, Kubilay Yazoğlu . <kyazog...@gmail.com>
wrote:

> Oh, that's a life saver information. Thanks. I edited my code.
> Unfortunately, only thing that has changed is the name of the error which
> looks like this right now: NOT NULL constraint failed:
> photo_photo.contest_id
>
> I'm going to take a break and try to solve the problem tomorrow. I
> appreciate your help.
>

Alright, for tomorrow then:

I don't usually use "initial" but if you are excluding (or not including)
the field in the form, "initial" would not be useful. A workaround would be:


if form.is_valid():
photo = form.save(commit=False)

photo.contest = random_item

photo.owner = 'SUMMERSON'

photo.save()



>
> On Tue, Nov 28, 2017 at 1:32 AM, Matemática A3K <matematica@gmail.com>
> wrote:
>
>>
>>
>> On Mon, Nov 27, 2017 at 7:30 PM, Matemática A3K <matematica@gmail.com
>> > wrote:
>>
>>>
>>>
>>> On Mon, Nov 27, 2017 at 7:18 PM, Kubilay Yazoğlu <kyazog...@gmail.com>
>>> wrote:
>>>
>>>> Nice try but I'm still getting this error: IntegrityError at
>>>> /photo/create/
>>>>
>>>> NOT NULL constraint failed: photo_photo.contest_id_id
>>>>
>>>>
>>>> I tried with both 'contest': random_item  and 'contest_id': 
>>>> random_item.contest_id. (I don't know why you wrote contest instead of 
>>>> contest_id. Field name is contest_id)
>>>>
>>>> That's because what you are passing is empty and the field is required.
>>> Are you sure that you have Contest objects?
>>>
>>> There is a convention in Django (models and ORM), "object.foreign_key"
>>> gives you the object, while "object.foreign_key_id" gives you the id of
>>> that object (and is what it is stored in the database). You should name
>>> your field only "contest" for avoiding confusions.
>>>
>>
>> Try "contest_id": random_object
>>
>>
>>
>>>
>>>
>>>
>>>>
>>>> 28 Kasım 2017 Salı 01:03:50 UTC+3 tarihinde Matemática A3K yazdı:
>>>>
>>>>>
>>>>> items = Contest.objects.all()
>>>>>> random_item = random.choice(items)
>>>>>>
>>>>>> if request.method =='POST':
>>>>>> data = {'contest': random_item,
>>>>>> 'ownername': 'SUMMERSON',
>>>>>> }
>>>>>> form=PhotoForm(request.POST, initial=data)
>>>>>> if form.is_valid():
>>>>>> photo = form.save()  # Instances go in lowercase, otherwise you 
>>>>>> are doing it to the class
>>>>>> else:
>>>>>> form = PhotoForm()
>>>>>>
>>>>>> --
>>>> 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/ms
>>>> gid/django-users/87731060-75a6-44c6-8d1f-56cba6d22278%40goog
>>>> legroups.com
>>>> <https://groups.google.com/d/msgid/django-users/87731060-75a6-44c6-8d1f-56cba6d22278%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/django-users/EUOXhT4V9Is/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/ms
>> gid/django-users/CA%2BFDnhLFdpf0Z%3DwSgtd3b7HTW_5xru7m963W%
>> 2Bo-g653RdX4w3Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CA%2BFDnhLFdp

Re: NOT NULL constraint failed when trying to create form with initial values

2017-11-27 Thread Matemática A3K
On Mon, Nov 27, 2017 at 7:30 PM, Matemática A3K <matematica@gmail.com>
wrote:

>
>
> On Mon, Nov 27, 2017 at 7:18 PM, Kubilay Yazoğlu <kyazog...@gmail.com>
> wrote:
>
>> Nice try but I'm still getting this error: IntegrityError at
>> /photo/create/
>>
>> NOT NULL constraint failed: photo_photo.contest_id_id
>>
>>
>> I tried with both 'contest': random_item  and 'contest_id': 
>> random_item.contest_id. (I don't know why you wrote contest instead of 
>> contest_id. Field name is contest_id)
>>
>> That's because what you are passing is empty and the field is required.
> Are you sure that you have Contest objects?
>
> There is a convention in Django (models and ORM), "object.foreign_key"
> gives you the object, while "object.foreign_key_id" gives you the id of
> that object (and is what it is stored in the database). You should name
> your field only "contest" for avoiding confusions.
>

Try "contest_id": random_object



>
>
>
>>
>> 28 Kasım 2017 Salı 01:03:50 UTC+3 tarihinde Matemática A3K yazdı:
>>
>>>
>>> items = Contest.objects.all()
>>>> random_item = random.choice(items)
>>>>
>>>> if request.method =='POST':
>>>> data = {'contest': random_item,
>>>> 'ownername': 'SUMMERSON',
>>>> }
>>>> form=PhotoForm(request.POST, initial=data)
>>>> if form.is_valid():
>>>> photo = form.save()  # Instances go in lowercase, otherwise you 
>>>> are doing it to the class
>>>> else:
>>>> form = PhotoForm()
>>>>
>>>> --
>> 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/ms
>> gid/django-users/87731060-75a6-44c6-8d1f-56cba6d22278%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/87731060-75a6-44c6-8d1f-56cba6d22278%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>> 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/CA%2BFDnhLFdpf0Z%3DwSgtd3b7HTW_5xru7m963W%2Bo-g653RdX4w3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NOT NULL constraint failed when trying to create form with initial values

2017-11-27 Thread Matemática A3K
On Mon, Nov 27, 2017 at 7:18 PM, Kubilay Yazoğlu <kyazog...@gmail.com>
wrote:

> Nice try but I'm still getting this error: IntegrityError at
> /photo/create/
>
> NOT NULL constraint failed: photo_photo.contest_id_id
>
>
> I tried with both 'contest': random_item  and 'contest_id': 
> random_item.contest_id. (I don't know why you wrote contest instead of 
> contest_id. Field name is contest_id)
>
> That's because what you are passing is empty and the field is required.
Are you sure that you have Contest objects?

There is a convention in Django (models and ORM), "object.foreign_key"
gives you the object, while "object.foreign_key_id" gives you the id of
that object (and is what it is stored in the database). You should name
your field only "contest" for avoiding confusions.



>
> 28 Kasım 2017 Salı 01:03:50 UTC+3 tarihinde Matemática A3K yazdı:
>
>>
>> items = Contest.objects.all()
>>> random_item = random.choice(items)
>>>
>>> if request.method =='POST':
>>> data = {'contest': random_item,
>>> 'ownername': 'SUMMERSON',
>>> }
>>> form=PhotoForm(request.POST, initial=data)
>>> if form.is_valid():
>>> photo = form.save()  # Instances go in lowercase, otherwise you are 
>>> doing it to the class
>>> else:
>>> form = PhotoForm()
>>>
>>> --
> 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/87731060-75a6-44c6-8d1f-56cba6d22278%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/87731060-75a6-44c6-8d1f-56cba6d22278%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhK%3Dkkjra0nXZ380%3D667xT0JwD8a2rmaPy0g%3DXEPU9Rx9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NOT NULL constraint failed when trying to create form with initial values

2017-11-27 Thread Matemática A3K
> items = Contest.objects.all()
> random_item = random.choice(items)
>
> if request.method =='POST':
> data = {'contest': random_item,
> 'ownername': 'SUMMERSON',
> }
> form=PhotoForm(request.POST, initial=data)
> if form.is_valid():
> photo = form.save()  # Instances go in lowercase, otherwise you are 
> doing it to the class
> else:
> form = PhotoForm()
>
>

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


Re: NOT NULL constraint failed when trying to create form with initial values

2017-11-27 Thread Matemática A3K
You shouldn't give the PK of new objects, leave that to Django. If photo_id
is the PK of Photo, don't set it, Django will on save.

If the same goes for Contest, then do a "contest = Contest()" - create a
new contest - and assign it to the photo "photo.contest = contest", then
"photo.save"

On Mon, Nov 27, 2017 at 5:56 PM, Kubilay Yazoğlu 
wrote:

> Hi. I'm trying to create a form to construct an object for my Photo class.
> All of the objects fields except the photo itself will be invisible to the
> user. So, the only thing can be seen in the form is the button to select
> and upload the photo.
>
> There is no problem with creating the form page. The problem is, giving
> the initial values for the rest of the fields.
> This is the relevant code in my view file:
>
>
>
> if request.method =='POST':
> data = {'photo_id': get_latest_photo_id_plusone(),
> 'contest_id': get_latest_contest_id_plusone(),
> 'ownername': 'SUMMERSON',
> }
> form=PhotoForm(request.POST, initial=data)
> if form.is_valid():
> Photo = form.save()
> else:
> form = PhotoForm()
>
>
> And the relevant functions:
>
>
>
> def get_latest_photo_id_plusone():
> max_rating = 
> Photo.objects.all().aggregate(Max('photo_id'))['photo_id__max']
> return max_rating+1
>
>
> def get_latest_contest_id_plusone():
> max_rating 
> =Photo.objects.all().aggregate(Max('contest_id'))['contest_id__max']
> return max_rating+1
>
>
>
> The error arises when I click on the send button after I select the image.
> It says:
>
> IntegrityError at /photo/create/
> NOT NULL constraint failed: photo_photo.contest_id_id
>
> But I've given the contest_id value. Haven't I? Where is the problem and
> how can I fix 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/57db225c-41bf-43d2-b9d8-ffb3174cddc7%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/CA%2BFDnhJM1k8kk4ZudQsaH9QpsnAAHHHDbMYwLB09oTT0L2bfNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Matemática A3K
On Mon, Nov 27, 2017 at 5:30 PM, Matemática A3K <matematica@gmail.com>
wrote:

>
>
> On Mon, Nov 27, 2017 at 10:50 AM, Kubilay Yazoğlu <kyazog...@gmail.com>
> wrote:
>
>> Thanks for your answer. I have one more question. What if there are more
>> than one primary keys in that table?
>>
>
> By definition, that won't happen, a primary key is unique. If you add a
> record with the same key Django will raise an IntegrityError.
>
>
>> I'm talking about the unique_together case.
>>
>
> I don't understand you
>

The ForeignKey uses the model's auto primary key to "link", if you define
other keys, np. You should read
https://docs.djangoproject.com/en/1.11/ref/models/fields/#foreignkey

The __str__() representation of the object is independent of the keys you
define on it. If you want to tweak what is displayed in the drop-down, use
this method to show whatever you need :)


>
>
>>
>> 27 Kasım 2017 Pazartesi 08:55:45 UTC+3 tarihinde Matemática A3K yazdı:
>>>
>>> What Django shows in that dropdown is the __str__() method of the
>>> object, define it to your needs in A :)
>>>
>>> On Sun, Nov 26, 2017 at 7:49 PM, Kubilay Yazoğlu <kyaz...@gmail.com>
>>> wrote:
>>>
>>>> Hello. I have two models. In one of them, I declared a foreign key to
>>>> the other one. Since this is done in Django by only specifying the Class
>>>> name, without specifying the field name(column name), when I try to create
>>>> an object in admin panel, it pulls the wrong column information.
>>>>
>>>> Two models A and B.
>>>> B has a Foreignkey for accessing A.
>>>> A has two fields Field1 and Field2.
>>>> When I try to create an instance of B, in the field of Foreignkey,
>>>> there is a drop down menu but the content is not from the right field of A.
>>>>
>>>> How to specify 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...@googlegroups.com.
>>>> To post to this group, send email to django...@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/ms
>>>> gid/django-users/ad0d40a3-cd7f-4f2f-821d-31cc007657b1%40goog
>>>> legroups.com
>>>> <https://groups.google.com/d/msgid/django-users/ad0d40a3-cd7f-4f2f-821d-31cc007657b1%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>> 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/ms
>> gid/django-users/60af36a5-7fec-46f7-a348-ae4a8784f01b%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/60af36a5-7fec-46f7-a348-ae4a8784f01b%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>> 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/CA%2BFDnhJ4ZxTmTwP1DKc30ACBpOcS6npTJLDSfEKpZ8xRUKGrxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select the proper column when I use ForeignKey?

2017-11-27 Thread Matemática A3K
On Mon, Nov 27, 2017 at 10:50 AM, Kubilay Yazoğlu <kyazog...@gmail.com>
wrote:

> Thanks for your answer. I have one more question. What if there are more
> than one primary keys in that table?
>

By definition, that won't happen, a primary key is unique. If you add a
record with the same key Django will raise an IntegrityError.


> I'm talking about the unique_together case.
>

I don't understand you


>
> 27 Kasım 2017 Pazartesi 08:55:45 UTC+3 tarihinde Matemática A3K yazdı:
>>
>> What Django shows in that dropdown is the __str__() method of the object,
>> define it to your needs in A :)
>>
>> On Sun, Nov 26, 2017 at 7:49 PM, Kubilay Yazoğlu <kyaz...@gmail.com>
>> wrote:
>>
>>> Hello. I have two models. In one of them, I declared a foreign key to
>>> the other one. Since this is done in Django by only specifying the Class
>>> name, without specifying the field name(column name), when I try to create
>>> an object in admin panel, it pulls the wrong column information.
>>>
>>> Two models A and B.
>>> B has a Foreignkey for accessing A.
>>> A has two fields Field1 and Field2.
>>> When I try to create an instance of B, in the field of Foreignkey, there
>>> is a drop down menu but the content is not from the right field of A.
>>>
>>> How to specify 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/ms
>>> gid/django-users/ad0d40a3-cd7f-4f2f-821d-31cc007657b1%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/ad0d40a3-cd7f-4f2f-821d-31cc007657b1%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/60af36a5-7fec-46f7-a348-ae4a8784f01b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/60af36a5-7fec-46f7-a348-ae4a8784f01b%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhJYq2rsw9BPGVhTSSBsr%2BLnn_DwffbUP4XM0Twon6fy8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure NGINX to run Django app in a subpath?

2017-11-27 Thread Matemática A3K
Something like this should work:
https://stackoverflow.com/a/20998131/8930660
and change STATIC_URL and MEDIA_URL

Also, the FORCE_SCRIPT_NAME should also work, but if it doesn't, the first
is the most "manual" thing you can do, I think...

Then you have no need to have 2 nginx confs, just put that the proxy_pass
"starts" in your prefix instead of root

On Mon, Nov 27, 2017 at 8:32 AM, Luca Moiana <luca.moi...@gmail.com> wrote:

> Googling around I found this page http://albertoconnor.ca/
> hosting-django-under-different-locations.html but ain't working for me
>
> Il giorno lunedì 27 novembre 2017 11:10:50 UTC+1, Etienne Robillard ha
> scritto:
>>
>> I have not been able to solve this problem with uWSGI. Apparently, uWSGI
>> is not using the same internal routing semantics than FastCGI.
>>
>> See: https://forum.nginx.org/read.php?2,275684,275706
>> Etienne
>>
>> Le 2017-11-26 à 15:41, Matemática A3K a écrit :
>>
>> I don't know / remember how to do it in Gunicorn, but here is an example
>> with uWSGI:
>> https://stackoverflow.com/questions/35792409/nginx-serving-
>> django-in-a-subdirectory-through-uwsgi
>>
>> The main thing is that you will have to deal with "/pmapp" prefix in your
>> routing / urls. You can deal with this inside Django or have it stripped
>> before it gets to Django (by nginx or gunicorn).
>>
>> HTH :)
>>
>> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana <luca@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> Sorry for the slight OT but after days of search I have no clue.
>>>
>>>
>>> Following this DigitalOcean tutorial
>>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>>  I
>>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my
>>> root,
>>>
>>> Now I'd like to change and have something like this:
>>>
>>> mydomain.com -> static HTML
>>> mydomain.com/pmapp -> Django app
>>>
>>> I created two server blocks in NGINX, one for my static website:
>>>
>>> server {
>>>
>>> listen 80;
>>>
>>> listen [::]:80;
>>>
>>>
>>>
>>> root /var/www/html/officinecartografiche.it;
>>>
>>> index index.html index.htm index.nginx-debian.html;
>>>
>>>
>>>
>>> server_name www.officinecartografiche.it, officinecartografiche.
>>> it, 207.154.206.172;
>>>
>>>
>>>
>>> location / {
>>>
>>> try_files $uri $uri/ =404;
>>>
>>>}
>>>
>>> }
>>>
>>>  and one for my django app:
>>>
>>> server {
>>>
>>> listen 80;
>>>
>>> listen [::]:80;
>>>
>>> server_name www.officinecartografiche.it, officinecartografiche.it,
>>> 207.154.206.172;
>>>
>>> location = /favicon.ico { access_log off; log_not_found off; }
>>>
>>> location /static/ {
>>>
>>> root /home/geouser/pmapp;
>>>
>>> }
>>>
>>>
>>>
>>> location /pmapp {
>>>
>>> #include proxy_params;
>>>
>>> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>>>
>>> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/
>>> http://$host/pmapp/;
>>>
>>> proxy_set_header SCRIPT_NAME /pmapp;
>>>
>>> }
>>>
>>> }
>>>
>>> and added this to settings.py:
>>>
>>> FORCE_SCRIPT_NAME = *'/pmapp'*
>>>
>>>
>>> WHAT AM I DOING WRONG??
>>>
>>> THANKS 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...@googlegroups.com.
>>> To post to this group, send email to django...@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/ms
>>> gid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e1

Re: How to configure NGINX to run Django app in a subpath?

2017-11-27 Thread Matemática A3K
That's good to know, I tried to do it some time ago, it was an attempt of a
"sort-of-tennats" which at the didn't go so I stop doing it. At that
moment, I remember trying with gunicorn without success and I was near
success with uWSGi but didn't make it at that time. I supposed that know
would be solved as the s-o question reports success.

Seems that the easiest way to go is to prefix all urls in Django with the
mount point - provided that no url is hardcoded in the django project - and
use a "regular" nginx conf...

On Mon, Nov 27, 2017 at 7:09 AM, Etienne Robillard <tkad...@yandex.com>
wrote:

> I have not been able to solve this problem with uWSGI. Apparently, uWSGI
> is not using the same internal routing semantics than FastCGI.
>
> See: https://forum.nginx.org/read.php?2,275684,275706
> Etienne
>
>
> Le 2017-11-26 à 15:41, Matemática A3K a écrit :
>
> I don't know / remember how to do it in Gunicorn, but here is an example
> with uWSGI:
> https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-
> subdirectory-through-uwsgi
>
> The main thing is that you will have to deal with "/pmapp" prefix in your
> routing / urls. You can deal with this inside Django or have it stripped
> before it gets to Django (by nginx or gunicorn).
>
> HTH :)
>
> On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana <luca.moi...@gmail.com>
> wrote:
>
>> Hi,
>>
>> Sorry for the slight OT but after days of search I have no clue.
>>
>>
>> Following this DigitalOcean tutorial
>> <https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04>
>>  I
>> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my
>> root,
>>
>> Now I'd like to change and have something like this:
>>
>> mydomain.com -> static HTML
>> mydomain.com/pmapp -> Django app
>>
>> I created two server blocks in NGINX, one for my static website:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>>
>>
>> root /var/www/html/officinecartografiche.it;
>>
>> index index.html index.htm index.nginx-debian.html;
>>
>>
>>
>> server_name www.officinecartografiche.it, officinecartografiche.
>> it, 207.154.206.172;
>>
>>
>>
>> location / {
>>
>> try_files $uri $uri/ =404;
>>
>>}
>>
>> }
>>
>>  and one for my django app:
>>
>> server {
>>
>> listen 80;
>>
>> listen [::]:80;
>>
>> server_name www.officinecartografiche.it, officinecartografiche.it,
>> 207.154.206.172;
>>
>> location = /favicon.ico { access_log off; log_not_found off; }
>>
>> location /static/ {
>>
>> root /home/geouser/pmapp;
>>
>> }
>>
>>
>>
>> location /pmapp {
>>
>> #include proxy_params;
>>
>> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>>
>> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/
>> http://$host/pmapp/;
>>
>> proxy_set_header SCRIPT_NAME /pmapp;
>>
>> }
>>
>> }
>>
>> and added this to settings.py:
>>
>> FORCE_SCRIPT_NAME = *'/pmapp'*
>>
>>
>> WHAT AM I DOING WRONG??
>>
>> THANKS 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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://gro

Re: Run manage.py test app_name command from view

2017-11-26 Thread Matemática A3K
On Mon, Nov 27, 2017 at 3:21 AM, Joshua O. Morales <
joshuao.morale...@gmail.com> wrote:

> I tried it out, but I'm still getting 400 error.
>

400 means "Bad Request", if was something wrong inside the view, the server
should return a 500 (Internal Server Error). I think probably it isn't
executing at all...
If you remove the call_command does it works?


> I attached a copy of the tests.py of the app. Maybe you'll find something
> I can't.
>

Nope, I'm not into Selenium nor I can dedicate the time to learn it for
that. If it runs via a regular "python manage.py test seleniumapp" then
it's alright :)

>
> views.py:
>
> from django.shortcuts import render
> from django.core.management import call_command
>
>
> def start_scraping(request):
> call_command('test','seleniumapp')
> return render(request, 'seleniumapp/selenium.html')
>
> On Monday, November 27, 2017 at 3:40:58 AM UTC+8, Matemática A3K wrote:
>>
>>
>>
>> On Sun, Nov 26, 2017 at 11:03 AM, Joshua O. Morales <
>> joshuao@gmail.com> wrote:
>>
>>>  What I would like to do is to execute the tests.py by clicking a
>>> certain button.  I am trying to run the tests.py via views.py, but it gives
>>> me a 400 Bad Request error. Is there any other solution?
>>> Your help would be very much appreciated.
>>> Here's a snippet of the code:
>>>
>>> from django.core.management import call_command
>>>
>>> def start(request):
>>> call_command('test appname')
>>>
>>> It should be:
>>
>> call_command('test', 'appname')
>>
>> Don't know why is your 400, how are you requesting your view? Also, note
>> that you are not returning any HttpResponse nor redirect in the snippet (It
>> will give you other error)
>>
> --
> 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/90dee471-a65b-404f-aa9f-b19223471944%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/90dee471-a65b-404f-aa9f-b19223471944%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhLHWcA1_66EkES3NioX_0G8%3D7yQPVYv_zJkLtxBz_DR4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to select the proper column when I use ForeignKey?

2017-11-26 Thread Matemática A3K
What Django shows in that dropdown is the __str__() method of the object,
define it to your needs in A :)

On Sun, Nov 26, 2017 at 7:49 PM, Kubilay Yazoğlu 
wrote:

> Hello. I have two models. In one of them, I declared a foreign key to the
> other one. Since this is done in Django by only specifying the Class name,
> without specifying the field name(column name), when I try to create an
> object in admin panel, it pulls the wrong column information.
>
> Two models A and B.
> B has a Foreignkey for accessing A.
> A has two fields Field1 and Field2.
> When I try to create an instance of B, in the field of Foreignkey, there
> is a drop down menu but the content is not from the right field of A.
>
> How to specify 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/ad0d40a3-cd7f-4f2f-821d-31cc007657b1%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/CA%2BFDnhKXdyZRwHrq%2B17zOY7ctWJJDm0S5WzT_%2BXMVyc-a6b%3DFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I limit my login form to just email and password?

2017-11-26 Thread Matemática A3K
On Sun, Nov 26, 2017 at 8:57 PM, Tom Tanner <dontsendemailher...@gmail.com>
wrote:

> Adding `exclude=["username"]` does nothing. Same if I replace "username"
> with "email" or "user".
>

it's one or another, you either use 'include' or 'exclude'


>
> On Sunday, November 26, 2017 at 2:44:44 PM UTC-5, Matemática A3K wrote:
>>
>>
>>
>> On Sun, Nov 26, 2017 at 12:55 AM, Tom Tanner <dontsende...@gmail.com>
>> wrote:
>>
>>> My `models.py` has this:
>>> class MyUser(AbstractBaseUser):
>>>  email= models.CharField(max_length=254, unique=True)
>>>  USERNAME_FIELD= "email"
>>>
>>> My `forms.py` has this:
>>> class LoginForm(AuthenticationForm):
>>>  email= forms.EmailField(label=_("Email"), max_length=254)
>>>
>>>  class Meta:
>>>   model= MyUser
>>>   fields= ("email",)
>>>
>>> The form on the template has three fields: Username, Password and Email,
>>> in that Order. I want only Email and Password to show up in the form. How
>>> do I do that?
>>>
>> https://docs.djangoproject.com/en/1.11/topics/forms/modelfor
>> ms/#selecting-the-fields-to-use
>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/4e9a3109-3dd0-4754-91f2-44731154920c%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/4e9a3109-3dd0-4754-91f2-44731154920c%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/b5db6a84-e370-4ccf-8fb6-2d2486f88a60%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b5db6a84-e370-4ccf-8fb6-2d2486f88a60%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhLHisnBbVP027%2B%2Bc_h4wQT%2BZyxfNu1Uxc%3De_wan5CuosQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to configure NGINX to run Django app in a subpath?

2017-11-26 Thread Matemática A3K
I don't know / remember how to do it in Gunicorn, but here is an example
with uWSGI:
https://stackoverflow.com/questions/35792409/nginx-serving-django-in-a-subdirectory-through-uwsgi

The main thing is that you will have to deal with "/pmapp" prefix in your
routing / urls. You can deal with this inside Django or have it stripped
before it gets to Django (by nginx or gunicorn).

HTH :)

On Sun, Nov 26, 2017 at 4:56 PM, Luca Moiana  wrote:

> Hi,
>
> Sorry for the slight OT but after days of search I have no clue.
>
>
> Following this DigitalOcean tutorial
> 
>  I
> was able to setup Django + Postgres + Gunicorn + NGINX running Django on my
> root,
>
> Now I'd like to change and have something like this:
>
> mydomain.com -> static HTML
> mydomain.com/pmapp -> Django app
>
> I created two server blocks in NGINX, one for my static website:
>
> server {
>
> listen 80;
>
> listen [::]:80;
>
>
>
> root /var/www/html/officinecartografiche.it;
>
> index index.html index.htm index.nginx-debian.html;
>
>
>
> server_name www.officinecartografiche.it, officinecartografiche.it
> , 207.154.206.172;
>
>
>
> location / {
>
> try_files $uri $uri/ =404;
>
>}
>
> }
>
>  and one for my django app:
>
> server {
>
> listen 80;
>
> listen [::]:80;
>
> server_name www.officinecartografiche.it, officinecartografiche.it,
> 207.154.206.172;
>
> location = /favicon.ico { access_log off; log_not_found off; }
>
> location /static/ {
>
> root /home/geouser/pmapp;
>
> }
>
>
>
> location /pmapp {
>
> #include proxy_params;
>
> proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
>
> proxy_redirect http://www.officinecartografiche.it:8000/pmapp/
> http://$host/pmapp/;
>
> proxy_set_header SCRIPT_NAME /pmapp;
>
> }
>
> }
>
> and added this to settings.py:
>
> FORCE_SCRIPT_NAME = *'/pmapp'*
>
>
> WHAT AM I DOING WRONG??
>
> THANKS 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b1ee39d2-fd04-4727-88e1-e130def5dd37%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/CA%2BFDnhLuJEm4kE1D1FHMApW8nYQv%2BWi1Xt9R7o07bgOwqLGsjw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I limit my login form to just email and password?

2017-11-26 Thread Matemática A3K
On Sun, Nov 26, 2017 at 12:55 AM, Tom Tanner 
wrote:

> My `models.py` has this:
> class MyUser(AbstractBaseUser):
>  email= models.CharField(max_length=254, unique=True)
>  USERNAME_FIELD= "email"
>
> My `forms.py` has this:
> class LoginForm(AuthenticationForm):
>  email= forms.EmailField(label=_("Email"), max_length=254)
>
>  class Meta:
>   model= MyUser
>   fields= ("email",)
>
> The form on the template has three fields: Username, Password and Email,
> in that Order. I want only Email and Password to show up in the form. How
> do I do that?
>
https://docs.djangoproject.com/en/1.11/topics/forms/modelforms/#selecting-the-fields-to-use

> --
> 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/4e9a3109-3dd0-4754-91f2-44731154920c%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/CA%2BFDnhLt-rz93nqAhOYE_VgWPFCU2pCKjL7qZu2z0u9%3DkBxY-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Run manage.py test app_name command from view

2017-11-26 Thread Matemática A3K
On Sun, Nov 26, 2017 at 11:03 AM, Joshua O. Morales <
joshuao.morale...@gmail.com> wrote:

>  What I would like to do is to execute the tests.py by clicking a certain
> button.  I am trying to run the tests.py via views.py, but it gives me a
> 400 Bad Request error. Is there any other solution?
> Your help would be very much appreciated.
> Here's a snippet of the code:
>
> from django.core.management import call_command
>
> def start(request):
> call_command('test appname')
>
> It should be:

call_command('test', 'appname')

Don't know why is your 400, how are you requesting your view? Also, note
that you are not returning any HttpResponse nor redirect in the snippet (It
will give you other error)

-- 
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/CA%2BFDnh%2BotG8uAGPzb57Pix_g%3DLManuNL9%3DFwg7ObacK6%3DEA9Zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make Django show the "user already exists" message when someone tries to register with an existing username?

2017-11-23 Thread Matemática A3K
> `views.py` has this:
> def login_register(request, template="pages/login_register.html"):
>  '''
>  Display registration and login forms
>  '''
>  registration_form= RegisterForm()
>  return render(request, template, {"registration_form": registration_form
> })
>
>
>
>
> def register(request):
>  '''
>  Process user registration
>  '''
>  if request.method=="POST":
>   form= RegisterForm(request.POST)
>   print form.is_valid()
>   if form.is_valid():
>form.save()
>email= form.cleaned_data.get("email")
>raw_password= form.cleaned_data.get("password1")
>user= authenticate(username=email, password=raw_password)
>login(request, user)
>return redirect(home_slug())
>


>  else:
>

-> Here you should redirect back to to login_register as fallback option,
for this code, try removing this "else"

>   return redirect(reverse("login_register"))
>
>
>
When I fill out registration with an email that already exists, I get this
> error: `ValueError: The view theme.views.register didn't return an
> HttpResponse object. It returned None instead.`. That's because when
> `form.is_valid()` is False, there is no return value. What do I need to
> return so that the message on the Registration form states the email
> already exists?
>
>
When you process the form in a different view, when you redirect you will
loose the form content, a better approach is to process it in the same
view, this way the errors will be shown "automatically":
https://stackoverflow.com/questions/14647723/django-forms-if-not-valid-show-form-with-error-message

Or handle the errors by yourself as shown here:
https://docs.djangoproject.com/en/1.11/intro/tutorial04/
:)

-- 
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/CA%2BFDnhKEjjz3PX-55ad%2BtiiFt2fF4Lx0cz10n_Rg4aL_xB_ezA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Some newbie questions on CBVs and FBVs

2017-11-23 Thread Matemática A3K
On Thu, Nov 23, 2017 at 8:49 PM, 'Simon Connah' via Django users <
django-users@googlegroups.com> wrote:

> Hi everyone,
>
> First of all sorry for the newbie questions it has been a long time since
> I used Django and I think I have forgotten just about everything I once
> knew.
>
> I'm working on a user app for a website. I can't use the built in user
> model as I need a little more flexibility and the ability to grow in the
> future if required.
>
> Basically I have three problems.
>
> 1) I need some views to be limited to the user who created the view.
>

Users do no create Views, what you are meaning is the objects "created" by
the user (or objects attributed or associated to the user if you want to be
even more precise)


> For instance I have an UpdateUser view and I only want the currently
> logged in user to be able to change their own user model data. So say I
> have the username "djangouser" and I go to UpdateView the only row in the
> database that I can change on the database server is the one with the
> username "djangouser". I'm not sure what the best way to handle this
> problem is?
>

Set the queryset attribute of the UpdateView to
User.objects.filter(name=self.request.user) or override the get_queryset()
method in the view:

def get_queryset(self):
base_qs = super(YourUpdateView, self).get_queryset()
return base_qs.filter(user=self.request.user)

https://stackoverflow.com/questions/8594759/django-updateview-restrict-per-user

https://docs.djangoproject.com/en/1.11/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.get_queryset

>
> I could do it manually in a function based view without any problem but I
> find CBVs to be really hard to customise when you want to do something that
> they were not specifically designed to do.
>

Overriding the queryset is a common pattern in CBV :)


> At that point I just end up writing a FBV instead and doing it all myself
> as it is quicker than trying to figure out all the mixins and all the
> methods of the class.
>

> I must be missing something simple with CBVs. Any help would be
> appreciated with this :).
>

You should read the whole topic:
https://docs.djangoproject.com/en/1.11/topics/class-based-views/intro/
and then read the reference:
https://docs.djangoproject.com/en/1.11/ref/class-based-views/mixins/

>
> 2) In FBVs you get passed a variable to the function with the URL conf
> variables, for instance: (path('/blah//', view, name='blah')
> would result in the FBV recieving a username parameter. Where are these
> variables stored when using a CBV?
>

You should read the topic :)


>
> 3) Is it considered bad practice to use FBVs in Django?
>

IMO, no :)


> I just find them so much easier and quicker to write. I know that CBVs
> result in less code duplication but I find I constantly need the Django
> docs open to see what each CBV supports and which methods it has available.
> Where as with FBVs I just write the code and everything works.
>
>
CBV is a pattern, if you don't embrace it, it may get in your way :)


> Anyway, thank you for any help :).
>
> 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/1609714478.2477254.1511480996285%40mail.yahoo.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/CA%2BFDnh%2BYZfaoRPAvZCeGr3L2uz6W%3DTgcVChAwJV%3DCmhC4Y9%2BQA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I make my form send a POST request to a specified view?

2017-11-23 Thread Matemática A3K
Because you are missing the form action, then the browser POSTs to the
current url as default, see:
https://docs.djangoproject.com/en/1.11/intro/tutorial04/#write-a-simple-form


> `pages/login_register.html`:
>  # For this example, I only include the registration form's HTML
>  Register
>  
>  {% csrf_token %}
>  {{ registration_form.as_p }}
>  Register
>  
>

-- 
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/CA%2BFDnh%2Br_oy5ZD%2B4yj974%3DeUpwDRLi%3DVurMrKqxwf-Ka%3Ds69Sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do you access parent object values in an admin inline

2017-11-22 Thread Matemática A3K
On Wed, Nov 22, 2017 at 5:38 PM, test <dudeofg...@gmail.com> wrote:

> Thanks for the response.
>
> I'm still kind of confused.
> So I save the request by overriding the function.
>

You save the object in the request so you can access it from the inline for
further processing, like showing or hiding something


> Then I can only read the request by overriding a function in the inline.
> How do I change the model in the overrided function in the inline.
>

If you want to change "the model entirely", you should do several inlines
(one per each model) and show the appropriate inline according to the
object. Here is sample (untested) code:
https://stackoverflow.com/questions/8074161/how-to-show-different-inlines-depending-of-current-object-field-value


>
> On Wednesday, November 22, 2017 at 1:54:08 PM UTC-5, Matemática A3K wrote:
>>
>>
>>
>> On Wed, Nov 22, 2017 at 3:21 PM, test <dudeo...@gmail.com> wrote:
>>
>>> For example:
>>>
>>> class AnswerInLine(admin.TabularInline):
>>>   model = Answers
>>>
>>> class QuestionAdmin(admin.ModelAdmin):
>>>   inlines = [AnswerInLine]
>>>
>>>
>>>  I want to change the model in the AnswerInLine depending on what the
>>> QuestionAdmin value is
>>>
>>> First save the request object in the parent of the inline, then use it
>> in fk field in the inline. Here is an example:
>> https://github.com/math-a3k/django-ai/blob/master/django_ai/
>> bayesian_networks/admin.py
>>
>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/7300b116-9681-46f9-8df5-aa95691f37d4%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/7300b116-9681-46f9-8df5-aa95691f37d4%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/9b1c32ba-7441-488a-a9e4-9bcec9eaa824%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9b1c32ba-7441-488a-a9e4-9bcec9eaa824%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> 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/CA%2BFDnhJYSXkwcQhtkHkRKMdJUu%3Dr8_KvXrRnGB_zaphLDqP4iA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do you access parent object values in an admin inline

2017-11-22 Thread Matemática A3K
On Wed, Nov 22, 2017 at 3:21 PM, test  wrote:

> For example:
>
> class AnswerInLine(admin.TabularInline):
>   model = Answers
>
> class QuestionAdmin(admin.ModelAdmin):
>   inlines = [AnswerInLine]
>
>
>  I want to change the model in the AnswerInLine depending on what the
> QuestionAdmin value is
>
> First save the request object in the parent of the inline, then use it in
fk field in the inline. Here is an example:
https://github.com/math-a3k/django-ai/blob/master/django_ai/bayesian_networks/admin.py


> --
> 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/7300b116-9681-46f9-8df5-aa95691f37d4%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/CA%2BFDnhLS%3D81v%2BR73_yryP%2BYgS0uqCUHdOeqFrBkfCKp_LxsMaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Introducing django-ai: Artificial Intelligence for Django

2017-11-13 Thread Matemática A3K
I'm very happy to announce the first release of django-ai: Artificial
Intelligence for Django!!

``django-ai`` is a collection of apps for integrating statistical models
into your Django project so you can implement machine learning conveniently.

It aims to integrate several libraries and engines providing your Django
app with a set of tools so you can leverage your project functionality with
the data generated within.

The integration is done through Django models - where most of the data is
generated and stored in a Django project - and an API focused on
integrating seamlessly within Django projects’ best practices and patterns.

The rationale of ``django-ai`` is to provide for each statistical model or
technique bundled a front-end for configuration and an API for integrating
it into your code.

Excited?

- http://django-ai.readthedocs.io/en/latest/overview.html
- http://django-ai.readthedocs.io/en/latest/readme.html#quickstart
- http://django-ai.readthedocs.io/en/latest/apps/examples.html

You are welcome to join the community of users and developers :)

Features
~~~

* Bayesian Networks: Integrate Bayesian Networks through your models using
the BayesPy framework .

Known Issues
~~~

* In development mode (``DEBUG = True``) the BayesPy Inference Engine may
stall during model estimation on certain states of the Pseudo Random Number
Generator. You may need to reset the PRNG or deactivate and activate again
your Python virtualenv. This does not affect other operations like cluster
assignment.

Cheers,
Rodrigo

-- 
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/CA%2BFDnhKGJj9_g5Bmv%3DKGg2s_xXJzpwbbcpaZVi1x_JsNtnCE%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.